/* Monochrome, hairline-bordered, dense. Red is reserved for the draft notice and
   blocking items so it keeps its meaning. */

:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #6b6b6b;
  --line: #e4e4e4;
  --line-strong: #d0d0d0;
  --panel: #fafafa;
  --danger: #b71c1c;
  --warn: #b45309;
  --ok: #15803d;
  --radius: 6px;
}

/* Dark palette applies when the OS asks for it (unless the user pinned
   light) or when the user pinned dark via the topbar toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --fg: #f5f5f5;
    --muted: #9a9a9a;
    --line: #262626;
    --line-strong: #3a3a3a;
    --panel: #141414;
    --danger: #ef5350;
    --warn: #f59e0b;
    --ok: #4ade80;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --fg: #f5f5f5;
  --muted: #9a9a9a;
  --line: #262626;
  --line-strong: #3a3a3a;
  --panel: #141414;
  --danger: #ef5350;
  --warn: #f59e0b;
  --ok: #4ade80;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.draft-bar {
  background: var(--danger);
  color: #fff;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 7px 12px;
  font-size: 12.5px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; text-decoration: none; color: var(--fg); }
.topbar nav { display: flex; gap: 16px; }
.topbar nav a, .steps a { color: var(--muted); text-decoration: none; font-size: 13px; }
.topbar nav a:hover, .steps a:hover { color: var(--fg); }

.steps {
  display: flex;
  gap: 4px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  overflow-x: auto;
}
.steps a {
  padding: 5px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  white-space: nowrap;
}
.steps a.on {
  color: var(--fg);
  background: var(--bg);
  border-color: var(--line-strong);
  font-weight: 600;
}

main { padding: 20px; max-width: 1400px; margin: 0 auto; }
footer {
  border-top: 1px solid var(--line);
  padding: 16px 20px 40px;
  color: var(--muted);
  font-size: 12px;
  max-width: 1400px;
  margin: 24px auto 0;
}

h1 { font-size: 20px; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 15px; margin: 24px 0 8px; font-weight: 650; }
h3 { font-size: 13px; margin: 16px 0 6px; font-weight: 650; text-transform: uppercase;
     letter-spacing: 0.05em; color: var(--muted); }
p.sub { color: var(--muted); margin: 0 0 16px; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  background: var(--bg);
}
.panel.quiet { background: var(--panel); }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase;
     letter-spacing: 0.05em; }
tbody tr:hover { background: var(--panel); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
input, select, textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--fg); outline-offset: -1px; }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.check input { width: auto; }
.check label { margin: 0; color: var(--fg); font-size: 13px; }

button, .btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .btn:hover { border-color: var(--fg); }
button.primary, .btn.primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
  font-weight: 600;
}
button.danger { border-color: var(--danger); color: var(--danger); }
button.small, .btn.small { padding: 4px 9px; font-size: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.tag.blocker { border-color: var(--danger); color: var(--danger); }
.tag.warning { border-color: var(--warn); color: var(--warn); }
.tag.info { border-color: var(--line-strong); color: var(--muted); }
.tag.ok { border-color: var(--ok); color: var(--ok); }

.callout {
  border-left: 3px solid var(--line-strong);
  padding: 10px 14px;
  margin: 10px 0;
  background: var(--panel);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 13px;
}
.callout.blocker { border-left-color: var(--danger); }
.callout.warning { border-left-color: var(--warn); }
.callout.ok { border-left-color: var(--ok); }

.cite { font-size: 11.5px; color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.value { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 15px; }

.preview {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  background: #fff;
  max-height: 62vh;
}
.preview img, .preview object { display: block; min-width: 100%; }

.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line-strong);
         border-radius: var(--radius); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }

/* -- motion (subtle, per the house style) --------------------------------- */

a, button, .btn, .steps a, tbody tr { transition: background-color .12s ease, color .12s ease,
  border-color .12s ease, box-shadow .12s ease; }
button.primary:hover, .btn.primary:hover { box-shadow: 0 1px 8px rgba(0,0,0,.18); }

/* -- brand and user box ---------------------------------------------------- */

.brand { letter-spacing: 0.02em; font-size: 15px; }
.brand-mark { font-weight: 800; }
.brand-mark-light { font-weight: 300; color: var(--muted); margin-left: 2px; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); border: 1px solid var(--line-strong);
  padding: 2px 7px; border-radius: 999px;
}
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { border-color: var(--line-strong); color: var(--fg); }
.btn.wide { display: block; width: 100%; text-align: center; margin-bottom: 8px; }

