/* ============================================================================
   NexaSecure Solutions Ltd — Zero Trust Admin Console
   Design system: dark, restrained, functional. One accent (cyan), status
   colours reserved for meaning (outcome/role), system font + monospace for
   data. 8px spacing rhythm throughout.
   ============================================================================ */

:root {
    --bg:          #0b0d12;
    --bg-raised:   #12151c;
    --bg-inset:    #080a0e;
    --border:      #22262f;
    --border-soft: #1a1d24;
    --text:        #e7e9ee;
    --text-dim:    #9aa1ad;
    --text-faint:  #5c626d;

    --accent:      #22d3ee;
    --accent-dim:  #0d94ab;
    --accent-bg:   rgba(34, 211, 238, 0.10);

    --success:     #34d399;
    --success-bg:  rgba(52, 211, 153, 0.10);
    --danger:      #f87171;
    --danger-bg:   rgba(248, 113, 113, 0.10);
    --warning:     #fbbf24;
    --warning-bg:  rgba(251, 191, 36, 0.10);

    --role-owner:    #f0abfc;
    --role-admin:    #22d3ee;
    --role-reviewer: #9aa1ad;

    --radius: 6px;
    --font-ui:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

::selection { background: var(--accent-bg); color: var(--text); }

/* ---------------------------------------------------------------- Login -- */

.login-screen {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100vh;
}

@media (min-width: 900px) {
    .login-screen { grid-template-columns: 42% 58%; }
}

.login-brand {
    background: var(--bg-inset);
    border-right: 1px solid var(--border-soft);
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.login-brand::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--border-soft) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: radial-gradient(circle at 30% 30%, black, transparent 70%);
    opacity: 0.6;
}

.brand-mark {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.02em;
}

.brand-mark svg { flex-shrink: 0; }

.login-brand-copy { position: relative; max-width: 34ch; }
.login-brand-copy h1 {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.35;
    margin: 0 0 12px;
}
.login-brand-copy p { color: var(--text-dim); margin: 0; font-size: 13px; }

.login-brand-foot {
    position: relative;
    font-size: 12px;
    color: var(--text-faint);
    display: flex;
    gap: 16px;
}

.login-form-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.login-form {
    width: 100%;
    max-width: 340px;
}

.login-form h2 { font-size: 18px; font-weight: 600; margin: 0 0 4px; }
.login-form .subhead { color: var(--text-dim); font-size: 13px; margin: 0 0 28px; }

.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.field input {
    width: 100%;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--text);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field input:hover { border-color: #343944; }
.field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}
.field input.otp-input {
    font-family: var(--font-mono);
    letter-spacing: 0.4em;
    font-size: 20px;
    text-align: center;
}
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: var(--accent);
    color: #04222a;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms ease, opacity 120ms ease, transform 60ms ease;
}
.btn:hover { background: #4fdcf0; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}
.btn-secondary:hover { background: var(--bg-raised); border-color: #34394d; }

.btn-danger { background: var(--danger); color: #2a0a0a; }
.btn-danger:hover { background: #ff9090; }

.btn-block-inline { width: auto; }

.form-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(248,113,113,0.25);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 16px;
}

.form-note {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(251,191,36,0.25);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 12px;
    margin-bottom: 16px;
    font-family: var(--font-mono);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
    margin-bottom: 20px;
}
.back-link:hover { color: var(--text); }

/* --------------------------------------------------------------- Shell --- */

.app-shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.sidebar {
    background: var(--bg-inset);
    border-right: 1px solid var(--border-soft);
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
}

.sidebar .brand-mark { padding: 0 8px; margin-bottom: 28px; }

.nav-group { margin-bottom: 4px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 2px;
}
.nav-item svg { opacity: 0.85; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-raised); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); }
.nav-item.disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.sidebar-foot {
    margin-top: auto;
    border-top: 1px solid var(--border-soft);
    padding-top: 12px;
    font-size: 12px;
    color: var(--text-faint);
}

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 56px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.user-chip .email { color: var(--text-dim); }

.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: 1px solid currentColor;
}
.role-badge.owner    { color: var(--role-owner); }
.role-badge.admin    { color: var(--role-admin); }
.role-badge.reviewer { color: var(--role-reviewer); }

.role-badge::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.content { padding: 24px; overflow-y: auto; flex: 1; }

.page-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; }
.page-head h1 { font-size: 18px; font-weight: 600; margin: 0; }
.page-head .desc { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.toolbar { display: flex; gap: 8px; align-items: center; }

/* --------------------------------------------------------------- Cards --- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card {
    background: var(--bg-raised);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.stat-card .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); margin-bottom: 6px; }
.stat-card .value { font-size: 22px; font-weight: 600; font-family: var(--font-mono); }

.panel {
    background: var(--bg-raised);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    overflow: hidden;
}
.panel-head {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
}

/* -------------------------------------------------------------- Tables --- */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-faint);
    font-weight: 600;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
}
tbody td { padding: 10px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.015); }

.table-scroll { overflow-x: auto; }

.cell-dim { color: var(--text-dim); }
.cell-faint { color: var(--text-faint); font-size: 12px; }

.outcome {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
}
.outcome::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.outcome.success { color: var(--success); }
.outcome.failure { color: var(--warning); }
.outcome.denied  { color: var(--danger); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: #34394d; background: var(--bg-inset); }
.icon-btn.danger:hover { color: var(--danger); border-color: rgba(248,113,113,0.4); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.empty-state { padding: 40px 16px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* ------------------------------------------------------------- Badges ---- */

.chain-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-mono);
}
.chain-status.valid { background: var(--success-bg); color: var(--success); }
.chain-status.invalid { background: var(--danger-bg); color: var(--danger); }

/* -------------------------------------------------------------- Modal ---- */

.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(4,6,10,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    padding: 16px;
}
.modal {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%; max-width: 400px;
    padding: 24px;
}
.modal h3 { margin: 0 0 4px; font-size: 16px; }
.modal .subhead { color: var(--text-dim); font-size: 13px; margin: 0 0 20px; }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; }
.modal-actions .btn { width: auto; flex: 1; }

.toast-stack {
    position: fixed; bottom: 20px; right: 20px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 200;
}
.toast {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px;
    min-width: 240px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

.hidden { display: none !important; }

.spinner {
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.25);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.select-wrap select {
    width: 100%;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--text);
}
