/* SAS Enterprises CRM: hand-written, no build step. */
:root {
  --ink: #16202b;
  --ink-2: #4a5866;
  --ink-3: #7b8794;
  --line: #dfe4ea;
  --line-2: #eef1f4;
  --paper: #ffffff;
  --canvas: #f3f5f7;
  --rail: #121c27;
  --rail-ink: #c9d3dd;
  --rail-dim: #7f8d9b;
  --brand: #1f6f8b;          /* replaced per company in the layout */
  --ok: #1d7a46;
  --ok-bg: #e6f4ec;
  --warn: #9a5b00;
  --warn-bg: #fff3dc;
  --bad: #b42318;
  --bad-bg: #fde9e7;
  --info-bg: #e8f1fb;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--sans); color: var(--ink); background: var(--canvas); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--ink-3); }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .9em; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.rail { background: var(--rail); color: var(--rail-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.rail .mark { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 700; letter-spacing: .02em; }
.rail .mark span.logo { width: 30px; height: 30px; border-radius: 7px; background: linear-gradient(135deg, var(--brand), #0d3b4f); display: grid; place-items: center; font-size: 13px; }
.rail .mark small { display: block; color: var(--rail-dim); font-weight: 400; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.rail nav a { display: flex; align-items: center; gap: 10px; color: var(--rail-ink); padding: 7px 10px; border-radius: 6px; font-size: 14px; }
.rail nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.rail nav a.on { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.rail nav .sect { color: var(--rail-dim); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 16px 10px 4px; }
.rail nav .soon { opacity: .45; pointer-events: none; }
.rail nav .soon::after { content: "soon"; margin-left: auto; font-size: 10px; border: 1px solid var(--rail-dim); border-radius: 4px; padding: 0 4px; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .ctx { display: flex; align-items: center; gap: 8px; }
.topbar .ctx .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.topbar .ctx select { font-weight: 600; border-color: transparent; background-color: var(--line-2); }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 14px; color: var(--ink-2); }
.btn.menu-btn { display: none; }
.content { padding: 22px 24px 60px; max-width: 1280px; }

/* ---------- page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.page-head .titles { flex: 1; min-width: 240px; }
.page-head .titles p { margin: 2px 0 0; color: var(--ink-2); }
.crumbs { font-size: 13px; color: var(--ink-3); margin-bottom: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- cards & grids ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card > h2:first-child, .card > h3:first-child { margin-bottom: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2:first-child { padding: 14px 18px 0; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.tile .value { font-size: 1.55rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .sub { font-size: 13px; color: var(--ink-2); }
.tile.bad .value { color: var(--bad); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.facts dt { color: var(--ink-3); font-size: 13px; }
dl.facts dd { margin: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 9px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
table.list td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover td { background: #fafcfd; }
table.list tfoot td { font-weight: 650; border-top: 2px solid var(--line); background: #fafbfc; }
table.list tr.void td { color: var(--ink-3); text-decoration: line-through; }
.empty { padding: 28px; text-align: center; color: var(--ink-3); }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge.draft { background: #eef1f4; color: #4a5866; }
.badge.open { background: var(--info-bg); color: #1d4f91; }
.badge.partial { background: var(--warn-bg); color: var(--warn); }
.badge.paid { background: var(--ok-bg); color: var(--ok); }
.badge.void { background: #f0f0f0; color: #8a8a8a; }
.badge.overdue { background: var(--bad-bg); color: var(--bad); }
.co { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.co i { width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--brand)); display: inline-block; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
input:not([type]), input[type=text], input[type=url], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=datetime-local], input[type=password], input[type=search], input[type=color], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #c9d1d9; border-radius: 6px; padding: 7px 10px; min-height: 38px;
}
input[type=color] { padding: 2px; width: 60px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 0; border-color: var(--brand); }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.field.err input, .field.err select, .field.err textarea { border-color: var(--bad); }
.field .error { color: var(--bad); font-size: 13px; margin-top: 3px; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.check input { width: 16px; height: 16px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; }
.seg { display: inline-flex; border: 1px solid #c9d1d9; border-radius: 6px; overflow: hidden; }
.seg label { margin: 0; padding: 6px 14px; cursor: pointer; font-weight: 500; color: var(--ink-2); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { color: #fff; }
.seg label:has(input:checked) { background: var(--brand); color: #fff; }

.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 14px; font-weight: 600; padding: 8px 14px; border-radius: 6px; border: 1px solid #c9d1d9; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; min-height: 38px; }
.btn:hover { background: #f6f8fa; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(.94); }
.btn.danger { color: var(--bad); border-color: #f0b6b0; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.link { border: 0; background: none; color: var(--brand); padding: 0; min-height: 0; font-weight: 500; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search] { width: 280px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 5px 12px; border-radius: 999px; font-size: 13px; color: var(--ink-2); border: 1px solid transparent; }
.tabs a.on { background: var(--paper); border-color: var(--line); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

/* ---------- alerts ---------- */
.alert { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; border: 1px solid; font-size: 14px; }
.alert.ok { background: var(--ok-bg); border-color: #b5dfc5; color: #12492b; }
.alert.bad { background: var(--bad-bg); border-color: #f4c2bc; color: #7a1b12; }
.alert.warn { background: var(--warn-bg); border-color: #f1d49a; color: #6b4000; }
.alert ul { margin: 4px 0 0 18px; padding: 0; }

/* ---------- invoice editor ---------- */
.lines-table td { vertical-align: middle; }
.lines-table input, .lines-table select { min-height: 34px; padding: 5px 8px; }
.lines-table .c-kind { width: 155px; }
.lines-table .c-qty { width: 90px; }
.lines-table .c-price { width: 120px; }
.lines-table .c-tax { width: 50px; text-align: center; }
.lines-table .c-acct { width: 210px; }
.lines-table .c-total { width: 110px; }
.lines-table .c-x { width: 36px; }
.totals { margin-left: auto; width: min(340px, 100%); }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 8px; font-weight: 700; font-size: 1.1rem; }

.picker { position: relative; }
.picker .results { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(16,24,40,.14); max-height: 300px; overflow-y: auto; }
.picker .results button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; font: inherit; cursor: pointer; }
.picker .results button:hover, .picker .results button.on { background: var(--info-bg); }
.picker .results small { display: block; }
.picked { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid #c9d1d9; border-radius: 6px; background: #fafbfc; }
.picked strong { flex: 1; }

details.ledger summary { cursor: pointer; color: var(--ink-2); font-size: 14px; }
.note { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin-bottom: 12px; }
.note .meta { font-size: 12px; color: var(--ink-3); }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, #1f6f8b33, transparent), var(--rail); }
.auth .box { width: min(400px, 100%); background: #fff; border-radius: 12px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth .brand { font-weight: 800; letter-spacing: .02em; font-size: 1.15rem; }
.auth .brand small { display: block; font-weight: 400; color: var(--ink-3); font-size: 13px; letter-spacing: 0; }

dialog { border: 0; border-radius: 10px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); width: min(440px, 92vw); }
dialog::backdrop { background: rgba(10, 18, 28, .45); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .grid.two, .grid.three, .grid.side { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  body.rail-open .rail { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 8px 16px; }
  .topbar .who { display: none; }
  .content { padding: 16px 16px 48px; }
  .toolbar input[type=search] { width: 100%; }
  .toolbar form { width: 100%; }
  .lines-table thead { display: none; }
  .lines-table, .lines-table tbody, .lines-table tr, .lines-table td { display: block; width: 100% !important; }
  .lines-table tr { border-bottom: 1px solid var(--line); padding: 8px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .lines-table td { border: 0; padding: 0; }
  .lines-table td.c-desc, .lines-table td.c-acct { grid-column: 1 / -1; }
}
@media print {
  .rail, .topbar, .no-print { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
}

/* Contract / agreement text inside the staff app */
.agreement-text h1 { font-size: 1.3rem; } .agreement-text h2 { font-size: 1.05rem; margin-top: 1.2rem; } .agreement-text h3 { font-size: .95rem; }
.agreement-text table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 13px; }
.agreement-text td, .agreement-text th { border: 1px solid var(--line); padding: 4px 6px; text-align: left; vertical-align: top; }

/* Inventory photos and the AI listing writer */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-bottom: 8px; }
.photo-tile { display: flex; flex-direction: column; gap: 2px; font-size: 12px; position: relative; }
.photo-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.photo-tile small { position: absolute; top: 4px; left: 4px; background: var(--brand); color: #fff; padding: 0 6px; border-radius: 4px; }
.ai-panel { border-left: 4px solid var(--brand); }
.ai-filled { background: color-mix(in srgb, var(--brand) 9%, #fff); border-color: var(--brand); }
.inv-bulk { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.inv-bulk .sites { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.site-dots { display: inline-flex; gap: 3px; flex-wrap: wrap; }
.site-dots span { font-size: 11px; padding: 0 6px; border-radius: 9px; background: color-mix(in srgb, var(--brand) 14%, #fff); }
