:root {
  --navy: #14284b;
  --navy-soft: #1f3864;
  --ink: #1c2430;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f7fb;
  --card: #ffffff;
  --green: #12805c;
  --green-bg: #e6f4ee;
  --amber: #a86b00;
  --amber-bg: #fdf3dc;
  --red: #b3261e;
  --red-bg: #fdecea;
  --accent: #2f6fed;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 6px 20px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

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

header.topbar {
  background: var(--navy);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { font-weight: 650; letter-spacing: -0.01em; font-size: 16px; color: #fff; }
.brand span { opacity: 0.55; font-weight: 400; }

nav.main { display: flex; gap: 4px; margin-left: auto; align-items: center; }
nav.main a {
  color: rgba(255, 255, 255, 0.78);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 14px;
}
nav.main a:hover { background: rgba(255, 255, 255, 0.1); color: #fff; text-decoration: none; }
nav.main a.active { background: rgba(255, 255, 255, 0.16); color: #fff; }

main { max-width: 1280px; margin: 0 auto; padding: 28px 24px 80px; }

h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 0 0 14px; letter-spacing: -0.01em; }
h3 { font-size: 14px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
p.lede { color: var(--muted); margin: 0 0 22px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.sidebar { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
@media (max-width: 900px) {
  .grid.two, .grid.three, .grid.sidebar { grid-template-columns: 1fr; }
}

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }
.stat .label { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.saving { opacity: 0.65; }
tr.just-saved td { background: var(--green-bg); transition: background 0.4s ease; }

.table-wrap { overflow-x: auto; }
table.task-list { width: 100%; }
table.task-list td { padding: 8px 8px; vertical-align: top; }
table.task-list th { white-space: nowrap; }
table.task-list td.task-cell { width: 99%; min-width: 16rem; }
table.task-list td:not(.task-cell) { width: 1%; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.grey { background: #eef1f6; color: var(--muted); }
.pill.blue { background: #e8f0fe; color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

form.inline { display: inline; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #334155; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="time"], input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(47, 111, 237, 0.25);
  border-color: var(--accent);
}
textarea { min-height: 74px; resize: vertical; }

input.cell, select.cell, select.cell-quiet, textarea.cell {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--ink);
}
textarea.cell-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  min-height: 2.15em;
  height: auto;
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}
input.cell-date { width: 11.2em; max-width: 11.2em; }
input.cell-num {
  width: 4.8em;
  max-width: 4.8em;
  margin-left: auto;
  display: block;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
select.cell-status { min-width: 8.2em; width: auto; }
.cell-flag { margin-top: 6px; }
.late { color: var(--red); font-weight: 600; }
.plan-cell { line-height: 1.35; }
.cell-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin-top: 5px;
}
select.cell-quiet {
  width: auto;
  max-width: 11em;
  padding: 1px 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}
select.cell-quiet:hover, select.cell-quiet:focus {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.field { margin-bottom: 14px; }
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
button:hover, .button:hover { background: var(--navy-soft); text-decoration: none; color: #fff; }
button.secondary, .button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
button.secondary:hover, .button.secondary:hover { background: #f1f5f9; color: var(--ink); }
button.subtle {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding: 4px 8px;
  font-weight: 500;
}
button.subtle:hover { background: #eef1f6; color: var(--ink); }
button.danger { background: var(--red); }
button.small, .button.small { padding: 5px 10px; font-size: 13px; }

.flash {
  background: #e8f0fe;
  border: 1px solid #c7dbff;
  color: #1c3f7c;
  padding: 11px 14px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 14px;
}
.error {
  background: var(--red-bg);
  border: 1px solid #f5c2bd;
  color: var(--red);
  padding: 11px 14px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 14px;
}

.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs a {
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.tabs a.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.tabs a:hover { text-decoration: none; }

.capacity-bar {
  height: 10px;
  background: #e9edf5;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  margin: 8px 0 4px;
}
.capacity-bar .fill { background: var(--accent); }
.capacity-bar .fill.over { background: var(--red); }

.choice {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  background: #eef1f6;
  padding: 4px;
  border-radius: 10px;
}
.choice button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}
.choice button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

.hidden { display: none; }

.login-wrap {
  max-width: 400px;
  margin: 80px auto;
}
.login-wrap .card { padding: 28px; }

.checkline { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checkline input { width: auto; }
.checkline label { margin: 0; font-weight: 500; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

details.help summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.help p { font-size: 13px; color: var(--muted); }

.empty { color: var(--muted); font-size: 14px; padding: 12px 0; }

.span-row { margin-bottom: 8px; }
.span-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
}
.span-remove-wrap button { margin-top: 2px; }

main:has(.cal-board) { max-width: 1480px; }

.cal-week { margin-bottom: 14px; }
.cal-week-label { margin-bottom: 6px; }
.cal-scroll { overflow-x: auto; }
.cal-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(154px, 1fr));
  gap: 6px;
  min-width: 1120px;
}
.cal-day {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  min-height: 168px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cal-day.is-weekend,
.cal-day.is-past { background: #f6f7fb; }
.cal-day.is-weekend { min-height: 88px; }
.cal-day.is-today { outline: 2px solid var(--accent); outline-offset: -1px; }
.cal-day.is-over { border-color: #f5c2bd; }
.cal-day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  color: var(--muted);
}
.cal-day-head strong { color: var(--ink); font-size: 13px; }
.cal-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}
.cal-day.is-weekend .cal-stack { min-height: 0; }
.cal-block {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 2px;
  min-height: 2.8em;
  padding: 6px 7px 6px 9px;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  text-decoration: none;
}
.cal-block:hover { filter: brightness(1.08); text-decoration: none; color: #fff; }
.cal-block.flag-red { box-shadow: inset 4px 0 0 #fecaca; }
.cal-block.flag-amber { box-shadow: inset 4px 0 0 #fde68a; }
.cal-block.flag-logged { color: #fff; }
.cal-block-title {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.cal-block-h { opacity: 0.85; font-variant-numeric: tabular-nums; }
.cal-free {
  flex-shrink: 1;
  min-height: 8px;
  border-radius: 6px;
  background: repeating-linear-gradient(
    -45deg,
    #eef1f6,
    #eef1f6 4px,
    #f8fafc 4px,
    #f8fafc 8px
  );
}
.cal-empty { padding: 8px 0; }
.cal-day-foot { font-variant-numeric: tabular-nums; }

tr.hot td { background: var(--red-bg); }
.latency-verdict { margin: 0; padding-left: 18px; }
.latency-verdict li { margin-bottom: 8px; }
.latency-dl { margin: 0; display: grid; gap: 10px; }
.latency-dl div { display: flex; justify-content: space-between; gap: 16px; }
.latency-dl dt { color: var(--muted); font-size: 13px; }
.latency-dl dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
code.latency-sql {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #334155;
  white-space: pre-wrap;
  word-break: break-word;
}
.latency-request { border-top: 1px solid var(--line); padding: 10px 0; }
.latency-request:first-of-type { border-top: none; }
.latency-request summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.latency-spans { margin: 10px 0; padding-left: 18px; }
.latency-spans li { margin: 4px 0; }
