/* ============ PermitPilot AI — "The Job Trailer Office" ============
   Construction-grade permit tracker: ink-navy project rail (the Procore
   standard), warm paper workspace, safety-orange accent, blueprint-grid
   texture, rubber-stamp statuses. Zero rounded edges. */

:root {
  --paper: #f6f3ea;
  --paper-2: #efe9d8;
  --card: #fffdf7;
  --ink: #232b33;
  --ink-soft: #4c5a66;
  --muted: #7d8894;
  --faint: #a9b2bd;
  --line: #e0d8c2;
  --navy: #1c2733;
  --navy-2: #121b25;
  --orange: #d95d1e;
  --orange-deep: #b34a12;
  --orange-soft: #fdeee2;
  --blue: #2f5d8a;
  --blue-soft: #e8f0f8;
  --good: #2e7d4f;
  --good-soft: #e9f4ec;
  --warn: #b8862e;
  --warn-soft: #faf1dc;
  --bad: #b3382e;
  --bad-soft: #fbeae8;
  --shadow: 0 1px 2px rgba(28, 39, 51, .08), 0 12px 28px -16px rgba(28, 39, 51, .22);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--sans); font-size: 15px; line-height: 1.55;
  color: var(--ink); background: var(--paper);
}
button { font-family: inherit; }
::selection { background: var(--orange); color: #fff; }

/* ============ shell + project rail ============ */
.shell { display: flex; min-height: 100vh; align-items: stretch; }
.rail {
  flex: none; width: 300px; background: var(--navy-2); color: #e8ecf1;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background-image:
    radial-gradient(520px 300px at 50% -80px, rgba(217,93,30,.12), transparent 70%),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(255,255,255,.022) 31px 32px),
    repeating-linear-gradient(90deg, transparent 0 31px, rgba(255,255,255,.022) 31px 32px);
}
.rail-inner { display: flex; flex-direction: column; gap: 12px; padding: 26px 22px 22px; min-height: 100%; }
.brandrow { display: flex; align-items: center; gap: 12px; }
.seal {
  width: 44px; height: 44px; display: grid; place-items: center; flex: none;
  background: var(--orange); color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.25);
}
.kicker {
  margin: 0; font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: 1.8px; text-transform: uppercase; color: #e8a06a;
}
.brand { margin: 2px 0 0; font-size: 22px; font-weight: 800; letter-spacing: -.4px; white-space: nowrap; }
.brand .ai { font-size: 13px; font-weight: 700; color: var(--navy-2); background: #e8a06a; padding: 2px 7px; vertical-align: 3px; margin-left: 4px; }
.rail-label {
  margin: 10px 0 0; font-size: 11px; font-weight: 800;
  letter-spacing: 2px; text-transform: uppercase; color: #8b98a8;
}
.project-rail { display: flex; flex-direction: column; gap: 6px; }
.rail-empty { color: #8b98a8; font-size: 13.5px; padding: 6px 2px; }
.rail-proj {
  border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.03);
  color: #e8ecf1; cursor: pointer; text-align: left; padding: 10px 12px;
  display: grid; gap: 3px; transition: background .15s, border-color .15s;
}
.rail-proj:hover { background: rgba(255,255,255,.07); }
.rail-proj.active { background: rgba(217,93,30,.16); border-color: var(--orange); border-left: 4px solid var(--orange); }
.rp-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-meta { font-family: var(--mono); font-size: 11.5px; color: #9fb0c2; }
.rp-bar { height: 5px; background: rgba(255,255,255,.14); margin-top: 3px; }
.rp-bar i { display: block; height: 100%; background: var(--orange); }
.rail-new {
  border: 1.5px dashed rgba(255,255,255,.3); background: transparent; color: #cfd8e3;
  font-weight: 700; font-size: 13.5px; padding: 10px; cursor: pointer;
}
.rail-new:hover { border-color: var(--orange); color: #fff; }
.local-pill {
  margin-top: auto; display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; color: #c3ccda;
  border: 1px solid rgba(255,255,255,.22); padding: 7px 13px; width: fit-content;
}
.local-pill i { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.2); }

/* ============ workspace ============ */
.mainwrap { flex: 1; min-width: 0; }
.disclaimer-banner {
  background: var(--warn-soft); border-bottom: 1.5px solid #e8d5a8;
  padding: 10px 32px; font-size: 13.5px; color: #6b5320;
  display: flex; gap: 10px; align-items: center;
}
.disclaimer-banner .badge {
  background: var(--warn); color: #fff; font-size: 10.5px; font-weight: 800;
  letter-spacing: 1.2px; padding: 3px 10px; text-transform: uppercase; flex: none;
}
.wrap { max-width: 1060px; margin: 0 auto; padding: 26px 32px 0; }
.tagline { color: var(--muted); font-size: 16px; margin: 0 0 18px; }

/* ============ dossier cards ============ */
.card {
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 26px 30px; margin: 38px 0 22px; position: relative;
}
.dossier { border-top: 4px solid var(--navy); }
.folder-tab {
  position: absolute; top: -31px; left: 24px;
  background: var(--navy); color: #f0c987;
  font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: 1.6px;
  padding: 7px 16px; text-transform: uppercase;
}
.card h2 { margin: 0 0 6px; font-size: 21px; letter-spacing: -.4px; }
.card h3 { margin: 22px 0 10px; font-size: 16px; }
.muted { color: var(--muted); }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }

/* ============ forms ============ */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 14px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.block-label { display: grid; gap: 6px; margin-bottom: 14px; }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--ink);
  border: 1.5px solid var(--line); padding: 10px 13px; background: #fff; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(217, 93, 30, .13);
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
button.primary, .primary {
  background: var(--orange); border: 1.5px solid var(--orange); color: #fff;
  padding: 10px 20px; font-weight: 700; font-size: 14px; cursor: pointer;
  box-shadow: 0 4px 14px -4px rgba(217, 93, 30, .55);
  transition: transform .15s, background .15s;
}
button.primary:hover, .primary:hover { background: var(--orange-deep); transform: translateY(-1px); }
button.ghost, .ghost {
  background: #fff; border: 1.5px solid var(--line); color: var(--ink);
  padding: 10px 18px; font-weight: 700; font-size: 14px; cursor: pointer;
}
button.ghost:hover, .ghost:hover { border-color: var(--orange); }
button.small, .small { padding: 7px 14px; font-size: 13px; }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.ok { color: var(--good); font-size: 13.5px; font-weight: 600; }

