:root {
  --ink: #0c2e36;
  --ink-soft: #1a4a55;
  --sea: #2a7a86;
  --mist: #e8f1f2;
  --paper: #f6f3ec;
  --paper-2: #efe9dc;
  --brass: #b08d57;
  --brass-soft: #d4bc8a;
  --line: rgba(12, 46, 54, 0.12);
  --text: #1c2a2e;
  --muted: #5c6d72;
  --danger: #9b3b3b;
  --radius: 14px;
  --shadow: 0 18px 40px rgba(12, 46, 54, 0.08);
  --side-w: 268px;
  --top-h: 64px;
  --font: "Noto Sans KR", sans-serif;
  --display: "Fraunces", "Noto Sans KR", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(42, 122, 134, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(176, 141, 87, 0.16), transparent 50%),
    linear-gradient(180deg, #f3efe6 0%, var(--paper) 40%, #f8f6f1 100%);
}

button,
select {
  font: inherit;
}

.app {
  min-height: 100vh;
}

/* Top */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.1rem 0 0.85rem;
  background: rgba(246, 243, 236, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
  min-width: 148px;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--ink) 0%, var(--sea) 100%);
  color: #f7f2e8;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}
.brand-text strong {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-text em {
  font-style: normal;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.top-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
  overflow-x: auto;
}
.top-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
}
.top-link:hover {
  color: var(--ink);
  background: rgba(42, 122, 134, 0.08);
}
.top-link.is-active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 0 var(--line);
}

.top-tools {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-left: auto;
}
.ledger-select {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.55rem 0.25rem 0.75rem;
}
.ledger-select select {
  border: 0;
  background: transparent;
  font-weight: 600;
  color: var(--ink);
  outline: none;
}
.period-chip,
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.period-chip .dot {
  color: var(--brass);
}
.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--mist);
  color: var(--sea);
  font-size: 0.75rem;
  font-weight: 700;
}
.user-name {
  font-weight: 600;
}

/* Shell */
.shell {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  min-height: calc(100vh - var(--top-h));
}

.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(12, 46, 54, 0.96), rgba(26, 74, 85, 0.98));
  color: #e8f0f2;
  padding: 1.15rem 0.85rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.side-label {
  margin: 0 0.55rem 0.2rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(232, 240, 242, 0.45);
}
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}
.side-group {
  border-radius: 12px;
  overflow: hidden;
}
.side-main {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0.72rem 0.8rem;
  cursor: pointer;
  text-align: left;
  border-radius: 12px;
  font-weight: 600;
}
.side-main:hover,
.side-group.is-open > .side-main {
  background: rgba(255, 255, 255, 0.08);
}
.side-main.is-current {
  background: rgba(176, 141, 87, 0.22);
}
.chev {
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid rgba(255, 255, 255, 0.55);
  border-bottom: 2px solid rgba(255, 255, 255, 0.55);
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  opacity: 0.7;
}
.side-group.is-open .chev {
  transform: rotate(45deg);
}
.side-sub {
  display: none;
  flex-direction: column;
  padding: 0.15rem 0.35rem 0.45rem 0.55rem;
  gap: 0.15rem;
}
.side-group.is-open .side-sub {
  display: flex;
}
.side-sub button {
  border: 0;
  background: transparent;
  color: rgba(232, 240, 242, 0.78);
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
}
.side-sub button:hover,
.side-sub button.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.side-foot {
  margin-top: auto;
  padding: 0.85rem 0.7rem 0.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.78rem;
  color: rgba(232, 240, 242, 0.55);
}
.side-foot a {
  color: var(--brass-soft);
  text-decoration: none;
}

.main {
  padding: 1.35rem 1.5rem 2.5rem;
  max-width: 1200px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}