/* -- login ------------------------------------------------------------------ */

.login-body { background: var(--panel); }
.login-wrap { min-height: calc(100vh - 60px); display: flex; align-items: center;
  justify-content: center; padding: 24px; }
.login-card {
  width: 360px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 32px 28px 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,.06);
}
.login-brand { font-size: 22px; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.login-error {
  border: 1px solid var(--danger); color: var(--danger); border-radius: var(--radius);
  padding: 8px 10px; font-size: 13px;
}
.login-card label { margin-top: 12px; }
.login-card button { margin-top: 18px; }
.login-foot { color: var(--muted); font-size: 11.5px; margin-top: 18px;
  border-top: 1px solid var(--line); padding-top: 12px; }

/* -- the drafter's editor --------------------------------------------------- */

.editor-head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; }
.editor-phases { display: flex; gap: 6px; }
.editor-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px;
  align-items: start; }
@media (max-width: 900px) { .editor-layout { grid-template-columns: 1fr; } }
.editor-map {
  height: 72vh; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: #dfe3e6;
}
.editor-map.no-aerial::after { content: "AERIAL UNAVAILABLE - plain ground"; }
.editor-panel { position: sticky; top: 52px; }
.panel-block { border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px; background: var(--bg); }
.editor-status { font-size: 12.5px; color: var(--ok); margin: 4px 0 0; }
.editor-status.warn { color: var(--warn); }
.problem-list, .change-list { margin: 0; padding-left: 18px; font-size: 12.5px; }
.problem-list li { color: var(--danger); margin-bottom: 4px; }
.change-list li { color: var(--fg); margin-bottom: 3px; }
.ok-line { color: var(--ok) !important; list-style: none; margin-left: -18px; }

/* Leaflet object icons (the editor draws the plan's glyph language). */
.ed-icon { background: none; border: none; }
.ed-handle { width: 12px; height: 12px; border-radius: 50%; background: #fff;
  border: 2.5px solid #009000; box-shadow: 0 1px 3px rgba(0,0,0,.4); cursor: grab; }
.ed-stand { width: 12px; height: 12px; background: #111; border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.5); cursor: grab; }
.ed-face { filter: drop-shadow(0 2px 4px rgba(0,0,0,.45)); cursor: grab; }
.ed-face-fallback { background: #FF8000; color: #111; font-weight: 700;
  font-size: 10px; padding: 4px; border: 2px solid #111; }
.ed-flagger, .ed-truck, .ed-arrow {
  color: #fff; font-weight: 700; font-size: 10px; text-align: center;
  border-radius: 3px; padding: 2px 4px; border: 1.5px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.5); cursor: grab; white-space: nowrap;
}
.ed-flagger { background: #C62200; }
.ed-truck { background: #8a7a00; }
.ed-arrow { background: #333; }
.ed-street { background: #008000; color: #fff; font-weight: 700; font-size: 11px;
  padding: 2px 8px; border: 1.5px solid #fff; border-radius: 4px; text-align: center;
  white-space: nowrap; cursor: grab; }

/* -- account management ----------------------------------------------------- */

.password-once {
  margin-top: 8px; padding: 10px 12px; font-size: 15px; letter-spacing: .03em;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--panel); user-select: all;
}


/* Theme toggle */
.theme-toggle { font-size: 12px; }

/* -- editor toolbar --------------------------------------------------------- */

.editor-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px; margin-bottom: 10px; background: var(--panel);
}
.editor-toolbar select { width: auto; padding: 4px 8px; font-size: 12px; }
.toolbar-sep { flex: 1; }
.ed-sign-preview { display: inline-flex; align-items: center; }
.ed-sign-preview svg { width: 26px; height: 26px; display: block; }
.ed-note {
  background: rgba(255,255,255,.85); color: #111; font-size: 10px;
  font-weight: 600; padding: 2px 6px; border: 1px solid #111;
  border-radius: 3px; text-align: center; white-space: nowrap; cursor: grab;
}

/* -- the review screen ------------------------------------------------------ */

.review-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px;
  align-items: start; }
@media (max-width: 900px) { .review-layout { grid-template-columns: 1fr; } }
.pdf-preview { width: 100%; height: 74vh; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: var(--panel); }
details.panel summary { cursor: pointer; font-weight: 600; font-size: 13px; }