/* ============ alerts & progress ============ */
.alert {
  border: 1.5px solid var(--line); border-left: 5px solid var(--blue);
  background: var(--blue-soft); padding: 12px 16px; margin: 10px 0; font-size: 14px;
}
.alert.next { border-left-color: var(--orange); background: var(--orange-soft); }
.alert.ready { border-left-color: var(--good); background: var(--good-soft); }
.alert.expired { border-left-color: var(--bad); background: var(--bad-soft); }
.alert.expiring { border-left-color: var(--warn); background: var(--warn-soft); }
.flag {
  display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: 1.2px;
  text-transform: uppercase; background: var(--ink); color: #fff; padding: 2px 9px; margin-right: 8px;
}
.progress-wrap { margin: 16px 0; }
.progress { height: 10px; background: #e8e0cb; }
.progress > div { height: 100%; background: var(--orange); transition: width .4s ease; }
.deadlines, .alerts { display: grid; gap: 8px; margin: 10px 0; }
.deadline-list { margin: 0; padding: 0; list-style: none; }
.deadline { display: flex; gap: 10px; align-items: baseline; font-size: 14px; padding: 8px 12px; background: #fff; border: 1px solid var(--line); }
.deadline.late { border-left: 4px solid var(--bad); }
.deadline .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.deadline.late .dot { background: var(--bad); }

/* ============ permit cards (stamped documents) ============ */
.res {
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow);
  margin-bottom: 16px; position: relative;
}
.permit-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 2px solid var(--navy);
  background-image: repeating-linear-gradient(0deg, transparent 0 27px, rgba(47,93,138,.05) 27px 28px);
}
.permit-head h3 { margin: 0; font-size: 17px; letter-spacing: -.2px; }
.fileno { font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 1.4px; color: var(--muted); }
.stamp {
  margin-left: auto; font-size: 11.5px; font-weight: 800; letter-spacing: 1.6px; text-transform: uppercase;
  border: 2.5px solid; padding: 5px 14px; transform: rotate(-2deg);
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.stamp.likely { color: var(--bad); border-color: var(--bad); background: rgba(179,56,46,.06); }
.stamp.maybe { color: var(--warn); border-color: var(--warn); background: rgba(184,134,46,.07); }
.stamp.unlikely { color: var(--ink-soft); border-color: #b9c2cb; background: rgba(109,123,136,.06); }
.permit-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); padding: 10px 20px 0; }
.permit-reason { padding: 8px 20px 14px; font-size: 14px; color: var(--ink-soft); }

