/* ============================================================
   Fortune Bulls - Enterprise Admin Theme (part 1: shell, cards, tables)
   ============================================================ */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --neutral: #64748b;
    --neutral-bg: #f1f5f9;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #2563eb;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

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

code { background: var(--neutral-bg); padding: 2px 6px; border-radius: 4px; font-size: 12px; }

/* ============================================================
   App shell
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    transition: transform .25s ease;
}

.sidebar-role-admin { background: #0c2d2a; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    flex-shrink: 0;
}

.brand-mark .brand-logo {
    font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
    font-weight: 900;
    font-size: 1em;
    letter-spacing: -0.5px;
    line-height: 1;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .2);
    display: block;
}

.brand-text strong { display: block; color: #fff; font-size: 16px; }
.brand-text small { font-size: 11px; opacity: .7; }

.sidebar-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }

.nav-section {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(148, 163, 184, .6);
    padding: 14px 10px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    margin-bottom: 2px;
    transition: background .15s, color .15s;
}

.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active { background: var(--sidebar-active); color: #fff; }
.nav-link.active .nav-icon { color: #fff; }
.nav-icon { width: 20px; text-align: center; font-size: 15px; }

.nav-cyan  { color: #22d3ee; }
.nav-blue  { color: #60a5fa; }
.nav-green { color: #4ade80; }
.nav-amber { color: #fbbf24; }
.nav-purple{ color: #c084fc; }
.nav-slate { color: #94a3b8; }
.nav-rose  { color: #fb7185; }

.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255, 255, 255, .06); }

.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-meta strong { display: block; color: #fff; font-size: 13px; }
.user-meta small { font-size: 11px; opacity: .7; }

.main {
    flex: 1;
    margin-left: 250px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left .25s ease;
}

.sidebar-overlay { display: none; }

/* Collapsed sidebar (desktop only): toggle hides sidebar and frees the main area */
@media (min-width: 769px) {
    body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
    body.sidebar-collapsed .main { margin-left: 0; }
}

/* No-sidebar layout (manager / employee) */
.no-sidebar .main { margin-left: 0; }
.no-sidebar .topbar { background: #0f172a; }

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #fff;
    white-space: nowrap;
    text-decoration: none;
}
.topbar-brand:hover { color: #fff; }
.topbar-brand strong { color: #fff; }

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
    flex-shrink: 0;
}
.topbar-nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, .7);
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.tn-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.topbar-nav-link:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.topbar-nav-link.active { background: rgba(255, 255, 255, .15); color: #fff; }

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}
.icon-btn:hover { background: var(--neutral-bg); color: var(--text); }

.topbar-left { display: flex; align-items: center; gap: 12px; }

.back-btn { font-weight: 600; white-space: nowrap; }

.topbar-search { flex: 1; max-width: 480px; margin: 0 auto; position: relative; }
.topbar-search form { position: relative; }
.topbar-search .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.topbar-search input {
    width: 100%;
    padding: 9px 14px 9px 34px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    font-size: 13px;
    outline: none;
    transition: border .15s, box-shadow .15s;
}
.topbar-search input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.topbar-datetime {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: var(--neutral-bg);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
.dt-icon { font-size: 14px; }
.dt-sep { color: var(--border); font-weight: 400; }

.topbar-logout { margin-left: 4px; }

/* Notification bell */
.notif-wrap { position: relative; }
.notif-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    cursor: pointer;
    font-size: 16px;
    transition: transform .12s ease, box-shadow .12s ease;
}
.notif-bell:hover { box-shadow: 0 4px 14px rgba(15, 23, 42, .14); }
.notif-bell--ring { border-color: var(--warning); animation: bell-ring 1.2s ease-in-out .4s 3; }
.notif-bell--open { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .18); }
@keyframes bell-ring {
    0%, 100% { transform: rotate(0); }
    20%      { transform: rotate(-14deg); }
    40%      { transform: rotate(14deg); }
    60%      { transform: rotate(-9deg); }
    80%      { transform: rotate(9deg); }
}
.notif-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.notif-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 340px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    z-index: 60;
    overflow: hidden;
}
.notif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.notif-list { max-height: 320px; overflow-y: auto; padding: 6px 0; }
.notif-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: #f8fafc; }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-body strong { display: block; font-size: 13px; }
.notif-item-body small { color: var(--text-muted); }
.notif-item-upcoming { border-left: 3px solid var(--warning); }
.notif-item-overdue  { border-left: 3px solid var(--danger); }
.notif-empty { padding: 18px; text-align: center; color: var(--text-muted); font-size: 13px; }

.badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-upcoming { background: var(--warning-bg); color: var(--warning); }
.badge-overdue  { background: var(--danger-bg); color: var(--danger); }
.badge-paid     { background: var(--success-bg); color: var(--success); }