.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sea);
  font-weight: 600;
}
.page-head h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  letter-spacing: -0.03em;
}
.page-desc {
  margin: 0.35rem 0 0;
  color: var(--muted);
  max-width: 36rem;
  line-height: 1.5;
}
.page-actions {
  display: flex;
  gap: 0.5rem;
}
.btn {
  border-radius: 12px;
  padding: 0.65rem 1rem;
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 600;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn.ghost {
  background: #fff;
}
.btn.primary {
  background: var(--ink);
  color: #f7f2e8;
  border-color: transparent;
}

.view[hidden] {
  display: none !important;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.kpi {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
}
.kpi.accent {
  background: linear-gradient(160deg, rgba(42, 122, 134, 0.12), rgba(255, 255, 255, 0.85));
  border-color: rgba(42, 122, 134, 0.25);
}
.kpi-label {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}
.kpi-value {
  margin: 0.35rem 0 0.15rem;
  font-family: var(--display);
  font-size: 1.65rem;
  letter-spacing: -0.03em;
}
.kpi-value.kpi-sm {
  font-size: 1.45rem;
}
.kpi-meta {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.85rem;
}
.panel {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}
.panel.span-2 {
  grid-column: 1 / -1;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}
.panel-head h2 {
  margin: 0;
  font-size: 1.02rem;
}
.tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--sea);
  background: var(--mist);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
}

.chart-mock {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background:
    linear-gradient(180deg, transparent 0%, rgba(246, 243, 236, 0.65) 100%),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 48px,
      rgba(12, 46, 54, 0.04) 48px,
      rgba(12, 46, 54, 0.04) 49px
    );
  border-radius: 12px;
  padding: 1rem 0.5rem 0.75rem;
}
.bars {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  height: 160px;
  padding: 0 0.75rem;
}
.bars i {
  flex: 1;
  height: var(--h);
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--sea), var(--ink-soft));
  opacity: 0.85;
  animation: rise 0.8s ease both;
}
.bars i:nth-child(odd) {
  background: linear-gradient(180deg, var(--brass-soft), var(--brass));
}
@keyframes rise {
  from {
    transform: scaleY(0.2);
    transform-origin: bottom;
    opacity: 0;
  }
}
.chart-caption {
  margin: 0.75rem 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.sum-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sum-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}
.sum-list li:last-child {
  border-bottom: 0;
}
.sum-list span {
  color: var(--muted);
}
.sum-list strong {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}
.quick {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, var(--paper-2));
  border-radius: 12px;
  padding: 1rem 0.9rem;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.quick:hover {
  transform: translateY(-2px);
  border-color: rgba(42, 122, 134, 0.35);
}

.placeholder-panel {
  min-height: 420px;
}
.placeholder-kicker {
  margin: 0;
  color: var(--sea);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
}
.placeholder-panel h2 {
  margin: 0.35rem 0 0.5rem;
  font-family: var(--display);
  font-size: 1.6rem;
}
.placeholder-panel > p {
  margin: 0 0 1.25rem;
  color: var(--muted);
  max-width: 40rem;
  line-height: 1.55;
}
.ph-frame {
  border: 1px dashed rgba(12, 46, 54, 0.22);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.5);
}
.ph-toolbar {
  height: 48px;
  background: linear-gradient(90deg, var(--mist), transparent);
  border-bottom: 1px solid var(--line);
}
.ph-grid {
  height: 260px;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 31px,
      rgba(12, 46, 54, 0.05) 31px,
      rgba(12, 46, 54, 0.05) 32px
    );
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 46, 54, 0.35);
  z-index: 30;
}

@media (max-width: 1100px) {
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dash-grid {
    grid-template-columns: 1fr;
  }
  .quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .nav-toggle {
    display: inline-flex;
  }
  .top-nav {
    display: none;
  }
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset: var(--top-h) auto 0 0;
    width: min(86vw, 300px);
    z-index: 35;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .user-name {
    display: none;
  }
  .main {
    padding: 1rem 1rem 2rem;
  }
  .page-head {
    flex-direction: column;
    align-items: flex-start;
  }
}
