/* ============================================================================
   Köprü design system
   ----------------------------------------------------------------------------
   One token set, three theme states (system / pinned light / pinned dark), a
   Teams-style shell (icon rail + command bar), and restyles for the Bootstrap 4
   + DataTables markup the administration pages still use. Every color in the
   app comes from a token here; the console (queue / call) components live in
   kopru.css and consume the same tokens.

   Palette: UNHCR blue #0072BC is the only accent. UNHCR yellow #FAEB00 is the
   "live" marker (brand deck, active nav notch, queue counter) - never text,
   never a fill. Neutrals are blue-biased so the grey reads as chosen.
   ============================================================================ */

@import url("../fonts/fonts.css");

/* ---------------------------------------------------------------- tokens */
:root {
    color-scheme: light dark;

    --font-ui: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-body: 'Source Sans 3', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Mono', Consolas, 'Courier New', monospace;

    --brand: #0072BC;
    --brand-strong: #005B97;
    --brand-soft: #E3F0FA;
    --brand-ink: #FFFFFF;
    --signal: #FAEB00;

    --bg: #F2F5F9;
    --surface: #FFFFFF;
    --surface-2: #F7F9FC;
    --raised: #FFFFFF;
    --line: #D9E2EC;
    --line-strong: #B7C6D7;

    --ink: #12233A;
    --ink-2: #3D4F67;
    --muted: #66788F;
    --faint: #98A8BC;

    --link: #0072BC;
    --focus: rgba(0, 114, 188, .32);

    --rail: #0F2340;
    --rail-ink: #B9C9DD;
    --rail-active: #FFFFFF;
    --rail-hover: rgba(255, 255, 255, .08);
    --rail-active-bg: rgba(255, 255, 255, .12);

    --ok: #1F9D5B;
    --ok-bg: #E2F4E9;
    --warn: #B97C00;
    --warn-bg: #FFF3D2;
    --bad: #D63C3C;
    --bad-bg: #FBE5E5;
    --info: #0072BC;
    --info-bg: #E3F0FA;
    --away: #E0A100;

    --stage: #0B1A2C;          /* the video stage is dark in both themes */
    --stage-2: #13294A;
    --stage-ink: #DCE7F3;

    --shadow-1: 0 1px 2px rgba(18, 35, 58, .06), 0 1px 4px rgba(18, 35, 58, .08);
    --shadow-2: 0 10px 28px rgba(18, 35, 58, .14);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    --rail-w: 72px;
    --topbar-h: 56px;

    accent-color: var(--brand);
    scrollbar-color: var(--line-strong) transparent;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --brand: #1F8BD8;
        --brand-strong: #0072BC;
        --brand-soft: rgba(31, 139, 216, .18);
        --bg: #091729;
        --surface: #10233E;
        --surface-2: #0D1E36;
        --raised: #163150;
        --line: #213858;
        --line-strong: #345279;
        --ink: #E8EFF8;
        --ink-2: #C3D0E1;
        --muted: #91A4BD;
        --faint: #6B809C;
        --link: #63B3EE;
        --focus: rgba(99, 179, 238, .45);
        --rail: #06111F;
        --rail-ink: #93A6BF;
        --ok: #3FC27C;
        --ok-bg: rgba(63, 194, 124, .16);
        --warn: #F2B632;
        --warn-bg: rgba(242, 182, 50, .16);
        --bad: #F16B6B;
        --bad-bg: rgba(241, 107, 107, .16);
        --info: #63B3EE;
        --info-bg: rgba(99, 179, 238, .16);
        --shadow-1: 0 1px 2px rgba(0, 0, 0, .35), 0 1px 4px rgba(0, 0, 0, .3);
        --shadow-2: 0 12px 32px rgba(0, 0, 0, .5);
        --stage: #050E1A;
        --stage-2: #0F213A;
    }
}

