:root {
  color-scheme: light dark;
  font-family: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --ease-out-decel: cubic-bezier(0.22, 1, 0.36, 1);
  --target-size: 36px;
  --control-h-sm: 36px;
  --control-h-md: 42px;

  /* Light palette (matched to household-dashboard) */
  --background: #f2f4f6;
  --foreground: #191f28;
  --surface: #ffffff;
  --surface-secondary: #f2f4f6;
  --default: #e5e8eb;
  --default-hover: #d9dde2;
  --muted: #6b7684;
  --border: #e5e8eb;
  --divider: #f2f4f6;
  --card-border: rgba(0, 27, 55, 0.055);
  --card-shadow: 0 2px 12px rgba(0, 27, 55, 0.04);

  --accent: #3182f6;
  --accent-hover: #1b64da;
  --accent-foreground: #ffffff;
  --accent-soft: #e8f3ff;
  --accent-soft-hover: #d5e8ff;
  --accent-soft-foreground: #1b64da;

  --ink-pill-bg: #191f28;
  --ink-pill-fg: #ffffff;

  --danger: #f04452;
  --danger-hover: #d93644;
  --danger-soft: #ffeeef;
  --danger-soft-foreground: #c92b39;

  --positive: #0d9468;
  --positive-soft: #e6f7f1;
  --positive-soft-foreground: #0a6e4c;

  --warning: #d97706;
  --warning-soft: #fff5e2;
  --warning-soft-foreground: #8c5206;

  --glass-bg: rgba(255, 255, 255, 0.86);

  /* Category / Domain colors */
  --cat-sky-accent: #2788f5;
  --cat-sky-soft: #e8f3ff;
  --cat-sky-text: #185fb2;

  --cat-indigo-accent: #4c64f0;
  --cat-indigo-soft: #edf0ff;
  --cat-indigo-text: #3143ad;

  --cat-teal-accent: #0ea5a9;
  --cat-teal-soft: #e6f7f8;
  --cat-teal-text: #0b6e72;

  --cat-amber-accent: #e09112;
  --cat-amber-soft: #fff5e2;
  --cat-amber-text: #8c5206;

  --cat-pine-accent: #13a070;
  --cat-pine-soft: #e6f7f1;
  --cat-pine-text: #0a6e4c;

  --cat-coral-accent: #eb6146;
  --cat-coral-soft: #ffedea;
  --cat-coral-text: #a5341f;

  --cat-slate-accent: #6b7684;
  --cat-slate-soft: #f2f4f6;
  --cat-slate-text: #4e5968;

  --scrollbar-thumb: rgba(107, 118, 132, 0.36);
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

/* Dark theme via system preference (when not explicitly pinned to light) */
@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) {
    --background: #101012;
    --foreground: #f2f4f6;
    --surface: #17171c;
    --surface-secondary: #202027;
    --default: #2c2c35;
    --default-hover: #363642;
    --muted: #9ea6b2;
    --border: #2a2a33;
    --divider: #22222a;
    --card-border: #262630;
    --card-shadow: none;

    --accent: #4593fc;
    --accent-hover: #5ca2ff;
    --accent-foreground: #ffffff;
    --accent-soft: rgba(69, 147, 252, 0.16);
    --accent-soft-hover: rgba(69, 147, 252, 0.24);
    --accent-soft-foreground: #7cb4ff;

    --ink-pill-bg: #f2f4f6;
    --ink-pill-fg: #101012;

    --danger: #ff6b78;
    --danger-hover: #ff5261;
    --danger-soft: rgba(240, 68, 82, 0.16);
    --danger-soft-foreground: #ff8c96;

    --positive: #3ed19b;
    --positive-soft: rgba(62, 209, 155, 0.16);
    --positive-soft-foreground: #7be8bf;

    --warning: #f5b342;
    --warning-soft: rgba(245, 179, 66, 0.16);
    --warning-soft-foreground: #ffd07a;

    --glass-bg: rgba(23, 23, 28, 0.84);

    --cat-sky-accent: #5ca2ff;
    --cat-sky-soft: rgba(92, 162, 255, 0.16);
    --cat-sky-text: #9bc6ff;

    --cat-indigo-accent: #8294ff;
    --cat-indigo-soft: rgba(130, 148, 255, 0.16);
    --cat-indigo-text: #b7c2ff;

    --cat-teal-accent: #38cfd4;
    --cat-teal-soft: rgba(56, 207, 212, 0.16);
    --cat-teal-text: #7ae5e8;

    --cat-amber-accent: #f5b342;
    --cat-amber-soft: rgba(245, 179, 66, 0.16);
    --cat-amber-text: #ffd07a;

    --cat-pine-accent: #3ed19b;
    --cat-pine-soft: rgba(62, 209, 155, 0.16);
    --cat-pine-text: #7be8bf;

    --cat-coral-accent: #ff846b;
    --cat-coral-soft: rgba(255, 132, 107, 0.16);
    --cat-coral-text: #ffb3a3;

    --cat-slate-accent: #8b95a1;
    --cat-slate-soft: rgba(139, 149, 161, 0.16);
    --cat-slate-text: #c2c8d1;

    --scrollbar-thumb: rgba(158, 166, 178, 0.32);
  }
}

