/* ENV Ops - corporate tokens. Navy + slate. Swap when the ENV Solutions brand kit arrives. */
:root {
  --brand-950: #101B28;
  --brand-900: #16283C;
  --brand-700: #1F4E79;
  --brand-600: #2A639A;
  --brand-100: #E6EDF5;
  --ink: #1C232B;
  --ink-soft: #5B6672;
  --ground: #F4F6F9;
  --panel: #FFFFFF;
  --line: #DEE3EA;
  --amber: #A8842B;
  --amber-bg: #FAF1D9;
  --red: #A8452F;
  --red-bg: #F9EAE5;
  --ok: #2F6B45;
  --ok-bg: #E7F1E8;
  --info: #2B5379;
  --info-bg: #E7EFF8;
  --radius: 8px;
  --mono: Consolas, "Cascadia Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--ground);
  color: var(--ink);
}
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 0.95rem; margin: 0 0 0.6rem; }
a { color: var(--brand-700); }
.mono { font-family: var(--mono); font-size: 0.85em; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.8rem; }
.note { font-size: 0.82rem; margin-top: 0.6rem; }
.empty { color: var(--ink-soft); text-align: center; padding: 1.2rem; }

/* shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--brand-900); color: #E8EEF4;
  display: flex; flex-direction: column; padding: 1.25rem 0.9rem; gap: 1.5rem;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand-mark {
  background: #fff; color: var(--brand-900); font-weight: 800; letter-spacing: 0.02em;
  padding: 0.35rem 0.5rem; border-radius: 6px; font-size: 0.95rem;
}
.brand-text { font-weight: 700; font-size: 1.15rem; line-height: 1.1; }
.brand-sub { display: block; font-weight: 400; font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.7; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.2rem; }
.sidebar nav a {
  color: #C4D2E0; text-decoration: none; padding: 0.55rem 0.7rem; border-radius: 6px; font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar nav a.on { background: var(--brand-700); color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.8rem; }
.tagline { font-size: 0.72rem; opacity: 0.65; font-style: italic; }
.logout { color: #C4D2E0; font-size: 0.8rem; }

.content { flex: 1; padding: 1.75rem 2rem 4rem; max-width: 1240px; }

/* header */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.crumbs { font-size: 0.8rem; color: var(--ink-soft); margin-bottom: 0.25rem; }
.head-meta { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 0.5rem; color: var(--ink-soft); font-size: 0.85rem; }
.kpi-stack { display: flex; flex-direction: column; gap: 0.3rem; align-items: flex-end; }
.kpi-big { font-size: 0.85rem; padding: 0.35rem 0.75rem; }

