/* CopyOps - Copyright (c) 2026 The Ludlow Synexis Group, LLC */
:root {
  --bg: #f4f5f7; --panel: #ffffff; --panel-2: #f9fafb; --line: #e3e6ea; --line-2: #d4d9df;
  --text: #1c2430; --muted: #5f6b7a; --faint: #8a95a3;
  --brand: #1f5d8c; --brand-ink: #ffffff; --brand-soft: #e6eff7;
  --ok: #1d7a46; --ok-soft: #e3f3ea; --warn: #9a6100; --warn-soft: #fbf0d9; --bad: #b42318; --bad-soft: #fde8e6; --info-soft: #e8eefb;
  --side: #17212e; --side-text: #c4cdd8; --side-active: #ffffff; --side-hover: #223043;
  --radius: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141a; --panel: #161d25; --panel-2: #1b232d; --line: #263140; --line-2: #33404f;
    --text: #e3e8ee; --muted: #9aa6b4; --faint: #6f7c8b;
    --brand: #4f9bd4; --brand-ink: #0b1118; --brand-soft: #1b2c3c;
    --ok: #4cc283; --ok-soft: #15291f; --warn: #e3a948; --warn-soft: #2d2414; --bad: #f2786c; --bad-soft: #321a18; --info-soft: #1a2436;
    --side: #0b1016; --side-text: #9aa6b4; --side-hover: #18212c;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.boot { padding: 40px; color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- layout */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 16px 16px 14px; display: flex; gap: 10px; align-items: center; color: #fff; font-weight: 600; }
.brand img { width: 26px; height: 26px; }
.brand small { display: block; font-weight: 400; color: var(--side-text); font-size: 11.5px; }
.nav { padding: 6px 8px; overflow-y: auto; flex: 1; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: 6px; color: var(--side-text); margin-bottom: 1px; }
.nav a:hover { background: var(--side-hover); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-hover); color: var(--side-active); box-shadow: inset 3px 0 0 var(--brand); }
.nav .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b7889; padding: 14px 10px 4px; }
.nav .count { background: #2c3a4c; color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; min-width: 20px; text-align: center; }
.nav .count.bad { background: var(--bad); }
.side-foot { padding: 12px 16px; border-top: 1px solid #223043; font-size: 12.5px; }
.side-foot a { color: var(--side-text); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; }
.search-results { position: absolute; top: 38px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.15); z-index: 20; max-height: 420px; overflow: auto; }
.search-results a { display: block; padding: 8px 12px; color: var(--text); border-bottom: 1px solid var(--line); }
.search-results a:hover, .search-results a.sel { background: var(--brand-soft); text-decoration: none; }
.search-results .k { font-size: 11px; color: var(--faint); text-transform: uppercase; margin-right: 6px; }
.content { padding: 20px 24px 48px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2, .card.flush > .card-head { padding: 14px 16px 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: var(--text); display: block; }
.tile:hover { border-color: var(--brand); text-decoration: none; }
.tile .n { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .l { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.tile.bad .n { color: var(--bad); }
.tile.warn .n { color: var(--warn); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.empty { padding: 24px 16px; color: var(--muted); text-align: center; }
.notice { padding: 10px 12px; border-radius: 6px; background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); margin-bottom: 12px; }
.notice.info { background: var(--info-soft); border-color: var(--line-2); }
.notice.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.notice pre { white-space: pre-wrap; margin: 6px 0 0; font: inherit; }
.keybox { font-family: var(--mono); background: var(--panel-2); border: 1px dashed var(--line-2); padding: 10px; border-radius: 6px; word-break: break-all; user-select: all; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel-2); position: sticky; top: 0; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--brand-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.void td { color: var(--faint); text-decoration: line-through; }
.table-tools { display: flex; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: center; flex-wrap: wrap; }
.table-tools input[type=search] { max-width: 320px; }

/* ---------- badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

/* ---------- supplies */
.supply { display: grid; grid-template-columns: 1fr 120px 44px; gap: 10px; align-items: center; padding: 6px 0; }
.bar { height: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--faint); }
.bar.black > span { background: #2b2f36; } .bar.cyan > span { background: #00a3d9; } .bar.magenta > span { background: #d1278b; } .bar.yellow > span { background: #e6c300; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bar.black > span { background: #c9ced6; } }

/* ---------- forms */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], input[type=email], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel); min-height: 34px;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field .hint { font-size: 12px; color: var(--faint); margin-top: 3px; }
.field.check { display: flex; align-items: center; gap: 8px; }
.field.check label { margin: 0; color: var(--text); font-weight: 400; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.err { color: var(--bad); margin-top: 10px; }
button, .btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; font-weight: 600; font-size: 13.5px; min-height: 34px; color: var(--text); }
button:hover, .btn:hover { border-color: var(--brand); text-decoration: none; }
button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button.small { padding: 3px 10px; min-height: 28px; font-size: 12.5px; }
button:disabled { opacity: .55; cursor: default; }
.rates td { padding: 4px 6px; }
.picker { position: relative; }
.picker .opts { position: absolute; top: 36px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line-2); border-radius: 6px; z-index: 30; max-height: 240px; overflow: auto; box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.picker .opts div { padding: 7px 10px; cursor: pointer; }
.picker .opts div:hover { background: var(--brand-soft); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs a.active { color: var(--text); border-color: var(--brand); text-decoration: none; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.seg a { padding: 5px 12px; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg a.active { background: var(--brand); color: var(--brand-ink); text-decoration: none; }

/* ---------- modal + toast */
.modal-back { position: fixed; inset: 0; background: rgba(10,16,24,.5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 10px; width: 100%; max-width: 680px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal.wide { max-width: 960px; }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 18px; }
.x { border: 0; background: none; font-size: 20px; padding: 0 6px; min-height: 0; color: var(--muted); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--panel); padding: 10px 14px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 380px; }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- auth screens */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 400px; padding: 28px; }
.auth .brand { color: var(--text); padding: 0 0 18px; }
.auth .brand small { color: var(--muted); }
.auth .field { margin-bottom: 12px; }
.auth button { width: 100%; justify-content: center; margin-top: 6px; }

/* ---------- invoice */
.invoice { background: #fff; color: #111; padding: 40px; max-width: 860px; margin: 0 auto; border: 1px solid var(--line); border-radius: var(--radius); }
.invoice table th { background: #f3f4f6; color: #333; }
.invoice td, .invoice th { border-color: #e5e7eb; }
.invoice .inv-head { display: flex; justify-content: space-between; margin-bottom: 28px; gap: 24px; }
.invoice .inv-title { font-size: 26px; font-weight: 700; letter-spacing: .02em; color: #1f5d8c; }
.invoice .totals { margin-left: auto; width: 280px; margin-top: 12px; }
.invoice .totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.invoice .totals .grand { font-weight: 700; border-top: 2px solid #111; padding-top: 8px; font-size: 16px; }
.invoice .addr { white-space: pre-line; }

@media print {
  .side, .topbar, .page-head .actions, .no-print, #toasts { display: none !important; }
  .shell { display: block; } .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .invoice { border: 0; padding: 0; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; width: 240px; left: -260px; transition: left .15s; }
  .side.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .g2, .g3, .form { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
  .invoice { padding: 20px; }
}

/* ---------- Phase 1 */
.menu { position: relative; display: inline-block; }
.menu-list { position: absolute; right: 0; top: 38px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.15); z-index: 25; min-width: 170px; }
.menu-list a { display: block; padding: 8px 12px; color: var(--text); white-space: nowrap; }
.menu-list a:hover { background: var(--brand-soft); text-decoration: none; }
a.btn.small { padding: 3px 10px; min-height: 28px; font-size: 12.5px; }
.print-only { display: none; }
@media print {
  body.print-slip .shell, body.print-slip #modal-root { display: none !important; }
  body.print-slip .print-only { display: block !important; }
}

/* ---------- Phase 2: service department */
.notice.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.clockbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.mlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 16px; }
.mcard, .dcard { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line-2); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.mcard.pri-Down, .dcard.pri-Down { border-left-color: var(--bad); }
.mcard.pri-High, .dcard.pri-High { border-left-color: var(--warn); }
.mcard.pri-Low, .dcard.pri-Low { border-left-color: var(--faint); }
.mtop { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-weight: 600; }
.mcust { font-size: 16px; font-weight: 600; margin: 6px 0 2px; }
.mprob { margin: 8px 0; white-space: pre-wrap; }
.mbtns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.mbtns button, .mbtns .btn { min-height: 40px; }
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.dcol { flex: 0 0 280px; background: var(--panel-2); border: 1px dashed transparent; border-radius: var(--radius); padding: 10px; min-height: 160px; }
.dcol.over { border-color: var(--brand); background: var(--brand-soft); }
.dhead { margin-bottom: 10px; }
.dhead .count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--line); font-size: 12px; text-align: center; }
.dcard { margin-bottom: 10px; cursor: grab; }
.dcard.dragging { opacity: .5; }
.dprob { margin: 6px 0; color: var(--muted); }
.dctl { display: grid; gap: 6px; margin-top: 8px; }
.dctl select, .dctl input { font-size: 12.5px; padding: 4px 6px; min-height: 30px; }
.dempty { padding: 20px 4px; text-align: center; }
.pmbar { position: relative; width: 110px; height: 16px; background: var(--line); border-radius: 8px; overflow: hidden; }
.pmbar span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ok); }
.pmbar.soon span { background: var(--warn); }
.pmbar.due span { background: var(--bad); }
.pmbar em { position: relative; font-style: normal; font-size: 11px; padding-left: 6px; color: var(--text); }
.sigpad { width: 100%; max-width: 560px; height: auto; aspect-ratio: 560 / 200; border: 1px solid var(--line-2); border-radius: 6px; background: #fff; touch-action: none; display: block; }
.sigimg { max-width: 280px; background: #fff; border: 1px solid var(--line); border-radius: 6px; display: block; margin-bottom: 6px; }
.days { display: flex; flex-wrap: wrap; gap: 10px; }
.daybox { display: flex; align-items: center; gap: 4px; font-weight: 400; color: var(--text); }
@media (max-width: 600px) { .mlist { grid-template-columns: 1fr; } .dcol { flex-basis: 85vw; } }

/* ---------- Phase 3: sales, purchasing, accounting */
.pipeline { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; margin-bottom: 16px; }
.stage { flex: 0 0 230px; background: var(--panel-2); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.stage-head { margin-bottom: 8px; font-size: 13px; }
.opp { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; color: var(--text); box-shadow: var(--shadow); font-size: 13px; }
.opp:hover { border-color: var(--brand); text-decoration: none; }
.opp > div + div { margin-top: 3px; }
.line-editor { margin-top: 6px; }
.line-editor table td { padding: 4px 6px; vertical-align: top; }
.line-editor input, .line-editor select { width: 100%; min-width: 0; }
.line-editor input[type=checkbox] { width: auto; }
.line-editor .picker { min-width: 160px; }
.range { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.range label { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.range input { width: auto; }
table.statement { width: 100%; max-width: 720px; }
table.statement tr.sec th { text-align: left; padding-top: 16px; border-bottom: 1px solid var(--line-2); }
table.statement td { padding: 5px 8px; }
table.statement tr.total td { font-weight: 600; border-top: 1px solid var(--line); }
table.statement tr.total.big td { font-size: 15px; border-top: 2px solid var(--line-2); padding-top: 10px; }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }
@media (max-width: 600px) { .stage { flex-basis: 80vw; } }
