:root {
  color: #17201c;
  background: #f4f6f4;
  font-family: "Segoe UI Variable", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  --ink: #17201c;
  --muted: #66716b;
  --line: #d9dedb;
  --surface: #ffffff;
  --surface-alt: #eef2ef;
  --accent: #176b4d;
  --accent-hover: #10553c;
  --accent-soft: #e5f1eb;
  --negative: #a43c32;
  --negative-soft: #f8e9e7;
  --focus: #176b4d;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  background: #f4f6f4;
  color: var(--ink);
  letter-spacing: 0;
}

button,
input { font: inherit; }

button { letter-spacing: 0; }

.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px clamp(18px, 4vw, 52px);
  border-bottom: 1px solid rgba(217, 222, 219, 0.92);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

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

.brand strong,
.brand small { display: block; }

.brand strong { font-size: 15px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.home-link {
  padding: 7px 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.home-link:hover { color: var(--accent); }

.service-status {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 42px clamp(18px, 4vw, 52px) 64px;
}

.auth-view {
  min-height: calc(100vh - 178px);
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(22, 31, 26, 0.08);
}

.auth-heading h1,
.dashboard-heading h1,
.section-title h2,
.code-band h2 { margin: 0; }

.auth-heading h1 { font-size: 30px; line-height: 1.25; }

.auth-heading > p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.auth-form {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.auth-form label {
  display: grid;
  gap: 8px;
  color: #39423e;
  font-size: 13px;
  font-weight: 600;
}

input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #bfc8c2;
  border-radius: 6px;
  outline: none;
  background: #fff;
  color: var(--ink);
}

input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(23, 107, 77, 0.14);
}

.button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button:disabled { cursor: wait; opacity: 0.62; }
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button.secondary { border-color: var(--line); background: #fff; color: var(--ink); }
.button.secondary:hover:not(:disabled) { border-color: #aeb8b1; background: var(--surface-alt); }
.button.quiet { background: transparent; color: var(--muted); }
.button.quiet:hover:not(:disabled) { background: var(--surface-alt); color: var(--ink); }

.auth-form .button { min-height: 46px; margin-top: 2px; }

.message {
  margin-top: 18px;
  padding: 11px 13px;
  border: 1px solid #e7b9b4;
  border-radius: 6px;
  background: var(--negative-soft);
  color: #7d2c25;
  font-size: 13px;
  line-height: 1.55;
}

.dashboard { display: block; }

.dashboard-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.dashboard-heading h1 {
  max-width: 760px;
  overflow-wrap: anywhere;
  font-size: 30px;
  line-height: 1.25;
}

.muted { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.rate-block { text-align: right; }
.rate-block span { display: block; color: var(--muted); font-size: 12px; }
.rate-block strong { display: block; margin-top: 4px; color: var(--accent); font-size: 25px; }

.code-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 24px 0;
  padding: 20px 22px;
  border: 1px solid #c9d7cf;
  border-radius: 8px;
  background: var(--accent-soft);
}

.code-band h2 { font-size: 18px; }

.code-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.code-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 6px 8px 6px 14px;
  border: 1px solid #b6cbbf;
  border-radius: 7px;
  background: #fff;
}

.code-item code {
  color: #123d2e;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
}

.code-copy {
  min-width: 56px;
  min-height: 30px;
  padding: 4px 9px;
  border: 0;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: var(--surface);
}

.metric {
  min-width: 0;
  min-height: 126px;
  padding: 20px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric span,
.metric small { display: block; }
.metric span { color: #4d5852; font-size: 13px; font-weight: 600; }
.metric strong { display: block; margin-top: 10px; overflow-wrap: anywhere; font-size: 23px; line-height: 1.25; }
.metric small { margin-top: 7px; color: #7a847f; font-size: 11px; line-height: 1.45; }
.metric.emphasis { box-shadow: inset 0 3px 0 var(--accent); }
.metric.emphasis strong { color: var(--accent); }
.metric.negative strong { color: var(--negative); }

.calculation-note {
  margin: 16px 0 28px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.view-tabs {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 42px;
  padding: 0 2px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.tab.active { border-bottom-color: var(--accent); color: var(--ink); }

.data-section { padding-top: 24px; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-title h2 { font-size: 18px; }
.section-title span { color: var(--muted); font-size: 12px; }

.table-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  table-layout: auto;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid #e6eae7;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  font-size: 12px;
}

th {
  background: #f7f8f7;
  color: #59635e;
  font-weight: 600;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcfb; }

.table-primary { color: var(--ink); font-weight: 600; }
.table-secondary { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.money-positive { color: var(--accent); font-weight: 700; }
.money-negative { color: var(--negative); font-weight: 700; }
.empty { padding: 36px 16px; color: var(--muted); text-align: center; }

@media (max-width: 980px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .topbar {
    min-height: 62px;
    align-items: flex-start;
    padding: 11px 16px;
  }

  .brand-mark { width: 34px; height: 34px; }
  .service-status { display: none; }
  .button { padding-inline: 10px; }
  .workspace { padding: 28px 16px 48px; }
  .auth-panel { padding: 26px 20px; }
  .auth-heading h1,
  .dashboard-heading h1 { font-size: 25px; }

  .dashboard-heading,
  .code-band,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-heading { gap: 18px; }
  .rate-block { text-align: left; }
  .code-list { width: 100%; justify-content: flex-start; }
  .code-item { width: 100%; justify-content: space-between; }
  .metrics { grid-template-columns: 1fr; }
  .metric { min-height: 108px; }
  .view-tabs { gap: 18px; overflow-x: auto; }
  .tab { flex: 0 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