/* Developer Support badge statuses */
.badge-status-open        { background: #dbeafe; color: #1d4ed8; }
.badge-status-in_progress { background: #fef3c7; color: #b45309; }
.badge-status-resolved    { background: #d1fae5; color: #047857; }
.badge-status-closed      { background: #e2e8f0; color: #475569; }
.pill-low    { background: #f1f5f9; color: #475569; }
.pill-medium { background: #dbeafe; color: #1d4ed8; }
.pill-high   { background: #fef3c7; color: #b45309; }
.pill-urgent { background: #fee2e2; color: #b91c1c; }

/* Developer unlock window banner (admin panel) */
.unlock-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #ecfdf5;
    border: 1px solid #34d399;
    color: #047857;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
}
.unlock-banner strong { color: #065f46; }
.dev-lock-note {
    background: #fffbeb;
    border: 1px dashed #f59e0b;
    color: #92400e;
    border-radius: 10px;
    padding: 10px 14px;
    margin-top: 10px;
    font-size: 13px;
}
.dev-lock-note a { color: #b45309; font-weight: 700; }

/* ============================================================
   Page content
   ============================================================ */
.page { padding: 24px; flex: 1; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-subtitle { color: var(--text-muted); margin-top: 2px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.footer {
    padding: 14px 24px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.footer-left {
    font-weight: 700;
    color: var(--text);
}

.footer-right {
    font-weight: 700;
    margin-right: 48px;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 15px; font-weight: 600; }
.link { font-size: 13px; font-weight: 500; }

/* ============================================================
   Stats / status cards
   ============================================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-grid-sm { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
}

.stat-card-grad {
    background:
        linear-gradient(var(--surface), var(--surface)) padding-box,
        linear-gradient(135deg, #2563eb, #7c3aed, #06b6d4) border-box;
    border: 2px solid transparent;
    border-radius: var(--radius);
    box-shadow: 0 6px 18px rgba(37, 99, 235, .18);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-icon-blue   { background: var(--primary-light); }
.stat-icon-purple { background: #f5f3ff; }
.stat-icon-green  { background: var(--success-bg); }
.stat-icon-red    { background: var(--danger-bg); }

.stat-value { font-size: 20px; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 12px; }

.stat-card-link {
    color: inherit;
    text-decoration: none;
    transition: border-color .2s, box-shadow .2s;
}
.stat-card-link:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    color: inherit;
}
.stat-card-link:hover .stat-value { color: var(--primary); }

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.status-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--neutral);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.status-card.status-upcoming { border-left-color: var(--warning); }
.status-card.status-today    { border-left-color: #f97316; }
.status-card.status-overdue  { border-left-color: var(--danger); }
.status-card.status-paid     { border-left-color: var(--success); }

.status-dot { font-size: 22px; }
.status-count { font-size: 24px; font-weight: 700; }
.status-label { color: var(--text-muted); font-size: 12px; }
.status-link { margin-left: auto; font-size: 13px; font-weight: 500; }

/* ============================================================
   Tables
   ============================================================ */
.table-responsive { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.table thead th {
    background: var(--neutral-bg);
    text-align: left;
    padding: 11px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    white-space: nowrap;
}
.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

.empty-cell {
    text-align: center;
    color: var(--text-muted);
    padding: 30px !important;
    font-size: 13px;
}

/* ============================================================
   Pills / badges / chips
   ============================================================ */
.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.pill-upcoming { background: var(--warning-bg); color: var(--warning); }
.pill-paid { background: var(--success-bg); color: var(--success); }
.badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    margin-left: 8px;
    vertical-align: middle;
    cursor: default;
}
.badge-today { background: #f97316; }
.pill-overdue  { background: var(--danger-bg); color: var(--danger); }
.pill-neutral  { background: var(--neutral-bg); color: var(--neutral); }

.serial-chip {
    display: inline-block;
    background: var(--neutral-bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
}

.serial-link { font-family: "SF Mono", Menlo, Consolas, monospace; font-weight: 600; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border .15s, box-shadow .15s;
    font-family: var(--font);
    line-height: 1.3;
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }

.btn-outline {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

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

.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* Action buttons in table rows */
.action-btns {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}
.action-btns form { margin: 0; }

/* Disabled button with permission tooltip */
.btn-disabled {
    position: relative;
    opacity: .45;
    cursor: not-allowed;
    filter: grayscale(.3);
}
.perm-tooltip {
    position: fixed;
    background: var(--sidebar-bg);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    padding: 8px 14px;
    border-radius: 8px;
    border: 2px solid var(--success);
    max-width: 220px;
    width: max-content;
    text-align: center;
    box-shadow: 0 4px 14px rgba(0,0,0,.18);
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
}
.perm-tooltip.show { opacity: 1; }
.perm-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: var(--sidebar-bg);
}

/* ============================================================
   Forms
   ============================================================ */
.form-card { padding: 20px; }

.form-section { margin-bottom: 24px; }
.form-section h2 {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.form-fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px 16px;
    margin: 0 0 22px;
    background: #fcfcfd;
    position: relative;
}
.form-fieldset > legend {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--primary);
    padding: 4px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    margin-left: -4px;
    line-height: 1.4;
    white-space: nowrap;
}
.form-fieldset .form-note { margin-top: 2px; }

.form-note { color: var(--text-muted); font-size: 12.5px; margin-bottom: 14px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.form-grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-group { margin-bottom: 4px; }
.form-group-full { grid-column: 1 / -1; }
.align-end { display: flex; align-items: flex-end; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.req { color: var(--danger); }

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: var(--font);
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border .15s, box-shadow .15s;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea.form-control { resize: vertical; }
.textarea-lg { min-height: 160px; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }

.form-hint { display: block; color: var(--text-muted); font-size: 12px; margin-top: 5px; }

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 13px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px 18px;
    margin-bottom: 10px;
}
.perm-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}
.perm-check input[type="checkbox"] { width: 15px; height: 15px; }
.input-suffix { position: relative; }
.input-suffix .form-control { padding-right: 40px; }

/* ============================================================
   Bank account match indicator
   ============================================================ */
.account-match { padding-right: 34px; }
.input-suffix .form-control.account-match { padding-right: 40px; }

.account-match-indicator {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
    opacity: 0;
}

.account-match-indicator.is-match {
    opacity: 1;
    color: #fff;
    background: #16a34a;
    animation: accountPop .35s ease;
}
.account-match-indicator.is-match::before {
    content: "✓";
}

.account-match-indicator.is-mismatch {
    opacity: 1;
    color: #fff;
    background: #dc2626;
    animation: accountPop .35s ease;
}
.account-match-indicator.is-mismatch::before {
    content: "✕";
}

@keyframes accountPop {
    0%   { transform: translateY(-50%) scale(0.3); opacity: 0; }
    60%  { transform: translateY(-50%) scale(1.25); opacity: 1; }
    100% { transform: translateY(-50%) scale(1); opacity: 1; }
}

.account-match.is-match {
    border-color: #16a34a !important;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, .12);
}
.account-match.is-mismatch {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}

.bank-match-hint.is-match { color: #16a34a; font-weight: 600; }
.bank-match-hint.is-mismatch { color: #dc2626; font-weight: 600; }

.input-suffix .account-mask {
    padding-right: 44px;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    letter-spacing: .08em;
}

.account-reveal {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-70%);
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}
.account-reveal:hover { background: rgba(37, 99, 235, .08); color: var(--primary); }

.ifsc-hint.is-match { color: #16a34a; font-weight: 600; }
.ifsc-hint.is-mismatch { color: #dc2626; font-weight: 600; }

input.bank-auto[readonly] {
    background: #f3f6fb;
    border-color: #d1dbe8;
    color: #1f2937;
    cursor: default;
}

.form-control-uppercase { text-transform: uppercase; }
.form-control-uppercase::placeholder { text-transform: none; }

/* ============================================================
   Payment frequency lock
   ============================================================ */
.lock-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fef3c7;
    color: #b45309;
    font-size: 11px;
    vertical-align: middle;
    cursor: help;
    margin-left: 4px;
}

select.form-control:disabled {
    background: #f3f6fb;
    border-color: #d1dbe8;
    color: #1f2937;
    cursor: not-allowed;
}

.lock-note {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid #fcd34d;
    background: #fffbeb;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    line-height: 1.5;
    color: #92400e;
}

.lock-note-soft {
    margin-top: 10px;
    padding: 8px 12px;
    border: 1px dashed #c7d2fe;
    background: #eef2ff;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: #4338ca;
}

/* ============================================================
   Payment slot days — reference
   ============================================================ */
.card-slot-ref {
    padding: 14px 16px;
    border: 1px dashed #a5b4fc;
    background: #f5f7ff;
}

.slot-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 6px;
}

.slot-chips-sm {
    gap: 5px;
    margin: 0;
}

.slot-chips-sm .slot-chip {
    min-width: 26px;
    height: 24px;
    padding: 0 8px;
    font-size: 12px;
}

.slot-days-display .form-control {
    background: #eef2ff;
    border-color: #6366f1;
    color: #4338ca;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.slot-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: #6366f1;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
}

select.form-control:disabled,
input.form-control[readonly] {
    background: #f3f6fb;
    border-color: #d1dbe8;
    color: #1f2937;
    cursor: not-allowed;
}

.locked-hint {
    color: #b45309;
    font-style: italic;
}

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.mini-cal {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.cal-head,
.cal-day {
    text-align: center;
    padding: 8px 0;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.cal-head {
    font-weight: 700;
    color: var(--text-muted, #64748b);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cal-day {
    background: #f8fafc;
    color: #0f172a;
}

.cal-empty {
    background: transparent;
}

.cal-slot {
    background: #6366f1;
    color: #fff;
    font-weight: 700;
}

.cal-legend {
    margin-top: 12px;
    font-size: 12.5px;
    color: var(--text-muted, #64748b);
    display: flex;
    align-items: center;
    gap: 6px;
}

.cal-legend-slot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    background: #6366f1;
}

/* Interactive calendar day cells — identical styles to the reference calendar */
.cal-day.calendar-day {
    background: #f8fafc;
    color: #0f172a;
    cursor: pointer;
    user-select: none;
}

.cal-day.calendar-day:hover {
    background: #eef2ff;
}

.cal-day.calendar-day.cal-slot,
.cal-day.cal-slot {
    background: #6366f1;
    color: #fff;
    font-weight: 700;
}

.cal-day.calendar-day.cal-slot:hover {
    background: #5658d9;
}

.cal-day.calendar-day.is-locked {
    cursor: default;
}

.cal-day.calendar-day.is-locked:hover {
    background: #f8fafc;
}

.cal-day.calendar-day.is-locked.cal-slot {
    background: #6366f1;
    color: #fff;
    font-weight: 700;
}

.cal-day.calendar-day.is-locked.cal-slot:hover {
    background: #6366f1;
}

/* PIN-protected slot days on the schedule form */
.slot-modify-row {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

#slotPinInput {
    max-width: 150px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid #d1dbe8;
    border-radius: var(--radius-sm);
    font-size: 14px;
    letter-spacing: 0.35em;
    text-align: center;
}

#slotPinInput:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.pin-new-wrap {
    margin-top: 14px;
    max-width: 340px;
}

.input-pin {
    letter-spacing: 0.35em;
    font-size: 16px;
}

/* Aadhaar Card number: 3 × 4-digit boxes */
.aadhaar-boxes {
    display: flex;
    align-items: center;
    gap: 10px;
}
.aadhaar-box {
    flex: 1;
    max-width: 130px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.35em;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
.aadhaar-box:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
}
.aadhaar-box::placeholder { letter-spacing: 0.35em; font-weight: 400; }
.aadhaar-sep { color: var(--text-muted); font-weight: 700; font-size: 18px; }


.input-suffix .suffix {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
}

.search-bar { display: flex; gap: 10px; padding: 16px 20px; }
.search-bar .form-control { max-width: 520px; }

.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 16px 20px;
    flex-wrap: wrap;
}
.filter-bar .form-control { width: auto; min-width: 150px; }
.filter-sep { color: var(--text-muted); }

/* ============================================================
   Alerts
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.alert-success { background: var(--success-bg); color: #14532d; border: 1px solid #bbf7d0; }
.alert-danger  { background: var(--danger-bg); color: #7f1d1d; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-bg); color: #78350f; border: 1px solid #fde68a; }

.alert a { text-decoration: underline; }

.alert-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: .6;
    line-height: 1;
}
.alert-close:hover { opacity: 1; }

.reminder-link { margin-right: 4px; white-space: nowrap; }

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}
.page-link {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-info { color: var(--text-muted); font-size: 13px; }

/* ============================================================
   User detail page
   ============================================================ */
.grid-user {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
    align-items: start;
}
.grid-right { display: flex; flex-direction: column; gap: 0; }

.user-card { padding: 20px; }
.user-card-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}
.user-card-head h2 { font-size: 17px; }

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}
.avatar-lg { width: 52px; height: 52px; font-size: 20px; }

.serial-block {
    text-align: center;
    padding: 16px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    background: var(--bg);
}
.serial-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
}
.serial-number {
    display: block;
    font-size: 22px;
    font-weight: 700;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    letter-spacing: .03em;
    margin: 4px 0 10px;
}
.barcode svg { max-width: 100%; height: auto; }

.info-table { width: 100%; font-size: 13.5px; }
.info-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    padding: 7px 10px 7px 0;
    width: 120px;
    vertical-align: top;
}
.info-table td { padding: 7px 0; }

.user-actions { margin-top: 16px; }

.schedule-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    padding: 16px 20px;
}
.schedule-item { text-align: center; }
.schedule-label { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.schedule-value { font-size: 16px; font-weight: 700; }
.schedule-actions { padding: 0 20px 16px; }

.user-list {
    padding: 8px 8px;
    max-height: 360px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.user-list::-webkit-scrollbar { width: 6px; }
.user-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.user-list::-webkit-scrollbar-track { background: transparent; }
.user-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin: 6px 0;
    color: var(--text);
    border: 1px solid transparent;
    border-radius: 12px;
    transition: background .15s, border-color .15s;
}
.user-list-item:hover { background: #f8fafc; }
.user-list-meta { flex: 1; }
.user-list-meta strong { display: block; font-size: 14px; }
.user-list-meta small { color: var(--text-muted); }
.user-list-arrow { color: var(--text-muted); }
.avatar-sm { width: 30px; height: 30px; font-size: 13px; }

/* Latest-Users payment status borders (rounded ring + soft tint) */
.user-list-item.user-status-upcoming { border-color: var(--warning); background: var(--warning-bg); }
.user-list-item.user-status-overdue { border-color: var(--danger); background: var(--danger-bg); }

/* Upcoming Payments notification list */
.pending-payments { max-height: 340px; overflow-y: auto; padding: 8px 0; }
.pp-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid transparent;
}
.pp-row:last-child { border-bottom: none; }
.pp-status-upcoming { border-left-color: var(--warning); }
.pp-status-overdue  { border-left-color: var(--danger); }
.pp-amount { font-weight: 700; color: var(--primary-dark); white-space: nowrap; }
.pp-row .user-list-meta { min-width: 0; }
.pp-row .badge { flex-shrink: 0; }

/* ============================================================
   Auth pages
   ============================================================ */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #2563eb 100%);
    padding: 20px;
}

.auth-wrap { width: 100%; max-width: 400px; }

.auth-card {
    background: var(--surface);
    border-radius: 14px;
    padding: 34px;
    box-shadow: var(--shadow-lg);
}

.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .brand-mark {
    width: 52px;
    height: 52px;
    font-size: 22px;
    margin: 0 auto 12px;
}
.auth-brand h1 { font-size: 20px; font-weight: 700; }
.auth-brand p { color: var(--text-muted); font-size: 13px; }

.auth-tabs {
    display: flex;
    background: var(--neutral-bg);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 18px;
    gap: 4px;
}
.auth-tab {
    flex: 1;
    border: none;
    background: none;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}
.auth-tab.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow);
}
.auth-panel { display: none; }
.auth-panel.active { display: block; }

.auth-panel .form-fieldset {
    border: 1.5px solid #b9c9ec;
    border-radius: 12px;
    padding: 18px 20px 16px;
    margin: 0 0 18px;
    background: linear-gradient(180deg, #fdfeff 0%, #f4f8ff 100%);
    box-shadow: inset 0 0 0 1px #ffffff, 0 1px 3px rgba(37, 99, 235, .08);
    position: relative;
}
.auth-panel .form-fieldset::before,
.auth-panel .form-fieldset::after {
    content: '';
    position: absolute;
    pointer-events: none;
}
.auth-panel .form-fieldset::before {
    inset: 4px;
    border: 1px dashed #c7d6f3;
    border-radius: 8px;
}
.auth-panel .form-fieldset > legend {
    position: relative;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #ffffff;
    padding: 5px 14px 5px 10px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(37, 99, 235, .35);
    margin-left: -2px;
    z-index: 1;
    line-height: 1.4;
    white-space: nowrap;
}
.auth-panel .form-fieldset > legend span.dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    margin-right: 7px;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .35);
    vertical-align: middle;
}

.auth-footer {
    text-align: center;
    margin-top: 18px;
    font-size: 13px;
}

/* Login toast notification */
.login-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #dc2626;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .3);
    z-index: 9999;
    animation: toastSlideIn .3s ease, toastFadeOut .5s ease 3.5s forwards;
    max-width: 400px;
}
.toast-icon { font-size: 18px; }

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastFadeOut {
    from { opacity: 1; }
    to { opacity: 0; pointer-events: none; }
}

/* Attempt warning bar */
.attempt-warning {
    margin-top: 10px;
    text-align: center;
}
.attempt-bar {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 6px;
}
.attempt-dot {
    width: 28px;
    height: 6px;
    border-radius: 3px;
    background: #d1d5db;
    transition: background .2s;
}
.attempt-dot.used {
    background: #dc2626;
}
.attempt-text {
    font-size: 12px;
    color: #dc2626;
    font-weight: 500;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
    .grid-user { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .5);
        z-index: 99;
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s;
    }
    .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
    .page { padding: 16px; }
    .topbar { padding: 10px 16px; }
    .topbar-search { max-width: none; }
    .topbar-nav { gap: 4px; margin-left: 8px; }
    .topbar-nav-link { padding: 5px 10px; font-size: 12px; gap: 4px; }
    .tn-icon { width: 14px; height: 14px; }
    .page-header { flex-direction: column; }
}

/* ============================================================
   Welcome popup
   ============================================================ */
.welcome-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
}
.welcome-overlay.show { opacity: 1; pointer-events: auto; }

.welcome-box {
    background: var(--surface);
    border-radius: 16px;
    padding: 36px 40px 28px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    position: relative;
    max-width: 380px;
    width: 90%;
    transform: scale(.9);
    transition: transform .3s;
    border: 2px solid var(--primary);
}
.welcome-overlay.show .welcome-box { transform: scale(1); }

/* ============================================================
   Flash popup (centered)
   ============================================================ */
.flash-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.flash-overlay.show { pointer-events: auto; }

.flash-box {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 480px;
    width: 90%;
    padding: 18px 20px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border: 2px solid #93c5fd;
    box-shadow: 0 20px 45px rgba(37, 99, 235, .35);
    color: #fff;
    font-weight: 700;
    font-size: 14.5px;
    line-height: 1.45;
    opacity: 0;
    transform: scale(.85) translateY(12px);
    transition: opacity .3s ease, transform .3s ease;
}
.flash-overlay.show .flash-box {
    opacity: 1;
    transform: scale(1) translateY(0);
}
.flash-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
}
.flash-message { flex: 1; word-break: break-word; font-size: 18px; font-weight: 700; }
.flash-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    opacity: .75;
    line-height: 1;
    padding: 0 4px;
}
.flash-close:hover { opacity: 1; }

.flash-danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    border-color: #fca5a5;
    box-shadow: 0 20px 45px rgba(220, 38, 38, .35);
}

/* ============================================================
   Confirm dialog (styled, replaces native confirm)
   ============================================================ */
.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(15, 23, 42, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
}
.confirm-overlay.show { opacity: 1; pointer-events: auto; }

.confirm-box {
    max-width: 440px;
    width: 90%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border: 2px solid #93c5fd;
    border-radius: 16px;
    padding: 30px 28px 24px;
    text-align: center;
    box-shadow: 0 20px 45px rgba(37, 99, 235, .4);
    color: #fff;
    transform: scale(.9);
    transition: transform .3s;
}
.confirm-overlay.show .confirm-box { transform: scale(1); }

.confirm-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    font-size: 28px;
    margin-bottom: 14px;
}
.confirm-message {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.5;
    color: #fff;
    word-break: break-word;
    margin-bottom: 20px;
}
.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.confirm-actions .btn {
    font-weight: 700;
    border-radius: 8px;
    padding: 9px 22px;
    min-width: 96px;
}
.confirm-actions .btn-primary {
    background: #fff;
    border-color: #fff;
    color: #1d4ed8;
}
.confirm-actions .btn-primary:hover {
    background: #e0edff;
    border-color: #e0edff;
}
.confirm-actions .btn-outline {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(255, 255, 255, .6);
    color: #fff;
}
.confirm-actions .btn-outline:hover {
    background: rgba(255, 255, 255, .22);
    border-color: #fff;
}

