:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #f8fbff;
  --panel-3: #eef7f2;
  --text: #1d2129;
  --muted: #86909c;
  --border: #e5e6eb;
  --border-strong: #cfe8d8;
  --accent: #165dff;
  --accent-2: #4080ff;
  --accent-dark: #1d2129;
  --accent-ink: #ffffff;
  --ok: #087443;
  --warn: #a15c07;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(29, 33, 41, .12);
  --soft-shadow: 0 2px 8px rgba(0, 0, 0, .08);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, #fbfffd 0%, var(--bg) 48%, #f8fffb 100%);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .52;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(82, 201, 154, .24);
  outline-offset: 1px;
  border-color: var(--accent);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 18px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #fbfffd 0%, #e9f8ef 48%, #ffffff 100%);
}

.login-panel {
  width: min(520px, 100%);
  display: grid;
  gap: 24px;
  padding: 28px 40px 34px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-head {
  display: grid;
  gap: 12px;
}

.login-brand {
  display: grid;
  place-items: center;
  padding: 2px 0 8px;
}

.login-logo {
  display: block;
  width: min(220px, 100%);
  height: auto;
  max-height: 220px;
  object-fit: contain;
  border-radius: 8px;
}

.login-form,
.form-grid {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #364152;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
}

input[type="file"] {
  padding: 7px 10px;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.primary,
.ghost,
.soft,
.danger {
  min-height: 36px;
  padding: 8px 13px;
  border-radius: 6px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 8px 18px rgba(18, 147, 99, .18);
}

.ghost {
  background: #ffffff;
  color: var(--muted);
  border-color: var(--border);
}

.soft {
  background: #eef9f3;
  color: #0d5f45;
  border-color: #cfe8d8;
}

.danger {
  background: #fff1f0;
  color: var(--danger);
  border-color: #ffd8d3;
}

.primary:hover {
  filter: brightness(.97);
}

.ghost:hover,
.soft:hover,
.danger:hover {
  filter: brightness(.98);
  border-color: rgba(18, 147, 99, .34);
}

.small {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 16px;
  background: linear-gradient(180deg, #e7f8ef 0%, #d8f0e2 48%, #cde9dc 100%);
  color: var(--text);
  box-shadow: 1px 0 0 rgba(255, 255, 255, .06) inset;
}

.brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-areas:
    "logo name"
    "logo user";
  column-gap: 10px;
  row-gap: 2px;
  min-height: 64px;
  align-content: center;
  align-items: center;
  padding: 0 12px 16px;
  border-bottom: 1px solid rgba(18, 147, 99, .16);
}

.brand-logo {
  grid-area: logo;
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 10px;
  background: #ffffff;
}

.brand strong {
  grid-area: name;
  min-width: 0;
  color: #0b3b2b;
  font-size: 18px;
  line-height: 1.1;
  white-space: nowrap;
}

.brand span {
  grid-area: user;
  min-width: 0;
  overflow: hidden;
  color: #5f756b;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#desktopNav,
.mobile-nav {
  display: grid;
  gap: 6px;
  align-content: start;
}

.nav-btn {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  background: transparent;
  color: #31564a;
  border: 1px solid transparent;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  box-sizing: border-box;
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
  transition: background-color .16s ease, color .16s ease, border-color .16s ease;
}

.nav-btn.active,
.nav-btn:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, .75), rgba(82, 201, 154, .24));
  color: #0d5f45;
  border-color: rgba(18, 147, 99, .22);
}

.nav-icon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-label {
  display: inline-flex;
  flex: 0 0 4em;
  width: 4em;
  min-width: 4em;
  align-items: center;
  justify-content: space-between;
  overflow: visible;
  white-space: nowrap;
}

.nav-label.count-1 {
  justify-content: center;
}

