:root {
  color-scheme: light;
  --ink: #191f28;
  --ink-subtle: #333d4b;
  --muted: #8b95a1;
  --quiet: #b0b8c1;
  --line: #e5e8eb;
  --page: #f2f4f6;
  --panel: #ffffff;
  --blue: #3182f6;
  --blue-hover: #1b64da;
  --blue-light: #e8f3ff;
  --red: #f04452;
  --red-light: #fee3e5;
  --green: #20c997;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 4px 16px rgba(0,0,0,0.04);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--page); scrollbar-gutter: stable; }
body { margin: 0; color: var(--ink); background: var(--page); font: 15px/1.5 var(--font-family); }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 700; color: var(--ink); }
p, span, div { margin: 0; }
a { color: inherit; text-decoration: none; }
button { border: 0; cursor: pointer; background: none; font: inherit; padding: 0; }
input, select { font: inherit; }

/* === CLIENT APP LAYOUT === */
#app-shell { max-width: 1280px; margin: 0 auto; min-height: 100vh; background: var(--page); padding-bottom: 40px; position: relative; }
.client-main { padding: 0 24px 48px; }
.route-view { width: 100%; }
.dashboard-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.conditions-sidebar { grid-column: 1; grid-row: 1 / span 2; position: sticky; top: 88px; display: flex; flex-direction: column; }
.desktop-only { display: inline-block; }
.mobile-only { display: none; }
.mobile-menu-btn { display: none; background: transparent; border: none; cursor: pointer; color: var(--ink); }
.close-drawer-btn { background: transparent; border: none; cursor: pointer; color: var(--ink); }
.analysis-card { grid-column: 2 / 4; grid-row: 1; }
.payback-card { grid-column: 2; grid-row: 2; }
.breakeven-card { grid-column: 3; grid-row: 2; }
.condition-card { border: 1px solid rgba(229,232,235,0.8); box-shadow: 0 10px 30px rgba(25,31,40,0.05); }
.page-heading { padding: 32px 8px 20px; }
.page-heading span { color: var(--blue); font-size: 13px; font-weight: 800; text-transform: uppercase; }
.page-heading h1 { margin-top: 4px; font-size: 30px; font-weight: 850; letter-spacing: 0; }
.page-heading p { margin-top: 6px; color: var(--muted); font-weight: 600; }
.costs-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 24px; align-items: start; }
.costs-filter-card { position: sticky; top: 88px; }
.costs-detail-card { min-width: 0; }
.drawer-overlay { display: none; }

/* Accordion Details */
details.condition-card > summary {
  list-style: none;
}
details.condition-card > summary::-webkit-details-marker {
  display: none;
}
.accordion-icon {
  transition: transform 0.3s ease;
  color: var(--blue);
}
details.condition-card[open] .accordion-icon {
  transform: rotate(180deg);
}
.accordion-content {
  animation: slideDown 0.2s ease-out;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1023px) {
  #app-shell { max-width: 640px; }
  .client-main { padding: 0 16px 96px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .conditions-sidebar, .analysis-card, .payback-card, .breakeven-card { grid-column: auto; grid-row: auto; position: static; }
  .analysis-card { order: 1; }
  .payback-card { order: 2; }
  .breakeven-card { order: 3; }
  .desktop-only { display: none !important; }
  .mobile-only { display: flex; }
  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
  .conditions-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 320px;
    height: 100vh;
    background: var(--page);
    z-index: 1000;
    overflow-y: auto;
    padding: 24px;
    box-shadow: -10px 0 30px rgba(0,0,0,0.1);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .conditions-sidebar.open { right: 0; }
  .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }
  .sidebar-header h2 { font-size: 20px; font-weight: 800; margin: 0; }
  .drawer-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .drawer-overlay.open { opacity: 1; pointer-events: auto; }
  .costs-layout { grid-template-columns: 1fr; }
  .costs-filter-card { position: static; }
}

/* === ADMIN SHELL === */
#admin-shell { width: 100%; min-height: 100vh; background: var(--page); position: relative; }

