:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #161a20;
  --muted: #6a7280;
  --line: #e4e7ec;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --ok: #15803d;
  --ok-bg: #e8f6ec;
  --bad: #b91c1c;
  --bad-bg: #fdeaea;
  --warn: #b45309;
  --warn-bg: #fdf0d9;
  --plan: #1d4ed8;
  --plan-bg: #e8edfd;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101418;
    --card: #171c22;
    --ink: #e7eaee;
    --muted: #98a1ad;
    --line: #2a313a;
    --accent: #2dd4bf;
    --accent-ink: #07211d;
    --ok: #4ade80;
    --ok-bg: #123024;
    --bad: #f87171;
    --bad-bg: #3a1717;
    --warn: #fbbf24;
    --warn-bg: #3a2a10;
    --plan: #93b4ff;
    --plan-bg: #16233f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-inner { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; }
.brand:hover { text-decoration: none; }
.logo {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 12px; font-weight: 800; letter-spacing: .02em;
}
.brand-text { font-size: 15px; }
.nav { display: flex; gap: 4px; overflow-x: auto; margin-left: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--muted); font-size: 14px; padding: 6px 10px; border-radius: 999px; white-space: nowrap;
}
.nav a:hover { color: var(--ink); text-decoration: none; background: var(--card); }
.nav a.active { color: var(--accent-ink); background: var(--accent); }

.main { padding: 20px 16px 48px; }

.flash {
  margin-top: 14px; padding: 10px 14px; border-radius: 12px; font-size: 14px;
}
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--bad-bg); color: var(--bad); }

