/* ============================================================
   OTI Deal Jacket — theme tokens (rebrand per tenant here)
   ============================================================ */
:root {
    --bg:           #0f1729;
    --surface:      #ffffff;
    --surface-2:    #f5f7fb;
    --border:       #e2e8f0;
    --ink:          #1a2233;
    --muted:        #64748b;

    --brand:        #14233f;   /* navy */
    --brand-ink:    #ffffff;
    --accent:       #c9a23f;   /* gold */

    --ok:           #157f54;
    --ok-bg:        #e6f4ec;
    --warn:         #b7791f;
    --warn-bg:      #fdf3e0;
    --alert:        #c0392b;
    --alert-bg:     #fbeae8;
    --neutral:      #475569;
    --neutral-bg:   #eef1f6;

    --radius:       10px;
    --shadow:       0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
    --font:         system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--surface-2);
    font-size: 14px;
}

a { color: inherit; text-decoration: none; }

.loading-shell {
    display: flex; align-items: center; justify-content: center;
    height: 100vh; color: var(--muted);
}

/* ---------------- Shell + sidebar ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px; flex-shrink: 0;
    background: var(--brand); color: var(--brand-ink);
    display: flex; flex-direction: column;
    padding: 20px 14px;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; padding: 0 6px; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 9px;
    background: var(--accent); color: var(--brand);
    display: grid; place-items: center; font-weight: 800; font-size: 15px;
}
.brand-name { font-weight: 700; }
.brand-sub { font-size: 11px; opacity: .6; }

.nav-items { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px;
    color: rgba(255,255,255,.78); font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.14); color: #fff; }
.nav-ico { width: 18px; text-align: center; opacity: .85; }
.nav-badge {
    margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px; font-size: 11px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}

.sidebar-foot { padding: 6px; }
.env-pill {
    font-size: 11px; padding: 5px 10px; border-radius: 20px;
    background: rgba(255,255,255,.1); color: rgba(255,255,255,.7);
    display: inline-block;
}

.content { flex: 1; overflow-x: auto; }
.content-inner { max-width: 1180px; margin: 0 auto; padding: 28px 32px 64px; }

/* ---------------- Headings ---------------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
h1 { font-size: 24px; margin: 4px 0 2px; }
h2 { font-size: 15px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.back { color: var(--muted); font-size: 13px; }
.pad { padding: 16px; }

.head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.deliver-gate { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 7px; }
.deliver-gate.ok { background: var(--ok-bg); color: var(--ok); }
.deliver-gate.blocked { background: var(--alert-bg); color: var(--alert); }

/* ---------------- KPI cards ---------------- */
.kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px; margin-bottom: 24px;
}
.kpi {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px 18px; border-left: 4px solid var(--neutral);
}
.kpi-val { font-size: 26px; font-weight: 700; }
.kpi-label { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi-ok    { border-left-color: var(--ok); }
.kpi-warn  { border-left-color: var(--warn); }
.kpi-alert { border-left-color: var(--alert); }

/* ---------------- Panels ---------------- */
.panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 18px; overflow: hidden;
}
.panel-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid var(--border); gap: 12px;
}
.panel-head.clickable:hover { background: var(--surface-2); }

/* ---------------- Jacket layout ---------------- */
.jacket-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.jacket-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 860px) { .jacket-grid { grid-template-columns: 1fr; } }

/* ---------------- Tables ---------------- */
.grid { width: 100%; border-collapse: collapse; }
.grid th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); padding: 11px 18px; border-bottom: 1px solid var(--border);
}
.grid td { padding: 13px 18px; border-bottom: 1px solid var(--border); }
.grid.tight td, .grid.tight th { padding: 9px 18px; }
.grid tbody tr:last-child td { border-bottom: none; }
.clickable { cursor: pointer; }
.grid tbody tr.clickable:hover { background: var(--surface-2); }
.chev { color: var(--muted); text-align: right; font-size: 18px; }

