:root {
  --canvas: #010102;
  --surface-1: #0f1011;
  --surface-2: #141516;
  --surface-3: #18191a;
  --hairline: #23252a;
  --hairline-strong: #34343a;
  --ink: #f7f8f8;
  --ink-muted: #d0d6e0;
  --ink-subtle: #8a8f98;
  --ink-tertiary: #62666d;
  --primary: #5e6ad2;
  --primary-hover: #828fff;
  --success: #27a644;
  --danger: #ff6b6b;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-edge: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
.button,
input,
select {
  height: 40px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 14px;
}

input,
select {
  width: 100%;
  padding: 0 12px;
  background: var(--surface-1);
  color: var(--ink);
  outline: none;
}

input::placeholder {
  color: var(--ink-tertiary);
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.2);
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--primary-hover);
}

.button.secondary {
  border-color: var(--hairline-strong);
  background: var(--surface-2);
  color: var(--ink);
}

.button.secondary:hover,
.nav:hover,
.nav.active {
  background: var(--surface-3);
  color: var(--ink);
}

.hidden {
  display: none !important;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--canvas);
}

.login-panel {
  width: min(392px, 100%);
  padding: 28px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow-edge);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-lockup.compact {
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(130, 143, 255, 0.35);
  border-radius: var(--radius-md);
  background: rgba(94, 106, 210, 0.16);
  color: var(--primary-hover);
  font-weight: 700;
}

.brand-lockup h1,
.brand-lockup strong {
  display: block;
  margin: 0;
  font-size: 22px;
  font-weight: 650;
}

.brand-lockup p,
.brand-lockup small {
  display: block;
  margin: 3px 0 0;
  color: var(--ink-subtle);
  font-size: 12px;
}

h2,
h3 {
  margin: 0;
  font-weight: 620;
}

.form-stack,
.form-grid {
  display: grid;
  gap: 12px;
}

.error-text {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--hairline);
  background: #08090a;
  padding: 18px 14px;
}

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

.nav {
  width: 100%;
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  color: var(--ink-subtle);
}

.nav.muted {
  margin-top: auto;
}

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

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

.topbar h2 {
  font-size: 24px;
  letter-spacing: 0;
}

.topbar span,
.panel-head span,
.stats span,
.result span {
  color: var(--ink-subtle);
  font-size: 12px;
}

.grid.two {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 16px;
}

.panel {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow-edge);
}

.panel h3 {
  font-size: 15px;
}

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

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

.table-wrap.tall {
  max-height: calc(100vh - 300px);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  color: var(--ink-subtle);
  font-size: 13px;
}

.pager div {
  display: flex;
  gap: 8px;
}

.pager button:disabled {
  border-color: var(--hairline);
  background: var(--surface-1);
  color: var(--ink-tertiary);
  cursor: not-allowed;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--hairline);
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--ink-subtle);
  font-weight: 560;
}

td {
  color: var(--ink-muted);
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

td.money,
td.ok {
  color: var(--success);
  font-variant-numeric: tabular-nums;
}

.stats,
.result {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stats div,
.result div {
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow-edge);
}

.stats strong,
.result strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  font-weight: 650;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(130px, 1fr) minmax(140px, 1fr) minmax(120px, 1fr) 140px 140px 78px 104px;
  gap: 10px;
  align-items: center;
}

.import-box {
  max-width: 620px;
}

.toast {
  max-width: 420px;
  border: 1px solid rgba(39, 166, 68, 0.35);
  border-radius: var(--radius-md);
  background: rgba(39, 166, 68, 0.12);
  color: #8be39f;
  padding: 9px 12px;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .sidebar {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--hairline);
  }

  .brand-lockup.compact {
    min-width: 172px;
    margin: 0;
  }

  .sidebar nav {
    display: flex;
  }

  .nav {
    width: auto;
    min-width: 72px;
    justify-content: center;
  }

  .nav.muted {
    margin: 0 0 0 auto;
  }

  .content {
    padding: 16px;
  }

  .grid.two,
  .stats,
  .result,
  .filters {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .pager {
    align-items: stretch;
    flex-direction: column;
  }

  .pager div {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
