/* ============================================================
   Sysinn Apps — Admin design system
   Pure CSS, no build step. Pairs with public/js/portal.js.
   ============================================================ */

:root {
    /* Brand */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --primary-ring: rgba(79, 70, 229, .28);
    --accent-grad: linear-gradient(135deg, #6366f1, #8b5cf6);

    /* Neutrals */
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e5e9f2;
    --border-strong: #d4dae6;
    --text: #101828;
    --text-2: #475467;
    --text-muted: #667085;

    /* Status */
    --success: #067647;
    --success-bg: #ecfdf3;
    --success-border: #abefc6;
    --danger: #d92d20;
    --danger-hover: #b42318;
    --danger-bg: #fef3f2;
    --danger-border: #fecdca;
    --warning: #b54708;
    --warning-bg: #fffaeb;
    --warning-border: #fedf89;
    --info: #175cd3;
    --info-bg: #eff8ff;
    --info-border: #b2ddff;

    /* Sidebar */
    --sidebar-bg: #101527;
    --sidebar-bg-2: #171e33;
    --sidebar-border: rgba(255, 255, 255, .06);
    --sidebar-text: #98a2c3;
    --sidebar-text-hover: #e6e9f5;
    --sidebar-active-bg: rgba(99, 102, 241, .16);
    --sidebar-active-text: #c7d2fe;

    /* Metrics */
    --sidebar-w: 264px;
    --sidebar-w-collapsed: 76px;
    --topbar-h: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .06);
    --shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, .14), 0 4px 8px -4px rgba(16, 24, 40, .06);
    --shadow-pop: 0 20px 40px -8px rgba(16, 24, 40, .18), 0 8px 16px -8px rgba(16, 24, 40, .08);
    --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

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

svg.icon { flex: none; display: block; }

code {
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: .86em;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1px 5px;
}

::selection { background: rgba(99, 102, 241, .22); }

/* ============================================================
   App shell
   ============================================================ */

.shell { min-height: 100vh; }

.content-area {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .22s var(--ease);
}
body.sidebar-collapsed .content-area { margin-left: var(--sidebar-w-collapsed); }

.page {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 28px 32px 72px;
    flex: 1;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: width .22s var(--ease), transform .25s var(--ease);
}
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-head {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-h);
    padding: 0 18px;
    border-bottom: 1px solid var(--sidebar-border);
    flex: none;
    overflow: hidden;
}
.sidebar-head .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -.01em;
    white-space: nowrap;
    min-width: 0;
}
.sidebar-head .brand:hover { text-decoration: none; }
.brand-mark {
    width: 34px; height: 34px;
    flex: none;
    border-radius: 10px;
    background: var(--accent-grad);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 16px;
    font-weight: 800;
    box-shadow: 0 4px 10px rgba(99, 102, 241, .4);
}
.brand-name { transition: opacity .15s var(--ease); }
body.sidebar-collapsed .brand-name { opacity: 0; width: 0; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 12px 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}

.nav-section { margin-bottom: 6px; }
.nav-section-title {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: rgba(152, 162, 195, .65);
    padding: 14px 12px 6px;
    white-space: nowrap;
    transition: opacity .15s var(--ease);
}
body.sidebar-collapsed .nav-section-title { opacity: 0; height: 8px; padding-top: 6px; padding-bottom: 0; overflow: hidden; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    margin: 2px 0;
    border-radius: 9px;
    color: var(--sidebar-text);
    font-weight: 500;
    font-size: 13.5px;
    white-space: nowrap;
    position: relative;
    transition: background .14s var(--ease), color .14s var(--ease);
}
.nav-item:hover { background: rgba(255, 255, 255, .05); color: var(--sidebar-text-hover); text-decoration: none; }
.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}
.nav-item.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 7px; bottom: 7px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: #818cf8;
}
.nav-item .icon { color: inherit; opacity: .85; }
.nav-item.active .icon { opacity: 1; }
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; transition: opacity .15s var(--ease); }
body.sidebar-collapsed .nav-label { opacity: 0; width: 0; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 10px; }
body.sidebar-collapsed .nav-item.active::before { left: -12px; }