.welcome-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.welcome-close:hover { background: var(--danger-bg); color: var(--danger); }

.welcome-icon { margin-bottom: 14px; }
.welcome-icon .brand-logo { font-size: 28px; }
.welcome-box h2 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.welcome-box p { font-size: 14px; color: var(--text-muted); margin-bottom: 10px; }

/* Profile avatar */
.profile-avatar-wrap { display: inline-block; }
.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
}
.profile-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
}
.sidebar-user .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
}
.sidebar-user .avatar img,
.sidebar-user img.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

/* ============================================================
   Siri Voice Assistant
   ============================================================ */
.siri { position: fixed; right: 22px; bottom: 22px; z-index: 10000; display: none; }
.siri.on { display: block; }
.siri-fab {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 25px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    box-shadow: 0 6px 20px rgba(37, 99, 235, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s, box-shadow .15s;
}
.siri-fab:hover { transform: scale(1.06); box-shadow: 0 8px 26px rgba(37, 99, 235, .55); }
.siri-fab.listening { animation: siriPulse 1s ease infinite; }

@keyframes siriPulse {
    0%   { box-shadow: 0 0 0 0 rgba(37, 99, 235, .5); }
    70%  { box-shadow: 0 0 0 16px rgba(37, 99, 235, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.siri-listening {
    display: none;
    position: absolute;
    right: 0;
    bottom: 68px;
    background: #fff;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 999px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
    white-space: nowrap;
    animation: siriBlink 1s ease infinite;
}
@keyframes siriBlink { 50% { opacity: .4; } }

.siri-panel {
    display: none;
    position: absolute;
    right: 0;
    bottom: 70px;
    width: 320px;
    max-height: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 34px rgba(15, 23, 42, .28);
    overflow: hidden;
    flex-direction: column;
}
.siri-panel.open { display: flex; }

.siri-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #0f172a, #1e3a8a);
    color: #fff;
}
.siri-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
}
.siri-title { flex: 1; }
.siri-title strong { font-size: 14px; display: block; }
.siri-title small { font-size: 11px; color: #cbd5e1; }
.siri-icon {
    background: none;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
}
.siri-icon:hover { opacity: .8; }

.siri-log {
    flex: 1;
    min-height: 120px;
    max-height: 230px;
    overflow-y: auto;
    padding: 10px 12px;
    background: var(--bg);
}
.siri-row { font-size: 12.5px; margin-bottom: 8px; line-height: 1.45; }
.siri-row .jwho {
    display: inline-block;
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-right: 6px;
    padding: 1px 6px;
    border-radius: 999px;
}
.siri-row.bot .jwho { background: var(--primary-light); color: var(--primary); }
.siri-row.user .jwho { background: #eef2f7; color: var(--text-muted); }

.siri-actions {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
}
.siri-pill {
    flex: 1;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    padding: 7px;
    border-radius: 8px;
    cursor: pointer;
}
.siri-pill:hover { border-color: var(--primary); }

.siri-duration {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    font-size: 11.5px;
    flex-wrap: wrap;
}
.siri-dur-label { font-weight: 700; color: var(--text-muted); margin-right: 2px; }
.siri-dur-input {
    width: 64px;
    padding: 5px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    background: var(--surface);
}
.siri-dur-forever {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: var(--text-muted);
    margin-left: 2px;
    font-weight: 600;
}
.siri-duration .siri-pill { font-size: 11px; padding: 5px 8px; }

/* ============================================================
   Renewal Agreement
   ============================================================ */
.renewal-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    vertical-align: middle;
    margin-left: 10px;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    color: #fff;
    cursor: default;
}
.renewal-badge.renewal-active   { background: var(--success); }
.renewal-badge.renewal-expiring { background: var(--warning); }
.renewal-badge.renewal-expired  { background: var(--danger); }
.renewal-badge.renewal-none     { background: var(--neutral); color: var(--text-muted); }
.renewal-badge.renewal-none { background: var(--neutral-bg); color: var(--neutral); border: 1px dashed var(--border); }
.renewal-days {
    font-size: 11px;
    opacity: .85;
    border-left: 1px solid rgba(255,255,255,.4);
    padding-left: 6px;
}
.renewal-summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
    border: 1px dashed #dbeafe;
    border-radius: var(--radius);
    background: #f8fafc;
}
.renewal-summary .schedule-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}
.renewal-summary .schedule-item:last-child { border-bottom: 0; }
.renewal-summary .renewal-badge { margin-left: 0; }

.renewal-btn {
    cursor: pointer;
    background: linear-gradient(135deg, #f97316, #ea580c);
    border-color: #fb923c;
    color: #fff;
}
.renewal-btn:hover {
    background: linear-gradient(135deg, #fb923c, #f97316);
    border-color: #fbbf24;
    color: #fff;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 16px;
    background: rgba(15, 23, 42, .55);
    overflow-y: auto;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
    width: 100%;
    max-width: 560px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: modalIn .18s ease-out;
}
@keyframes modalIn {
    from { transform: translateY(-8px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal-close {
    background: none;
    border: 0;
    font-size: 18px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}
.modal-close:hover { color: var(--text); }
.modal-box form { padding: 20px; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* ============================================================
   Re-admisery Profile (standalone page)
   ============================================================ */
.re-body {
    background: linear-gradient(180deg, #0f172a 0, #1e293b 240px, #f1f5f9 240px);
    min-height: 100vh;
    padding: 24px;
}
.re-page {
    max-width: 900px;
    margin: 0 auto;
}
.re-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.re-header h1 {
    color: #fff;
    font-size: 24px;
}
.re-subtitle {
    color: #94a3b8;
    font-size: 13px;
    margin-top: 4px;
}
.re-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.re-card-title {
    font-size: 16px;
    margin-bottom: 4px;
}
.re-card-note {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 16px;
}
.re-alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
}
.re-alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.re-alert-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #fecaca; }

.re-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: var(--neutral-bg);
    color: var(--text);
}
.re-btn-primary { background: var(--primary); color: #fff; }
.re-btn-primary:hover { background: var(--primary-dark); }
.re-btn-danger { background: var(--danger-bg); color: var(--danger); }
.re-btn-danger:hover { background: #fee2e2; }
.re-btn-outline {
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #334155;
}
.re-btn-outline:hover { background: #334155; }

/* ---- Tree diagram ---- */
.re-tree-wrap { overflow-x: auto; padding: 10px 0 4px; }
.re-chain-flow {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    align-items: flex-start;
    justify-content: center;
    margin-top: 26px;
    position: relative;
}
.re-chain {
    flex: 0 1 auto;
    min-width: 220px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.re-chain .re-tree { padding-left: 0; }
.re-tree {
    list-style: none;
    margin: 0;
    padding: 0 0 0 4px;
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    justify-content: safe center;
    align-items: flex-start;
}
.re-tree ul {
    position: relative;
    margin: 0;
    padding: 20px 0 0;
}
.re-tree ul::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 20px;
    margin-left: -1px;
    background: #cbd5e1;
}
.re-tree li {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 12px 0;
}
.re-tree li::before,
.re-tree li::after {
    content: "";
    position: absolute;
    top: 0;
    width: 50%;
    height: 20px;
    border-top: 2px solid #cbd5e1;
    pointer-events: none;
}
.re-tree li::before {
    left: 0;
}
.re-tree li::after {
    left: 50%;
    border-left: 2px solid #cbd5e1;
}
.re-tree li:first-child::before {
    border-top: 0 none;
}
.re-tree li:last-child::after {
    border-top: 0 none;
    border-radius: 5px 0 0 0;
}
.re-tree li:only-child::before,
.re-tree li:only-child::after {
    display: none;
}
.re-tree li:only-child::before {
    display: block;
    left: 50%;
    width: 2px;
    margin-left: -1px;
    border: none;
    background: #cbd5e1;
}

.re-node {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 3px;
    min-width: 170px;
    max-width: 220px;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(15,23,42,.12);
    border: 1px solid var(--border);
}
.re-node-client {
    background: #0f172a;
    border-color: #0f172a;
    color: #fff;
    min-width: 190px;
}
.re-node-client .re-node-sub { color: #94a3b8; }
.re-node-main {
    background: #6366f1;
    border-color: #4f46e5;
    color: #fff;
}
.re-node-main .re-node-sub { color: #e0e7ff; }
.re-node-user {
    background: #eff6ff;
    border-color: #bfdbfe;
}
.re-node-empty { background: #f8fafc; border-style: dashed; }
.re-node-title { font-weight: 700; font-size: 14px; }
.re-node-sub { font-size: 12px; color: var(--text-muted); }
.re-node-tag {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #475569;
}
.re-node-tag-main { background: rgba(255,255,255,.22); color: #fff; }
.re-node-client .re-node-tag { background: #334155; color: #e2e8f0; }

.re-detach { margin-top: 6px; }
.re-detach .re-btn { padding: 4px 10px; font-size: 11.5px; }

/* ---- Forms ---- */
.re-forms {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 720px) {
    .re-forms { grid-template-columns: 1fr; }
}
.re-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.re-form-row .re-select { flex: 1 1 200px; }
.re-select {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--surface);
}
/* Main Head optgroup — dark, bold, prominent */
.re-select optgroup:first-of-type {
    font-weight: 700;
    font-size: 13px;
    color: #1e1b4b !important;
}
.re-select optgroup:first-of-type option {
    font-weight: 700;
    color: #1e1b4b !important;
    padding-left: 10px;
    font-style: normal;
}
/* Sub-user optgroup — light, muted */
.re-select optgroup:nth-of-type(2) {
    font-weight: 600;
    font-size: 12px;
    color: #94a3b8 !important;
}
.re-select optgroup:nth-of-type(2) option {
    font-weight: 400;
    color: #94a3b8 !important;
    padding-left: 10px;
    font-style: normal;
}
.re-input {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
    flex: 1 1 180px;
    min-width: 0;
}
.re-form-row .re-input::placeholder { color: #94a3b8; }
.re-card-subtitle {
    margin: 18px 0 10px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
}
.re-node-main .re-node-sub strong,
.re-node-user .re-node-sub strong { color: var(--text); }
.re-note-admin p { color: var(--neutral); font-size: 13px; margin: 0; }

/* ---- Relationship model ---- */
.re-model {
    margin: 8px 0 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.re-model li {
    padding: 10px 14px;
    border-left: 3px solid var(--primary);
    background: var(--primary-light);
    border-radius: 0 8px 8px 0;
    font-size: 13.5px;
}
.re-model li strong { color: var(--primary-dark); }

/* ---- v4.9: Main Head overview cards + detail drill-down ---- */
.re-header-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }

.re-client-node {
    position: relative;
    margin: 18px auto 6px;
    padding: 12px 20px;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: #334155;
    border-radius: var(--radius);
    color: #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .16);
}
.re-client-node .re-node-sub { color: #cbd5e1; }

.re-head-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 26px;
}
.re-head-card {
    position: relative;
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.re-head-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15, 23, 42, .12); border-color: #4f46e5; }
.re-head-card-body { flex: 1; min-width: 0; }
.re-avatar {
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}
.re-head-name { font-weight: 700; font-size: 15px; }
.re-head-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.re-head-stats { display: flex; gap: 22px; margin-top: 10px; }
.re-head-card .re-head-stats,
.re-head-profile .re-head-stats { flex-wrap: wrap; row-gap: 10px; }
.re-head-card .re-head-stats { gap: 10px 20px; }
.re-stat { display: flex; flex-direction: column; gap: 2px; }
.re-stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.re-stat-value { font-size: 14px; font-weight: 700; color: var(--primary-dark); }
.re-head-arrow { font-size: 24px; color: #cbd5e1; font-weight: 700; }
.re-head-card:hover .re-head-arrow { color: #4f46e5; transform: translateX(2px); }
.re-head-arrow { transition: transform .12s ease, color .12s ease; }

.re-empty {
    margin-top: 26px;
    padding: 26px;
    text-align: center;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 13.5px;
}

.re-head-profile {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 20px 22px;
    background: linear-gradient(135deg, #312e81, #4f46e5);
    border-radius: var(--radius);
    color: #fff;
    margin-bottom: 20px;
    box-shadow: 0 8px 24px rgba(79, 70, 229, .25);
}
.re-head-profile .re-avatar { flex-basis: 62px; width: 62px; height: 62px; font-size: 26px; background: rgba(255,255,255,.18); border: 2px solid rgba(255,255,255,.4); }
.re-head-profile-body { flex: 1; min-width: 0; }
.re-head-profile .re-head-name { font-size: 20px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.re-head-profile .re-node-tag-main { background: rgba(255,255,255,.22); color: #fff; }
.re-head-profile .re-head-meta { color: #e0e7ff; }
.re-head-profile .re-stat-label { color: #c7d2fe; }
.re-head-profile .re-stat-value { color: #fff; }

.re-tree-detail { display: flex; flex-direction: column; align-items: center; }
.re-tree-detail .re-tree { padding-left: 0; }
.re-tree-detail > .re-tree { position: relative; padding-top: 20px; width: 100%; }
.re-tree-detail > .re-tree::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 20px;
    margin-left: -1px;
    background: #cbd5e1;
}

/* Commission breakdown table */
.re-table-wrap { overflow-x: auto; margin-top: 14px; }
.re-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.re-table th,
.re-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.re-table thead th { text-transform: uppercase; font-size: 10.5px; letter-spacing: .05em; color: var(--text-muted); border-bottom: 2px solid var(--border); }
.re-table tbody tr:hover { background: rgba(79, 70, 229, .04); }
.re-table .re-col-commission { font-weight: 700; color: var(--primary-dark); }
.re-row-total td { border-top: 2px solid var(--border); border-bottom: none; background: rgba(79, 70, 229, .06); }
.re-row-total .re-col-commission { color: #1e1b4b; }
