/* ============================================================================
   Clipad — design system
   A password locker for an operations team, not a marketing site: the design
   priority is fast scanning of dense credential lists, unmistakable role/
   status signals, and zero third-party requests (no external fonts/CDNs —
   everything here is self-contained, which also keeps the CSP tight).
   ============================================================================ */

:root {
    /* --- Color: "vault" ink/navy base, brass accent (luggage-tag buckle),
       teal for safe/positive states, muted brick for danger. Deliberately
       not the cream+terracotta or near-black+neon defaults. --- */
    --ink-900: #0D1626;
    --ink-800: #101B33;
    --ink-700: #1C2B4A;
    --ink-600: #2A3C60;
    --ink-500: #48597F;
    --ink-300: #8C9AB8;
    --ink-100: #DDE2ED;

    --paper: #F2F4F3;
    --paper-raised: #FFFFFF;
    --paper-sunken: #E7EAE7;
    --hairline: #D8DCDA;

    --brass: #B8863B;
    --brass-dark: #966E2E;
    --brass-tint: #F3E7D2;

    --teal: #1F7A6C;
    --teal-tint: #DCEEEA;

    --brick: #B3413E;
    --brick-tint: #F6E1E0;

    --amber: #C98A2C;
    --amber-tint: #F6E9D3;

    --slate-blue: #3B5B8C;
    --slate-blue-tint: #E4EAF4;

    --text-primary: #16202F;
    --text-secondary: #55627A;
    --text-inverse: #F4F6F8;

    --font-sans: -apple-system, "Segoe UI", "Helvetica Neue", Roboto, Arial, sans-serif;
    --font-mono: ui-monospace, "Cascadia Mono", "Consolas", "SFMono-Regular", "Liberation Mono", monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --sidebar-w: 248px;
    --shadow-card: 0 1px 2px rgba(13, 22, 38, 0.06), 0 1px 1px rgba(13, 22, 38, 0.04);
    --shadow-pop: 0 12px 32px rgba(13, 22, 38, 0.18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--paper);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
}

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

h1, h2, h3, h4 { font-weight: 650; letter-spacing: -0.01em; margin: 0 0 4px; color: var(--text-primary); }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 12px; color: var(--text-secondary); }

code, .mono, .credential-value { font-family: var(--font-mono); font-size: 0.93em; }

:focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