:root[data-theme="dark"] {
    --brand: #1F8BD8;
    --brand-strong: #0072BC;
    --brand-soft: rgba(31, 139, 216, .18);
    --bg: #091729;
    --surface: #10233E;
    --surface-2: #0D1E36;
    --raised: #163150;
    --line: #213858;
    --line-strong: #345279;
    --ink: #E8EFF8;
    --ink-2: #C3D0E1;
    --muted: #91A4BD;
    --faint: #6B809C;
    --link: #63B3EE;
    --focus: rgba(99, 179, 238, .45);
    --rail: #06111F;
    --rail-ink: #93A6BF;
    --ok: #3FC27C;
    --ok-bg: rgba(63, 194, 124, .16);
    --warn: #F2B632;
    --warn-bg: rgba(242, 182, 50, .16);
    --bad: #F16B6B;
    --bad-bg: rgba(241, 107, 107, .16);
    --info: #63B3EE;
    --info-bg: rgba(99, 179, 238, .16);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .35), 0 1px 4px rgba(0, 0, 0, .3);
    --shadow-2: 0 12px 32px rgba(0, 0, 0, .5);
    --stage: #050E1A;
    --stage-2: #0F213A;
}

/* Black: a true-black high-contrast scheme for dark rooms and OLED screens. Same accent,
   same semantics, surfaces lifted only enough to separate from the ground. */
:root[data-theme="black"] {
    --brand: #2A97E5;
    --brand-strong: #0072BC;
    --brand-soft: rgba(42, 151, 229, .2);
    --bg: #000000;
    --surface: #0D0F12;
    --surface-2: #14171C;
    --raised: #1A1E25;
    --line: #23282F;
    --line-strong: #3A414B;
    --ink: #F2F5F8;
    --ink-2: #CAD2DB;
    --muted: #97A2AF;
    --faint: #6C7681;
    --link: #6DB9F0;
    --focus: rgba(109, 185, 240, .5);
    --rail: #000000;
    --rail-ink: #9AA5B1;
    --rail-hover: rgba(255, 255, 255, .1);
    --rail-active-bg: rgba(255, 255, 255, .14);
    --ok: #45C982;
    --ok-bg: rgba(69, 201, 130, .16);
    --warn: #F5BC3C;
    --warn-bg: rgba(245, 188, 60, .16);
    --bad: #F47272;
    --bad-bg: rgba(244, 114, 114, .16);
    --info: #6DB9F0;
    --info-bg: rgba(109, 185, 240, .16);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .6), 0 1px 4px rgba(0, 0, 0, .5);
    --shadow-2: 0 12px 32px rgba(0, 0, 0, .7);
    --stage: #000000;
    --stage-2: #101418;
    color-scheme: dark;
}
:root[data-theme="black"] .k-rail { border-right: 1px solid var(--line); }

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* ---------------------------------------------------------------- base */
html { font-size: 100%; scrollbar-width: thin; }
body.k-body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: .9375rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
.k-body h1, .k-body h2, .k-body h3, .k-body h4, .k-body h5, .k-body .h1, .k-body .h2, .k-body .h3, .k-body .h4 {
    font-family: var(--font-ui);
    color: var(--ink);
    letter-spacing: -.01em;
    text-wrap: balance;
}
.k-body a { color: var(--link); }
.k-body a:hover { color: var(--brand-strong); }
.k-body :is(button, a, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}
.k-body ::selection { background: var(--brand-soft); }
.k-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.k-num { font-variant-numeric: tabular-nums; }
.k-muted { color: var(--muted); }
.k-visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------------------------------------------------------------- shell */
.k-app {
    display: grid;
    grid-template-columns: var(--rail-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas: "rail top" "rail main";
    min-height: 100dvh;
}
.k-app.k-app--console { height: 100dvh; overflow: hidden; }

/* icon rail (Teams app bar): dark in both themes - it is the brand strip */
.k-rail {
    grid-area: rail;
    background: var(--rail);
    color: var(--rail-ink);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0 12px;
    gap: 2px;
    position: sticky;
    top: 0;
    height: 100dvh;
}
.k-rail-brand {
    display: grid;
    place-items: center;
    width: 44px; height: 44px;
    margin-bottom: 10px;
    border-radius: 12px;
}
.k-rail-brand img { width: 40px; height: 40px; display: block; border-radius: 10px; }
.k-rail-nav { display: flex; flex-direction: column; align-items: stretch; gap: 2px; width: 100%; padding: 0 8px; }
.k-rail-item {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px;
    height: 58px;
    border-radius: 10px;
    color: var(--rail-ink);
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .01em;
    transition: background .15s ease, color .15s ease;
}
.k-rail-item i { font-size: 1.15rem; }
.k-rail-item:hover { background: var(--rail-hover); color: var(--rail-active); text-decoration: none; }
.k-rail-item.is-active { background: var(--rail-active-bg); color: var(--rail-active); }
.k-rail-item.is-active::before {
    content: ""; position: absolute; left: -8px; top: 14px; bottom: 14px; width: 4px;
    border-radius: 0 4px 4px 0; background: var(--signal);
}
.k-rail-spacer { flex: 1; }
.k-rail-foot { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; padding: 0 8px; }
.k-rail-btn {
    width: 44px; height: 44px; border-radius: 10px; border: 0; background: transparent; color: var(--rail-ink);
    display: grid; place-items: center; font-size: 1.05rem; cursor: pointer;
}
.k-rail-btn:hover { background: var(--rail-hover); color: var(--rail-active); }
.k-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--brand); color: #fff;
    display: grid; place-items: center;
    font-family: var(--font-ui); font-weight: 700; font-size: .85rem; letter-spacing: .02em;
    border: 2px solid rgba(255,255,255,.18);
}

