/* ============================================================================
   IGLOO UI — Design System v1
   Brand: #083E8C  ·  Neutral: gray-blue  ·  Radius scale: 6 / 8 / 12
   Every visible component on the panel is defined here. Utility classes
   (flex/grid/spacing) come from Tailwind; looks come from this file only.
   ========================================================================== */
@import url('inter.css');

:root {
    /* Brand */
    --brand-900: #052654;
    --brand-800: #062F6B;
    --brand-700: #083E8C;   /* main */
    --brand-600: #0A4DAE;
    --brand-500: #1B62C4;
    --brand-100: #D9E5F6;
    --brand-50:  #EDF3FB;

    /* Neutrals */
    --bg:          #F6F7F9;
    --surface:     #FFFFFF;
    --line:        #E4E7EC;
    --line-strong: #D0D5DD;
    --ink:         #101828;
    --sub:         #475467;
    --faint:       #98A2B3;

    /* Semantic */
    --green:      #067647;
    --green-bg:   #ECFDF3;
    --red:        #B42318;
    --red-bg:     #FEF3F2;
    --amber:      #B54708;
    --amber-bg:   #FFFAEB;

    /* Shape */
    --r-sm: 6px;
    --r-md: 8px;
    --r-lg: 12px;

    --shadow-modal: 0 20px 40px -12px rgb(16 24 40 / 0.18);
}

/* ---------------------------------------------------------------- base --- */
html, body { height: 100%; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

button, a, input, select, textarea, [tabindex] { outline: none; }
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px rgb(8 62 140 / 0.4);
}

/* -------------------------------------------------------------- layout --- */
.app { display: flex; height: 100dvh; overflow: hidden; }

.sidebar {
    width: 232px;
    flex: none;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--line);
}
.sidebar-logo {
    height: 56px;
    flex: none;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1; overflow-y: auto; scrollbar-gutter: stable; }

/* Identical container for EVERY tab — no page may deviate. */
.page {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 32px 64px;
}
@media (max-width: 640px) {
    .page { padding: 20px 16px 48px; }
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 24px;
    min-height: 44px;
}
.page-title { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.page-desc  { font-size: 13px; color: var(--sub); margin-top: 2px; }

.topbar {
    height: 56px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

/* ----------------------------------------------------------------- nav --- */
.s-nav { flex: 1; overflow-y: auto; padding: 12px; }
.s-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 2px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--sub);
    transition: background-color 120ms ease, color 120ms ease;
}
.s-nav-item:hover { background: var(--bg); color: var(--ink); }
.s-nav-item.active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.s-nav-item.active svg { color: var(--brand-700); }
.s-nav-item svg { width: 16px; height: 16px; color: var(--faint); flex: none; }
.s-nav-item .kbd { margin-left: auto; opacity: 0; transition: opacity 120ms ease; }
.s-nav-item:hover .kbd { opacity: 1; }
.s-nav-item.danger:hover { background: var(--red-bg); color: var(--red); }
.s-nav-item.danger:hover svg { color: var(--red); }
.sidebar-foot { flex: none; padding: 12px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------- buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.15;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn svg { width: 15px; height: 15px; flex: none; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn-primary { background: var(--brand-700); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }

.btn-outline { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover { background: var(--bg); }

.btn-tint { background: var(--brand-50); color: var(--brand-700); }
.btn-tint:hover { background: var(--brand-100); }

.btn-ghost { background: transparent; color: var(--sub); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }

.btn-danger-ghost { background: transparent; color: var(--faint); }
.btn-danger-ghost:hover { background: var(--red-bg); color: var(--red); }

.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }
.btn-icon.btn-sm { padding: 5px; }

/* --------------------------------------------------------------- forms --- */
.label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--sub);
    margin-bottom: 6px;
}
.label .req { color: var(--red); }

.input {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    font-size: 13px;
    color: var(--ink);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input::placeholder { color: var(--faint); }
.input:focus {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgb(8 62 140 / 0.12);
}
select.input { padding-right: 32px; }

.input-wrap { position: relative; }
.input-wrap > svg.lead {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    width: 15px; height: 15px; color: var(--faint); pointer-events: none;
}
.input-wrap .input { padding-left: 32px; }
.input-clear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    color: var(--faint); display: flex; padding: 2px; border-radius: 4px;
}
.input-clear:hover { color: var(--ink); }
.input-clear svg { width: 14px; height: 14px; }