/* === SHARED HEADER === */
.site-header { display: flex; align-items: center; justify-content: space-between; height: 64px; padding: 0 24px; position: sticky; top: 0; z-index: 100; background: rgba(242,244,246,0.9); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.brand img { width: 36px; height: 36px; border-radius: 10px; background: var(--blue-light); padding: 4px; }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand strong { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; }
.brand small { font-size: 12px; color: var(--blue); font-weight: 600; text-transform: uppercase; }
.header-actions a { font-size: 14px; font-weight: 600; color: var(--muted); padding: 8px 12px; border-radius: 8px; background: #e5e8eb; }
.public-tabs { position: absolute; left: 50%; transform: translateX(-50%); gap: 28px; }
.public-tabs a { padding: 20px 0; font-size: 15px; font-weight: 800; border-bottom-width: 3px; }

/* === HERO === */
.toss-hero { padding: 32px 8px 28px; }
.toss-hero .subtitle { font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.toss-hero .title { font-size: 28px; font-weight: 800; color: var(--ink); letter-spacing: -1px; line-height: 1.3; margin-bottom: 24px; }

/* === CARDS === */
.toss-card { background: var(--panel); border-radius: var(--radius); padding: 24px; margin: 0; box-shadow: var(--shadow); }
.toss-card-title { font-size: 18px; font-weight: 700; color: var(--ink-subtle); margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; }

/* === NUMBERS === */
.toss-big-number { font-size: 26px; font-weight: 800; color: var(--blue); letter-spacing: -0.5px; }
.toss-sub-number { font-size: 14px; color: var(--muted); font-weight: 500; margin-top: 4px; }

/* === LIST === */
.toss-list { display: flex; flex-direction: column; gap: 16px; }
.toss-list-item { display: flex; justify-content: space-between; align-items: center; }
.toss-list-item .label { font-size: 15px; font-weight: 500; color: var(--ink-subtle); display: flex; flex-direction: column; }
.toss-list-item .value { font-size: 16px; font-weight: 700; color: var(--ink); text-align: right; }
.toss-list-item .sub-label { font-size: 13px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.metric-tile { background: var(--page); padding: 24px; border-radius: 20px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.02); }
.metric-tile span { color: var(--ink-subtle); font-size: 14px; font-weight: 700; }
.metric-tile strong { color: var(--ink); font-size: 24px; font-weight: 850; letter-spacing: -0.5px; }
.metric-tile small { color: var(--muted); font-size: 13px; font-weight: 600; line-height: 1.4; margin-top: auto; padding-top: 8px; }
.metric-tile.good strong { color: var(--blue); }
.metric-tile.danger strong { color: var(--red); }
#kpiGrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 32px; }

/* === CHART === */
.toss-chart { min-height: 180px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: end; gap: 8px; margin: 8px 0 32px; padding: 24px; border-radius: 20px; background: var(--page); }
.month-bar { min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.month-bar .bar-track { width: 100%; max-width: 28px; height: 120px; border-radius: 8px; background: var(--line); display: flex; align-items: flex-end; overflow: hidden; }
.month-bar .bar-fill { width: 100%; border-radius: 8px; background: var(--blue); transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1); }
.month-bar.loss .bar-fill { background: var(--red); }
.month-bar strong { font-size: 13px; color: var(--ink); font-weight: 800; }
.month-bar span { font-size: 11px; color: var(--blue); width: 100%; overflow: visible; white-space: nowrap; text-align: center; background: var(--page); border-radius: 4px; padding: 2px 0; font-weight: 700; margin-top: 4px; }

/* === FORM FIELDS === */
.toss-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; min-width: 0; }
.toss-field label { font-size: 14px; font-weight: 600; color: var(--muted); }
.toss-select, .toss-input { background: var(--page); border: 1px solid transparent; border-radius: 12px; padding: 14px 44px 14px 16px; font-size: 16px; font-weight: 600; color: var(--ink); width: 100%; min-height: 56px; transition: 0.2s; appearance: none; -webkit-appearance: none; }
.toss-select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 24px) 50%,
    calc(100% - 17px) 50%;
  background-size: 7px 7px, 7px 7px;
  background-repeat: no-repeat;
}
.toss-select:hover, .toss-input:hover { background-color: #edf1f5; }
.toss-select:focus, .toss-input:focus { outline: none; border-color: var(--blue); background-color: var(--panel); box-shadow: 0 0 0 4px var(--blue-light); }
.toss-select option { color: var(--ink); background: var(--panel); font-weight: 600; }
.native-select-source { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; outline: none !important; border: none; }
.app-select { position: relative; width: 100%; display: flex; flex-direction: column; }
.app-select-trigger {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px 0 20px;
  border-radius: 14px;
  background: #f3f5f7;
  border: 1px solid transparent;
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  outline: none;
  cursor: pointer;
}
.app-select-trigger:focus-visible { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-light); }
.app-select-trigger:hover { background: #edf1f5; }
.app-select.open .app-select-trigger {
  background: var(--panel);
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-light);
}
.app-select-trigger i {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.app-select.open .app-select-trigger i {
  border-color: var(--blue);
  transform: rotate(225deg) translateY(-2px);
}
.app-select-menu {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  display: grid;
  gap: 4px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(255,255,255,0.98);
  border: 1px solid var(--line);
  box-shadow: 0 18px 44px rgba(25,31,40,0.13), 0 4px 12px rgba(25,31,40,0.06);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top;
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
}
.app-select.open .app-select-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}
.app-select-option {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 14px;
  border-radius: 11px;
  color: var(--ink-subtle);
  font-size: 16px;
  font-weight: 750;
  text-align: left;
}
.app-select-option:hover { background: var(--page); }
.app-select-option.selected {
  color: var(--blue);
  background: var(--blue-light);
}
.app-select-option.selected::after {
  content: "";
  width: 7px;
  height: 12px;
  border-right: 2px solid var(--blue);
  border-bottom: 2px solid var(--blue);
  transform: rotate(45deg);
  margin-right: 4px;
}
.scenario-field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.scenario-field-head strong { color: var(--blue); font-size: 14px; font-weight: 700; text-align: right; }
.scenario-control { display: grid; grid-template-columns: minmax(0, 1fr) 100px; gap: 16px; align-items: center; }
.scenario-control.has-range { grid-template-columns: minmax(0, 1fr) 100px; }
.scenario-control .scenario-number:only-child { grid-column: 1 / -1; }
.scenario-number { min-height: 44px !important; padding: 0 16px !important; text-align: center !important; font-size: 17px !important; border-radius: 12px; font-weight: 800; }
.toss-range { -webkit-appearance: none; appearance: none; width: 100%; min-width: 0; height: 34px; margin: 0; background: transparent; cursor: grab; touch-action: pan-y; }
.toss-range:active { cursor: grabbing; }
.toss-range::-webkit-slider-runnable-track { height: 8px; border-radius: 999px; background: var(--line); }
.toss-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; margin-top: -8px; width: 24px; height: 24px; border-radius: 50%; background: var(--blue); box-shadow: 0 2px 8px rgba(49, 130, 246, 0.28); }
.toss-range::-moz-range-track { height: 8px; border-radius: 999px; background: var(--line); }
.toss-range::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: var(--blue); box-shadow: 0 2px 8px rgba(49, 130, 246, 0.28); }
.computed-field { display: grid; gap: 4px; padding: 14px 16px; border-radius: 14px; background: var(--blue-light); margin-bottom: 20px; }
.computed-field span { color: var(--blue); font-size: 13px; font-weight: 800; }
.computed-field strong { color: var(--blue); font-size: 22px; font-weight: 900; }
.computed-field small { color: var(--ink-subtle); font-size: 12px; font-weight: 650; }

