:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f5f6f8;
  --panel-3: #eceff3;
  --text: #111318;
  --muted: #69707d;
  --line: #d9dde5;
  --line-soft: rgba(17, 19, 24, 0.08);
  --accent: #111318;
  --accent-hover: #2a2e36;
  --accent-soft: rgba(17, 19, 24, 0.055);
  --positive: #00a878;
  --danger: #ef4444;
  --shadow: 0 16px 42px rgba(17, 19, 24, 0.08);
  --font-sans:
    Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-display:
    "SF Pro Display", Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-number: "DIN Alternate", "Roboto Mono", "SFMono-Regular", Consolas, monospace;
  font-family: var(--font-sans);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ui-icon {
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1fr);
  gap: 18px;
  width: min(920px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-visual {
  min-height: 430px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #f5f6f8;
}

.login-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.88) contrast(1.03);
}

.login-content {
  display: grid;
  align-content: center;
  gap: 18px;
  padding: clamp(18px, 4vw, 36px);
}

.login-content .brand-mark {
  width: 42px;
  height: 42px;
}

.login-content .brand-mark .ui-icon {
  width: 24px;
  height: 24px;
}

.login-submit {
  width: 100%;
  min-height: 42px;
}

.login-submit.loading {
  cursor: wait;
  opacity: 0.82;
}

.login-message {
  display: flex;
  align-items: center;
  min-height: 34px;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 12px;
}

.login-message:empty {
  display: none;
}

.login-message[data-type="error"] {
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 56px;
  padding: 8px clamp(12px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 850;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
}

.brand-mark .ui-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 750;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease;
}

.btn:hover,
.icon-btn:hover {
  border-color: #b7beca;
  background: var(--panel-3);
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 820;
}

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

.btn.subtle {
  border-color: var(--line-soft);
  background: #fff;
  color: var(--muted);
}

.btn.danger {
  border-color: rgba(239, 68, 68, 0.32);
  color: var(--danger);
}

.btn .ui-icon {
  width: 14px;
  height: 14px;
}

.icon-btn {
  width: 32px;
  padding: 0;
  font-size: 15px;
}

.layout {
  width: min(1420px, 100%);
  margin: 0 auto;
  padding: 10px clamp(10px, 2.4vw, 24px) 32px;
}

.content {
  display: grid;
  grid-template-columns: minmax(230px, 270px) minmax(330px, 420px) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.side-panel,
.list-panel,
.detail-panel {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.side-panel,
.list-panel,
.detail-panel {
  position: sticky;
  top: 66px;
  display: grid;
  max-height: calc(100vh - 76px);
  overflow: hidden;
}

.detail-panel {
  grid-template-rows: auto minmax(0, 1fr);
}

.panel-head,
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  border-bottom: 1px solid var(--line-soft);
  padding: 11px 12px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(24px, 2.6vw, 32px);
  font-weight: 860;
  line-height: 1.08;
  letter-spacing: 0;
}

h2,
h3 {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 850;
  line-height: 1.2;
}

h3 {
  font-size: 14px;
}

h2 .ui-icon,
h3 .ui-icon {
  color: var(--positive);
}

.summary-copy {
  max-width: 600px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 9px;
  outline: none;
}

input::placeholder {
  color: #a1a7b3;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 19, 24, 0.08);
}

.month-card,
.year-overview {
  display: grid;
  gap: 10px;
  border-bottom: 1px solid var(--line-soft);
  padding: 12px;
}

.year-overview {
  border-bottom: 0;
  padding: 0;
}

.year-head {
  display: grid;
  grid-template-columns: minmax(86px, 0.8fr) minmax(0, 1.2fr);
  align-items: end;
  gap: 8px;
}

.annual-total {
  min-height: 54px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(0, 168, 120, 0.08), transparent 62%),
    #fff;
  padding: 9px;
}

.annual-total strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-family: var(--font-number);
  font-size: 18px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.annual-total span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.year-chart {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.year-month {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  padding: 4px 6px;
  text-align: left;
}

.year-month:hover,
.year-month.active {
  background: var(--accent-soft);
}

.year-bar-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-2);
}

.year-bar {
  display: block;
  width: var(--value);
  height: 100%;
  border-radius: inherit;
  background: #b7beca;
}

.year-month.active .year-bar {
  background: var(--accent);
}