.bar { display: inline-block; width: 80px; height: 6px; background: var(--neutral-bg); border-radius: 4px; overflow: hidden; vertical-align: middle; }
.bar-fill { height: 100%; background: var(--accent); }
.bar-label { font-size: 12px; color: var(--muted); margin-left: 8px; }

/* ---------------- Toolbar ---------------- */
.toolbar { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.search {
    flex: 1; min-width: 220px; padding: 9px 13px;
    border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: var(--surface);
}
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter {
    border: 1px solid var(--border); background: var(--surface);
    padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.filter.on { border-color: var(--brand); background: var(--brand); color: #fff; }
.filter.on .badge { background: rgba(255,255,255,.18); color: #fff; }

/* ---------------- Badges ---------------- */
.badge {
    display: inline-block; font-size: 11.5px; font-weight: 600;
    padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.badge.ok      { background: var(--ok-bg);      color: var(--ok); }
.badge.warn    { background: var(--warn-bg);    color: var(--warn); }
.badge.alert   { background: var(--alert-bg);   color: var(--alert); }
.badge.neutral { background: var(--neutral-bg); color: var(--neutral); }

/* ---------------- Checklist ---------------- */
.checklist, .compliance { list-style: none; margin: 0; padding: 8px 0; }
.checklist li {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 18px;
}
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.check .done { color: var(--muted); text-decoration: line-through; }
.gate-tag { font-size: 11px; color: var(--alert); background: var(--alert-bg); padding: 2px 8px; border-radius: 12px; }

/* ---------------- Compliance list ---------------- */
.compliance li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 18px; }

/* ---------------- Documents ---------------- */
.doc-group { padding: 6px 0; }
.doc-group-head {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); padding: 10px 18px 4px;
}
.doc-row {
    display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
    padding: 9px 18px; border-top: 1px solid var(--surface-2);
}
.doc-name { display: flex; flex-direction: column; gap: 4px; }
.doc-name > span:first-child { display: flex; align-items: center; gap: 10px; }
.sig-tag { font-size: 11px; color: var(--warn); background: var(--warn-bg); padding: 2px 8px; border-radius: 12px; }
.stored-meta { font-size: 12px; color: var(--muted); }
.doc-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.upload-btn { cursor: pointer; }
.upload-btn input[type=file] { display: none; }

/* ---------------- Buttons ---------------- */
.btn-sm {
    border: 1px solid var(--border); background: var(--surface);
    padding: 6px 11px; border-radius: 7px; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.btn-sm:hover { background: var(--surface-2); }
.btn-sm.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-sm.primary:hover { opacity: .92; }
.btn-sm.danger { color: var(--alert); border-color: var(--alert); background: var(--surface); }
.btn-sm.danger:hover { background: var(--alert); color: #fff; }

/* ---------------- Records retention & legal hold ---------------- */
.records-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--surface-2); }
.records-actions .search { min-width: 280px; flex: 1; }

/* ---------------- Product cancellation / refunds ---------------- */
.strike { text-decoration: line-through; }
.refund-amt { width: 90px; padding: 4px 8px; font-size: 12.5px; }

/* ---------------- Trade-in / title blocks ---------------- */
.title-block { padding: 14px 18px; border-top: 1px solid var(--surface-2); }
.title-block:first-of-type { border-top: none; }
.title-block-head {
    display: flex; justify-content: space-between; align-items: center;
    font-weight: 600; margin-bottom: 10px;
}
.kv-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px 24px; margin-bottom: 10px;
}
.kv-grid > div { display: flex; flex-direction: column; }
.kv-k { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kv-v { font-size: 13.5px; }
.kv-v.neg { color: var(--alert); font-weight: 600; }
.trade-status { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; border-top: 1px dashed var(--border); }
.trade-status-row { display: flex; align-items: center; gap: 10px; }
.trade-status-row .kv-k { min-width: 130px; }
.title-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Batch scan import ---------------- */
.batch-bar { display: flex; align-items: center; gap: 12px; padding: 14px 18px; flex-wrap: wrap; }
.batch-review { border-top: 1px solid var(--border); }
.batch-assign { min-width: 240px; padding: 6px 10px; font-size: 13px; }
.batch-actions { display: flex; gap: 8px; padding: 14px 18px; }

/* ---------------- Forms (create / edit deal) ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.form-input {
    padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; background: var(--surface); width: 100%;
}
.form-input:disabled { background: var(--surface-2); color: var(--muted); }
.check-field { justify-content: flex-end; }
.trade-edit { padding: 14px 18px; border-top: 1px solid var(--surface-2); }
.trade-edit .btn-sm { margin-top: 10px; }
.form-actions { display: flex; gap: 10px; margin: 18px 0 40px; }
.form-error {
    background: var(--alert-bg); color: var(--alert); border: 1px solid var(--alert);
    padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px;
}

/* ---------------- Auth / login ---------------- */
.auth-shell { min-height: 100vh; display: grid; place-items: center; background: var(--brand); padding: 20px; }
.auth-card {
    width: 100%; max-width: 380px; background: var(--surface);
    border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.25); padding: 28px;
}
.auth-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.auth-title { font-size: 20px; margin: 0 0 16px; }
.auth-card .field { margin-bottom: 14px; }
.auth-submit { width: 100%; justify-content: center; padding: 10px; margin-top: 4px; }
.auth-hint { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.auth-hint ul { margin: 8px 0 0; padding-left: 16px; }
.auth-hint li { margin: 2px 0; }

/* ---------------- Sidebar user ---------------- */
.user-box { padding: 8px 6px 10px; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role { font-size: 11px; color: rgba(255,255,255,.6); }
.signout {
    width: 100%; text-align: left; background: rgba(255,255,255,.08); color: rgba(255,255,255,.85);
    border: none; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.signout:hover { background: rgba(255,255,255,.16); color: #fff; }

/* ---------------- Activity / audit ---------------- */
.activity { list-style: none; margin: 0; padding: 6px 0; }
.activity li { padding: 10px 18px; border-top: 1px solid var(--surface-2); }
.activity li:first-child { border-top: none; }
.activity-action { font-weight: 600; }

/* ---------------- Document viewer modal ---------------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(16,24,40,.55);
    display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 24px;
}
.modal {
    background: #fff; width: 88%; height: 90%; max-width: 1100px;
    border-radius: 10px; box-shadow: 0 12px 48px rgba(0,0,0,.35);
    display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; border-bottom: 1px solid var(--border); gap: 12px;
}
.modal-title { font-weight: 600; font-size: 14px; }
.modal-actions { display: flex; gap: 8px; }
.modal-frame { flex: 1; width: 100%; border: none; background: var(--surface-2); }

/* ---------------- Misc ---------------- */
.not-found { text-align: center; padding: 80px 20px; }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: #fee; padding: 10px 16px; box-shadow: 0 -1px 3px rgba(0,0,0,.1); z-index: 1000;
}
#blazor-error-ui .reload { text-decoration: underline; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ---------------- Mobile / responsive (D7) ---------------- */
@media (max-width: 640px) {
    /* Sidebar becomes a horizontal top bar */
    .app-shell { flex-direction: column; }
    .sidebar { width: auto; flex-direction: row; align-items: center; gap: 8px; padding: 8px 10px; overflow-x: auto; }
    .brand { margin-bottom: 0; flex-shrink: 0; }
    .brand-sub { display: none; }
    .nav-items { flex-direction: row; flex: 0 1 auto; gap: 2px; }
    .nav-item { padding: 8px 10px; white-space: nowrap; }
    .sidebar-foot { margin-left: auto; flex-shrink: 0; padding: 0; }

    .content-inner { padding: 16px 14px 48px; }
    .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
    .head-right { display: flex; flex-wrap: wrap; gap: 8px; }
    .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
    /* Wide tables scroll horizontally rather than overflow the viewport */
    .grid { display: block; overflow-x: auto; white-space: nowrap; }
    .modal { width: 96vw; height: 92vh; }
}

.rollup-total td { font-weight: 700; border-top: 2px solid var(--border); }