/* Explicit dark override via <meta name="color-scheme"> */
:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  color-scheme: dark;
  --background: #101012;
  --foreground: #f2f4f6;
  --surface: #17171c;
  --surface-secondary: #202027;
  --default: #2c2c35;
  --default-hover: #363642;
  --muted: #9ea6b2;
  --border: #2a2a33;
  --divider: #22222a;
  --card-border: #262630;
  --card-shadow: none;

  --accent: #4593fc;
  --accent-hover: #5ca2ff;
  --accent-foreground: #ffffff;
  --accent-soft: rgba(69, 147, 252, 0.16);
  --accent-soft-hover: rgba(69, 147, 252, 0.24);
  --accent-soft-foreground: #7cb4ff;

  --ink-pill-bg: #f2f4f6;
  --ink-pill-fg: #101012;

  --danger: #ff6b78;
  --danger-hover: #ff5261;
  --danger-soft: rgba(240, 68, 82, 0.16);
  --danger-soft-foreground: #ff8c96;

  --positive: #3ed19b;
  --positive-soft: rgba(62, 209, 155, 0.16);
  --positive-soft-foreground: #7be8bf;

  --warning: #f5b342;
  --warning-soft: rgba(245, 179, 66, 0.16);
  --warning-soft-foreground: #ffd07a;

  --glass-bg: rgba(23, 23, 28, 0.84);

  --cat-sky-accent: #5ca2ff;
  --cat-sky-soft: rgba(92, 162, 255, 0.16);
  --cat-sky-text: #9bc6ff;

  --cat-indigo-accent: #8294ff;
  --cat-indigo-soft: rgba(130, 148, 255, 0.16);
  --cat-indigo-text: #b7c2ff;

  --cat-teal-accent: #38cfd4;
  --cat-teal-soft: rgba(56, 207, 212, 0.16);
  --cat-teal-text: #7ae5e8;

  --cat-amber-accent: #f5b342;
  --cat-amber-soft: rgba(245, 179, 66, 0.16);
  --cat-amber-text: #ffd07a;

  --cat-pine-accent: #3ed19b;
  --cat-pine-soft: rgba(62, 209, 155, 0.16);
  --cat-pine-text: #7be8bf;

  --cat-coral-accent: #ff846b;
  --cat-coral-soft: rgba(255, 132, 107, 0.16);
  --cat-coral-text: #ffb3a3;

  --cat-slate-accent: #8b95a1;
  --cat-slate-soft: rgba(139, 149, 161, 0.16);
  --cat-slate-text: #c2c8d1;

  --scrollbar-thumb: rgba(158, 166, 178, 0.32);
}

/* Explicit light override via <meta name="color-scheme"> */
:root:has(> head > meta[name="color-scheme"][content="light"]) {
  color-scheme: light;
}