/* stats */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 1rem; }
.stat b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; color: var(--brand-700); }
.stat span { font-size: 0.75rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-warn b { color: var(--amber); }

/* panels & tables */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.panel-attention { border-left: 4px solid var(--amber); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th { text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); padding: 0.45rem 0.6rem; border-bottom: 2px solid var(--line); }
td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr[onclick] { cursor: pointer; }
tbody tr[onclick]:hover { background: var(--brand-100); }
.addr { max-width: 240px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* pills & chips */
.pill { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.st-new { background: var(--amber-bg); color: var(--amber); }
.st-accepted { background: var(--info-bg); color: var(--info); }
.st-scheduled { background: var(--info-bg); color: var(--info); }
.st-visited { background: var(--brand-100); color: var(--brand-700); }
.st-report_review { background: var(--amber-bg); color: var(--amber); }
.st-report_uploaded { background: var(--ok-bg); color: var(--ok); }
.st-invoiced { background: var(--ok-bg); color: var(--ok); }
.st-complete { background: var(--ok-bg); color: var(--ok); }
.st-cancelled { background: #EBEDEF; color: #6E7680; }

.kpi-chip { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 4px; font-size: 0.7rem; font-weight: 700; white-space: nowrap; margin: 0 0.15rem 0.15rem 0; }
.k-ok { background: var(--ok-bg); color: var(--ok); }
.k-at_risk { background: var(--amber-bg); color: var(--amber); }
.k-breached { background: var(--red-bg); color: var(--red); }
.k-met { background: #EBEDEF; color: #6E7680; }
.k-pending { background: #F2F4F6; color: #97A0AA; }

/* mini R/U/I flags (spreadsheet parity) */
.flags { white-space: nowrap; }
.flag-mini {
  display: inline-block; width: 1.35rem; text-align: center; border-radius: 4px;
  font-size: 0.7rem; font-weight: 800; padding: 0.1rem 0; margin-right: 0.15rem;
}
.f-yes { background: var(--ok-bg); color: var(--ok); }
.f-no { background: #F2F4F6; color: #B3BAC2; }

/* stepper */
.stepper {
  display: flex; gap: 0; overflow-x: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem; margin-bottom: 1.25rem;
}
.step { display: flex; align-items: center; gap: 0.45rem; flex: 1; min-width: 110px; position: relative; padding-right: 1.2rem; }
.step:not(:last-child)::after {
  content: ""; position: absolute; right: 0.3rem; top: 50%; width: 0.7rem; height: 2px; background: var(--line);
}
.step-dot {
  width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: #EBEDEF; color: #8B939C; font-size: 0.72rem; font-weight: 700;
}
.step-label { font-size: 0.72rem; color: var(--ink-soft); line-height: 1.15; }
.step.done .step-dot { background: var(--ok-bg); color: var(--ok); }
.step.done .step-label { color: var(--ink); }
.step.now .step-dot { background: var(--brand-700); color: #fff; }
.step.now .step-label { color: var(--brand-700); font-weight: 700; }

/* calendar */
.cal-nav { display: flex; gap: 0.4rem; }
.cal { table-layout: fixed; min-width: 900px; }
.cal th, .cal td { border: 1px solid var(--line); }
.cal td { height: 70px; padding: 0.3rem; }
.cal-name { width: 140px; }
.cal-today { background: var(--brand-100); }
.cal-job {
  display: block; border-radius: 5px; padding: 0.3rem 0.4rem; margin-bottom: 0.3rem;
  font-size: 0.7rem; line-height: 1.3; text-decoration: none; color: inherit;
  border-left: 3px solid currentColor;
}
.cal-job:hover { filter: brightness(0.96); }
.cal-addr { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.8; }
.stat-link { text-decoration: none; display: block; }
.stat-link:hover { border-color: var(--brand-600); }

/* pipeline board */
.board-wrap { overflow-x: auto; padding-bottom: 0.5rem; }
.board { display: flex; gap: 0.9rem; align-items: flex-start; min-width: max-content; }
.board-col { width: 230px; flex-shrink: 0; background: #ECEFF3; border-radius: var(--radius); padding: 0.6rem; }
.board-col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; padding: 0 0.2rem; }
.board-count { font-size: 0.75rem; font-weight: 700; color: var(--ink-soft); }
.board-card {
  display: flex; flex-direction: column; gap: 0.15rem; background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 0.6rem 0.7rem; margin-bottom: 0.5rem; text-decoration: none; color: var(--ink);
  font-size: 0.82rem;
}
.board-card:hover { border-color: var(--brand-600); }
.board-card b { font-weight: 600; line-height: 1.25; }
.board-meta { color: var(--ink-soft); font-size: 0.75rem; }
.board-empty { color: #A6ADB6; font-size: 0.78rem; text-align: center; padding: 0.8rem 0; }
.cancelled-line { display: block; padding: 0.3rem 0; color: var(--ink-soft); text-decoration: none; }
.cancelled-line:hover { color: var(--brand-700); }

/* forms */
.filters { display: flex; gap: 0.6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters input[type="search"] { flex: 1; min-width: 220px; }
input, select, textarea {
  font: inherit; padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-600); outline-offset: 1px; }
textarea[readonly] { background: var(--ground); color: var(--ink-soft); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem 1rem; }
.form-grid label { font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); display: flex; flex-direction: column; gap: 0.3rem; }
.span2 { grid-column: span 2; }
.form-actions { display: flex; gap: 0.6rem; align-items: center; }
.inline-form { display: flex; gap: 0.6rem; align-items: center; }
.inline { display: inline; }

.btn {
  display: inline-block; padding: 0.5rem 0.9rem; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  width: auto;
}
.btn:hover { border-color: var(--brand-600); color: var(--brand-700); }
.btn-primary { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.btn-primary:hover { background: var(--brand-600); color: #fff; }
.btn-copy { font-size: 0.75rem; padding: 0.3rem 0.6rem; flex-shrink: 0; }
.btn-link { background: none; border: none; color: var(--red); font-size: 0.75rem; cursor: pointer; padding: 0; text-decoration: underline; }

/* tabs */
.tabs { display: flex; gap: 0.25rem; border-bottom: 2px solid var(--line); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tab {
  background: none; border: none; font: inherit; font-weight: 600; color: var(--ink-soft);
  padding: 0.55rem 0.9rem; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tab:hover { color: var(--brand-700); }
.tab.on { color: var(--brand-700); border-bottom-color: var(--brand-700); }
.tab-pane { display: none; }
.tab-pane.on { display: block; }

/* layout helpers */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) {
  .two-col, .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: span 1; }
  .sidebar { position: static; height: auto; width: 100%; flex-direction: row; align-items: center; }
  .shell { flex-direction: column; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .content { padding: 1.25rem 1rem 3rem; }
}

/* misc */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; margin: 0 0 1rem; font-size: 0.88rem; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; }
.claim { white-space: pre-wrap; }
.checklist { padding-left: 1.2rem; font-size: 0.9rem; }
.checklist li { margin-bottom: 0.45rem; }
.breakdown { max-width: 420px; margin-bottom: 0.8rem; }
.breakdown .sum td { font-weight: 700; }
.copy-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.copy-row:last-child { border-bottom: none; }
.copy-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); width: 130px; flex-shrink: 0; }
.copy-row code { font-family: var(--mono); font-size: 0.8rem; background: var(--ground); padding: 0.3rem 0.5rem; border-radius: 4px; overflow-x: auto; white-space: nowrap; flex: 1; }
.flag { padding: 0.6rem 0.8rem; border-radius: 6px; font-size: 0.85rem; margin: 0.5rem 0; }
.flag-ok { background: var(--ok-bg); color: var(--ok); }
.flag-warn { background: var(--amber-bg); color: var(--amber); }
.flag-info { background: var(--info-bg); color: var(--info); }

/* comments */
.note-form { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.note-author { max-width: 200px; }
.note-form .btn { align-self: flex-start; }
.notes { display: flex; flex-direction: column; gap: 0.6rem; max-height: 340px; overflow-y: auto; }
.note-item { background: var(--ground); border-radius: 6px; padding: 0.55rem 0.75rem; }
.note-item p { margin: 0.2rem 0 0; font-size: 0.88rem; white-space: pre-wrap; }
.note-head { display: flex; justify-content: space-between; font-size: 0.78rem; }

/* documents */
.upload-form { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.upload-form input[type="file"] { flex: 1; min-width: 220px; }
.upload-form input[type="text"] { flex: 1; min-width: 200px; }
.upload-form .btn { flex-shrink: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.9rem; }
.photo { margin: 0; }
.photo img { width: 100%; height: 130px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.photo figcaption { font-size: 0.75rem; color: var(--ink-soft); margin-top: 0.3rem; display: flex; justify-content: space-between; gap: 0.5rem; }

/* report */
.report-form { display: flex; flex-direction: column; gap: 0.9rem; }
.report-form label { font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); display: flex; flex-direction: column; gap: 0.3rem; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; background: var(--brand-900); }
.login-card {
  background: var(--panel); border-radius: 10px; padding: 2rem; width: min(360px, 92vw);
  display: flex; flex-direction: column; gap: 0.9rem;
}
.login-brand { color: var(--ink); }
.login-brand .brand-mark { background: var(--brand-900); color: #fff; }
.login-hint { font-size: 0.85rem; color: var(--ink-soft); margin: 0; }
.login-error { color: var(--red); font-size: 0.85rem; margin: 0; }