/* --------------------------------------------------------------- cards --- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}
.card-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
}
.card-hd h3 { font-size: 13px; font-weight: 600; }
.card-bd { padding: 20px; }

.stat { padding: 18px 20px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stat-label { font-size: 12px; font-weight: 500; color: var(--sub); }
.stat-top svg { width: 15px; height: 15px; color: var(--faint); }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; }
.badge-gray   { background: var(--bg); color: var(--sub); border: 1px solid var(--line); }
.badge-brand  { background: var(--brand-50); color: var(--brand-700); }
.badge-green  { background: var(--green-bg); color: var(--green); }
.badge-red    { background: var(--red-bg); color: var(--red); }
.badge-amber  { background: var(--amber-bg); color: var(--amber); }

/* --------------------------------------------------------------- table --- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
    position: sticky; top: 0; z-index: 1;
    background: var(--surface);
    padding: 10px 20px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--faint);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table tbody td { padding: 14px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.row-link { cursor: pointer; transition: background-color 100ms ease; }
.table tbody tr.row-link:hover { background: var(--bg); }
.num { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- misc --- */
.avatar {
    border-radius: 999px;
    object-fit: cover;
    background: var(--bg);
    border: 1px solid var(--line);
    flex: none;
}
.avatar-fallback {
    border-radius: 999px;
    background: var(--brand-50);
    color: var(--brand-700);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    border: 1px solid var(--brand-100);
    flex: none;
}
.dot {
    width: 9px; height: 9px; border-radius: 999px;
    border: 1.5px solid var(--surface);
    position: absolute; right: 0; bottom: 0;
}

.kbd {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 4px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-family: ui-monospace, monospace;
    font-size: 10px; font-weight: 600;
    color: var(--sub);
}

.tab {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 12px; font-weight: 500;
    color: var(--sub);
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.tab svg { width: 13px; height: 13px; }
.tab:hover { background: var(--bg); }
.tab.active { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.tab .count { font-size: 10px; padding: 0 5px; border-radius: 999px; background: var(--bg); color: var(--faint); }
.tab.active .count { background: rgb(255 255 255 / 0.2); color: #fff; }

.empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 64px 24px; text-align: center; color: var(--faint);
}
.empty svg { width: 32px; height: 32px; margin-bottom: 10px; }
.empty p { font-size: 13px; font-weight: 500; }

.section-label {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--faint);
}

/* -------------------------------------------------------------- modals --- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: rgb(16 24 40 / 0.5);
    display: flex; align-items: flex-end; justify-content: center;
    padding: 0;
}
@media (min-width: 640px) {
    .modal-overlay { align-items: center; padding: 24px; }
}
.modal {
    background: var(--surface);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-height: 92dvh;
    display: flex; flex-direction: column;
    overflow: hidden;
}
@media (min-width: 640px) {
    .modal { border-radius: var(--r-lg); max-width: 640px; }
    .modal.modal-lg { max-width: 760px; }
    .modal.modal-sm { max-width: 480px; }
}
.modal-hd {
    flex: none;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--line);
}
.modal-hd h3 { font-size: 15px; font-weight: 600; }
.modal-bd { flex: 1; overflow-y: auto; padding: 24px; }
.modal-ft {
    flex: none;
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--line);
    background: var(--bg);
}

/* ------------------------------------------------------------ terminal --- */
.terminal {
    background: #0C111D;
    border: 1px solid #1F242F;
    border-radius: var(--r-lg);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.terminal-hd {
    flex: none;
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px;
    background: #161B26;
    border-bottom: 1px solid #1F242F;
}
.terminal-bd {
    flex: 1; overflow-y: auto;
    padding: 16px 20px;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 12px; line-height: 1.7;
    color: #75E0A7;
}
.terminal-bd pre { white-space: pre-wrap; word-break: break-word; }

/* -------------------------------------------------------------- toasts --- */
.toast {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px;
    border-radius: var(--r-md);
    background: var(--ink);
    color: #fff;
    font-size: 13px; font-weight: 500;
    box-shadow: var(--shadow-modal);
    margin-bottom: 8px;
}
.toast svg { width: 15px; height: 15px; flex: none; }
.toast-error { background: var(--red); }
.toast-success { background: var(--green); }

/* --------------------------------------------------------------- print --- */
@media print {
    body { background: #fff; }
    .no-print { display: none !important; }
}
.pdf-mode .hide-for-agency { display: none !important; }