/* ---------------------------------------------------------------------
   App shell: fixed dark sidebar + main content
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--ink-800);
    color: var(--text-inverse);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 40;
    transition: transform .22s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-mark {
    width: 34px; height: 34px; border-radius: 8px;
    background: linear-gradient(155deg, var(--brass) 0%, var(--brass-dark) 100%);
    display: flex; align-items: center; justify-content: center;
    color: #1A1103; font-weight: 700; font-size: 0.95rem;
    flex-shrink: 0;
}
.brand-text { line-height: 1.2; }
.brand-text strong { display: block; font-size: 1.02rem; color: #fff; }
.brand-text span { font-size: 0.72rem; color: var(--ink-300); }

.nav-group { padding: 14px 12px; }
.nav-label {
    font-size: 0.68rem; color: var(--ink-300); padding: 8px 10px 6px;
    letter-spacing: 0.02em;
}
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    color: #C9D2E3; font-size: 0.92rem; font-weight: 500;
    margin-bottom: 2px;
}
.nav-link:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.nav-link.active { background: rgba(184,134,59,0.16); color: #F3D9A9; }
.nav-link .ic { width: 18px; text-align: center; opacity: 0.85; flex-shrink: 0; }

.sidebar-footer {
    margin-top: auto; padding: 14px 18px; border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.78rem; color: var(--ink-300);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 10px 6px; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--ink-600); color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.82rem; flex-shrink: 0;
}
.sidebar-user .who { line-height: 1.25; overflow: hidden; }
.sidebar-user .who strong { display: block; font-size: 0.85rem; color: #fff; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.sidebar-user .who span { font-size: 0.72rem; color: var(--ink-300); }

.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 14px 28px;
    background: var(--paper-raised); border-bottom: 1px solid var(--hairline);
    position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.15rem; }
.topbar .crumb { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }
.menu-toggle { display: none; }

.content { padding: 24px 28px 60px; max-width: 1180px; }

/* ---------------------------------------------------------------------
   Buttons, forms, badges
   --------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    padding: 8px 16px; font-size: 0.87rem; font-weight: 600;
    cursor: pointer; font-family: inherit; line-height: 1.2;
    transition: filter .12s ease, box-shadow .12s ease;
}
.btn:active { filter: brightness(0.95); }
.btn-primary { background: var(--brass); color: #241705; }
.btn-primary:hover { background: var(--brass-dark); text-decoration: none; }
.btn-secondary { background: var(--paper-raised); color: var(--text-primary); border-color: var(--hairline); }
.btn-secondary:hover { background: var(--paper-sunken); text-decoration: none; }
.btn-danger { background: var(--brick); color: #fff; }
.btn-danger:hover { background: #942f2c; text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--paper-sunken); text-decoration: none; }
.btn-sm { padding: 5px 11px; font-size: 0.8rem; }
.btn-icon { padding: 7px 9px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.83rem; font-weight: 600; margin-bottom: 6px; color: var(--text-primary); }
.field .hint { font-size: 0.78rem; color: var(--text-secondary); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=url], select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--hairline); border-radius: var(--radius-sm);
    font-size: 0.92rem; font-family: inherit; background: var(--paper-raised); color: var(--text-primary);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brass); outline-offset: 0; border-color: var(--brass); }
.input-group { position: relative; }
.input-group input { padding-right: 40px; }
.input-group .adorn {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; color: var(--text-secondary); padding: 6px;
}

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700;
    letter-spacing: 0.01em;
}
.badge-role-super_admin { background: var(--ink-700); color: #E9EEF8; }
.badge-role-admin { background: var(--slate-blue-tint); color: var(--slate-blue); }
.badge-role-user { background: var(--paper-sunken); color: var(--text-secondary); }
.badge-active { background: var(--teal-tint); color: var(--teal); }
.badge-blocked { background: var(--brick-tint); color: var(--brick); }
.badge-locked { background: var(--brass-tint); color: var(--brass-dark); }

/* ---------------------------------------------------------------------
   Cards, tables, stats
   --------------------------------------------------------------------- */
.card {
    background: var(--paper-raised); border: 1px solid var(--hairline);
    border-radius: var(--radius-md); box-shadow: var(--shadow-card);
    padding: 20px 22px; margin-bottom: 20px;
}
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }

.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat {
    background: var(--ink-800); color: var(--text-inverse); border-radius: var(--radius-md);
    padding: 16px 18px; position: relative; overflow: hidden;
}
.stat::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brass);
}
.stat .num { font-size: 1.7rem; font-weight: 700; font-family: var(--font-mono); color: #F3D9A9; }
.stat .lbl { font-size: 0.78rem; color: var(--ink-300); margin-top: 2px; }

table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; font-size: 0.72rem; color: var(--text-secondary);
    font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--hairline);
    background: var(--paper-sunken);
}
th:first-child { border-top-left-radius: var(--radius-sm); }
th:last-child { border-top-right-radius: var(--radius-sm); }
td { padding: 12px 14px; border-bottom: 1px solid var(--hairline); font-size: 0.88rem; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.login-row { cursor: pointer; }
tr.login-row:hover td, tr.login-row.is-focused td { background: var(--slate-blue-tint); }
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--hairline); background: var(--paper-raised); box-shadow: var(--shadow-card); }
.table-wrap table { min-width: 640px; }

.team-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; background: var(--brass); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-secondary); }
.empty-state h3 { color: var(--text-primary); margin-bottom: 6px; }

/* ---------------------------------------------------------------------
   Login / 2FA screens
   --------------------------------------------------------------------- */