/* Theme toggle icon visibility (follows active color-scheme without JS desync) */
.theme-opt-light {
  display: none;
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-opt-dark {
  display: none;
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-opt-light {
  display: inline-flex;
}

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-opt-dark {
    display: none;
  }

  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-opt-light {
    display: inline-flex;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  overscroll-behavior-y: contain;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin: 0;
  text-wrap: balance;
  word-break: keep-all;
}

p {
  margin: 0;
  text-wrap: pretty;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:where(button, select, input, summary, [tabindex="0"]):focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.app-frame {
  width: 100%;
  min-width: 0;
}

/* Sticky Top Bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
}

.top-bar-inner {
  width: min(100%, 1120px);
  margin-inline: auto;
  padding: 8px clamp(12px, 2.8vw, 22px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-group {
  display: flex;
  align-items: center;
  min-width: 0;
}

.brand-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  margin: -4px -6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  transition: opacity 140ms ease;
}

.brand-home-btn:hover {
  opacity: 0.84;
}

.brand-mark {
  flex-shrink: 0;
}

.brand-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.brand-title-text {
  font-size: 1.02rem;
  font-weight: 760;
  letter-spacing: -0.025em;
  white-space: nowrap;
}

.brand-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-soft-foreground);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Password Lock Screen */
.lock-screen[hidden],
.app-frame[hidden] {
  display: none;
}

.lock-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--background);
}

.lock-card {
  width: min(380px, 100%);
  padding: 32px 24px 26px;
  border-radius: 24px;
  border: 1px solid var(--card-border);
  background: var(--surface);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.lock-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.lock-brand h1 {
  font-size: 1.24rem;
  font-weight: 780;
  letter-spacing: -0.025em;
  margin-top: 4px;
}

.lock-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lock-input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--surface-secondary);
  color: var(--foreground);
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-align: center;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.lock-input::placeholder {
  letter-spacing: normal;
  font-size: 0.92rem;
  font-weight: 500;
}

.lock-input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.lock-error {
  min-height: 18px;
  font-size: 0.82rem;
  font-weight: 640;
  color: var(--danger);
  text-align: center;
}

.lock-error:empty {
  display: none;
}

.lock-submit-btn {
  width: 100%;
  height: 46px;
  border-radius: 14px;
  font-size: 0.95rem;
}

.top-bar-divider {
  display: none;
}

.icon-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

@media (hover: hover) {
  .icon-action-btn:hover {
    background: var(--surface-secondary);
    color: var(--foreground);
  }
}

.icon-action-btn.is-spinning svg {
  animation: spin 650ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (min-width: 768px) {
  .top-bar-inner {
    padding-block: 11px;
  }

  .brand-title-text {
    font-size: 1.15rem;
  }

  .top-bar-divider {
    display: block;
    width: 1px;
    height: 18px;
    margin-inline: 2px;
    background: var(--border);
  }
}

/* Main Shell */
.shell {
  width: min(100%, 1120px);
  margin-inline: auto;
  padding: clamp(12px, 2vw, 20px) max(clamp(12px, 2.8vw, 22px), env(safe-area-inset-right, 0px)) calc(92px + env(safe-area-inset-bottom, 0px)) max(clamp(12px, 2.8vw, 22px), env(safe-area-inset-left, 0px));
}

@media (min-width: 768px) {
  .shell {
    padding-bottom: 56px;
  }
}

/* Responsive Navigation (Desktop underline tabs, Mobile bottom frosted glass bar) */
.ledger-nav {
  position: fixed;
  inset-block-end: 0;
  inset-inline: 0;
  z-index: 30;
  background: var(--glass-bg);
  border-top: 1px solid var(--divider);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 4px max(6px, env(safe-area-inset-left, 0px)) max(6px, env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-right, 0px));
}

.ledger-tablist {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 2px;
  max-width: 600px;
  margin-inline: auto;
}

.ledger-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 50px;
  min-width: 0;
  padding: 5px 2px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 140ms ease;
}

.ledger-tab[aria-current="page"] {
  color: var(--foreground);
  font-weight: 740;
}

.ledger-tab[aria-current="page"] svg {
  color: var(--accent);
}

.ledger-tab[aria-current="page"]::after {
  content: "";
  position: absolute;
  inset: 0 28% auto;
  border-block-start: 2.5px solid var(--accent);
  border-radius: 0 0 2px 2px;
}

.tab-label-desktop {
  display: none;
}

.tab-label-mobile {
  display: inline;
}