.nav-char {
  display: inline-block;
  line-height: 1;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 28px;
  background: linear-gradient(90deg, #ffffff 0%, #f2fbf6 62%, #e8f8ef 100%);
  border-bottom: 1px solid var(--border);
}

.top-actions,
.row-actions,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.finance-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.segment-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.segment-tabs button {
  min-height: 34px;
  padding: 6px 14px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segment-tabs button.active,
.segment-tabs button:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.filter-panel {
  display: grid;
  grid-template-columns: 1.4fr repeat(5, minmax(120px, 1fr)) auto;
  align-items: end;
  gap: 10px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 1px;
}

.content {
  display: grid;
  align-content: start;
  align-items: start;
  grid-auto-rows: max-content;
  gap: 12px;
  padding: 16px 22px 28px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.card-grid.two {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.stat-card,
.action-card,
.table-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

.stat-card {
  min-height: 72px;
  display: grid;
  align-content: start;
  gap: 3px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #ffffff 0%, #f0fbf5 100%);
  border-color: #cfe8d8;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  color: var(--accent-dark);
  font-size: 18px;
  line-height: 1.15;
}

.stat-card .inline-action {
  justify-self: start;
  margin-top: 8px;
}

.action-card {
  min-height: 46px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  display: flex;
  align-items: center;
  font-weight: 800;
}

.action-card:hover {
  color: #0d5f45;
  border-color: rgba(18, 147, 99, .34);
}

.table-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.table-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.table-card h3 {
  color: var(--text);
  font-size: 18px;
}

.table-scroll {
  overflow: auto;
  max-height: calc(100vh - 248px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}

table {
  width: 100%;
  min-width: 960px;
  table-layout: fixed;
  border-collapse: collapse;
  border: 1px solid var(--border);
}

th,
td {
  height: 64px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  color: var(--text);
  font-size: 13px;
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th:last-child,
td:last-child {
  border-right: 0;
}

th {
  color: #475467;
  background: #f2fbf6;
  font-weight: 700;
}

.sort-head {
  width: 100%;
  min-height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: inherit;
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.sort-head.active {
  color: var(--accent);
}

.sort-arrow {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

th.col-action,
td.col-action {
  width: 420px;
}

td.col-action {
  overflow: visible;
  white-space: normal;
}

td.col-action .row-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px;
}

td.col-action .small {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 13px !important;
}

tbody tr:hover td {
  background: #f7fdf9;
}

.empty {
  padding: 18px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f7f8fa;
  color: #4e5969;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  color: #087443;
  background: #eafaf2;
  border-color: #b9ebcf;
}

.badge.warn {
  color: #a15c07;
  background: #fff7e8;
  border-color: #ffe0a3;
}

.badge.danger {
  color: #b42318;
  background: #fff1f0;
  border-color: #ffd8d3;
}

.modal {
  width: min(760px, calc(100vw - 28px));
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
}

.modal::backdrop {
  background: rgba(17, 25, 40, .48);
}

.modal-card {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-card header,
.modal-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-card footer {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.modal-body {
  max-height: min(72vh, 720px);
  overflow: auto;
  padding: 18px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: #4e5969;
  font-size: 22px;
  line-height: 1;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.mobile-nav {
  display: none;
}

body,
button,
input,
select,
textarea,
label,
h1,
h2,
h3,
p,
span,
strong,
th,
td,
.badge,
.nav-btn,
.primary,
.ghost,
.soft,
.danger {
  font-weight: 400 !important;
}

button,
input,
select,
textarea,
label,
p,
span,
th,
td,
.badge,
.nav-btn,
.primary,
.ghost,
.soft,
.danger,
.table-card,
.toolbar {
  font-size: 14px !important;
}

.stat-card strong {
  font-size: 18px !important;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101623;
  --panel: #161d2b;
  --panel-2: #101827;
  --panel-3: #1d2b43;
  --text: #e6edf7;
  --muted: #9aa8ba;
  --border: #263244;
  --border-strong: #2d3a4f;
  --accent: #4f8cff;
  --accent-2: #78a6ff;
  --accent-dark: #e6edf7;
  --shadow: 0 18px 48px rgba(0, 0, 0, .34);
  --soft-shadow: 0 2px 10px rgba(0, 0, 0, .24);
  background: #101623;
  color: var(--text);
}

body[data-theme="dark"] .login-shell,
body[data-theme="dark"] .app-shell {
  background: linear-gradient(180deg, #0e1420 0%, #101623 100%);
}

body[data-theme="dark"] .login-panel,
body[data-theme="dark"] .stat-card,
body[data-theme="dark"] .action-card,
body[data-theme="dark"] .table-scroll,
body[data-theme="dark"] .modal-card,
body[data-theme="dark"] .modal-card footer {
  background: #161d2b;
  border-color: #263244;
  color: var(--text);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .28);
}

body[data-theme="dark"] .side-nav,
body[data-theme="dark"] .topbar {
  background: #121a27;
  border-color: #263244;
  color: var(--text);
  box-shadow: none;
}

body[data-theme="dark"] .brand {
  border-bottom-color: #263244;
}

body[data-theme="dark"] .brand strong,
body[data-theme="dark"] h1,
body[data-theme="dark"] h2,
body[data-theme="dark"] h3,
body[data-theme="dark"] .stat-card strong {
  color: #e6edf7;
}

body[data-theme="dark"] .brand span,
body[data-theme="dark"] .nav-btn,
body[data-theme="dark"] .muted,
body[data-theme="dark"] .eyebrow,
body[data-theme="dark"] label {
  color: #9aa8ba;
}

body[data-theme="dark"] .brand-logo,
body[data-theme="dark"] .login-logo {
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .08);
}

body[data-theme="dark"] .nav-btn.active,
body[data-theme="dark"] .nav-btn:hover {
  color: #d7e6ff;
  background: #1d2b43;
  border-color: #2d3a4f;
}

body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea,
body[data-theme="dark"] .ghost,
body[data-theme="dark"] .icon-btn {
  background: #101827;
  color: #e6edf7;
  border-color: #2d3a4f;
}

body[data-theme="dark"] .primary {
  background: linear-gradient(135deg, #2f73ff 0%, #19b989 100%);
  color: #ffffff;
}

body[data-theme="dark"] .soft {
  background: #18243a;
  color: #8db5ff;
  border-color: #2d3a4f;
}

body[data-theme="dark"] .finance-switch,
body[data-theme="dark"] .segment-tabs,
body[data-theme="dark"] .filter-panel {
  background: #161d2b;
  border-color: #263244;
}

body[data-theme="dark"] .danger {
  background: #321b22;
  color: #ff9c96;
  border-color: #74333a;
}

body[data-theme="dark"] th {
  color: #c4cfdd;
  background: #1a2332;
}

body[data-theme="dark"] td {
  color: #dce5f2;
}

body[data-theme="dark"] table,
body[data-theme="dark"] th,
body[data-theme="dark"] td {
  border-color: #263244;
}

body[data-theme="dark"] tbody tr:hover td {
  background: #1a2332;
}

body[data-theme="dark"] .badge {
  background: #1a2332;
  border-color: #2d3a4f;
  color: #c4cfdd;
}

body[data-theme="dark"] .badge.ok {
  border-color: #1f6f4a;
  background: #10291f;
  color: #66e29b;
}

body[data-theme="dark"] .badge.warn {
  border-color: #7a5521;
  background: #2a2115;
  color: #f6c06d;
}

body[data-theme="dark"] .badge.danger {
  border-color: #74333a;
  background: #2b171d;
  color: #ff9c96;
}

body[data-theme="dark"] .empty {
  color: #c4cfdd;
}

body[data-theme="dark"] .toast {
  background: #eef4ff;
  color: #101827;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: static;
    height: auto;
  }

  .workspace {
    display: grid;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px 16px;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .content {
    align-content: start;
    padding: 16px;
  }

  .card-grid,
  .card-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .card-grid,
  .card-grid.two {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .filter-panel {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 24px 20px 28px;
  }

  .login-logo {
    width: min(260px, 100%);
  }

  .stat-card {
    min-height: 72px;
    padding: 12px;
  }

  .stat-card strong {
    font-size: 20px;
  }

  .action-card {
    min-height: 46px;
    font-size: 15px;
  }

  .topbar h2 {
    font-size: 22px;
  }
}