.auth-shell {
    min-height: 100vh; display: flex; align-items: stretch; background: var(--ink-800);
}
.auth-visual {
    flex: 1.1; display: flex; flex-direction: column; justify-content: center;
    padding: 60px; color: var(--text-inverse); position: relative; overflow: hidden;
}
.auth-visual::after {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(circle at 15% 20%, rgba(184,134,59,0.18), transparent 45%),
                radial-gradient(circle at 85% 80%, rgba(31,122,108,0.16), transparent 45%);
}
.auth-visual .inner { position: relative; z-index: 1; max-width: 420px; }
.auth-visual .tag { display: inline-block; padding: 5px 12px; border: 1px solid rgba(255,255,255,0.2); border-radius: 999px; font-size: 0.75rem; color: #DCE3EF; margin-bottom: 22px; }
.auth-visual h1 { color: #fff; font-size: 1.9rem; line-height: 1.25; margin-bottom: 14px; }
.auth-visual p { color: #B9C3D8; font-size: 0.95rem; }
.auth-panel {
    flex: 1; background: var(--paper); display: flex; align-items: center; justify-content: center; padding: 40px 24px;
}
.auth-box { width: 100%; max-width: 380px; }
.auth-box .logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.auth-box h2 { font-size: 1.3rem; margin-bottom: 6px; }
.auth-box .sub { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 26px; }

.otp-input { display: flex; gap: 8px; margin-bottom: 6px; }
.otp-input input {
    width: 42px; height: 50px; text-align: center; font-size: 1.3rem; font-family: var(--font-mono);
    padding: 0;
}

/* ---------------------------------------------------------------------
   Alerts / toasts / modals
   --------------------------------------------------------------------- */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 0.86rem; margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: var(--teal-tint); color: #0F5148; border-color: rgba(31,122,108,0.25); }
.alert-error { background: var(--brick-tint); color: #7C2D2A; border-color: rgba(179,65,62,0.25); }
.alert-info { background: var(--slate-blue-tint); color: #2B426A; border-color: rgba(59,91,140,0.2); }
.alert-warning { background: var(--amber-tint); color: #7A521A; border-color: rgba(201,138,44,0.25); }

#toast-region { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: var(--ink-800); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm);
    font-size: 0.85rem; box-shadow: var(--shadow-pop); display: flex; align-items: center; gap: 8px;
    animation: toast-in .18s ease;
}
.toast .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); flex-shrink: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.modal-backdrop {
    position: fixed; inset: 0; background: rgba(13,22,38,0.55); display: none;
    align-items: center; justify-content: center; z-index: 80; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--paper-raised); border-radius: var(--radius-md); width: 100%; max-width: 460px;
    box-shadow: var(--shadow-pop); max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--hairline); }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--hairline); display: flex; justify-content: flex-end; gap: 10px; }

.credential-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 12px; background: var(--paper-sunken); border-radius: var(--radius-sm); margin-bottom: 10px;
}
.credential-row .val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.credential-row .label { font-size: 0.7rem; color: var(--text-secondary); text-transform: none; display: block; margin-bottom: 2px; }

.kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--hairline); border-bottom-width: 2px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.76rem; background: var(--paper-raised); color: var(--text-secondary); }

.shortcut-bar {
    display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
    font-size: 0.78rem; color: var(--text-secondary); padding: 10px 4px 4px;
}

.pill-toggle { display: inline-flex; border: 1px solid var(--hairline); border-radius: 999px; overflow: hidden; }
.pill-toggle a { padding: 6px 14px; font-size: 0.8rem; color: var(--text-secondary); }
.pill-toggle a.active { background: var(--ink-800); color: #fff; }
.pill-toggle a:hover { text-decoration: none; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.toolbar .filters { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 980px) {
    .stat-strip { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 840px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-pop); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .menu-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--hairline);
        background: var(--paper-raised); cursor: pointer;
    }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(13,22,38,0.5); z-index: 30; display: none; }
    .sidebar-backdrop.open { display: block; }
    .auth-visual { display: none; }
    .content { padding: 18px 16px 50px; }
    .topbar { padding: 12px 16px; }
}

@media (max-width: 560px) {
    .stat-strip { grid-template-columns: 1fr 1fr; }
    .card { padding: 16px; }
    .otp-input input { width: 36px; height: 44px; font-size: 1.1rem; }
    table, thead, tbody, th, td, tr { display: block; }
    .table-wrap table { min-width: 0; }
    thead tr { position: absolute; left: -9999px; }
    tr.login-row { border-bottom: 1px solid var(--hairline); padding: 10px 4px; }
    tr.login-row td { border-bottom: none; padding: 4px 10px; }
    tr.login-row td::before { content: attr(data-label); display: block; font-size: 0.68rem; color: var(--text-secondary); font-weight: 700; margin-bottom: 2px; }
}