.year-month strong {
  color: var(--text);
  font-family: var(--font-number);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.year-month em {
  color: var(--muted);
  font-family: var(--font-number);
  font-size: 11px;
  font-style: normal;
  white-space: nowrap;
}

.filter-details {
  border-bottom: 1px solid var(--line-soft);
}

.filter-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 850;
}

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

.filter-details summary::after {
  content: "+";
  color: var(--muted);
  font-family: var(--font-number);
  font-size: 16px;
}

.filter-details[open] summary::after {
  content: "-";
}

.filter-panel {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 12px;
}

.panel-count {
  border: 1px solid rgba(17, 19, 24, 0.16);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 4px 8px;
  font-family: var(--font-number);
  font-size: 11px;
  font-weight: 800;
}

.expense-list {
  display: grid;
  align-content: start;
  overflow: auto;
}

.expense-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: inherit;
  padding: 12px;
  text-align: left;
  transition: background 0.16s ease;
}

.expense-card:hover {
  background: #f7f8fa;
}

.expense-card.active {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--positive);
}

.expense-card strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 840;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expense-card span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.expense-card b {
  color: var(--danger);
  font-family: var(--font-number);
  font-size: 18px;
  font-weight: 850;
  white-space: nowrap;
}

.detail-head {
  border-bottom: 1px solid var(--line-soft);
}

.detail-head h2 {
  font-size: 16px;
}

.detail-head span {
  color: var(--muted);
  font-family: var(--font-number);
  font-size: 12px;
  white-space: nowrap;
}

.section-block {
  display: grid;
  gap: 10px;
}

.bar-list {
  display: grid;
  align-content: start;
  gap: 2px;
  overflow: auto;
  padding: 0 12px 12px;
}

.category-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 0;
}

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

.row-label {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-main {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.line-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.line-item span {
  color: var(--text);
  font-family: var(--font-number);
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.line-item em {
  color: var(--muted);
  font-family: var(--font-number);
  font-size: 11px;
  font-style: normal;
  text-align: right;
}

.bar-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-2);
}

.bar-fill {
  width: var(--value);
  max-width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--positive), #2563eb);
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.empty.compact {
  padding: 12px;
}

.dialog {
  width: min(720px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0;
  box-shadow: 0 24px 80px rgba(17, 19, 24, 0.2);
}

.dialog::backdrop {
  background: rgba(17, 19, 24, 0.38);
}

.dialog form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 12px;
}

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

.dialog-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

@media (max-width: 1120px) {
  .content {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 14px;
  }

  .login-card,
  .content,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .login-screen {
    align-items: start;
    padding: 12px;
  }

  .login-card {
    gap: 10px;
    padding: 10px;
  }

  .login-visual {
    min-height: 240px;
  }

  .login-content {
    padding: 18px;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 10px;
    padding: 10px 12px;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 92px;
    justify-content: start;
    width: 100%;
  }

  .actions .btn {
    min-height: 38px;
  }

  .side-panel,
  .list-panel,
  .detail-panel {
    position: static;
    max-height: none;
  }

  .side-panel,
  .list-panel,
  .detail-panel {
    box-shadow: none;
  }

  .layout {
    padding: 10px 10px 24px;
  }

  .content {
    gap: 10px;
  }

  input,
  select {
    min-height: 40px;
  }

  .dialog {
    width: min(640px, calc(100vw - 16px));
  }

  .dialog form {
    padding: 14px;
  }
}

@media (max-width: 520px) {
  .login-visual {
    min-height: 170px;
  }

  .brand {
    font-size: 14px;
  }

  .panel-head,
  .month-card,
  .filter-panel {
    padding: 10px;
  }

  .year-overview {
    padding: 0;
  }

  .year-head {
    grid-template-columns: 1fr;
  }

  .year-chart {
    gap: 5px;
    padding: 8px;
  }

  .year-month {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .year-month em {
    grid-column: 2;
  }

  .expense-card {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 11px 10px;
  }

  .expense-card b {
    font-size: 17px;
  }

  .category-row {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
  }

  .line-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px;
  }

  .line-item span {
    font-size: 11px;
  }

  .dialog-actions {
    grid-template-columns: 1fr 1fr;
  }

  .dialog-actions span {
    display: none;
  }

  .dialog-actions .danger {
    grid-column: 1 / -1;
  }
}

@media (max-width: 380px) {
  .actions {
    grid-template-columns: 1fr;
  }

}
