:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #15202b;
  --muted: #6b7785;
  --line: #dfe5ec;
  --dark: #18212f;
  --blue: #1f6feb;
  --green: #0f8a5f;
  --orange: #b96a00;
  --red: #c2413a;
  --shadow: 0 12px 32px rgba(24, 33, 47, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 9px 13px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

button:hover { filter: brightness(0.96); }

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid rgba(31, 111, 235, 0.22);
  border-color: var(--blue);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  padding: 22px 16px;
  background: var(--dark);
  color: #edf4ff;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span,
.sidebar-links a {
  color: #aab8ca;
  font-size: 13px;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.side-nav button {
  min-height: 42px;
  background: transparent;
  color: #cbd6e5;
  text-align: left;
  font-weight: 650;
}

.side-nav button.active,
.side-nav button:hover {
  background: #263348;
  color: #fff;
}

.sidebar-links {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.sidebar-links a {
  text-decoration: none;
}

.shell {
  margin-left: 248px;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 17px;
}

.api-box {
  display: grid;
  grid-template-columns: 220px auto auto;
  gap: 8px;
}

.notice {
  display: none;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #eaf3ff;
  color: #174ea6;
  border: 1px solid #cfe0ff;
}

.notice.active { display: block; }
.notice.error { background: #fff1f0; color: var(--red); border-color: #ffd2cf; }

.page {
  display: none;
}

.page.active {
  display: grid;
  gap: 16px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metrics article,
.panel,
.ledger-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 16px;
}

.metrics span,
.panel-title span,
td span,
.empty {
  color: var(--muted);
}

.metrics strong {
  display: block;
  margin-top: 7px;
  font-size: 22px;
}

.panel {
  padding: 16px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.wide {
  grid-column: 1 / -1;
}

.checkline {
  grid-template-columns: 20px 1fr;
  align-items: start;
  color: var(--ink);
  line-height: 1.45;
}

.checkline input {
  width: 18px;
  min-height: 18px;
  margin-top: 1px;
}

.form-grid button[type="submit"] {
  min-height: 42px;
}

.ledger-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ledger-card {
  padding: 14px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

dl {
  margin: 14px 0 0;
  display: grid;
  gap: 8px;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 750;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
}

td strong {
  display: block;
}

.mono {
  font-family: "Cascadia Mono", Consolas, monospace;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: #174ea6;
  font-size: 12px;
  font-weight: 750;
}

.status.confirmed,
.status.active {
  background: #e8f7ef;
  color: var(--green);
}

.status.finance_submitted {
  background: #fff4df;
  color: var(--orange);
}

.status.stopped {
  background: #fff1f0;
  color: var(--red);
}

.download {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.empty {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: auto;
    padding: 14px;
  }

  .side-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .shell {
    margin-left: 0;
    padding: 14px;
  }

  .topbar,
  .two-col {
    grid-template-columns: 1fr;
    display: grid;
  }

  .api-box,
  .metrics,
  .ledger-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
