/* =========================================================================
   Odecci Project Delivery — global design system
   Shared tokens + components used across every page.
   Page-specific styles live in each page's isolated .razor.css file.
   ========================================================================= */

:root {
    --bg: #F4F5F7;
    --surface: #FFFFFF;
    --surface-2: #FAFBFC;
    --ink: #14181F;
    --muted: #5A6270;
    --muted-2: #8B95A5;
    --line: #E2E5EA;
    --line-2: #EEF0F3;
    --line-input: #D5D9E0;
    --track: #E8EBF0;
    --primary: #1D5FD1;
    --primary-dark: #1747A0;
    --primary-soft: #E3ECFB;
    --primary-tint: #F0F5FE;
    --side: #121821;
    --side-hover: #1B232E;
    --side-on: #243041;
    --side-ink: #C9CFD8;

    --healthy: #1F7A4D;
    --warning: #B08600;
    --risk: #D9661F;
    --critical: #B42318;

    --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}

html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
}
*, *::before, *::after { box-sizing: border-box; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
h1:focus { outline: none; }
button { font: inherit; }

/* ---------- Text helpers ---------- */
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.h2 { font-size: 15px; font-weight: 600; margin: 0; }
.lbl { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.link-btn { all: unset; cursor: pointer; color: var(--primary); font-size: 13px; }
.link-btn:hover { color: var(--primary-dark); text-decoration: underline; }
.link-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 3px; }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head.flat { border-bottom: 0; }
.card-body { padding: 16px 20px; }
.row-line { border-bottom: 1px solid var(--line-2); }

/* ---------- Badges / tones ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; line-height: 20px; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.nodot::before { display: none; }
.t-healthy { background: #E3F3EA; color: #1A6B43; }
.t-warning { background: #FBF1D4; color: #7A5600; }
.t-risk { background: #FDE8D9; color: #A3470D; }
.t-critical { background: #FCE4E2; color: #A51F16; }
.t-active { background: #E3ECFB; color: #1A55BD; }
.t-gray { background: #EEF0F3; color: #4E5664; }
.t-none { background: transparent; color: var(--muted-2); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-input); background: #fff; color: var(--ink); font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--bg); color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.pri { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.pri:hover { background: var(--primary-dark); }
.btn.ok { background: #1A6B43; border-color: #1A6B43; color: #fff; }
.btn.ok:hover { background: #145535; }
.btn.warn, .btn.no { color: #A51F16; border-color: #F0B8B2; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 40px; padding: 0; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-input); background: #fff; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; position: relative; }
.chip b { font-weight: 500; color: #1A55BD; }
.chip:focus-within { outline: 2px solid var(--primary); outline-offset: 1px; }
/* A chip wrapping a native select: select is invisible but covers the chip */
.chip select { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; font-size: 14px; }

/* Segmented tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--track); border-radius: 9px; align-self: flex-start; }
.tabb { all: unset; cursor: pointer; height: 36px; padding: 0 14px; border-radius: 6px; font-size: 13.5px; font-weight: 500; color: #4E5664; display: inline-flex; align-items: center; gap: 8px; }
.tabb:hover { color: var(--ink); }
.tabb.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(20,24,31,.12); }
.tabb:focus-visible { outline: 2px solid var(--primary); }

/* ---------- Avatar / progress ---------- */
.av { width: 26px; height: 26px; border-radius: 50%; background: #DCE4F2; color: #1A3B73; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 3px; transition: width .3s ease; }

/* ---------- Tables ---------- */
table { border-collapse: collapse; width: 100%; }
th { font-size: 12px; font-weight: 500; color: var(--muted); text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.sel td { background: var(--primary-tint); }
tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
.rowbtn { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: 1px; min-height: 36px; justify-content: center; }
.rowbtn:hover span:first-child { color: var(--primary); }
.rowbtn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.field > span { font-weight: 500; }
.field input, .field select, .field textarea, .input {
    font: inherit; font-size: 13.5px; color: var(--ink); border: 1px solid var(--line-input); border-radius: 8px;
    padding: 0 10px; height: 40px; background: #fff; width: 100%;
}
.field textarea { height: 84px; padding: 8px 10px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.field .validation-message, .validation-message { color: #A51F16; font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.chk { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; padding: 4px 0; cursor: pointer; }
.chk input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--primary); flex: none; }
.search-box { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--line-input); border-radius: 8px; background: var(--surface-2); max-width: 100%; }
.search-box input { border: 0; background: transparent; font: inherit; font-size: 13px; outline: none; flex: 1; min-width: 0; color: var(--ink); }
.search-box:focus-within { outline: 2px solid var(--primary); outline-offset: -1px; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; background: var(--bg); }
.side { flex: 0 0 236px; background: var(--side); padding: 20px 12px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex: none; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 7px; color: var(--side-ink); text-decoration: none; font-size: 13.5px; }
.nav:hover { background: var(--side-hover); color: #fff; }
.nav.active { background: var(--side-on); color: #fff; font-weight: 500; }
.navc { font-size: 11.5px; color: var(--muted-2); }
.navh { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted-2); padding: 0 10px; margin-bottom: 4px; }
.shell-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; padding: 12px 32px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.crumbs { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.crumbs strong { color: var(--ink); font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.me { display: flex; align-items: center; gap: 8px; padding-left: 4px; }
.dotbadge { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--critical); border: 2px solid #fff; }

.pg { padding: 24px 32px 56px; display: flex; flex-direction: column; gap: 22px;  width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head .titles { display: flex; flex-direction: column; gap: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: stretch; }

.mbar { display: none; }
.mclose { all: unset; cursor: pointer; width: 44px; height: 44px; border-radius: 8px; align-items: center; justify-content: center; margin-left: auto; display: none; }
.mbtn { all: unset; cursor: pointer; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; flex: none; position: relative; }
.mbtn:focus-visible, .mclose:focus-visible { outline: 2px solid #7FA3E3; }
.scrim { display: none; }
.tabbar { display: none; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; min-height: 52px; justify-content: center; font-size: 11px; color: var(--muted); text-decoration: none; }
.tabbar a.active { color: var(--primary); font-weight: 600; }

/* ---------- Popovers / overlays ---------- */
.pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(20,24,31,.16); min-width: 320px; max-width: min(380px, 92vw); max-height: 70vh; overflow-y: auto; }
.pop-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-bottom: 1px solid var(--line-2); text-decoration: none; color: var(--ink); }
.pop-item:hover { background: var(--surface-2); color: var(--ink); }
.pop-item.unread { background: var(--primary-tint); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(20,24,31,.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .12s ease; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(20,24,31,.25); }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(20,24,31,.35); z-index: 100; display: flex; justify-content: flex-end; animation: fade .12s ease; }
.drawer { background: #fff; width: min(520px, 100%); height: 100%; display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(20,24,31,.2); animation: slidein .16s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slidein { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; border-radius: 10px; padding: 12px 14px; font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; box-shadow: 0 12px 30px rgba(20,24,31,.3); animation: fade .15s ease; }
.toast.error { background: #8F1B13; }
.toast.success { background: #155A38; }
.toast button { all: unset; cursor: pointer; margin-left: auto; opacity: .7; }

/* ---------- States ---------- */
.empty { padding: 32px 20px; text-align: center; color: var(--muted); font-size: 13.5px; }
.skeleton { background: linear-gradient(90deg, #EEF0F3 25%, #F6F7F9 37%, #EEF0F3 63%); background-size: 400% 100%; animation: shimmer 1.2s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.error-box { background: #FCE4E2; color: #8F1B13; border: 1px solid #F0B8B2; border-radius: 10px; padding: 12px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); }
.kpi-label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.kpi-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.kpi-value { font-size: 30px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
    .side { display: none; }
    .side.open { display: flex; position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 85vw); height: auto; z-index: 90; }
    .scrim.open { display: block; position: fixed; inset: 0; background: rgba(20,24,31,.5); z-index: 80; }
    .mclose { display: inline-flex; }
    .mbar { display: flex; align-items: center; gap: 4px; padding: 4px 6px; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 30; }
    .topbar { display: none; }
    .pg { padding: 16px 16px 88px; gap: 16px; }
    .pgx { padding: 16px 16px 0 !important; }
    .stack-m { grid-template-columns: minmax(0, 1fr) !important; gap: 6px !important; }
    .wrap-m { flex-wrap: wrap !important; }
    .hide-m { display: none !important; }
    .h1, h1 { font-size: 20px !important; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fff; border-top: 1px solid var(--line); padding: 2px 4px 6px; }
    .pop { position: fixed; left: 8px; right: 8px; top: 56px; max-width: none; min-width: 0; }
}
@media (min-width: 761px) { .show-m { display: none !important; } }

/* ---------- Blazor framework UI ---------- */
#blazor-error-ui { background: #FBF1D4; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem .7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.blazor-error-boundary { background: #FCE4E2; padding: 1rem; color: #8F1B13; border-radius: 10px; }
.blazor-error-boundary::after { content: "An error has occurred while rendering this section."; }
.valid.modified:not([type=checkbox]) { outline: 1px solid #1F7A4D; }
.invalid { outline: 1px solid #B42318; }