/* command bar */
.k-top {
    grid-area: top;
    display: flex; align-items: center; gap: 14px;
    padding: 0 20px 0 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
}
.k-top-title { display: flex; flex-direction: column; min-width: 0; }
.k-top-title .k-eyebrow { font-family: var(--font-ui); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); line-height: 1.1; }
.k-top-title .k-title { font-family: var(--font-ui); font-weight: 700; font-size: 1.02rem; color: var(--ink); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-top-spacer { flex: 1; }
.k-top-actions { display: flex; align-items: center; gap: 8px; }
.k-unhcr { display: inline-flex; align-items: center; padding-right: 14px; margin-right: 4px; border-right: 1px solid var(--line); }
.k-unhcr img { height: 30px; width: auto; display: block; }
.k-unhcr .k-unhcr-ondark { display: none; }
:root[data-theme="dark"] .k-unhcr .k-unhcr-onlight, :root[data-theme="black"] .k-unhcr .k-unhcr-onlight { display: none; }
:root[data-theme="dark"] .k-unhcr .k-unhcr-ondark, :root[data-theme="black"] .k-unhcr .k-unhcr-ondark { display: block; }
@media (max-width: 640px) { .k-unhcr { padding-right: 8px; } .k-unhcr img { height: 22px; } }
.k-icon-btn {
    width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--ink-2);
    display: grid; place-items: center; cursor: pointer; font-size: .98rem;
}
.k-icon-btn:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink); }

/* live-connection indicator (console pages) */
.k-live { display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); font-family: var(--font-ui); font-weight: 600; }
.k-live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); }
.k-live-dot.kopru-conn-on { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in oklab, var(--ok) 22%, transparent); }
.k-live-dot.kopru-conn-off { background: var(--bad); }

/* user chip + menu */
.k-user { position: relative; }
.k-user-btn {
    display: flex; align-items: center; gap: 10px;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer; font-family: var(--font-ui); font-weight: 600; font-size: .82rem;
}
.k-user-btn:hover { background: var(--surface-2); }
.k-user-btn .k-avatar { width: 30px; height: 30px; font-size: .74rem; border: 0; }
.k-user-btn .k-user-role { color: var(--muted); font-weight: 500; }
.k-menu {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
    background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-2);
    padding: 6px; z-index: 40;
}
.k-menu[hidden] { display: none; }
.k-menu-head { padding: 8px 10px 6px; font-size: .78rem; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.k-menu-head strong { display: block; color: var(--ink); font-family: var(--font-ui); font-size: .86rem; }
.k-menu a, .k-menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; color: var(--ink); background: transparent; border: 0; font: inherit; cursor: pointer; text-decoration: none; }
.k-menu a:hover, .k-menu button:hover { background: var(--surface-2); text-decoration: none; }
.k-menu i { width: 18px; text-align: center; color: var(--muted); }
.k-menu-theme { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.k-menu-theme button { flex-direction: column; gap: 4px; padding: 8px 4px; font-family: var(--font-ui); font-size: .72rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line); justify-content: center; }
.k-menu-theme button i { width: auto; font-size: .95rem; color: inherit; }
.k-menu-theme button.is-on { background: var(--brand-soft); color: var(--ink); border-color: var(--brand); }

/* main */
.k-main { grid-area: main; min-width: 0; padding: 22px 24px 40px; }
.k-app--console .k-main { padding: 14px 18px 16px; overflow: auto; display: flex; flex-direction: column; }
.k-app--console .k-main > .kopru-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.k-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.k-page-head h1 { font-size: 1.45rem; font-weight: 800; margin: 0; }
.k-page-head p { margin: 4px 0 0; color: var(--muted); max-width: 64ch; }
.k-page-tools { display: flex; gap: 8px; flex-wrap: wrap; }