.sidebar-foot {
    flex: none;
    border-top: 1px solid var(--sidebar-border);
    padding: 12px;
}
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--sidebar-text);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-collapse-btn:hover { background: rgba(255, 255, 255, .05); color: var(--sidebar-text-hover); }
.sidebar-collapse-btn .icon { transition: transform .22s var(--ease); }
body.sidebar-collapsed .sidebar-collapse-btn { justify-content: center; padding: 10px; }
body.sidebar-collapsed .sidebar-collapse-btn .icon { transform: rotate(180deg); }
body.sidebar-collapsed .sidebar-collapse-btn .nav-label { display: none; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16, 21, 39, .55);
    backdrop-filter: blur(2px);
    z-index: 49;
    opacity: 0;
    transition: opacity .25s var(--ease);
}

/* ============================================================
   Topbar
   ============================================================ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--topbar-h);
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
}
.topbar-title { font-weight: 600; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-spacer { flex: 1; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 0;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    position: relative;
    transition: background .14s var(--ease), color .14s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .dot {
    position: absolute;
    top: 8px; right: 9px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--danger);
    border: 2px solid var(--surface);
}

.menu-toggle { display: none; }

.avatar {
    width: 36px; height: 36px;
    flex: none;
    border-radius: 50%;
    background: var(--accent-grad);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .02em;
}
.avatar-sm { width: 30px; height: 30px; font-size: 11.5px; }

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 8px 5px 5px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    font: inherit;
    color: var(--text);
}
.user-menu-btn:hover { background: var(--surface-2); }
.user-menu-btn .who { text-align: left; line-height: 1.25; }
.user-menu-btn .who .name { font-weight: 600; font-size: 13.5px; }
.user-menu-btn .who .role { color: var(--text-muted); font-size: 11.5px; }
.user-menu-btn > .icon { color: var(--text-muted); }

/* ============================================================
   Dropdowns
   ============================================================ */

.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 230px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    padding: 6px;
    z-index: 60;
    opacity: 0;
    transform: translateY(-6px) scale(.98);
    pointer-events: none;
    transition: opacity .16s var(--ease), transform .16s var(--ease);
}
.dropdown.open .dropdown-menu { opacity: 1; transform: none; pointer-events: auto; }
.dropdown-header { padding: 10px 12px 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-header .name { font-weight: 600; font-size: 13.5px; }
.dropdown-header .email { color: var(--text-muted); font-size: 12px; word-break: break-all; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-2);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}
.dropdown-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-bg); color: var(--danger-hover); }
.dropdown-item .icon { color: var(--text-muted); }
.dropdown-item.danger .icon { color: inherit; }
.dropdown-sep { height: 1px; background: var(--border); margin: 6px 0; border: 0; }

.dropdown-menu .empty-note { padding: 18px 12px; text-align: center; color: var(--text-muted); font-size: 13px; }

.notif-item { display: flex; gap: 10px; padding: 9px 10px; border-radius: 8px; }
.notif-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-item .notif-ic {
    width: 30px; height: 30px; flex: none;
    border-radius: 8px;
    display: grid; place-items: center;
}
.notif-item .t { font-size: 13px; color: var(--text); line-height: 1.35; }
.notif-item .s { font-size: 11.5px; color: var(--text-muted); }

/* ============================================================
   Page headers & breadcrumbs
   ============================================================ */