@media (min-width: 768px) {
  .ledger-nav {
    position: static;
    background: transparent;
    border-top: 0;
    border-bottom: 1px solid var(--border);
    padding: 0;
    margin-bottom: 18px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .ledger-tablist {
    display: flex;
    align-items: center;
    max-width: none;
    gap: 6px;
    overflow-x: auto;
  }

  .ledger-tab {
    flex: none;
    flex-direction: row;
    gap: 7px;
    min-height: 42px;
    padding: 8px 14px;
    font-size: 0.92rem;
    border-radius: 10px 10px 0 0;
  }

  .ledger-tab[aria-current="page"]::after {
    inset: auto 10px -1px;
    border-block-start: 0;
    border-block-end: 2.5px solid var(--foreground);
    border-radius: 2px 2px 0 0;
  }

  @media (hover: hover) {
    .ledger-tab:not([aria-current="page"]):hover {
      color: var(--foreground);
    }
  }

  .tab-label-desktop {
    display: inline;
  }

  .tab-label-mobile {
    display: none;
  }
}

/* Page Heading */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.page-kicker {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 2px;
}

.page-title {
  font-size: clamp(1.24rem, 1.08rem + 0.8vw, 1.56rem);
  font-weight: 780;
  letter-spacing: -0.03em;
  line-height: 1.24;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--control-h-sm);
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 0.85rem;
  font-weight: 660;
  letter-spacing: -0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 140ms ease, border-color 140ms ease, transform 120ms ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-foreground);
}

@media (hover: hover) {
  .btn-primary:not(:disabled):hover {
    background: var(--accent-hover);
  }
}

.btn-secondary {
  background: var(--default);
  color: var(--foreground);
}

@media (hover: hover) {
  .btn-secondary:not(:disabled):hover {
    background: var(--default-hover);
  }
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--foreground);
}

@media (hover: hover) {
  .btn-outline:not(:disabled):hover {
    background: var(--surface-secondary);
  }
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

@media (hover: hover) {
  .btn-ghost:not(:disabled):hover {
    background: var(--surface-secondary);
    color: var(--foreground);
  }
}

.btn-sm {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 10px;
  font-size: 0.79rem;
}

/* Bento Overview Grid */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(10px, 2vw, 14px);
  margin-bottom: 16px;
}

@media (min-width: 820px) {
  .overview-grid.cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .overview-grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 819px) {
  .overview-grid.cols-3 > .metric-card:first-child {
    grid-column: 1 / -1;
  }
}

.metric-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 5px;
  min-width: 0;
  padding: clamp(12px, 1.8vw, 16px) clamp(14px, 2.2vw, 18px);
  border-radius: 18px;
  border: 1px solid var(--card-border);
  background: var(--surface);
  box-shadow: var(--card-shadow);
  text-align: left;
}

button.metric-card {
  cursor: pointer;
  transition: transform 140ms var(--ease-out-decel), border-color 140ms ease;
}

@media (hover: hover) {
  button.metric-card:hover {
    border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
    transform: translateY(-1px);
  }
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.metric-label-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.metric-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  flex-shrink: 0;
}

.metric-dot.is-danger {
  background: var(--danger);
}

.metric-dot.is-positive {
  background: var(--positive);
}

.metric-dot.is-muted {
  background: var(--muted);
}

.metric-label {
  font-size: 0.77rem;
  font-weight: 660;
  color: var(--muted);
}

.metric-cue {
  font-size: 0.75rem;
  font-weight: 660;
  color: var(--accent);
  white-space: nowrap;
}

.metric-value {
  font-size: clamp(1.16rem, 1rem + 0.75vw, 1.44rem);
  font-weight: 780;
  letter-spacing: -0.03em;
  line-height: 1.18;
  color: var(--foreground);
}

.metric-value.is-danger {
  color: var(--danger);
}

.metric-value.is-positive {
  color: var(--positive);
}

.metric-sub {
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--muted);
}

/* Panels */
.panel {
  border: 1px solid var(--card-border);
  border-radius: 22px;
  padding: clamp(16px, 2.5vw, 24px);
  margin-bottom: 14px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
}

.panel-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-heading h2 {
  font-size: clamp(1.02rem, 0.96rem + 0.3vw, 1.16rem);
  font-weight: 740;
  letter-spacing: -0.02em;
}

