*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #666666;
  --faint: #8f8f8f;
  --border: #e8e8e8;
  --border-strong: #d6d6d6;
  --soft: #fafafa;
  --green: #067a46;
  --green-bg: #ecfdf3;
  --red: #c0392b;
  --red-bg: #fef3f2;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.wrap {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 24px;
}

.narrow {
  max-width: 660px;
}

.main {
  padding-top: 40px;
  padding-bottom: 72px;
}

/* nav */

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.brand span {
  color: var(--faint);
}

.nav-link {
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 7px;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
  color: var(--fg);
  background: var(--soft);
}

/* hero */

.hero {
  padding: 6px 0 34px;
}

.eyebrow {
  font-size: 13px;
  color: var(--muted);
}

.hero-value {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 2px;
  font-size: clamp(52px, 9vw, 78px);
  font-weight: 600;
  letter-spacing: -0.05em;
  line-height: 1.02;
  font-variant-numeric: tabular-nums;
}

.hero-unit {
  font-size: 20px;
  font-weight: 500;
  color: var(--faint);
  letter-spacing: 0;
}

.hero-meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.hero-meta .mono {
  color: var(--fg);
}

/* cards */

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  padding: 20px 22px;
}

.chart-card {
  padding-bottom: 12px;
  margin-bottom: 16px;
}

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

.card-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

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

.small {
  font-size: 13px;
}

/* goal */

.goal-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.goal-value {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.goal-value span {
  font-size: 15px;
  font-weight: 500;
  color: var(--faint);
  letter-spacing: 0;
}

.goal-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.goal-pct {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
}

.progress {
  height: 8px;
  margin: 16px 0 6px;
  border-radius: 999px;
  background: #f0f0f0;
  overflow: hidden;
}

.progress > div {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: #111;
  transition: width 0.45s ease;
}

.progress.done > div {
  background: var(--green);
}

.rows {
  margin-top: 8px;
  border-top: 1px solid var(--border);
}

.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

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

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

.row b {
  font-weight: 500;
  text-align: right;
}

/* badges + verdict */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge.ok {
  color: var(--green);
  background: var(--green-bg);
  border-color: #c9ecd8;
}

.badge.bad {
  color: var(--red);
  background: var(--red-bg);
  border-color: #f4d6d2;
}

.badge.neutral {
  color: var(--muted);
  background: var(--soft);
  border-color: var(--border);
}

.verdict {
  margin-bottom: 12px;
  font-size: 15px;
  line-height: 1.45;
}

.verdict b {
  font-weight: 600;
}

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

/* chart */

.chart {
  width: 100%;
  min-height: 220px;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart .empty {
  padding: 56px 0;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: #111;
}

.swatch.goal {
  background: repeating-linear-gradient(90deg, #bdbdbd 0 4px, transparent 4px 7px);
}

.swatch.proj {
  background: repeating-linear-gradient(90deg, #7a7a7a 0 2px, transparent 2px 5px);
}

/* table */

.table-wrap {
  margin: 0 -22px;
  padding: 0 22px;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  padding: 0 0 8px;
  border-bottom: 1px solid var(--border);
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table tr:last-child td {
  padding-bottom: 0;
  border-bottom: 0;
}

.table th:not(:first-child),
.table td:not(:first-child) {
  padding-left: 18px;
}

.table .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

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

.table .note-col {
  color: var(--muted);
}

.table .note-col span {
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.empty {
  padding: 28px 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.empty a,
.inline-link {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* footer */

.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 13px;
}

.footer a {
  color: var(--muted);
  text-decoration: none;
}

.footer a:hover {
  color: var(--fg);
}

/* admin */

.page-title {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.page-sub {
  margin: 4px 0 24px;
  color: var(--muted);
  font-size: 14px;
}

#panel > .card {
  margin-bottom: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--fg);
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus {
  border-color: #000;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.07);
}

input[type="date"],
input[type="datetime-local"] {
  min-height: 41px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid #000;
  border-radius: 8px;
  background: #000;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}

.btn:hover {
  opacity: 0.86;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn.ghost {
  border-color: var(--border-strong);
  background: #fff;
  color: var(--fg);
}

.btn.ghost:hover {
  background: var(--soft);
  opacity: 1;
}

.btn.danger {
  padding: 4px 8px;
  border-color: transparent;
  background: transparent;
  color: var(--red);
  font-size: 13px;
}

.btn.danger:hover {
  background: var(--red-bg);
  opacity: 1;
}

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

.hint {
  color: var(--faint);
  font-size: 12px;
}

.entry-list {
  max-height: 420px;
  margin: 0 -22px;
  padding: 0 22px;
  overflow-y: auto;
}

.entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.entry-main {
  min-width: 0;
}

.entry-w {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.entry-w span {
  margin-left: 3px;
  color: var(--faint);
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
}

.entry-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-actions {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 4px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 50;
  padding: 9px 16px;
  border-radius: 8px;
  background: #111;
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* responsive */

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

  .main {
    padding-top: 28px;
    padding-bottom: 48px;
  }

  .hero {
    padding-bottom: 26px;
  }
}

@media (max-width: 560px) {
  .wrap {
    padding: 0 16px;
  }

  .card {
    padding: 16px;
  }

  .table-wrap,
  .entry-list {
    margin: 0 -16px;
    padding: 0 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .hero-value {
    font-size: 50px;
  }

  .hide-sm {
    display: none;
  }

  .footer {
    flex-direction: column;
    gap: 6px;
  }
}