.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.breadcrumbs a { color: var(--text-muted); font-weight: 500; }
.breadcrumbs a:hover { color: var(--primary); text-decoration: none; }
.breadcrumbs .sep { color: var(--border-strong); }
.breadcrumbs .current { color: var(--text-2); font-weight: 600; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--text-muted); font-size: 13.5px; }
.page-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   Panels / cards
   ============================================================ */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    overflow: clip;
}
.panel + .panel, .panel + form, form .panel + .panel { margin-top: 20px; }
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
}
.panel-head .sub { font-weight: 400; font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.panel-body { padding: 20px; }

/* Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    padding: 18px 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: box-shadow .16s var(--ease), transform .16s var(--ease);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
    width: 42px; height: 42px;
    flex: none;
    border-radius: 11px;
    display: grid;
    place-items: center;
}
.stat-icon.indigo { background: var(--primary-soft); color: var(--primary); }
.stat-icon.green  { background: var(--success-bg); color: var(--success); }
.stat-icon.amber  { background: var(--warning-bg); color: var(--warning); }
.stat-icon.blue   { background: var(--info-bg); color: var(--info); }
.stat-icon.red    { background: var(--danger-bg); color: var(--danger); }
.stat-meta { min-width: 0; }
.stat-label { font-size: 12.5px; font-weight: 500; color: var(--text-muted); }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.stat-hint { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   App launcher cards
   ============================================================ */

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.app-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: var(--text);
    position: relative;
    transition: transform .16s var(--ease), box-shadow .16s var(--ease), border-color .16s var(--ease);
}
.app-card:hover {
    text-decoration: none;
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: #c7d2fe;
}
.app-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 23px;
    background: var(--primary-soft);
}
.app-card h3 { margin: 0; font-size: 15px; font-weight: 600; }
.app-card p { margin: 0; color: var(--text-muted); font-size: 13px; flex: 1; }
.app-open { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--primary); }
.app-card:hover .app-open .icon { transform: translateX(2px); }
.app-open .icon { transition: transform .16s var(--ease); }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 15px;
    border-radius: 9px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    font-size: 13.5px;
    line-height: 1.3;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, .12);
    transition: background .14s var(--ease), box-shadow .14s var(--ease), transform .06s var(--ease);
    white-space: nowrap;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--primary-ring); outline-offset: 1px; }
.btn-block { width: 100%; }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost { background: transparent; color: var(--text-2); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-icon { padding: 6px; width: 30px; height: 30px; }

.btn.is-loading { pointer-events: none; opacity: .75; }
.btn.is-loading .btn-label { visibility: hidden; }
.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 16px; height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.btn { position: relative; }

.spinner {
    width: 22px; height: 22px;
    border: 2.5px solid var(--border-strong);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Forms
   ============================================================ */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 20px;
}
.form-grid .span-2 { grid-column: 1 / -1; }

.field { margin-bottom: 16px; min-width: 0; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text-2); }
.field .hint { color: var(--text-muted); font-size: 12px; margin: 5px 0 0; }
.field .error { color: var(--danger); font-size: 12.5px; font-weight: 500; margin: 5px 0 0; }

input[type="text"], input[type="email"], input[type="password"],
input[type="url"], input[type="number"], input[type="search"], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    font: inherit;
    font-size: 13.5px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-xs);
    transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
}
input::placeholder { color: #98a2b3; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}
input.is-invalid, select.is-invalid { border-color: var(--danger); }
input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(217, 45, 32, .18); }

select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

.input-icon-wrap { position: relative; }
.input-icon-wrap .icon {
    position: absolute;
    left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.input-icon-wrap input { padding-left: 36px; }

.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.checkbox-row label { margin: 0; font-weight: 500; }

input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Toggle switch (same input semantics, fancier look) */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
    width: 40px; height: 22px;
    border-radius: 999px;
    background: var(--border-strong);
    transition: background .16s var(--ease);
    flex: none;
}
.switch .track::after {
    content: "";
    display: block;
    width: 16px; height: 16px;
    margin: 3px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform .16s var(--ease);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--primary-ring); }
.switch-row { display: flex; align-items: center; gap: 12px; }
.switch-row .switch-label { font-weight: 600; font-size: 13.5px; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.check-grid label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 13.5px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    background: var(--surface);
    transition: border-color .14s var(--ease), background .14s var(--ease), box-shadow .14s var(--ease);
}
.check-grid label:hover { background: var(--surface-2); }
.check-grid label:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 1px var(--primary);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 22px;
    flex-wrap: wrap;
}

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.filters .field { margin-bottom: 0; min-width: 170px; }
.filters .grow { flex: 1; min-width: 220px; }