/* responsive: rail becomes a bottom bar on narrow screens */
@media (max-width: 760px) {
    .k-app { grid-template-columns: 1fr; grid-template-rows: var(--topbar-h) 1fr auto; grid-template-areas: "top" "main" "rail"; }
    .k-rail { position: sticky; bottom: 0; top: auto; height: auto; flex-direction: row; padding: 6px 8px; border-top: 1px solid rgba(255,255,255,.08); }
    .k-rail-brand, .k-rail-spacer, .k-rail-foot { display: none; }
    .k-rail-nav { flex-direction: row; justify-content: space-around; padding: 0; }
    .k-rail-item { height: 52px; flex: 1; }
    .k-rail-item.is-active::before { left: 12px; right: 12px; top: auto; bottom: -6px; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
    .k-main { padding: 16px 14px 24px; }
}

/* ---------------------------------------------------------------- surfaces */
.k-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.k-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.k-card-head h2, .k-card-head h3 { font-size: .98rem; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 8px; }
.k-card-head h2 i, .k-card-head h3 i { color: var(--brand); }
.k-card-body { padding: 18px; }
.k-card-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.k-note { background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: var(--radius-sm); padding: 12px 14px; font-size: .88rem; color: var(--ink-2); }
.k-note code, .k-body code { font-family: var(--font-mono); font-size: .82em; background: var(--brand-soft); color: var(--ink); padding: .1em .4em; border-radius: 4px; }
.k-body pre.k-pre { font-family: var(--font-mono); font-size: .84rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; color: var(--ink); overflow-x: auto; }

/* KPI tiles */
.k-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.k-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.k-stat .v { font-family: var(--font-ui); font-weight: 800; font-size: 1.7rem; line-height: 1; font-variant-numeric: tabular-nums; }
.k-stat .l { font-size: .8rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.k-stat.ok .v { color: var(--ok); }
.k-stat.info .v { color: var(--brand); }
.k-stat.warn .v { color: var(--warn); }
.k-stat.off .v { color: var(--faint); }

/* pills / status */
.k-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-family: var(--font-ui); font-size: .72rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; line-height: 1.6; }
.k-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.k-pill.ok { background: var(--ok-bg); color: var(--ok); }
.k-pill.warn { background: var(--warn-bg); color: var(--warn); }
.k-pill.bad { background: var(--bad-bg); color: var(--bad); }
.k-pill.info { background: var(--info-bg); color: var(--info); }
.k-pill.off { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.k-pill.plain::before { display: none; }
.k-count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--brand); color: #fff; font-family: var(--font-ui); font-size: .74rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.k-count.hot { background: var(--signal); color: #12233A; }

/* empty state */
.k-empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.k-empty i { display: block; font-size: 1.9rem; color: var(--faint); margin-bottom: 10px; }

/* ---------------------------------------------------------------- buttons */
.k-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
    font-family: var(--font-ui); font-weight: 700; font-size: .86rem; line-height: 1.2;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .05s ease;
}
.k-btn:active { transform: translateY(1px); }
.k-btn:disabled, .k-btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
.k-btn-primary { background: var(--brand); color: #fff; }
.k-btn-primary:hover { background: var(--brand-strong); color: #fff; text-decoration: none; }
.k-btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.k-btn-ghost:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink); text-decoration: none; }
.k-btn-quiet { background: var(--surface-2); color: var(--ink); }
.k-btn-quiet:hover { background: var(--brand-soft); color: var(--ink); text-decoration: none; }
.k-btn-danger { background: var(--bad); color: #fff; }
.k-btn-danger:hover { background: color-mix(in oklab, var(--bad) 82%, black); color: #fff; }
.k-btn-danger-ghost { background: transparent; border-color: var(--bad); color: var(--bad); }
.k-btn-danger-ghost:hover { background: var(--bad-bg); color: var(--bad); }
.k-btn-ok { background: var(--ok); color: #fff; }
.k-btn-ok:hover { background: color-mix(in oklab, var(--ok) 82%, black); color: #fff; }
.k-btn-sm { padding: 6px 11px; font-size: .78rem; border-radius: 8px; }
.k-btn-lg { padding: 13px 22px; font-size: 1rem; border-radius: 12px; }
.k-btn-block { width: 100%; }
.k-btn-round { border-radius: 999px; }

/* ---------------------------------------------------------------- forms */
.k-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.k-label { font-family: var(--font-ui); font-weight: 700; font-size: .8rem; color: var(--ink-2); letter-spacing: .01em; }
.k-help { font-size: .8rem; color: var(--muted); }
.k-input, .k-select, .k-textarea {
    width: 100%; box-sizing: border-box;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line-strong); border-radius: 10px;
    padding: 9px 12px; font: inherit; line-height: 1.4;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.k-input::placeholder, .k-textarea::placeholder { color: var(--faint); }
.k-input:focus, .k-select:focus, .k-textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); }
.k-input-lg { padding: 12px 14px; font-size: 1.05rem; }
.k-input-icon { position: relative; }
.k-input-icon > i { position: absolute; left: 13px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.k-input-icon > .k-input { padding-left: 38px; }
.k-check { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; }
.k-check input { width: 18px; height: 18px; margin-top: 2px; flex: none; }
.k-seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.k-seg label, .k-seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 12px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); font-family: var(--font-ui); font-weight: 700; font-size: .8rem; cursor: pointer; margin: 0; }
.k-seg label:has(input:checked), .k-seg button.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.k-seg label.danger:has(input:checked), .k-seg button.danger.is-on { color: var(--bad); }
.k-seg label.ok:has(input:checked), .k-seg button.ok.is-on { color: var(--ok); }
.k-seg label.warn:has(input:checked), .k-seg button.warn.is-on { color: var(--warn); }
.k-seg input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; }