.panel-sub {
  margin-top: 3px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

.section-subhead {
  margin: 16px 0 6px;
  font-size: 0.83rem;
  font-weight: 720;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.empty-note {
  padding: 18px 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

/* Filters Container (matched to household-dashboard .list-filters) */
.list-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  margin-bottom: 14px;
  border-radius: 16px;
  background: var(--surface-secondary);
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-icon {
  position: absolute;
  inset-inline-start: 12px;
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: var(--control-h-md);
  min-height: var(--control-h-md);
  padding: 0 36px 0 36px;
  border: 1.5px solid transparent;
  border-radius: 12px;
  background: var(--surface);
  color: var(--foreground);
  font-size: 0.9rem;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-clear-btn {
  position: absolute;
  inset-inline-end: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.filter-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: var(--control-h-sm);
  min-height: var(--control-h-sm);
  padding: 0 13px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 640;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.filter-pill.is-active {
  background: var(--ink-pill-bg);
  border-color: var(--ink-pill-bg);
  color: var(--ink-pill-fg);
  font-weight: 700;
}

.filter-pill.is-danger-alert:not(.is-active) {
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  background: var(--danger-soft);
  color: var(--danger-soft-foreground);
}

.filter-pill-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 13%, transparent);
  font-size: 0.72rem;
  font-weight: 720;
  line-height: 1;
}

.filter-select,
.filter-date {
  height: var(--control-h-sm);
  min-height: var(--control-h-sm);
  padding: 0 11px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--foreground);
  font-size: 0.83rem;
  font-weight: 600;
  max-width: 100%;
}

.filter-select {
  max-width: 240px;
}

.seg-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--default);
}

.seg-btn {
  height: 30px;
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 0.81rem;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 140ms ease, color 140ms ease;
}

.seg-btn.is-active {
  background: var(--surface);
  color: var(--foreground);
  font-weight: 720;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Status & Category Pills */
.tx-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 7px;
  background: var(--surface-secondary);
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 640;
  white-space: nowrap;
}

.tx-pill.is-accent {
  background: var(--accent-soft);
  color: var(--accent-soft-foreground);
}

.tx-pill.is-danger {
  background: var(--danger-soft);
  color: var(--danger-soft-foreground);
}

.tx-pill.is-positive {
  background: var(--positive-soft);
  color: var(--positive-soft-foreground);
}

.tx-pill.is-warning {
  background: var(--warning-soft);
  color: var(--warning-soft-foreground);
}

.tx-pill.cat-sky {
  background: var(--cat-sky-soft);
  color: var(--cat-sky-text);
}

.tx-pill.cat-indigo {
  background: var(--cat-indigo-soft);
  color: var(--cat-indigo-text);
}

.tx-pill.cat-teal {
  background: var(--cat-teal-soft);
  color: var(--cat-teal-text);
}

.tx-pill.cat-amber {
  background: var(--cat-amber-soft);
  color: var(--cat-amber-text);
}

/* Domain Icon Badges */
.balance-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent-soft-foreground);
  flex-shrink: 0;
  font-weight: 750;
  font-size: 0.85rem;
}

.balance-icon.cat-sky {
  background: var(--cat-sky-soft);
  color: var(--cat-sky-text);
}

.balance-icon.cat-indigo {
  background: var(--cat-indigo-soft);
  color: var(--cat-indigo-text);
}

.balance-icon.cat-teal {
  background: var(--cat-teal-soft);
  color: var(--cat-teal-text);
}

.balance-icon.cat-amber {
  background: var(--cat-amber-soft);
  color: var(--cat-amber-text);
}

.balance-icon.is-danger {
  background: var(--danger-soft);
  color: var(--danger-soft-foreground);
}

.balance-icon.is-positive {
  background: var(--positive-soft);
  color: var(--positive-soft-foreground);
}

.balance-icon.is-slate {
  background: var(--cat-slate-soft);
  color: var(--cat-slate-text);
}

/* Balance / Inventory List Groups */
.balance-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.balance-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.balance-group-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.96rem;
  font-weight: 740;
}

.balance-group-meta {
  font-size: 0.8rem;
  font-weight: 660;
  color: var(--muted);
}

.balance-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.balance-row {
  border-bottom: 1px solid var(--divider);
}

.balance-row:last-child {
  border-bottom: 0;
}