.hero { padding: 6px 0 18px; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
h1 { margin: 0; font-size: 28px; line-height: 1.2; letter-spacing: -.01em; }
h2 { margin: 0; font-size: 17px; }
h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 8px 0; }
.hero-sub { margin: 8px 0 0; color: var(--muted); }
.hero-actions, .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.actions.sticky { position: sticky; bottom: 12px; background: var(--bg); padding: 10px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-size: 15px; cursor: pointer; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.wide { width: 100%; }

.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.danger-text { color: var(--bad); }
.inline { display: inline; }

.stats-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 18px;
}
.stats-strip.compact { grid-template-columns: repeat(5, 1fr); }
.stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line);
  color: inherit; box-shadow: var(--shadow);
}
a.stat:hover { text-decoration: none; border-color: var(--accent); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-value.small-value { font-size: 16px; }
.stat-small { font-size: 14px; font-weight: 500; color: var(--muted); }
.stat-note { font-size: 12px; color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-wrap { flex-wrap: wrap; }
.row-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-link { color: inherit; flex: 1; }
.row-link:hover { text-decoration: none; }
.row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.time { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.date { color: var(--muted); font-size: 14px; min-width: 62px; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--line); color: var(--muted); white-space: nowrap;
}
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.plan { background: var(--plan-bg); color: var(--plan); }
.pill.mute { background: var(--line); color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { padding: 3px 9px; border-radius: 999px; background: var(--line); font-size: 12px; color: var(--ink); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.quote { margin: 12px 0 0; padding-left: 12px; border-left: 3px solid var(--accent); color: var(--ink); font-style: italic; }
.pain { margin: 12px 0 0; color: var(--bad); }
.empty { color: var(--muted); margin: 6px 0; }

.list { margin: 6px 0; padding-left: 18px; }
.list li { margin: 4px 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.month-nav { display: flex; gap: 8px; }

.calendar {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.cal-head, .cal-week { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-head { background: var(--bg); border-bottom: 1px solid var(--line); }
.cal-head span { padding: 8px 0; text-align: center; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cal-week { border-bottom: 1px solid var(--line); }
.cal-week:last-child { border-bottom: 0; }
.cal-day {
  position: relative; min-height: 78px; padding: 6px; border-right: 1px solid var(--line);
  color: inherit; display: flex; flex-direction: column; gap: 4px; overflow: hidden;
}
.cal-day:last-child { border-right: 0; }
.cal-day:hover { text-decoration: none; background: var(--bg); }
.cal-day.empty { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-num { font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-day.done .cal-num, .cal-day.sick .cal-num, .cal-day.missed .cal-num, .cal-day.planned .cal-num { color: var(--ink); }
.cal-body { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-item { font-size: 10.5px; line-height: 1.25; padding: 1px 3px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-item b { font-weight: 600; }
.cal-item.done { background: var(--ok-bg); color: var(--ok); }
.cal-item.planned { background: var(--plan-bg); color: var(--plan); }
.cal-item.missed { background: var(--bad-bg); color: var(--bad); }
.cal-item.sick { background: var(--warn-bg); color: var(--warn); }
.cal-item.rest { background: var(--line); color: var(--muted); }
.cal-dot { display: none; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 2px; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dot.done { background: var(--ok); }
.dot.planned { background: var(--plan); }
.dot.missed { background: var(--bad); }
.dot.sick { background: var(--warn); }

.details { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.details summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.details summary::-webkit-details-marker { display: none; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-top: 10px; }
.inline-form label, .form-inline label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

.status-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.form .card { overflow: visible; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); margin: 8px 0; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], input[type=email], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: inherit; font-size: 15px; min-height: 42px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.rows-grid { display: flex; flex-direction: column; gap: 8px; }
.tech-row { display: grid; grid-template-columns: 2fr .6fr .6fr 1.2fr; gap: 6px; }
.spar-row { display: grid; grid-template-columns: 1.4fr .6fr .9fr 1fr 1fr; gap: 6px; }
.zones { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; align-items: center; }
.zones .label { font-size: 13px; color: var(--muted); }
.check { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); margin: 0; }
.check input { width: auto; min-height: 0; }
.form-inline { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }

.raw {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  font-size: 13px; white-space: pre-wrap; word-break: break-word; overflow-x: auto;
}

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid var(--line); }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 44px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; }
.bar-label { color: var(--muted); }
.bar-track { display: block; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-done { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar-warn { display: block; height: 100%; background: var(--warn); border-radius: 999px; }
.bar-value { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.tech-stats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.tech-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 5px; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.segmented a { padding: 7px 12px; font-size: 13px; color: var(--muted); }
.segmented a:hover { text-decoration: none; background: var(--card); }
.segmented a.on { background: var(--accent); color: var(--accent-ink); }

.chart { width: 100%; height: 160px; color: var(--accent); background: var(--bg); border-radius: 10px; }
.chart-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

.copy { display: flex; gap: 8px; }
.copy input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.login { min-height: 68vh; display: grid; place-items: center; }
.login-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); padding: 28px 22px;
}
.login-logo {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 16px;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 16px;
}
.login-card h1 { font-size: 24px; }
.login-card form { margin-top: 18px; text-align: left; }
.login-card .btn { margin-top: 12px; }
.login-note { margin-top: 16px; }

.foot { border-top: 1px solid var(--line); margin-top: 12px; }
.foot-inner { display: flex; justify-content: space-between; gap: 12px; padding: 18px 16px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.foot-links { display: flex; gap: 14px; align-items: center; }

@media (max-width: 640px) {
  h1 { font-size: 24px; }
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
  .stats-strip.compact { grid-template-columns: repeat(5, 1fr); }
  .stats-strip.compact .stat { padding: 8px 6px; }
  .stats-strip.compact .stat-value { font-size: 17px; }
  .stats-strip.compact .stat-label { font-size: 9px; }
  .grid, .grid-3 { grid-template-columns: 1fr; }
  .tech-row { grid-template-columns: 2fr .7fr .7fr; }
  .tech-row input[name=tech_notes] { grid-column: 1 / -1; }
  .spar-row { grid-template-columns: 1.4fr .7fr 1fr; }
  .spar-row input[name=sp_submission], .spar-row input[name=sp_notes] { grid-column: span 1; }
  .cal-day { min-height: 54px; padding: 4px; }
  .cal-item { display: none; }
  .cal-dot { display: block; width: 6px; height: 6px; border-radius: 50%; margin-top: auto; }
  .cal-day.done .cal-dot { background: var(--ok); }
  .cal-day.planned .cal-dot { background: var(--plan); }
  .cal-day.missed .cal-dot { background: var(--bad); }
  .cal-day.sick .cal-dot { background: var(--warn); }
  .cal-day.rest .cal-dot { background: var(--muted); }
  .nav a { padding: 6px 8px; font-size: 13px; }
  .bar-row { grid-template-columns: 38px 1fr 58px; }
}