/* ---------------------------------------------------------------- tables */
.k-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.k-table th { text-align: left; font-family: var(--font-ui); font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.k-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.k-table tbody tr:hover td { background: var(--surface-2); }
.k-table tbody tr:last-child td { border-bottom: 0; }
.k-table .muted td { color: var(--faint); }
.k-table-wrap { overflow-x: auto; }

/* ---------------------------------------------------------------- Bootstrap 4 restyle (administration pages) */
.k-body .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); color: var(--ink); }
.k-body .card-header { background: var(--surface-2) !important; color: var(--ink) !important; border-bottom: 1px solid var(--line); font-family: var(--font-ui); font-weight: 700 !important; border-radius: var(--radius) var(--radius) 0 0 !important; padding: 14px 18px; }
.k-body .card-header h2, .k-body .card-header h3 { font-size: 1.05rem; margin: 0; display: inline; }
.k-body .card-header .fas, .k-body .card-header .far { color: var(--brand); }
.k-body .card-body { padding: 18px; }
.k-body .card-footer { background: var(--surface-2); border-top: 1px solid var(--line); }
.k-body .card .card { box-shadow: none; }

.k-body .btn { font-family: var(--font-ui); font-weight: 700; font-size: .84rem; border-radius: 9px; padding: .5rem .95rem; }
.k-body .btn-sm, .k-body .btn-group-sm > .btn { font-size: .76rem; padding: .32rem .6rem; border-radius: 7px; }
.k-body .btn-xs { font-size: .72rem; padding: .22rem .5rem; border-radius: 6px; }
.k-body .btn-primary, .k-body .btn-info, .k-body .btn-secondary { background: var(--brand); border-color: var(--brand); color: #fff; }
.k-body .btn-primary:hover, .k-body .btn-info:hover, .k-body .btn-secondary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.k-body .btn-primary:focus, .k-body .btn-info:focus, .k-body .btn-secondary:focus { box-shadow: 0 0 0 3px var(--focus); }
.k-body .btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.k-body .btn-outline-primary:hover { background: var(--brand); color: #fff; }
.k-body .btn-outline-secondary { color: var(--ink-2); border-color: var(--line-strong); }
.k-body .btn-outline-secondary:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-strong); }
.k-body .btn-light { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.k-body .btn-warning { background: var(--warn); border-color: var(--warn); color: #fff; }
.k-body .btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.k-body .btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
.k-body .btn-outline-danger { color: var(--bad); border-color: var(--bad); }
.k-body .btn-outline-danger:hover { background: var(--bad); color: #fff; }
.k-body .btn-outline-success { color: var(--ok); border-color: var(--ok); }
.k-body .btn-outline-success:hover { background: var(--ok); color: #fff; }
.k-body .btn-outline-warning { color: var(--warn); border-color: var(--warn); }
.k-body .btn-outline-warning:hover { background: var(--warn); color: #fff; }
.k-body .btn-link { color: var(--link); }

.k-body .form-control, .k-body .custom-select {
    background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 9px; height: auto; padding: .5rem .75rem; font: inherit;
}
.k-body .form-control:focus, .k-body .custom-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus); background: var(--surface); color: var(--ink); }
.k-body .form-control::placeholder { color: var(--faint); }
.k-body .form-control:disabled, .k-body .form-control[readonly] { background: var(--surface-2); color: var(--muted); }
.k-body select.form-control option { background: var(--surface); color: var(--ink); }
.k-body .form-control-lg { font-size: 1.05rem; padding: .7rem .9rem; }
.k-body .form-control-sm { font-size: .84rem; padding: .35rem .6rem; }
.k-body label, .k-body .control-label { font-family: var(--font-ui); font-weight: 600; font-size: .82rem; color: var(--ink-2); }
.k-body .input-group-text { background: var(--surface-2); border-color: var(--line-strong); color: var(--muted); }
.k-body .form-check-input { accent-color: var(--brand); }
.k-body .text-muted { color: var(--muted) !important; }
.k-body .text-primary { color: var(--brand) !important; }
.k-body .text-danger { color: var(--bad) !important; }
.k-body .text-success { color: var(--ok) !important; }
.k-body .text-warning { color: var(--warn) !important; }
.k-body hr { border-color: var(--line); }

.k-body .table { color: var(--ink); }
.k-body .table th, .k-body .table td { border-color: var(--line); vertical-align: middle; }
.k-body .table thead th, .k-body .table thead td { border-bottom: 1px solid var(--line); background: var(--surface-2); font-family: var(--font-ui); font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.k-body .table-striped tbody tr:nth-of-type(odd) { background: transparent; }
.k-body .table-hover tbody tr:hover, .k-body .table tbody tr:hover { background: var(--surface-2); }
.k-body .table-bordered { border: 1px solid var(--line); border-radius: var(--radius-sm); }
.k-body .table thead input.form-control { font-size: .82rem; padding: .3rem .55rem; text-transform: none; letter-spacing: 0; font-weight: 400; }

.k-body .badge { font-family: var(--font-ui); font-weight: 700; border-radius: 999px; padding: .32em .7em; font-size: .74rem; }
.k-body .badge-light { background: var(--brand-soft); color: var(--ink); border: 1px solid var(--line); }
.k-body .badge-primary { background: var(--brand); color: #fff; }
.k-body .badge-info { background: var(--info-bg); color: var(--info); }
.k-body .badge-success { background: var(--ok-bg); color: var(--ok); }
.k-body .badge-warning { background: var(--warn-bg); color: var(--warn); }
.k-body .badge-danger { background: var(--bad-bg); color: var(--bad); }

.k-body .alert { border-radius: var(--radius-sm); border: 1px solid transparent; }
.k-body .alert-danger { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in oklab, var(--bad) 35%, transparent); }
.k-body .alert-success { background: var(--ok-bg); color: var(--ok); }
.k-body .alert-warning { background: var(--warn-bg); color: var(--warn); }
.k-body .alert-info { background: var(--info-bg); color: var(--info); }

.k-body .dropdown-menu { background: var(--raised); border-color: var(--line); box-shadow: var(--shadow-2); border-radius: var(--radius-sm); }
.k-body .dropdown-item { color: var(--ink); }
.k-body .dropdown-item:hover { background: var(--surface-2); color: var(--ink); }
.k-body .modal-content { background: var(--surface); color: var(--ink); border-color: var(--line); border-radius: var(--radius); }
.k-body .modal-header, .k-body .modal-footer { border-color: var(--line); }
.k-body .close { color: var(--ink); text-shadow: none; }
.k-body .page-link { background: var(--surface); border-color: var(--line); color: var(--link); }
.k-body .page-item.active .page-link { background: var(--brand); border-color: var(--brand); color: #fff; }
.k-body .list-group-item { background: var(--surface); border-color: var(--line); color: var(--ink); }

/* DataTables */
.k-body .dataTables_wrapper { color: var(--ink); }
.k-body .dataTables_wrapper .dataTables_length select,
.k-body .dataTables_wrapper .dataTables_filter input { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 8px; padding: .35rem .6rem; margin-left: 6px; }
.k-body .dataTables_wrapper .dataTables_info { color: var(--muted); font-size: .84rem; }
.k-body .dataTables_wrapper .dataTables_paginate .paginate_button { color: var(--ink) !important; border-radius: 8px; border: 1px solid transparent; }
.k-body .dataTables_wrapper .dataTables_paginate .paginate_button:hover { background: var(--surface-2); border-color: var(--line); color: var(--ink) !important; }
.k-body .dataTables_wrapper .dataTables_paginate .paginate_button.current,
.k-body .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover { background: var(--brand); border-color: var(--brand); color: #fff !important; }
.k-body .dataTables_wrapper .dataTables_paginate .paginate_button.disabled { color: var(--faint) !important; }
.k-body table.dataTable thead th, .k-body table.dataTable thead td { border-bottom: 1px solid var(--line); }
.k-body table.dataTable.no-footer { border-bottom: 1px solid var(--line); }
.k-body .dt-buttons .dt-button { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; font-family: var(--font-ui); font-weight: 700; font-size: .78rem; padding: .35rem .7rem; }
.k-body .dt-buttons .dt-button:hover { background: var(--brand-soft) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.k-body table.dataTable thead .sorting:before, .k-body table.dataTable thead .sorting:after,
.k-body table.dataTable thead .sorting_asc:before, .k-body table.dataTable thead .sorting_asc:after,
.k-body table.dataTable thead .sorting_desc:before, .k-body table.dataTable thead .sorting_desc:after { color: var(--muted); }

/* SweetAlert2 - theme aware */
.k-body .swal2-popup { background: var(--surface); color: var(--ink); border-radius: var(--radius); font-family: var(--font-body); }
.k-body .swal2-title { font-family: var(--font-ui); color: var(--ink); }
.k-body .swal2-html-container { color: var(--ink-2); }
.k-body .swal2-styled.swal2-confirm { background: var(--brand) !important; border-radius: 9px; font-family: var(--font-ui); font-weight: 700; }

/* toastr - theme aware */
.k-body #toast-container > div { border-radius: var(--radius-sm); box-shadow: var(--shadow-2); opacity: 1; font-family: var(--font-body); }

/* ---------------------------------------------------------------- auth pages (login / MFA) */
.k-auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--bg); }
.k-auth-brand {
    position: relative; overflow: hidden;
    /* the UNHCR flag under a navy wash: the emblem stays visible, the text stays readable */
    background:
        linear-gradient(160deg, rgba(8, 26, 48, .78) 0%, rgba(10, 34, 66, .62) 50%, rgba(6, 20, 38, .86) 100%),
        url("../images/unhcr-flag.jpg") center / cover no-repeat,
        #0B1F3A;
    color: #E8EFF8;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 36px 48px 32px;
}
.k-auth-brand-top { display: flex; flex-direction: column; gap: 26px; align-items: flex-start; }
.k-auth-brand .k-unhcr-logo { width: 208px; height: auto; display: block; }
.k-auth-brand .k-logo { display: flex; align-items: center; gap: 14px; font-family: var(--font-ui); font-weight: 800; font-size: 1.5rem; letter-spacing: -.01em; color: #fff; }
.k-auth-brand .k-logo img { width: 46px; height: 46px; border-radius: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.k-auth-brand .k-logo small { display: block; font-family: var(--font-body); font-weight: 500; font-size: .8rem; color: #C3D4E8; letter-spacing: .04em; }
.k-auth-hero h1 { font-family: var(--font-ui); font-weight: 800; font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.1; margin: 0 0 14px; color: #fff; max-width: 14ch; text-shadow: 0 2px 12px rgba(0,0,0,.35); }
.k-auth-hero p { color: #C9D8EA; max-width: 46ch; font-size: 1.02rem; margin: 0 0 22px; text-shadow: 0 1px 8px rgba(0,0,0,.35); }
.k-auth-foot { font-size: .78rem; color: #A9BCD2; display: flex; gap: 18px; align-items: center; }
.k-auth-foot .unhcr { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-ui); font-weight: 700; color: #E3EDF8; letter-spacing: .06em; }
.k-auth-foot .unhcr::before { content: ""; width: 26px; height: 3px; background: var(--signal); border-radius: 2px; }
.k-auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.k-auth-card { width: min(100%, 420px); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-2); padding: 30px 32px 26px; }
.k-auth-card h2 { font-family: var(--font-ui); font-weight: 800; font-size: 1.35rem; margin: 0 0 4px; }
.k-auth-card .lead { color: var(--muted); font-size: .92rem; margin: 0 0 22px; }
.k-auth-divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: .74rem; font-family: var(--font-ui); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin: 18px 0 14px; }
.k-auth-divider::before, .k-auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.k-ms { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 16px; height: 16px; }
.k-ms span { display: block; }
.k-ms span:nth-child(1) { background: #F35325; } .k-ms span:nth-child(2) { background: #81BC06; }
.k-ms span:nth-child(3) { background: #05A6F0; } .k-ms span:nth-child(4) { background: #FFBA08; }
.k-auth-legal { margin-top: 20px; font-size: .74rem; color: var(--faint); line-height: 1.45; }
.k-auth-topright { position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; }
.k-code-input { font-family: var(--font-mono); font-size: 1.7rem; letter-spacing: .55em; text-align: center; padding: 12px 8px 12px 20px; }
.k-auth-qr { display: grid; place-items: center; background: #fff; border-radius: 12px; padding: 10px; margin: 6px auto 16px; width: fit-content; border: 1px solid var(--line); }
.k-auth-steps { margin: 0 0 14px; padding-left: 20px; color: var(--ink-2); font-size: .9rem; }
.k-auth-steps li { margin-bottom: 4px; }
@media (max-width: 900px) {
    .k-auth { grid-template-columns: 1fr; }
    .k-auth-brand { padding: 26px 24px; min-height: 0; }
    .k-auth-hero h1 { font-size: 1.6rem; }
    .k-auth-hero p { display: none; }
    .k-auth-foot { display: none; }
    .k-auth-panel { padding: 24px 16px 40px; }
}

/* ---------------------------------------------------------------- landing hub */
.k-hub-hero { display: flex; align-items: center; gap: 22px; padding: 26px 28px; border-radius: 16px; background: linear-gradient(120deg, rgba(8, 26, 48, .86) 0%, rgba(10, 40, 76, .7) 100%), url("../images/unhcr-flag.jpg") center / cover no-repeat, var(--rail); color: #fff; position: relative; overflow: hidden; margin-bottom: 22px; }
.k-hub-hero .k-unhcr { position: absolute; right: 26px; top: 50%; translate: 0 -50%; width: 150px; height: auto; opacity: .95; }
@media (max-width: 760px) { .k-hub-hero .k-unhcr { display: none; } }
.k-hub-hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--signal); }
.k-hub-hero > img { width: 56px; height: 56px; border-radius: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.k-hub-hero h1 { color: #fff; font-size: 1.6rem; font-weight: 800; margin: 0; }
.k-hub-hero p { color: #B6C8DE; margin: 4px 0 0; }
.k-hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.k-tile { display: flex; flex-direction: column; gap: 10px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow-1); transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.k-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--brand); color: var(--ink); text-decoration: none; }
.k-tile .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.15rem; background: var(--brand-soft); color: var(--brand); }
.k-tile .ic.ok { background: var(--ok-bg); color: var(--ok); }
.k-tile .ic.warn { background: var(--warn-bg); color: var(--warn); }
.k-tile h3 { font-size: 1.02rem; font-weight: 800; margin: 0; }
.k-tile p { margin: 0; color: var(--muted); font-size: .88rem; }
.k-tile .go { margin-top: auto; font-family: var(--font-ui); font-weight: 700; font-size: .82rem; color: var(--link); display: inline-flex; gap: 6px; align-items: center; }
.k-tile.is-muted { opacity: .75; }
.k-tile.is-muted:hover { transform: none; box-shadow: var(--shadow-1); border-color: var(--line); }
.k-section-title { font-family: var(--font-ui); font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 26px 0 12px; }

/* ---------------------------------------------------------------- motion */
@media (prefers-reduced-motion: reduce) {
    .k-tile, .k-btn, .k-rail-item { transition: none; }
}

/* ---- inline alert on the auth cards (e-mail-only sign-in, 2026-09-21) ---- */
.k-alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: .88rem; margin-bottom: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.k-alert i { margin-top: 2px; }
.k-alert-bad { border-color: color-mix(in oklab, var(--bad) 45%, var(--line)); background: var(--bad-bg); color: var(--bad); }
.k-alert-ok { border-color: color-mix(in oklab, var(--ok) 45%, var(--line)); background: var(--ok-bg); color: var(--ok); }
