:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d232b;
  --muted: #66707c;
  --line: #dde1e6;
  --accent: #0b5cad;
  --ok: #1a8a3a;
  --warn: #d97400;
  --late: #d42020;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.top { padding: 14px 24px; background: #12324f; color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.top h1 { margin: 0; font-size: 20px; font-weight: 650; }
.top h1 span { font-weight: 400; opacity: 0.75; margin-left: 8px; font-size: 15px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  padding: 18px 24px 40px;
  max-width: 1500px;
  margin: 0 auto;
}
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 10px; font-size: 16px; font-weight: 650; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 8px; }
.row.between { justify-content: space-between; align-items: center; }
.row.small, .small { font-size: 13px; }
.grow { flex: 1; min-width: 200px; }

.field { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
.field input { width: 100%; }

input[type=text], input[type=number], select, textarea {
  font: inherit;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3ec; border-color: var(--accent); }
select { min-width: 220px; }

button, .button {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f7f8fa;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
button:hover, .button:hover { background: #eceff3; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: #094c90; }
button.danger { color: var(--late); }

.hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.paste { display: flex; gap: 8px; margin-top: 6px; }
.paste[hidden] { display: none; }
.paste textarea { flex: 1; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 3px 4px; border-bottom: 1px solid #eef0f3; vertical-align: middle; }
tr.selected td { background: #eaf2fb; }
tr.invalid td:first-child { box-shadow: inset 3px 0 var(--late); }
td input[type=text], td input[type=number] { width: 100%; padding: 4px 6px; }
td.c-name { min-width: 170px; }
td.c-km, td.c-num { width: 82px; }
td.c-lim { width: 90px; }
td.c-chk { text-align: center; width: 38px; }
td.c-idx { color: var(--muted); width: 26px; }
td.c-est { white-space: nowrap; width: 120px; }
td.c-act { white-space: nowrap; width: 92px; }
td.c-act button { padding: 2px 7px; }
.est-ok { color: var(--ok); font-weight: 600; }
.est-warn { color: var(--warn); font-weight: 600; }
.est-late { color: var(--late); font-weight: 600; }

.output textarea { width: 100%; font: 12px/1.4 ui-monospace, Consolas, monospace; resize: vertical; }
.issues { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.issues li { padding: 4px 8px; border-radius: 6px; margin-bottom: 4px; }
.issues li.error { background: #fde8e8; color: #8a1414; }
.issues li.warning { background: #fff3e0; color: #7a4300; }
.issues li.fine { background: #e7f5ea; color: #1a5c2a; }

.help ol { margin: 0; padding-left: 20px; font-size: 14px; }
.help li { margin-bottom: 4px; }

/* Watch preview: same layout as the full-screen field (docs/SPEC.md § 6.2) */
.watch {
  --w: 300px;
  width: var(--w);
  height: var(--w);
  margin: 6px auto 4px;
  border-radius: 50%;
  border: 10px solid #3a3f45;
  box-shadow: 0 0 0 3px #8a9099;
  background: #fff;
  color: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  font-family: "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  text-align: center;
}
.watch.dark { background: #000; color: #fff; }
.watch .w-name { margin-top: 24px; font-size: 21px; font-weight: 700; max-width: 62%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.watch .w-icons { height: 24px; margin: 2px 0; display: flex; gap: 5px; align-items: center; font-size: 15px; font-weight: 700; }
.watch .w-icons img { width: 20px; height: 20px; }
.watch .w-sub { font-size: 14px; font-weight: 700; max-width: 80%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.watch .w-big { font-size: 34px; font-weight: 700; line-height: 1.05; }
.watch .w-margin { font-size: 14px; font-weight: 700; }
.watch .w-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; width: 88%; border-top: 1px solid #3d8ee0; border-bottom: 1px solid #3d8ee0; margin-top: 4px; }
.watch .w-grid > div { border-left: 1px solid #3d8ee0; }
.watch .w-grid > div:first-child { border-left: none; }
.watch .w-head { font-size: 12px; font-weight: 700; }
.watch .w-head.fill-ok { background: #00e000; color: #000; }
.watch .w-head.fill-warn { background: #ff9000; color: #000; }
.watch .w-head.fill-late { background: #ff2020; color: #000; }
.watch .w-val { font-size: 22px; font-weight: 700; }
.watch .w-grid2 { display: grid; grid-template-columns: 1fr 1fr; width: 62%; }
.watch .w-grid2 > div + div { border-left: 1px solid #3d8ee0; }
.watch .w-foot { font-size: 13px; font-weight: 700; margin-top: 2px; }
.watch .ok { color: #1a9a1a; }
.watch.dark .ok { color: #00e000; }
.watch .warn { color: #ff9000; }
.watch .late { color: #ff2020; }
.watch .w-empty { margin: auto; padding: 0 40px; font-size: 16px; }

/* Roadbook import with Claude */
.ai { margin-top: 12px; padding: 12px; border: 1px dashed #9cc3ec; border-radius: 8px; background: #f6faff; }
.ai h3 { margin: 0 0 4px; font-size: 14px; }
.ai textarea { width: 100%; margin: 6px 0; }
.ai[hidden] { display: none; }
button.busy { opacity: 0.6; cursor: progress; }

.help h3 { margin: 10px 0 2px; font-size: 14px; }

/* Account */
.account { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.account[hidden] { display: none; }
.account span { opacity: 0.85; }
.dialog { border: 1px solid #c9d1db; border-radius: 10px; padding: 20px 22px; width: min(440px, 92vw); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); }
.dialog::backdrop { background: rgba(10, 25, 40, 0.45); }
.dialog h2 { margin: 0 0 14px; font-size: 18px; }
.dialog .field { margin-bottom: 10px; }
.dialog .field[hidden] { display: none; }
.dialog input { font-size: 15px; padding: 7px 9px; }
.hint.error { color: #8a1414; }.dialog.wide { width: min(760px, 96vw); }
#adminUsers td, #adminUsers th { font-size: 13px; padding: 5px 8px; text-align: left; }
#adminUsers tr.asked td { background: #fff4e0; }
.watches { list-style: none; padding: 0; margin: 0 0 8px; }
.watches li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #e4e8ee; font-size: 14px; }
.watches li .hint { margin: 0; }
#pairCode { width: 9em; text-transform: uppercase; }
#pairCode::placeholder { text-transform: none; }