/* === PAYBACK / COST VISUALS === */
.analysis-duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.payback-layout { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 18px; align-items: start; }
.analysis-section { display: grid; gap: 14px; min-width: 0; }
.analysis-section h3 { font-size: 18px; font-weight: 850; color: var(--ink); }
.analysis-main-card { min-width: 0; display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 16px; align-items: center; padding: 18px; border-radius: 20px; background: var(--page); }
.donut-card { min-width: 0; display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; align-items: center; padding: 16px; border-radius: 18px; background: var(--page); }
.donut {
  width: 96px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--blue) calc(var(--value) * 1%), var(--line) 0);
  position: relative;
}
.donut::after { content: ""; position: absolute; inset: 12px; border-radius: inherit; background: var(--panel); }
.donut span { position: relative; z-index: 1; color: var(--blue); font-size: 18px; font-weight: 850; }
.donut-card.danger .donut { background: conic-gradient(var(--red) calc(var(--value) * 1%), var(--line) 0); }
.donut-card.danger .donut span { color: var(--red); }
.analysis-main-card.danger .donut { background: conic-gradient(var(--red) calc(var(--value) * 1%), var(--line) 0); }
.analysis-main-card.danger .donut span { color: var(--red); }
.donut-card > div:last-child { display: grid; gap: 4px; min-width: 0; }
.donut-card > div:last-child span { color: var(--muted); font-size: 13px; font-weight: 800; }
.donut-card > div:last-child strong { color: var(--ink); font-size: 18px; font-weight: 850; }
.donut-card > div:last-child small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.analysis-main-card > div:last-child { display: grid; gap: 5px; min-width: 0; }
.analysis-main-card > div:last-child span { color: var(--muted); font-size: 13px; font-weight: 850; }
.analysis-main-card > div:last-child strong { color: var(--ink); font-size: 24px; font-weight: 900; line-height: 1.15; }
.analysis-main-card > div:last-child small { color: var(--muted); font-size: 13px; line-height: 1.35; }
.payback-panel { background: var(--page); border-radius: 16px; padding: 18px; display: grid; gap: 6px; }
.payback-panel.slim { padding: 20px; border-radius: 20px; }
.payback-panel span { color: var(--muted); font-size: 13px; font-weight: 700; }
.payback-panel strong { color: var(--blue); font-size: 26px; font-weight: 800; }
.payback-panel small { color: var(--muted); font-size: 13px; }
.payback-panel.danger strong { color: var(--red); }
.payback-track { height: 9px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 8px; }
.payback-track i { display: block; height: 100%; border-radius: inherit; background: var(--blue); }
.payback-panel.danger .payback-track i { background: var(--red); }

.payback-overview { display: grid; gap: 12px; margin-bottom: 16px; }
.payback-hero { background: var(--blue-light); border-radius: 20px; padding: 28px 20px; text-align: center; display: grid; gap: 6px; }
.payback-hero.danger { background: var(--red-light); }
.payback-hero span { color: var(--blue); font-size: 14px; font-weight: 800; }
.payback-hero.danger span { color: var(--red); }
.payback-hero strong { color: var(--blue); font-size: 32px; font-weight: 900; letter-spacing: -1px; }
.payback-hero.danger strong { color: var(--red); }
.payback-hero small { color: var(--blue); font-size: 13px; font-weight: 600; opacity: 0.8; }
.payback-hero.danger small { color: var(--red); opacity: 0.8; }

.payback-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.payback-stats .stat-box { background: var(--page); border-radius: 16px; padding: 16px; display: grid; gap: 4px; text-align: center; }
.payback-stats .stat-box span { color: var(--muted); font-size: 12px; font-weight: 700; }
.payback-stats .stat-box strong { color: var(--ink); font-size: 18px; font-weight: 800; }