.balance-row-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  padding: 11px 8px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms ease;
}

@media (hover: hover) {
  .balance-row-btn:hover {
    background: var(--surface-secondary);
  }
}

.balance-main {
  flex: 1;
  min-width: 0;
}

.balance-title-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.balance-title-line strong {
  font-size: 0.94rem;
  font-weight: 680;
  line-height: 1.35;
  word-break: keep-all;
}

.balance-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.balance-amount-col {
  flex-shrink: 0;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.balance-amount {
  font-size: 0.98rem;
  font-weight: 760;
  white-space: nowrap;
}

.balance-amount.is-danger {
  color: var(--danger);
}

.balance-sub-qty {
  font-size: 0.72rem;
  color: var(--muted);
}

.balance-chevron {
  color: var(--muted);
  flex-shrink: 0;
}

/* Responsive Data Table (modern-web-guidance: responsive-table) */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(640px, 72vh);
  container-type: inline-size;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

.inv-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 640px;
}

.inv-table caption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.inv-table th,
.inv-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
}

.inv-table thead th {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: var(--surface-secondary);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.inv-table thead th.is-num,
.inv-table td.is-num {
  text-align: right;
}

.inv-table tbody th {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  background: var(--surface);
  text-align: left;
  font-weight: 680;
  font-size: 0.89rem;
  min-width: 185px;
  max-width: 300px;
  white-space: normal;
  word-break: keep-all;
  border-right: 1px solid var(--divider);
}

.inv-table tbody tr:hover td,
.inv-table tbody tr:hover th {
  background: var(--surface-secondary);
}

.inv-table tbody tr:last-child th,
.inv-table tbody tr:last-child td {
  border-bottom: 0;
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-weight: inherit;
  cursor: pointer;
}

.sort-btn:hover {
  color: var(--foreground);
}

.sort-ind {
  font-size: 0.72rem;
  color: var(--accent);
}

/* History / Transaction Feed */
.summary-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--card-border);
  font-size: 0.83rem;
  color: var(--muted);
}

.summary-strip-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}

.summary-strip strong {
  color: var(--foreground);
}

.summary-strip strong.is-danger {
  color: var(--danger);
}

.summary-strip strong.is-positive {
  color: var(--positive);
}

.tx-date-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--divider);
}

.tx-date-title {
  font-size: 0.9rem;
  font-weight: 740;
}

.tx-date-total {
  font-size: 0.8rem;
  font-weight: 660;
  color: var(--muted);
}

.tx-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--divider);
}

.tx-row:last-child {
  border-bottom: 0;
  padding-bottom: 2px;
}

.tx-main {
  flex: 1;
  min-width: 0;
}

.tx-label {
  display: block;
  font-size: 0.93rem;
  font-weight: 660;
  line-height: 1.38;
  word-break: keep-all;
}

.tx-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
}

.tx-amount {
  flex-shrink: 0;
  font-size: 0.96rem;
  font-weight: 750;
  text-align: right;
  white-space: nowrap;
}

.tx-amount.is-out {
  color: var(--foreground);
}

.tx-amount.is-plus {
  color: var(--positive);
}