/* review pipeline */
.pipeline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 12px 20px; }
.step {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700;
  border: 1.5px solid var(--line); background: #fff; padding: 7px 12px; color: var(--muted);
}
.step small { font-family: var(--mono); font-weight: 400; font-size: 11px; }
.step .dot { width: 9px; height: 9px; border-radius: 50%; background: #c3cbd2; flex: none; }
.step.done { color: var(--good); border-color: #bfe3cb; background: var(--good-soft); }
.step.done .dot { background: var(--good); }
.step.current { color: #fff; background: var(--orange); border-color: var(--orange); }
.step.current .dot { background: #fff; }
.step-arrow { color: var(--faint); font-weight: 800; }

/* docs / inspections / payments */
.docs { border: 1px solid var(--line); margin: 0 20px 12px; background: #fff; }
.docs summary { cursor: pointer; padding: 10px 14px; font-weight: 700; font-size: 13.5px; }
.docs summary:hover { color: var(--orange-deep); }
.doc-row { display: flex; gap: 10px; align-items: center; padding: 8px 14px; border-top: 1px dashed var(--line); font-size: 13.5px; }
.doc-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--orange); }
.doc-row.done { color: var(--muted); text-decoration: line-through; }
.insp, .insppay { padding: 0 20px 14px; }
.insp-list, .pay-list { margin: 8px 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.insp-list li, .pay-list li {
  display: flex; gap: 10px; align-items: center; font-size: 13.5px;
  background: var(--paper); border: 1px solid var(--line); padding: 8px 12px;
}
.outcome { font-weight: 800; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; padding: 2px 8px; }
.outcome.pass { background: var(--good-soft); color: var(--good); }
.outcome.fail { background: var(--bad-soft); color: var(--bad); }
.fee-inputs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.fee-inputs input { width: 110px; }

/* fee box */
.fee-box {
  display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--navy); color: #e8ecf1; padding: 18px 24px; margin: 18px 0;
}
.fee-box .muted { color: #9fb0c2; }
.fee-box .total { font-family: var(--mono); font-size: 30px; font-weight: 800; color: #f0c987; }
.fee-note { max-width: 420px; font-size: 13px; }

/* cover note */
.cover-note { border: 1px solid var(--line); background: #fff; padding: 16px 18px; }
.note-area { min-height: 150px; font-family: var(--sans); }

/* ============ site log ============ */
.log-list { display: grid; gap: 10px; margin-top: 14px; }
.log-entry {
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--orange);
  padding: 12px 16px;
}
.log-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.log-type {
  font-size: 11px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase;
  background: var(--navy); color: #f0c987; padding: 3px 10px;
}
.log-date { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.log-del {
  margin-left: auto; border: 1px solid #eec5c1; background: transparent; color: var(--bad);
  font-size: 12px; font-weight: 700; padding: 4px 10px; cursor: pointer;
}
.log-del:hover { background: var(--bad-soft); }
.log-text { font-size: 14px; }

/* ============ settings / footer ============ */
.settings-note { font-size: 13px; color: var(--muted); }
footer { margin: 10px 0 0; padding-bottom: 40px; }
footer .disc {
  border: 1.5px solid var(--line); border-left: 5px solid var(--warn);
  background: var(--warn-soft); padding: 12px 16px; font-size: 13.5px; margin-bottom: 12px;
}
footer .center { text-align: center; font-size: 12.5px; color: var(--faint); }

/* print */
.print-summary { display: none; }
@media print {
  .rail, .disclaimer-banner, .row, .toolbar, .cover-note .row { display: none !important; }
  .print-summary { display: block !important; }
  .card { box-shadow: none; break-inside: avoid; }
  /* one-page report: only the generated summary prints */
  body.print-report #projectsSection,
  body.print-report #detailsSection,
  body.print-report #settingsSection,
  body.print-report #logSection,
  body.print-report #nextAction,
  body.print-report #deadlines,
  body.print-report #alerts,
  body.print-report .progress-wrap,
  body.print-report .toolbar,
  body.print-report #permitList,
  body.print-report .fee-box,
  body.print-report #resultsSection > h2,
  body.print-report #resultsSection > p.muted,
  body.print-report #resultsSection > h3,
  body.print-report .cover-note,
  body.print-report footer { display: none !important; }
  body.print-report #resultsSection { display: block !important; }
  body.print-report .print-summary { display: block !important; }
}

/* motion */
@media (prefers-reduced-motion: no-preference) {
  .card { animation: rise .3s ease both; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } }
}

/* responsive */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .rail { width: 100%; height: auto; position: static; }
  .rail-inner { padding: 18px 16px 14px; }
  .project-rail { flex-direction: row; overflow-x: auto; }
  .rail-proj { min-width: 200px; }
  .local-pill { margin-top: 0; }
  .disclaimer-banner { padding: 10px 16px; }
  .wrap { padding: 20px 16px 0; }
  .card { padding: 20px 18px; }
  .folder-tab { left: 16px; }
}