.payback-alert { margin-top: 16px; padding: 18px; border-radius: 16px; display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.4; word-break: keep-all; overflow-wrap: break-word; }
.payback-alert.good { background: rgba(49, 130, 246, 0.08); color: #1b64da; }
.payback-alert.good i { color: var(--blue); font-size: 20px; margin-top: 2px; }
.payback-alert.danger { background: rgba(240, 68, 82, 0.08); color: #c92a2a; }
.payback-alert.danger i { color: var(--red); font-size: 20px; margin-top: 2px; }
.payback-alert strong { font-weight: 750; }

.premium-info-list { display: flex; flex-direction: column; gap: 8px; }
.premium-info-row { background: var(--page); border-radius: 14px; padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; }
.premium-info-row .info-label { color: var(--ink-subtle); font-size: 14px; font-weight: 700; }
.premium-info-row .info-value-stack { text-align: right; display: flex; flex-direction: column; gap: 4px; }
.premium-info-row .info-value-stack strong { color: var(--ink); font-size: 16px; font-weight: 800; }
.premium-info-row .info-value-stack small { color: var(--muted); font-size: 12px; font-weight: 600; }

.breakeven-overview { display: grid; gap: 16px; }

.revenue-tracker { background: var(--page); border-radius: 20px; padding: 24px; display: grid; margin-bottom: 8px; }
.tracker-labels { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.tracker-labels span { color: var(--ink-subtle); font-size: 16px; font-weight: 750; margin-top: 4px; }
.tracker-labels strong { color: var(--ink); font-size: 28px; font-weight: 900; letter-spacing: -0.5px; line-height: 1; }

.tracker-bar-wrapper { position: relative; height: 16px; border-radius: 999px; background: var(--line); margin-top: 40px; margin-bottom: 16px; }
.tracker-bar-fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 999px; transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.tracker-bar-fill.achieved.good { background: var(--muted); z-index: 2; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.tracker-bar-fill.achieved.danger { background: var(--red); z-index: 2; }
.tracker-bar-fill.excess { background: var(--blue); border-top-left-radius: 0; border-bottom-left-radius: 0; z-index: 1; }

.tracker-marker { position: absolute; top: -34px; bottom: -12px; width: 2px; z-index: 5; display: flex; flex-direction: column; align-items: center; }
.tracker-marker .marker-line { width: 2px; height: 100%; background: var(--ink-subtle); border-radius: 2px; }
.tracker-marker .marker-text { position: absolute; top: 0; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 13px; font-weight: 750; color: #fff; background: var(--ink-subtle); padding: 6px 10px; border-radius: 8px; z-index: 2; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

.tracker-footer { text-align: right; margin-top: 14px; }
.tracker-footer span { font-size: 16px; font-weight: 850; letter-spacing: -0.3px; }
.tracker-footer span.good { color: var(--blue); }
.tracker-footer span.danger { color: var(--red); }

.donut-widgets-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.donut-card-mini { background: var(--page); border-radius: 20px; padding: 24px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: space-between; }
.donut-card-mini span { color: var(--ink-subtle); font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.donut-card-mini small { color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 12px; }

.donut-large { width: 110px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; position: relative; }
.donut-large::after { content: ""; position: absolute; inset: 12px; border-radius: inherit; background: var(--page); z-index: 1; }
.donut-large strong { position: relative; z-index: 2; font-size: 22px; font-weight: 850; letter-spacing: -0.5px; }
.donut-large.good { background: conic-gradient(var(--muted) calc(var(--target) * 1%), var(--blue) calc(var(--target) * 1%), var(--blue) calc(var(--value) * 1%), var(--line) 0); }
.donut-large.good strong { color: var(--blue); }
.donut-large.danger { background: conic-gradient(var(--red) calc(var(--value) * 1%), var(--line) 0); }
.donut-large.danger strong { color: var(--red); }

.donut-target-tick { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.donut-target-tick::before { content: ""; position: absolute; top: -4px; left: 50%; width: 3px; height: 20px; background: var(--ink-subtle); border-radius: 2px; transform: translateX(-50%); box-shadow: 0 0 0 2px var(--page); }
.bar-card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.bar-card-header .bar-label { color: var(--ink-subtle); font-size: 14px; font-weight: 700; }
.bar-card-header .bar-value { color: var(--ink); font-size: 16px; font-weight: 800; text-align: right; }
.premium-bar-card.danger .bar-value { color: var(--red); }
.premium-bar-card.good .bar-value { color: var(--blue); }

.premium-bar-card .bar-track { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.premium-bar-card .bar-fill { height: 100%; border-radius: inherit; background: var(--blue); transition: width 0.3s ease; }
.premium-bar-card.danger .bar-fill { background: var(--red); }

.bar-card-footer small { color: var(--muted); font-size: 13px; font-weight: 600; }

.analysis-bar { display: grid; gap: 7px; padding: 14px; border-radius: 14px; background: var(--page); overflow: hidden; }
.analysis-bar div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.analysis-bar span { color: var(--muted); font-size: 13px; font-weight: 800; }
.analysis-bar strong { color: var(--ink); font-size: 16px; font-weight: 850; text-align: right; }
.analysis-bar b { display: block; height: 9px; border-radius: 999px; background: var(--line); overflow: hidden; }
.analysis-bar i { display: block; height: 100%; border-radius: inherit; background: var(--blue); }
.analysis-bar.danger i { background: var(--red); }
.analysis-bar small { color: var(--muted); font-size: 12px; font-weight: 650; }
.break-grid { display: grid; gap: 10px; }
.break-grid.compact { gap: 8px; }
.break-item { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.break-item span { color: var(--muted); font-size: 14px; font-weight: 600; }
.break-item strong { text-align: right; font-size: 15px; font-weight: 800; color: var(--ink); }
.cost-summary { display: grid; gap: 20px; padding: 28px; border-radius: 20px; background: var(--panel); margin-bottom: 24px; box-shadow: 0 4px 20px rgba(0,0,0,0.02); }
.cost-summary-row { display: grid; gap: 10px; }
.cost-summary-row div { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; }
.cost-summary-row span { color: var(--ink-subtle); font-size: 14px; font-weight: 700; }
.cost-summary-row strong { font-size: 18px; font-weight: 850; letter-spacing: -0.5px; }
.cost-summary-row b { display: block; height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; position: relative; }
.cost-summary-row i { display: block; height: 100%; border-radius: inherit; background: var(--blue); transition: width 0.4s ease; }

.cost-summary-row.blue b { background: rgba(49, 130, 246, 0.12); }
.cost-summary-row.blue i { background: #3182f6; }
.cost-summary-row.purple b { background: rgba(124, 77, 255, 0.12); }
.cost-summary-row.purple i { background: #7c4dff; }
.cost-summary-row.teal b { background: rgba(38, 198, 218, 0.12); }
.cost-summary-row.teal i { background: #26c6da; }
.cost-summary-row.coral b { background: rgba(255, 112, 67, 0.12); }
.cost-summary-row.coral i { background: #ff7043; }

/* === PREMIUM ACCORDION COST CARDS === */
.premium-cost-card { background: var(--panel); border-radius: 20px; padding: 0; margin-bottom: 16px; box-shadow: 0 4px 20px rgba(0,0,0,0.02); overflow: hidden; }
.cost-card-header { display: flex; justify-content: space-between; align-items: center; padding: 24px; cursor: pointer; background: var(--panel); transition: background 0.2s; }
.cost-card-header:active { background: #f9f9f9; }
.cost-card-header.no-children { cursor: default; }
.cost-card-header.no-children:active { background: var(--panel); }
.cost-title { font-size: 17px; font-weight: 800; color: var(--ink); }
.cost-amount-wrap { display: flex; align-items: center; gap: 6px; }
.cost-amount { font-size: 18px; font-weight: 850; color: var(--ink); letter-spacing: -0.5px; }
.chevron { color: var(--quiet); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.accordion.open > .cost-card-header .chevron,
.accordion.open > .cost-child-item .chevron { transform: rotate(-180deg); color: var(--ink); }

.cost-card-body-wrapper { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.accordion.open > .cost-card-body-wrapper { grid-template-rows: 1fr; }
.cost-card-body { overflow: hidden; }
.cost-card-body-inner { padding: 0 24px 24px; opacity: 0; transition: opacity 0.3s ease; }
.accordion.open > .cost-card-body-wrapper > .cost-card-body > .cost-card-body-inner,
.accordion.open > .cost-card-body-wrapper > .cost-card-body > .grandchildren-list { opacity: 1; }
/* Adding opacity transition to grandchildren list as well */
.grandchildren-list { opacity: 0; transition: opacity 0.3s ease; }

.children-list { display: flex; flex-direction: column; gap: 18px; padding-top: 20px; border-top: 1px solid var(--line); }
.cost-child-item { display: flex; align-items: center; gap: 14px; }
.child-icon { width: 6px; height: 6px; border-radius: 50%; background: var(--quiet); flex-shrink: 0; }
.child-content { flex: 1; display: flex; justify-content: space-between; align-items: center; }
.child-name { font-size: 15px; font-weight: 650; color: var(--ink-subtle); }
.child-amount { font-size: 16px; font-weight: 750; color: var(--ink); letter-spacing: -0.3px; }

/* === NESTED ACCORDION (GRANDCHILDREN) === */
.cost-child-accordion { display: flex; flex-direction: column; }
.cost-child-item.has-children { cursor: pointer; padding: 8px; margin: -8px; border-radius: 12px; transition: background 0.2s; }
.cost-child-item.has-children:hover { background: var(--page); }
.cost-child-item.has-children:active { background: #e5e8eb; }

.grandchildren-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 16px;
  margin-left: 2px;
  border-left: 2px solid var(--line);
  padding-left: 20px;
  margin-top: 8px;
  margin-bottom: 4px;
}
.cost-grandchild-item {
  display: flex;
  align-items: center;
  position: relative;
}
.cost-grandchild-item::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 50%;
  width: 12px;
  height: 2px;
  background: var(--line);
}
.cost-grandchild-item .child-name { font-size: 14px; font-weight: 600; color: var(--muted); }
.cost-grandchild-item .child-amount { font-size: 15px; font-weight: 700; color: var(--ink-subtle); }

/* === CLIENT BUTTONS === */
.toss-button-primary { background: var(--blue); color: #fff; font-size: 16px; font-weight: 700; border-radius: 14px; padding: 16px; width: 100%; text-align: center; transition: 0.2s; display: block; box-sizing: border-box; }
.toss-button-primary:active { background: var(--blue-hover); transform: scale(0.98); }
.toss-button-secondary { background: var(--blue-light); color: var(--blue); font-size: 16px; font-weight: 700; border-radius: 14px; padding: 16px; width: 100%; text-align: center; transition: 0.2s; }
.toss-button-quiet { background: var(--line); color: var(--ink-subtle); font-size: 14px; font-weight: 600; border-radius: 8px; padding: 8px 12px; }

/* === BASE SETUP === */
*, *::before, *::after { box-sizing: border-box; }
html { }
body { margin: 0; padding: 0; font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background-color: var(--page); color: var(--ink); -webkit-font-smoothing: antialiased; font-size: 15px; line-height: 1.5; }

/* === BADGES === */
.toss-badge { display: inline-block; background: var(--blue-light); color: var(--blue); font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 6px; }

/* === ACCORDION === */
.toss-accordion-summary { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; font-weight: 600; font-size: 16px; cursor: pointer; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.toss-accordion-details { padding-bottom: 16px; display: none; }
.toss-accordion.open .toss-accordion-details { display: block; }

/* === UTILITIES === */
.text-right { text-align: right; }
.mt-4 { margin-top: 16px; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-blue { color: var(--blue); }

/* === TOAST === */
#toastContainer { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 1000; pointer-events: none; display: flex; flex-direction: column; gap: 8px; width: 90%; max-width: 400px; }
.toast { background: rgba(0, 0, 0, 0.95); color: #fff; padding: 16px; border-radius: 12px; font-size: 15px; font-weight: 600; text-align: center; animation: toastIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes toastIn { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* === GLOBAL === */
[hidden] { display: none !important; }

/* === DRAWER & MODAL === */
.drawer { position: fixed; inset: 0; z-index: 1000; display: flex; justify-content: flex-end; }
.drawer[hidden] { display: none !important; }
.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); z-index: 999; }
.drawer-content { position: relative; width: 100%; max-width: 400px; background: #fff; height: 100%; display: flex; flex-direction: column; animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: -4px 0 24px rgba(0,0,0,0.1); }
.drawer-header { padding: 24px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.drawer-header h2 { font-size: 20px; font-weight: 800; margin: 0; }
.drawer-body { padding: 24px; flex: 1; overflow-y: auto; }
.close-btn { background: none; border: none; cursor: pointer; color: var(--ink); padding: 4px; display: flex; align-items: center; justify-content: center; }

.modal { position: fixed; inset: 0; z-index: 1050; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none !important; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); }
.modal-content { position: relative; width: 100%; max-width: 500px; background: #fff; border-radius: 24px; padding: 24px; animation: slideUpFade 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 12px 40px rgba(0,0,0,0.15); max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.modal-header h2 { font-size: 22px; font-weight: 800; margin: 0; }

@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes slideUpFade { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* === AUTH & SCENARIOS UI === */
.auth-widget { background: var(--page); padding: 20px; border-radius: 16px; margin-bottom: 24px; text-align: center; }
.auth-widget p { font-weight: 700; color: var(--ink); margin: 0 0 16px 0; font-size: 16px; }
.auth-buttons { display: flex; flex-direction: column; gap: 8px; }
.social-btn { padding: 14px; border-radius: 12px; font-size: 15px; font-weight: 700; border: none; cursor: pointer; transition: transform 0.2s; }
.social-btn:active { transform: scale(0.98); }
.social-btn.google { background: #fff; color: #000; border: 1px solid #ddd; }
.social-btn.kakao { background: #fee500; color: #000; }
.social-btn.apple { background: #000; color: #fff; }
.social-btn.naver { background: #03C75A; color: #fff; }

.scenarios-list { display: flex; flex-direction: column; gap: 12px; }
.scenario-item { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; cursor: pointer; transition: all 0.2s; position: relative; text-align: left; }
.scenario-item:hover { border-color: var(--blue); }
.scenario-item.active { border-color: var(--blue); background: rgba(49,130,246,0.04); }
.scenario-item h4 { margin: 0 0 4px 0; font-size: 16px; font-weight: 750; color: var(--ink); }
.scenario-item p { margin: 0; font-size: 13px; color: var(--muted); }
.scenario-item .delete-btn { position: absolute; right: 16px; top: 16px; background: none; border: none; color: var(--red); font-size: 13px; font-weight: 600; cursor: pointer; }

.compare-results { background: var(--page); border-radius: 16px; padding: 16px; }
.compare-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.compare-row:last-child { border-bottom: none; }
.compare-row span { font-size: 14px; color: var(--ink-subtle); font-weight: 600; width: 33%; }
.compare-row strong { font-size: 15px; font-weight: 800; color: var(--ink); width: 33%; text-align: right; }
.compare-row strong.better { color: var(--blue); }
.compare-row strong.worse { color: var(--red); }

/* ============================== */
/* === ADMIN UI ================ */
/* ============================== */

/* Auth Screen */
.auth-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-card { background: var(--panel); border-radius: 24px; padding: 40px; width: 100%; max-width: 480px; box-shadow: var(--shadow); }
.auth-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-card .brand img { width: 40px; height: 40px; border-radius: 12px; }
.auth-card h1 { font-size: 28px; font-weight: 800; letter-spacing: -1px; margin-bottom: 8px; }
.auth-card p { font-size: 15px; color: var(--muted); margin-bottom: 24px; }
.credential-box { background: var(--page); border-radius: 12px; padding: 16px; margin-bottom: 24px; display: flex; flex-direction: column; gap: 4px; }
.credential-box span { font-size: 13px; color: var(--muted); font-weight: 600; }
.credential-box strong { font-size: 15px; color: var(--ink); }

/* Admin Layout */
.app-content { flex: 1; max-width: 900px; margin: 0 auto; width: 100%; padding: 32px 16px 80px; position: relative; }
.mobile-toc { display: none; }
.admin-main { display: flex; max-width: 1200px; margin: 0 auto; padding: 32px 24px; gap: 32px; align-items: flex-start; }
.admin-rail { width: 300px; flex-shrink: 0; background: var(--panel); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); position: sticky; top: 88px; }
.admin-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 24px; }

/* Rail Elements */
.admin-rail h1 { font-size: 20px; font-weight: 700; margin-bottom: 24px; }
.admin-rail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.admin-save-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 32px; }

/* Admin Cards */
.admin-card { background: var(--panel); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); }
.admin-card-head { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.admin-card-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.admin-card-head .eyebrow { font-size: 13px; font-weight: 600; color: var(--blue); text-transform: uppercase; margin-bottom: 4px; display: block; }

body[data-app="admin"] > .toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 1000;
  width: min(420px, calc(100vw - 32px));
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
body[data-app="admin"] > .toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Admin Fields */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.admin-grid.three { grid-template-columns: repeat(3, 1fr); }
.admin-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.admin-field.full { grid-column: 1 / -1; }
.admin-field span { font-size: 14px; font-weight: 600; color: var(--ink-subtle); }
.admin-field input, .admin-field select, .admin-field textarea { background: var(--page); border: 1px solid transparent; border-radius: 12px; padding: 12px 16px; font-size: 15px; font-weight: 500; color: var(--ink); width: 100%; min-width: 0; transition: 0.2s; outline: none; }
.admin-field input:focus, .admin-field select:focus, .admin-field textarea:focus { border-color: var(--blue); background: var(--panel); box-shadow: 0 0 0 4px var(--blue-light); }
.admin-field textarea { min-height: 100px; resize: vertical; }
.admin-field .app-select { width: 100%; min-width: 0; }
.admin-field .app-select-trigger { min-height: 48px; border-radius: 12px; font-size: 15px; padding-inline: 16px; }
.admin-field .app-select-menu { z-index: 90; }
.editable-node-head .admin-field .app-select-trigger,
.editable-child-row .admin-field .app-select-trigger { min-height: 44px; border-radius: 10px; font-size: 14px; }

/* Admin Buttons */
.primary-button { background: var(--blue); color: #fff; font-size: 15px; font-weight: 600; border-radius: 12px; padding: 14px; width: 100%; display: flex; justify-content: center; align-items: center; transition: 0.2s; white-space: nowrap; word-break: keep-all; flex-shrink: 0; min-width: max-content; }
.primary-button:hover { background: var(--blue-hover); }
.danger-button { background: var(--red-light); color: var(--red); font-size: 14px; font-weight: 600; border-radius: 8px; padding: 10px 16px; transition: 0.2s; white-space: nowrap; word-break: keep-all; flex-shrink: 0; min-width: max-content; }
.quiet-button { background: var(--line); color: var(--ink-subtle); font-size: 14px; font-weight: 600; border-radius: 8px; padding: 10px 16px; transition: 0.2s; white-space: nowrap; word-break: keep-all; flex-shrink: 0; min-width: max-content; }
.quiet-button:hover { background: #d1d6db; }

/* Admin Tabs */
.top-tabs { display: flex; gap: 16px; }
.top-tabs a { font-size: 16px; font-weight: 600; color: var(--muted); padding: 8px 0; border-bottom: 2px solid transparent; transition: 0.2s; display: flex; align-items: center; }
.top-tabs a.active { color: var(--ink); border-bottom-color: var(--ink); }

/* Public Navigation */
#app-shell .public-tabs { position: absolute; left: 50%; transform: translateX(-50%); display: flex; gap: 32px; }
#app-shell .public-tabs a { font-size: 15px; padding: 21px 0 18px; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 800; }
#app-shell .public-tabs a.active { color: var(--ink); border-bottom-color: var(--ink); }
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 32px));
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: 18px;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 14px 36px rgba(25,31,40,0.15);
  backdrop-filter: blur(14px);
  z-index: 90;
}
.bottom-nav a {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 13px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 0 10px;
}
.bottom-nav a svg {
  width: 20px;
  height: 20px;
  margin: 0 !important;
  flex-shrink: 0;
}
.bottom-nav a.active { color: var(--blue); background: var(--blue-light); }
.brand-points { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.brand-points span { min-height: 88px; display: flex; align-items: center; justify-content: center; padding: 18px; border-radius: 16px; background: var(--page); font-size: 16px; font-weight: 800; text-align: center; }

/* Admin Header Overrides */
#admin-shell .site-header { max-width: 100%; border-bottom: 1px solid var(--line); padding: 0 40px; }
#admin-shell .top-tabs { position: absolute; left: 50%; transform: translateX(-50%); display: flex; gap: 32px; }
#admin-shell .top-tabs a { font-size: 15px; padding: 18px 0; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; transition: 0.2s; }
#admin-shell .top-tabs a:hover { color: var(--ink); }
#admin-shell .top-tabs a.active { color: var(--ink); border-bottom-color: var(--ink); }
#admin-shell .top-tabs a svg { width: 20px; height: 20px; margin-right: 6px; flex-shrink: 0; }

@media (max-width: 1024px) {
  #admin-shell .site-header { padding: 0 24px; }
  #admin-shell .top-tabs { position: static; transform: none; margin-left: 24px; }
}

@media (max-width: 768px) {
  #admin-shell { overflow-x: hidden; width: 100%; }
  #app-shell .public-tabs { display: none; }
  #app-shell .header-actions a { padding: 7px 10px; font-size: 12px; }
  .bottom-nav { display: grid; }
  .app-content { padding-bottom: 90px; }
  .mobile-toc { position: -webkit-sticky; position: sticky; top: 63px; z-index: 90; display: flex; gap: 6px; padding: 12px 16px; margin: -32px -16px 24px; background: rgba(242, 244, 246, 0.95); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(0,0,0,0.05); justify-content: center; box-shadow: 0 4px 16px rgba(0,0,0,0.02); }
  .mobile-toc a, .mobile-toc button { flex: 1; text-align: center; text-decoration: none; padding: 10px 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; font-size: 13px; font-weight: 700; color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,0.04); transition: transform 0.15s ease; cursor: pointer; font-family: inherit; }
  .mobile-toc a:active, .mobile-toc button:active { transform: scale(0.96); }
  .toss-card { scroll-margin-top: 130px; }
  .brand-points { grid-template-columns: 1fr; }
  .analysis-duo { grid-template-columns: 1fr; }
  .payback-layout { grid-template-columns: 1fr; }
  .analysis-main-card { grid-template-columns: 84px minmax(0, 1fr); }
  .donut-card { grid-template-columns: 84px minmax(0, 1fr); }
  .donut { width: 84px; }
  #kpiGrid { grid-template-columns: 1fr; }
  #admin-shell .top-tabs { display: none; }
  .admin-main { flex-direction: column; padding: 24px 16px 120px 16px; align-items: stretch; }
  .admin-rail { width: 100%; position: static; }
  .admin-card { padding: 24px 16px; }
  .layout-block { padding: 16px; }
  .admin-grid, .admin-grid.three { grid-template-columns: 1fr; gap: 16px; }
  .scenario-control.has-range { grid-template-columns: 1fr; gap: 10px; }
  .scenario-control.has-range .toss-range { grid-row: 2; }
  .scenario-control.has-range .scenario-number { grid-row: 1; justify-self: end; width: min(100%, 166px); }
}

/* Layout Builder Styles */
.layout-builder { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.layout-block { background: var(--page); padding: 20px; border-radius: 16px; display: flex; flex-direction: column; gap: 12px; }
.layout-flags { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 4px; }
.layout-actions, .block-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 16px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; }
.check-row input[type="checkbox"] { width: 18px; height: 18px; border-radius: 4px; border: 1px solid var(--line); cursor: pointer; flex-shrink: 0; }
.layout-block .admin-field { display: grid; grid-template-columns: 80px minmax(0, 1fr); align-items: center; gap: 8px; width: 100%; }
.layout-block .admin-field span { font-size: 13px; font-weight: 600; color: var(--muted); text-align: left; margin: 0; white-space: nowrap; }

/* ============================== */
/* === ADMIN TREE (Polished) === */
/* ============================== */
.editable-node {
  background: var(--panel);
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
  border: 1px solid var(--line);
}

.editable-node-head {
  display: grid;
  grid-template-columns: minmax(170px, 1.1fr) minmax(170px, 1fr) minmax(100px, 0.7fr) auto;
  align-items: end;
  gap: 14px;
}

.editable-node-head .admin-field,
.editable-child-row .admin-field {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin-bottom: 0;
}

.editable-node-head .admin-field span,
.editable-child-row .admin-field span {
  white-space: nowrap;
  margin-bottom: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
}

.editable-node-head .admin-field input,
.editable-node-head .admin-field select,
.editable-child-row .admin-field input,
.editable-child-row .admin-field select {
  min-width: 0;
  padding: 10px 8px;
  border-radius: 10px;
  background: var(--page);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  transition: 0.2s;
}

.editable-node-head .admin-field input:focus,
.editable-child-row .admin-field input:focus {
  border-color: var(--blue);
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--blue-light);
  outline: none;
}

.node-diff {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.node-diff.has-gap { color: var(--red); font-weight: 600; }

.editable-children { padding-top: 8px; }
.editable-children > .quiet-button { margin-top: 10px; margin-left: 42px; }

.editable-child-row {
  display: grid;
  grid-template-columns: 34px minmax(170px, 1fr) minmax(170px, 0.8fr) auto;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
}
.editable-child-row.is-leaf { grid-template-columns: 34px minmax(170px, 1fr) minmax(170px, 0.8fr) auto; }
.editable-child-name { min-width: 0; }
.editable-child-amount { min-width: 0; }

/* Toggle Button */
.child-toggle-button {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--page);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--line);
  color: var(--muted);
}
.child-toggle-button:hover { background: var(--blue-light); color: var(--blue); border-color: var(--blue-light); }
.child-toggle-button svg { transition: transform 0.25s ease; }
.editable-child-group.is-collapsed .child-toggle-button svg { transform: rotate(-90deg); }
.child-toggle-spacer { width: 28px; height: 28px; flex-shrink: 0; }

/* Grandchildren */
.editable-grandchildren {
  padding-left: 36px;
  border-left: 2px solid var(--line);
  margin-left: 16px;
  margin-top: 8px;
  padding-top: 4px;
  padding-bottom: 2px;
}
.editable-child-group.is-collapsed > .editable-grandchildren { display: none; }

/* Row Actions */
.editable-node-head .danger-button,
.editable-row-actions { justify-self: end; }
.editable-row-actions { display: flex; gap: 8px; flex-shrink: 0; }

@media (max-width: 680px) {
  .editable-node-head {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 12px;
  }
  .editable-child-row,
  .editable-child-row.is-leaf {
    grid-template-columns: 34px 1fr;
    align-items: stretch;
    gap: 12px;
  }
  .editable-child-row > .child-toggle-button,
  .editable-child-row > .child-toggle-spacer { grid-column: 1; grid-row: 1; }
  .editable-child-row > .editable-child-name { grid-column: 2; grid-row: 1; }
  .editable-child-row > .editable-child-amount { grid-column: 2; grid-row: 2; }
  .editable-child-row > .editable-row-actions { grid-column: 2; grid-row: 3; justify-self: stretch; justify-content: flex-end; }
  
  .editable-node-head .danger-button { justify-self: stretch; width: 100%; }
  .editable-grandchildren { margin-left: 8px; padding-left: 20px; }
  .editable-children > .quiet-button { margin-left: 22px; }
}
