/* ============================================================
   USV Approach — rugged field-ops with a corporate finish
   ============================================================ */
:root {
  --bg: #EFEEE9;          /* concrete */
  --surface: #FFFFFF;
  --surface-2: #F6F5F1;
  --line: #D8D5CC;
  --line-strong: #B9B5A9;
  --ink: #16191C;         /* charcoal */
  --ink-2: #444A50;
  --muted: #767C82;
  --navy: #163B65;        /* USV logo blue */
  --navy-2: #0F2A49;
  --navy-tint: #E6ECF3;
  --steel: #1F5E96;
  --hivis: #E0661B;       /* safety orange */
  --hivis-2: #C4550F;
  --hivis-tint: #FBEBDF;
  --ok: #2E6B3E;
  --ok-tint: #E4EFE5;
  --warn: #9A6A12;
  --warn-tint: #F6EDD9;
  --danger: #A33A28;
  --danger-tint: #F6E3DF;
  --radius: 4px;
  --shadow: 0 1px 0 rgba(22, 25, 28, 0.06), 0 1px 3px rgba(22, 25, 28, 0.06);
  --font-head: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
  --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 700; letter-spacing: 0.01em; margin: 0 0 4px; color: var(--ink); }
h1 { font-size: 30px; text-transform: uppercase; }
h2 { font-size: 26px; text-transform: uppercase; }
h3 { font-size: 19px; text-transform: uppercase; }
p { margin: 0 0 10px; }
a { color: var(--steel); }
button, input, select, textarea { font: inherit; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- app shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 64px;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px;
  background: linear-gradient(90deg, var(--navy) 0 70%, var(--hivis) 70% 100%);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand img { height: 34px; width: auto; display: block; }
.brand .app-name {
  font-family: var(--font-head); font-weight: 700; font-size: 22px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--navy); padding-left: 14px; border-left: 2px solid var(--line);
  white-space: nowrap;
}
.brand .app-name b { color: var(--hivis); font-weight: 700; }
.topbar .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.userchip .role-tag { font-family: var(--font-head); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; font-size: 12px; padding: 3px 8px; border-radius: 2px; background: var(--navy); color: #fff; }
.userchip .role-tag.sub { background: var(--hivis); }
.userchip .role-tag.client { background: var(--ok); }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 64px); }
.sidenav { background: var(--ink); color: #C9CDD1; padding: 18px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidenav a {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: #C9CDD1;
  font-family: var(--font-head); font-weight: 600; font-size: 16px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 11px 12px; border-left: 3px solid transparent; border-radius: 2px;
}
.sidenav a:hover { background: #22272B; color: #fff; }
.sidenav a.active { background: #22272B; color: #fff; border-left-color: var(--hivis); }
.sidenav .count { margin-left: auto; background: var(--hivis); color: #fff; font-size: 12px; padding: 0 7px; border-radius: 2px; }
.sidenav .foot { margin-top: auto; padding: 14px 12px 4px; border-top: 1px solid #2C3237; font-size: 12px; color: #8A9096; font-style: italic; }
main { padding: 26px 30px 70px; min-width: 0; }
.container { max-width: 1180px; margin: 0 auto; }

@media (max-width: 860px) {
  .topbar { padding: 0 14px; height: 58px; }
  .brand img { height: 26px; }
  .brand .app-name { font-size: 18px; padding-left: 10px; }
  .userchip .who { display: none; }
  .layout { grid-template-columns: 1fr; min-height: 0; }
  .sidenav { flex-direction: row; overflow-x: auto; padding: 6px 8px; gap: 2px; position: sticky; top: 58px; z-index: 20; }
  .sidenav a { white-space: nowrap; flex-shrink: 0; padding: 10px 12px; font-size: 15px; border-left: none; border-bottom: 3px solid transparent; }
  .sidenav a.active { border-bottom-color: var(--hivis); }
  .sidenav .foot { display: none; }
  main { padding: 18px 16px 70px; }
}
@media (max-width: 520px) { .brand img { display: none; } .brand .app-name { border-left: none; padding-left: 0; } }

/* ---------- page head ---------- */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead .kicker { font-family: var(--font-head); font-weight: 600; text-transform: uppercase; letter-spacing: 0.14em; font-size: 13px; color: var(--hivis); }
.pagehead .sub { color: var(--muted); font-size: 14px; }
.pagehead .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius);
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-family: var(--font-head); font-weight: 700; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); border-color: var(--navy-2); }
.btn-go { background: var(--hivis); border-color: var(--hivis); color: #fff; }
.btn-go:hover { background: var(--hivis-2); border-color: var(--hivis-2); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 32px; padding: 4px 11px; font-size: 13px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- cards / stats ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 17px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--navy); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
.stat.hot { border-top-color: var(--hivis); }
.stat.good { border-top-color: var(--ok); }
.stat.bad { border-top-color: var(--danger); }
.stat .num { font-family: var(--font-head); font-weight: 700; font-size: 34px; line-height: 1; color: var(--ink); }
.stat .label { font-family: var(--font-head); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; font-size: 13px; color: var(--muted); margin-top: 6px; }
a.stat:hover { border-color: var(--line-strong); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-family: var(--font-head); font-weight: 700; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 10px 14px; border-bottom: 2px solid var(--line); background: var(--surface-2); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
td.r, th.r { text-align: right; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); background: var(--surface-2); }
.empty { text-align: center; color: var(--muted); padding: 34px 16px; font-style: italic; }
.money { font-family: var(--font-mono); font-weight: 600; white-space: nowrap; }

/* ---------- status tags (squared, stencil feel) ---------- */
.tag { display: inline-block; font-family: var(--font-head); font-weight: 700; font-size: 12.5px; letter-spacing: 0.07em; text-transform: uppercase; padding: 3px 8px; border-radius: 2px; white-space: nowrap; border: 1px solid transparent; }
.tag-requested, .tag-sub_quoted { background: var(--navy-tint); color: var(--navy); border-color: #C5D2E0; }
.tag-priced, .tag-sent { background: var(--warn-tint); color: var(--warn); border-color: #E8D5AC; }
.tag-approved, .tag-scheduled { background: var(--ok-tint); color: var(--ok); border-color: #C3DAC7; }
.tag-in_progress { background: var(--hivis-tint); color: var(--hivis-2); border-color: #F2CDB2; }
.tag-completed { background: var(--ink); color: #fff; }
.tag-invoiced { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.tag-declined { background: var(--danger-tint); color: var(--danger); border-color: #EBC3BB; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label, .label { display: block; font-family: var(--font-head); font-weight: 700; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 5px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 11px; border: 1.5px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font-size: 15px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(22, 59, 101, 0.15); }
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
textarea { min-height: 70px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 640px) { .row2, .row3 { grid-template-columns: 1fr; } }
.seg { display: inline-flex; border: 1.5px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg button { border: none; background: none; padding: 8px 14px; font-family: var(--font-head); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1.5px solid var(--line-strong); }
.seg button.on { background: var(--navy); color: #fff; }

/* ---------- alerts ---------- */
.alert { border-radius: var(--radius); padding: 11px 14px; font-size: 14px; margin-bottom: 14px; border: 1px solid; border-left-width: 5px; }
.alert-stop { background: var(--danger-tint); border-color: var(--danger); color: #6E2417; }
.alert-warn { background: var(--warn-tint); border-color: var(--warn); color: #5E410A; }
.alert-info { background: var(--navy-tint); border-color: var(--navy); color: var(--navy-2); }
.alert-ok { background: var(--ok-tint); border-color: var(--ok); color: #1D4527; }

/* ---------- site (billboard) card ---------- */
.site { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--navy); border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); }
.site.st-in_progress { border-left-color: var(--hivis); }
.site.st-approved, .site.st-scheduled { border-left-color: var(--ok); }
.site.st-completed, .site.st-invoiced { border-left-color: var(--ink); }
.site.st-declined { border-left-color: var(--danger); opacity: 0.8; }
.site-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.site-head .board { font-family: var(--font-head); font-weight: 700; font-size: 22px; letter-spacing: 0.04em; }
.site-head .meta { color: var(--muted); font-size: 13.5px; }
.site-body { padding: 16px; }
.section { margin-top: 18px; }
.section:first-child { margin-top: 0; }
.section-title { display: flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 700; font-size: 14px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 18px; }
.kv .k { font-family: var(--font-head); font-weight: 600; font-size: 12.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.kv .v { font-size: 15px; }
.kv .v.big { font-family: var(--font-head); font-weight: 700; font-size: 24px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.doc { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 10px; min-height: 96px; display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); }
.doc.have { border-style: solid; border-color: var(--ok); background: var(--ok-tint); }
.doc.need { border-color: var(--danger); background: var(--danger-tint); }
.doc .dl { font-family: var(--font-head); font-weight: 700; font-size: 13px; letter-spacing: 0.07em; text-transform: uppercase; }
.doc img { width: 100%; height: 110px; object-fit: cover; border-radius: 2px; border: 1px solid var(--line); }
.doc .fname { font-size: 12.5px; color: var(--ink-2); word-break: break-all; }

.upload { position: relative; overflow: hidden; }
.upload input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- order list cards ---------- */
.order { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; }
.order-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.order-head .wo { font-family: var(--font-head); font-weight: 700; font-size: 20px; letter-spacing: 0.05em; }

/* ---------- calendar ---------- */
.cal-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-bar .month { font-family: var(--font-head); font-weight: 700; font-size: 22px; text-transform: uppercase; letter-spacing: 0.04em; min-width: 190px; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal .dow { background: var(--ink); color: #fff; font-family: var(--font-head); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 12.5px; padding: 7px 8px; }
.cal .day { background: var(--surface); min-height: 104px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal .day.out { background: var(--surface-2); }
.cal .day.out .dn { opacity: 0.45; }
.cal .dn { font-family: var(--font-head); font-weight: 700; font-size: 15px; color: var(--ink-2); }
.cal .day.today .dn { color: #fff; background: var(--hivis); align-self: flex-start; padding: 0 7px; border-radius: 2px; }
.cal .ev { font-size: 12px; line-height: 1.25; padding: 4px 6px; border-radius: 2px; border-left: 3px solid var(--ok); background: var(--ok-tint); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; color: var(--ink); display: block; }
.cal .ev b { font-family: var(--font-head); font-size: 13.5px; letter-spacing: 0.03em; }
.cal .ev.st-in_progress { border-left-color: var(--hivis); background: var(--hivis-tint); }
.cal .ev.st-completed, .cal .ev.st-invoiced { border-left-color: var(--ink); background: var(--surface-2); color: var(--ink-2); }
@media (max-width: 640px) {
  .cal .day { min-height: 64px; padding: 3px; }
  .cal .dow { text-align: center; padding: 5px 1px; font-size: 11px; }
  .cal .ev { font-size: 10.5px; padding: 2px 3px; }
  .cal .ev .x { display: none; }
}

/* ---------- modal + toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 20, 24, 0.55); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 50px 16px; overflow-y: auto; }
.modal { background: var(--surface); width: 100%; max-width: 620px; border-radius: var(--radius); border-top: 5px solid var(--navy); box-shadow: 0 18px 50px rgba(0,0,0,0.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }
.x-btn { border: none; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 36px); }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: var(--radius); border-left: 5px solid var(--ok); font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.25); }
.toast.err { border-left-color: var(--danger); }

/* ---------- auth screens ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  background:
    linear-gradient(160deg, rgba(15, 42, 73, 0.94), rgba(22, 25, 28, 0.96)),
    repeating-linear-gradient(135deg, #1b2229 0 14px, #161b20 14px 28px);
  color: #fff; padding: 48px 52px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 10px; background: repeating-linear-gradient(135deg, var(--hivis) 0 18px, var(--ink) 18px 36px); }
.auth-hero .logo-plate { background: #fff; display: inline-block; padding: 10px 14px; border-radius: 3px; align-self: flex-start; }
.auth-hero .logo-plate img { height: 42px; display: block; }
.auth-hero h1 { color: #fff; font-size: 64px; line-height: 0.95; letter-spacing: 0.02em; margin: 30px 0 14px; }
.auth-hero h1 span { color: var(--hivis); }
.auth-hero .lede { font-size: 18px; color: #D5DBE1; max-width: 460px; }
.auth-hero .pts { display: grid; gap: 10px; margin-top: 26px; max-width: 460px; }
.auth-hero .pt { display: flex; gap: 12px; align-items: baseline; font-size: 15px; color: #C7CED5; }
.auth-hero .pt b { font-family: var(--font-head); color: #fff; letter-spacing: 0.06em; text-transform: uppercase; font-size: 15px; min-width: 90px; }
.auth-hero .fine { font-size: 12.5px; color: #8E98A2; margin-bottom: 8px; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 410px; }
.auth-card h2 { margin-bottom: 4px; }
.auth-card .switch { margin-top: 16px; font-size: 14px; color: var(--ink-2); text-align: center; }
.auth-card .switch a { cursor: pointer; font-weight: 600; }
.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.roles label { border: 1.5px solid var(--line-strong); border-radius: var(--radius); padding: 10px; cursor: pointer; background: var(--surface); font-size: 13.5px; text-transform: none; letter-spacing: 0; font-family: var(--font-body); font-weight: 500; color: var(--ink); }
.roles label b { display: block; font-family: var(--font-head); font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; }
.roles input { display: none; }
.roles label:has(input:checked) { border-color: var(--navy); background: var(--navy-tint); box-shadow: inset 0 0 0 1px var(--navy); }
@media (max-width: 880px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 26px 22px 34px; }
  .auth-hero h1 { font-size: 42px; margin-top: 18px; }
  .auth-hero .pts, .auth-hero .fine { display: none; }
}

.center-screen { min-height: 70vh; display: flex; align-items: center; justify-content: center; text-align: center; padding: 30px; }
.spinner { width: 34px; height: 34px; border: 4px solid var(--line); border-top-color: var(--hivis); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