/* ============================================================
   Tables
   ============================================================ */

.table-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.table-toolbar .grow { flex: 1; min-width: 200px; }

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

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
table.data th {
    text-align: left;
    padding: 11px 20px;
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}
table.data td {
    padding: 13px 20px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s var(--ease); }
table.data tbody tr:hover { background: #f8faff; }
table.data .th-right, table.data .cell-right { text-align: right; }

.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { color: var(--text-muted); font-size: 12.5px; margin-top: 1px; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }

.user-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.user-cell .meta { min-width: 0; line-height: 1.3; }
.user-cell .meta .cell-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pagination-wrap { padding: 12px 20px; border-top: 1px solid var(--border); }

/* Custom paginator */
.paginator { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.paginator .page-info { color: var(--text-muted); font-size: 13px; }
.paginator .pages { display: flex; gap: 4px; align-items: center; }
.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px; height: 32px;
    padding: 0 8px;
    border-radius: 8px;
    border: 1px solid transparent;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
}
.page-link:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.page-link.current { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.page-link.disabled { color: var(--border-strong); pointer-events: none; }
.page-link.gap { pointer-events: none; }

/* ============================================================
   Badges
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-2);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.badge + .badge { margin-left: 4px; }
.badge::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .7;
}
.badge.no-dot::before { display: none; }
.badge-green { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.badge-red { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.badge-blue { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.badge-indigo { background: var(--primary-soft); color: var(--primary); border-color: #c7d2fe; }
.badge-amber { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }

/* ============================================================
   Alerts
   ============================================================ */

.alert {
    display: flex;
    gap: 11px;
    align-items: flex-start;
    padding: 13px 15px;
    border-radius: 11px;
    margin-bottom: 20px;
    font-size: 13.5px;
    border: 1px solid transparent;
    box-shadow: var(--shadow-xs);
}
.alert .icon { flex: none; margin-top: 1px; }
.alert-body { flex: 1; min-width: 0; }
.alert-success { background: var(--success-bg); color: #085d3a; border-color: var(--success-border); }
.alert-success .icon { color: var(--success); }
.alert-error { background: var(--danger-bg); color: #912018; border-color: var(--danger-border); }
.alert-error .icon { color: var(--danger); }
.alert-info { background: var(--info-bg); color: #194185; border-color: var(--info-border); }
.alert-info .icon { color: var(--info); }
.alert ul { margin: 0; padding-left: 16px; }
.alert-close {
    flex: none;
    border: 0;
    background: transparent;
    color: inherit;
    opacity: .55;
    cursor: pointer;
    padding: 2px;
    border-radius: 6px;
    display: inline-flex;
}
.alert-close:hover { opacity: 1; }

.credentials-box {
    background: #0c111d;
    color: #e2e8f0;
    border-radius: 12px;
    padding: 16px 18px;
    font-family: "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    margin-bottom: 20px;
    overflow-x: auto;
    box-shadow: var(--shadow-md);
}
.credentials-box .k { color: #94a3b8; }

/* ============================================================
   Tabs
   ============================================================ */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
}
.tab {
    padding: 9px 14px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ============================================================
   Tooltips  (data-tip attribute)
   ============================================================ */

[data-tip] { position: relative; }
[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%) translateY(3px);
    background: #101828;
    color: #fff;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.3;
    padding: 5px 9px;
    border-radius: 7px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    z-index: 70;
    transition: opacity .14s var(--ease) .1s, transform .14s var(--ease) .1s;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Modal (confirm dialogs)
   ============================================================ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 21, 39, .55);
    backdrop-filter: blur(2px);
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s var(--ease);
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    padding: 24px;
    transform: translateY(10px) scale(.97);
    transition: transform .18s var(--ease);
}
.modal-backdrop.open .modal { transform: none; }
.modal-icon {
    width: 44px; height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    margin-bottom: 14px;
    background: var(--danger-bg);
    color: var(--danger);
}
.modal-icon.neutral { background: var(--primary-soft); color: var(--primary); }
.modal h2 { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.modal p { margin: 0; color: var(--text-muted); font-size: 13.5px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ============================================================
   Empty states
   ============================================================ */

.empty-state {
    text-align: center;
    padding: 56px 24px;
    color: var(--text-muted);
}
.empty-state .glyph {
    width: 52px; height: 52px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    color: var(--text-muted);
    font-size: 24px;
}
.empty-state h3 { margin: 0 0 4px; font-size: 15px; color: var(--text); }
.empty-state p { margin: 0; font-size: 13.5px; }
.empty-state .btn { margin-top: 16px; }

/* ============================================================
   Activity feed & mini chart
   ============================================================ */

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li {
    display: flex;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}
.activity-list li:last-child { border-bottom: 0; }
.activity-ic {
    width: 32px; height: 32px;
    flex: none;
    border-radius: 9px;
    display: grid;
    place-items: center;
}
.activity-ic.ok { background: var(--success-bg); color: var(--success); }
.activity-ic.fail { background: var(--danger-bg); color: var(--danger); }
.activity-ic.neutral { background: var(--primary-soft); color: var(--primary); }
.activity-body { min-width: 0; flex: 1; }
.activity-body .t { font-size: 13px; line-height: 1.4; }
.activity-body .t strong { font-weight: 600; }
.activity-body .s { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

.mini-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 120px;
    padding: 18px 20px 8px;
}
.mini-chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.mini-chart .bar {
    width: 100%;
    max-width: 34px;
    border-radius: 6px 6px 2px 2px;
    background: linear-gradient(180deg, #818cf8, var(--primary));
    min-height: 3px;
    transition: opacity .14s var(--ease);
}
.mini-chart .col:hover .bar { opacity: .8; }
.mini-chart .lbl { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; }

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.01em;
    margin: 28px 0 14px;
}
.section-title:first-child { margin-top: 0; }

/* ============================================================
   Auth screens
   ============================================================ */

.auth-body {
    background:
        radial-gradient(700px 400px at 85% -10%, rgba(139, 92, 246, .16), transparent 60%),
        radial-gradient(700px 420px at 5% 110%, rgba(79, 70, 229, .14), transparent 60%),
        var(--bg);
}
.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 410px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    padding: 36px;
}
.auth-card .brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    margin-bottom: 22px;
}
.auth-card h1 { font-size: 19px; text-align: center; margin: 0 0 4px; letter-spacing: -.01em; }
.auth-card .sub { text-align: center; color: var(--text-muted); font-size: 13.5px; margin: 0 0 22px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 13.5px; }

/* ============================================================
   Utilities
   ============================================================ */

.muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.hidden { display: none !important; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1100px) {
    .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-w) !important;
        box-shadow: none;
    }
    body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-pop); }
    body.sidebar-open .sidebar-backdrop { display: block; opacity: 1; }
    body.sidebar-collapsed .sidebar .nav-label,
    body.sidebar-collapsed .sidebar .brand-name,
    body.sidebar-collapsed .sidebar .nav-section-title { opacity: 1; width: auto; height: auto; }
    body.sidebar-collapsed .sidebar .nav-item { justify-content: flex-start; padding: 9px 12px; }
    .sidebar-foot { display: none; }
    .content-area { margin-left: 0 !important; }
    .menu-toggle { display: inline-flex; }
    table.data th { position: static; }
}

@media (max-width: 768px) {
    .page { padding: 20px 16px 56px; }
    .topbar { padding: 0 14px; }
    .user-menu-btn .who { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .page-head h1 { font-size: 19px; }
    table.data th, table.data td { padding-left: 14px; padding-right: 14px; }
    .table-toolbar, .panel-head, .panel-body { padding-left: 16px; padding-right: 16px; }
    .activity-list li { padding-left: 16px; padding-right: 16px; }
    .cell-actions { flex-wrap: wrap; justify-content: flex-end; }
    .auth-card { padding: 26px 22px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
