:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #637083;
  --line: #dfe5ec;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

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

button {
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 10px 14px;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.96);
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.12), rgba(37, 99, 235, 0.08)),
    var(--bg);
}

.login-panel {
  width: min(920px, calc(100vw - 32px));
  min-height: 420px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 48px;
}

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

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: 42px;
}

.login-copy,
.muted {
  color: var(--muted);
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

.amount-filter {
  max-width: 132px;
}

textarea {
  min-width: 180px;
  resize: vertical;
}

.form-error {
  min-height: 20px;
  color: var(--danger);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: #111827;
  color: #e5e7eb;
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand small {
  display: block;
  margin-top: 4px;
  color: #9ca3af;
}

nav {
  display: grid;
  gap: 8px;
}

nav button,
.ghost {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #d1d5db;
  border: 1px solid transparent;
}

nav button.active,
nav button:hover,
.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
}

.ghost {
  margin-top: auto;
}

.content {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.user-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: var(--muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.usage-panel {
  margin-bottom: 16px;
}

.usage-head {
  align-items: flex-end;
  margin-bottom: 10px;
}

.usage-head p {
  margin: 6px 0 0;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.usage-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
  padding: 18px;
}

.usage-card.current {
  border-color: rgba(15, 118, 110, 0.42);
  box-shadow: 0 10px 26px rgba(15, 118, 110, 0.12);
}

.usage-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.usage-card-head span {
  font-size: 18px;
  font-weight: 800;
}

.usage-card-head strong {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-size: 12px;
  padding: 5px 9px;
}

.usage-card ol {
  margin: 0;
  padding-left: 22px;
  color: #334155;
}

.usage-card li {
  margin: 8px 0;
  line-height: 1.55;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.panel-head,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.toolbar {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select {
  width: auto;
  min-width: 160px;
}

.toolbar #taskSearch,
.toolbar #invoiceSearch {
  min-width: 240px;
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-filters button {
  padding: 8px 11px;
  background: #eef2f7;
  color: var(--ink);
}

.quick-filters button.active {
  background: var(--accent);
  color: #fff;
}

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

.assist-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.assist-grid h4 {
  margin: 0 0 10px;
}

.assist-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 9px 0;
}

.assist-row.compact {
  grid-template-columns: minmax(180px, 1fr) auto;
}

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

.assist-row strong,
.assist-row small {
  display: block;
}

.assist-row small {
  color: var(--muted);
  margin-top: 3px;
}

.assist-row span {
  font-weight: 700;
  white-space: nowrap;
}

.assist-row button {
  padding: 7px 9px;
  background: #eef2f7;
  color: var(--ink);
}

.desk-item {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.desk-item span,
.desk-item small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.desk-item strong {
  display: block;
  margin-top: 6px;
  font-size: 21px;
}

.toolbar input {
  max-width: 360px;
}

.toolbar select {
  max-width: 180px;
}

.text-btn {
  background: transparent;
  color: var(--accent-2);
  padding: 0;
}

.rank-list {
  display: grid;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

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

.rank-name {
  min-width: 0;
}

.rank-name strong {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.rank-name small,
.import-list small {
  color: var(--muted);
}

.rank-amount {
  text-align: right;
  font-weight: 700;
}

.rank-amount .mini-action {
  margin-left: 8px;
}

.mini-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 6px 8px;
  background: #eef2f7;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.mini-action.danger,
.row-actions button.danger {
  background: #fee2e2;
  color: var(--danger);
}

.bar {
  grid-column: 1 / -1;
  height: 6px;
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-top-scroll {
  height: 18px;
  margin: 8px 0 6px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.table-top-scroll-spacer {
  height: 1px;
}

.table-top-scroll.is-hidden {
  display: none;
}

table {
  width: 100%;
  min-width: 1800px;
  border-collapse: collapse;
  background: #fff;
}

.user-table {
  min-width: 900px;
}

.user-reset {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.user-reset button:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

td {
  font-size: 14px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef2f7;
  color: #334155;
  white-space: nowrap;
}

.status.danger {
  background: #fee2e2;
  color: var(--danger);
}

.status.ok {
  background: #dcfce7;
  color: var(--ok);
}

.status.warn {
  background: #fef3c7;
  color: var(--warn);
}

.manual-review-row {
  background: #fff7ed;
}

.manual-review-tag {
  display: inline-block;
  margin-top: 5px;
  color: var(--warn);
  font-weight: 700;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions button,
.row-actions .mini-action {
  padding: 7px 9px;
  background: #eef2f7;
  color: var(--ink);
}

.mini-form {
  min-width: 170px;
}

.mini-form select,
.mini-form input {
  min-width: 150px;
  padding: 7px 8px;
  margin-bottom: 6px;
}

.note-cell {
  max-width: 260px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-result {
  margin-top: 14px;
  color: var(--muted);
}

.skipped-account-details {
  margin-top: 12px;
  color: var(--ink);
}

.skipped-account-details summary {
  cursor: pointer;
  color: var(--danger);
  font-weight: 700;
}

.compact-table-wrap {
  margin-top: 10px;
  max-height: 320px;
}

.compact-table {
  min-width: 1080px;
}

.compact-table th,
.compact-table td {
  padding: 8px 10px;
  font-size: 13px;
}

.settings-panel {
  max-width: 520px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.45);
  padding: 20px;
}

.modal-card {
  width: min(560px, 100%);
  display: grid;
  gap: 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .metric-grid,
  .desk-grid,
  .assist-grid,
  .usage-grid,
  .two-col,
  .three-col,
  .login-panel {
    grid-template-columns: 1fr;
  }

  .usage-card-head {
    display: grid;
  }
}
