/* PMR eSevai web dashboards – same design language as the desktop app */
:root {
  --navy-950: #071631; --navy-900: #0b1f3f; --navy-800: #112b54; --navy-700: #183a6b; --blue-600: #1f5fbf; --blue-500: #2b72d6; --blue-100: #dbe8fb; --blue-50: #eef4fd; --gold: #f2b01e;
  --bg: #f3f6fa; --surface: #fff; --surface-2: #f8fafd; --ink: #0f1c2e; --ink-2: #33435a; --muted: #64748b; --line: #e2e8f0; --line-2: #cfd9e6;
  --ok: #0f7b55; --ok-bg: #e7f6ef; --warn: #9a5b00; --warn-bg: #fff5e0; --err: #b42318; --err-bg: #fdecea;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,28,46,.05), 0 6px 20px rgba(15,28,46,.06);
  --font: "Segoe UI Variable Text", "Segoe UI", Inter, system-ui, "Nirmala UI", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue-600); text-decoration: none; font-weight: 600; }
svg.i { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: Consolas, "Cascadia Mono", monospace; } .spacer { flex: 1; } .pre { white-space: pre-line; }
.note { color: var(--muted); font-size: 12.5px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 80% -10%, rgba(43,114,214,.25), transparent 45%), linear-gradient(160deg, var(--navy-900), var(--navy-950)); }
.login-card { width: min(400px, 100%); background: var(--surface); border-radius: 18px; padding: 28px; box-shadow: 0 18px 50px rgba(7,22,49,.35); text-align: center; }
.login-card img { width: 76px; height: 76px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(242,176,30,.7); }
.login-card h1 { margin: 10px 0 2px; font-size: 22px; }
.login-card .field { text-align: left; }
.login-card .btn { width: 100%; margin-top: 6px; }
.loading { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 30px; color: var(--muted); }
.login-wrap > .loading { color: #c9d8ee; }

/* layout */
.top { position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; gap: 14px; padding: 0 20px; background: var(--navy-900); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; } .brand img { width: 38px; height: 38px; border-radius: 50%; background: #fff; }
.brand b { display: block; } .brand small { color: #9fb5d6; font-size: 12px; }
.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; } .who small { color: #9fb5d6; }
.top .btn.secondary { background: transparent; color: #dbe6f7; border-color: rgba(255,255,255,.25); }
.menu-btn { display: none !important; color: #fff !important; }
.layout { display: grid; grid-template-columns: 236px 1fr; min-height: calc(100vh - 60px); }
.side-nav { background: var(--surface); border-right: 1px solid var(--line); padding: 12px 10px; position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; }
.side-nav a { display: flex; gap: 10px; align-items: center; padding: 9px 11px; border-radius: 9px; color: var(--ink-2); font-weight: 500; }
.side-nav a:hover { background: var(--surface-2); }
.side-nav a.active { background: var(--blue-50); color: var(--blue-600); font-weight: 700; }
.main { padding: 24px 28px 48px; min-width: 0; outline: none; }
.main > * { max-width: 1400px; margin-left: auto; margin-right: auto; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; } .page-head p { margin: 2px 0 0; color: var(--muted); max-width: 760px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card.flush { padding: 0; overflow: auto; margin-bottom: 0; }
.card h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; } .card-head h3 { margin: 0; }
h4 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-2); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 20px; } .stat span { font-size: 12.5px; color: var(--muted); }
.stat.blue { border-left-color: var(--blue-500); } .stat.ok { border-left-color: #16a34a; } .stat.warn { border-left-color: #f59e0b; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .input { width: auto; min-width: 170px; } .filters .search { flex: 1 1 300px; }
label.inline { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--muted); font-size: 13px; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: linear-gradient(180deg, var(--blue-500), var(--blue-600)); color: #fff; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 31px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { width: 34px; padding: 0; height: 34px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; } .btnrow.end { justify-content: flex-end; margin-bottom: 0; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field label { font-weight: 600; font-size: 13px; color: var(--ink-2); }
.input { width: 100%; height: 38px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); padding: 0 11px; outline: none; }
textarea.input { height: auto; min-height: 76px; padding: 8px 11px; resize: vertical; }
input[type=color].input { padding: 3px; height: 38px; }
.input:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(43,114,214,.14); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; } .form-grid .span2, .form-grid h4, .form-grid .alert { grid-column: 1 / -1; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 10px; background: var(--blue-50); color: var(--blue-600); text-transform: capitalize; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.err { background: var(--err-bg); color: var(--err); }
.alert { padding: 10px 13px; border-radius: 10px; background: var(--blue-50); color: var(--ink-2); margin: 10px 0; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.alert.error { background: var(--err-bg); color: var(--err); } .alert.warn { background: var(--warn-bg); color: var(--warn); }
.spin { width: 16px; height: 16px; border: 2px solid var(--line-2); border-top-color: var(--blue-600); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* tables */
.table-wrap { min-width: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.changed td { background: var(--warn-bg); }
.empty { padding: 26px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-2); border-radius: 12px; }
.pager { display: flex; gap: 8px; align-items: center; padding: 10px 2px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 18px; }
.kv small { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; font-weight: 700; }
.keybox { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 14px 16px; border: 2px dashed var(--blue-500); border-radius: 12px; font: 700 20px Consolas, monospace; letter-spacing: 1px; margin: 10px 0; word-break: break-all; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding: 8px 0; margin-bottom: 12px; overflow-x: auto; }
.bar-col { flex: 1 0 18px; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 4px; }
.bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, var(--blue-500), var(--blue-600)); border-radius: 4px 4px 0 0; }
.bar-col small { font-size: 10px; color: var(--muted); white-space: nowrap; }

/* dialogs & toasts */
.modal-back { position: fixed; inset: 0; background: rgba(7,22,49,.55); display: grid; place-items: center; z-index: 90; padding: 20px; }
.modal { background: var(--surface); border-radius: 16px; width: min(620px, 100%); max-height: 100%; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 18px 50px rgba(7,22,49,.3); }
.modal.wide { width: min(1000px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); } .modal-head h2 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 18px; overflow: auto; } .modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 36px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 11px; background: var(--navy-800); color: #fff; box-shadow: 0 8px 26px rgba(7,22,49,.25); }
.toast.success { background: #0f6a43; } .toast.error { background: #a5281b; } .toast.warn { background: #8a5a00; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .side-nav { position: fixed; top: 60px; left: 0; width: 250px; z-index: 30; box-shadow: 0 12px 40px rgba(7,22,49,.25); display: none; }
  body.nav-open .side-nav { display: block; }
  .brand small { display: none; }
  .menu-btn { display: inline-flex !important; }
  .who { display: none; } .two, .form-grid { grid-template-columns: 1fr; } .main { padding: 18px 16px 40px; }
  .card.flush { overflow-x: auto; }
}