/* Expandable Item History Cards (출고 기록 → 품목별) */
.item-history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-history-card {
  border: 1px solid var(--card-border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.item-history-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

.item-history-summary::-webkit-details-marker {
  display: none;
}

.item-history-summary:hover {
  background: var(--surface-secondary);
}

.item-history-chevron {
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 160ms var(--ease-out-decel);
}

.item-history-card[open] .item-history-chevron {
  transform: rotate(90deg);
}

.item-history-body {
  padding: 0 16px 12px;
  border-top: 1px solid var(--divider);
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

/* Work Forms (출고 확인 / 전수조사 / 설정 기준수량) */
.work-list {
  display: flex;
  flex-direction: column;
}

.work-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}

.work-row:last-child {
  border-bottom: 0;
}

.work-row.is-modified {
  background: color-mix(in srgb, var(--accent-soft) 45%, transparent);
  margin-inline: -10px;
  padding-inline: 10px;
  border-radius: 12px;
}

.work-info {
  flex: 1 1 240px;
  min-width: 0;
}

.work-name {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.94rem;
  font-weight: 680;
  word-break: keep-all;
}

.work-stock-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 0.79rem;
  color: var(--muted);
}

.work-preview {
  font-weight: 700;
}

.work-preview.is-danger {
  color: var(--danger);
}

.work-preview.is-positive {
  color: var(--positive);
}

.work-inputs {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.work-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.work-field-label {
  font-size: 0.71rem;
  font-weight: 700;
  color: var(--muted);
}

.work-field-label.is-out {
  color: var(--danger-soft-foreground);
}

.work-field-label.is-prod {
  color: var(--positive-soft-foreground);
}

.num-input {
  width: 92px;
  height: 38px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-secondary);
  color: var(--foreground);
  font-size: 0.92rem;
  font-weight: 680;
  text-align: right;
}

.num-input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.num-input.is-invalid {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.audit-after-row {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-secondary);
  font-size: 0.78rem;
  color: var(--muted);
}

.audit-after-row .num-input {
  width: 78px;
  height: 32px;
  min-height: 32px;
  background: var(--surface);
}

/* Sticky Action Bar */
.sticky-action-bar {
  position: sticky;
  bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  z-index: 15;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--glass-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 8px 24px rgba(0, 27, 55, 0.1);
}

@media (min-width: 768px) {
  .sticky-action-bar {
    bottom: 16px;
  }
}

.sticky-summary {
  font-size: 0.84rem;
  color: var(--muted);
}

.sticky-summary strong {
  color: var(--foreground);
}

.sticky-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Info Banner */
.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-soft-foreground);
  font-size: 0.84rem;
  line-height: 1.45;
}

.info-banner.is-positive {
  background: var(--positive-soft);
  color: var(--positive-soft-foreground);
}

.info-banner.is-warning {
  background: var(--warning-soft);
  color: var(--warning-soft-foreground);
}

/* Settings Page */
.settings-section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}

.settings-form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 180px;
}

.form-field label {
  font-size: 0.78rem;
  font-weight: 680;
  color: var(--muted);
}

.text-input {
  height: var(--control-h-md);
  min-height: var(--control-h-md);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-secondary);
  color: var(--foreground);
  font-size: 0.9rem;
}

.text-input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.theme-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 560px) {
  .theme-choice-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.theme-choice-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface-secondary);
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.theme-choice-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.theme-choice-btn strong {
  font-size: 0.9rem;
}

.theme-choice-btn small {
  font-size: 0.76rem;
  color: var(--muted);
}

/* Native <dialog> Confirmation Modal (modern-web-guidance: dialog) */
.app-dialog {
  width: min(480px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  padding: 20px;
  border: 1px solid var(--card-border);
  border-radius: 22px;
  background: var(--surface);
  color: var(--foreground);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.app-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.app-dialog:modal {
  overscroll-behavior: contain;
}

.app-dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(4px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialog-head h1 {
  font-size: 1.1rem;
  font-weight: 760;
}

.dialog-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-secondary);
  color: var(--muted);
  cursor: pointer;
}

.dialog-desc {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.dialog-body {
  overflow-y: auto;
  max-height: 46dvh;
  border: 1px solid var(--divider);
  border-radius: 14px;
  padding: 6px 12px;
  background: var(--surface-secondary);
}

.dialog-body:empty {
  display: none;
}

.dialog-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 0.84rem;
}

.dialog-item-row:last-child {
  border-bottom: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

@media (max-width: 640px) {
  .app-dialog {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  }

  .dialog-actions .btn {
    flex: 1;
  }
}

/* Floating Toast */
.app-toast:not(:empty) {
  position: fixed;
  left: 50%;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(92vw, 420px);
  padding: 11px 18px;
  border-radius: 999px;
  background: var(--ink-pill-bg);
  color: var(--ink-pill-fg);
  font-size: 0.85rem;
  font-weight: 660;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  text-align: center;
}

@media (min-width: 768px) {
  .app-toast:not(:empty) {
    bottom: 24px;
  }
}

/* Collapsible details summary in Home */
details.panel summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.94rem;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

details.panel summary::-webkit-details-marker {
  display: none;
}

details.panel[open] summary {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--divider);
}

@media (max-width: 560px) {
  .work-inputs {
    width: 100%;
    justify-content: flex-end;
  }
}
