:root {
    --rd-primary: #0d6efd;
    --rd-primary-2: #005f99;
    --rd-primary-dark: #003366;
    --rd-bg: #f5f8ff;
    --rd-surface: #ffffff;
    --rd-surface-2: #eef5ff;
    --rd-text: #0f172a;
    --rd-muted: #64748b;
    --rd-border: rgba(15, 23, 42, .10);
    --rd-danger: #dc2626;
    --rd-success: #16a34a;
    --rd-warning: #d97706;
    --rd-radius-sm: 12px;
    --rd-radius: 18px;
    --rd-radius-lg: 26px;
    --rd-shadow: 0 18px 48px rgba(15, 23, 42, .08);
    --rd-shadow-soft: 0 10px 28px rgba(15, 23, 42, .06);
    --rd-sidebar-width: 286px;
    --rd-header-height: 72px;
    --rd-font: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
    --rd-bg: #08111f;
    --rd-surface: #0f1b2d;
    --rd-surface-2: #12243d;
    --rd-text: #e5eefb;
    --rd-muted: #9aa8bd;
    --rd-border: rgba(148, 163, 184, .18);
    --rd-shadow: 0 18px 48px rgba(0, 0, 0, .28);
    --rd-shadow-soft: 0 10px 28px rgba(0, 0, 0, .22);
}

body { font-family: var(--rd-font); background: var(--rd-bg); color: var(--rd-text); }

.td-navbar { background: var(--rd-primary); box-shadow: 0 10px 30px rgba(13,110,253,.22); min-height: var(--rd-header-height); }
.td-navbar .navbar-brand span, .td-navbar .nav-link { color: #fff !important; }
.td-navbar .nav-link { font-weight: 650; font-size: .92rem; border-radius: 999px; padding: .58rem .82rem; opacity: .9; }
.td-navbar .nav-link:hover, .td-navbar .nav-link.active { background: rgba(255,255,255,.16); opacity: 1; }
.td-theme-toggle { border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.12); color: #fff; border-radius: 999px; min-height: 36px; padding: 0 .75rem; font-weight: 700; display:inline-flex; align-items:center; gap:6px; cursor:pointer; transition:.18s ease; }
.td-theme-toggle:hover { background: rgba(255,255,255,.22); }
/* Icon visibility by theme */
[data-theme="light"] .td-icon-dark { display:none; }
[data-theme="dark"]  .td-icon-light { display:none; }
/* Default (before JS runs) hide dark icon */
html:not([data-theme="dark"]) .td-icon-dark { display:none; }
html:not([data-theme="light"]) .td-icon-light { display:none; }
.td-accent-bar { height: 4px; background: linear-gradient(90deg, var(--rd-primary-dark), var(--rd-primary-2), var(--rd-primary-dark)); }

.rd-shell { min-height: 100vh; background: radial-gradient(circle at top right, rgba(13,110,253,.16), transparent 28rem), var(--rd-bg); padding-top: var(--rd-header-height); color: var(--rd-text); }
.rd-sidebar { position: fixed; top: var(--rd-header-height); left: 0; bottom: 0; width: var(--rd-sidebar-width); padding: 22px; background: rgba(255,255,255,.86); backdrop-filter: blur(20px); border-right: 1px solid var(--rd-border); display: flex; flex-direction: column; z-index: 20; overflow-y: auto; }
[data-theme="dark"] .rd-sidebar { background: rgba(15, 27, 45, .90); }
.rd-sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 10px 8px 20px; border-bottom: 1px solid var(--rd-border); margin-bottom: 18px; }
.rd-brand-mark { width: 44px; height: 44px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(135deg, var(--rd-primary), var(--rd-primary-2)); color: #fff; font-weight: 900; letter-spacing: -.05em; box-shadow: 0 14px 26px rgba(13,110,253,.25); }
.rd-sidebar-brand strong { display:block; font-size:.98rem; }
.rd-sidebar-brand span { color: var(--rd-muted); font-size:.78rem; }
.rd-menu { display: grid; gap: 10px; }
.rd-menu-link, .rd-submenu a, .rd-menu-toggle { width:100%; display:flex; align-items:center; gap:12px; text-decoration:none; color:var(--rd-muted); font-weight:760; font-size:.9rem; border:0; background:transparent; border-radius:16px; padding:12px 13px; transition:.18s ease; text-align:left; }
.rd-menu-link:hover, .rd-submenu a:hover, .rd-menu-toggle:hover { background: var(--rd-surface-2); color:var(--rd-text); transform: translateX(2px); }
.rd-menu-link.active, .rd-submenu a.active { background: linear-gradient(135deg, var(--rd-primary), var(--rd-primary-2)); color:#fff; box-shadow: 0 14px 30px rgba(13,110,253,.28); }
.rd-menu-icon { width:30px; height:30px; display:grid; place-items:center; border-radius:11px; background:rgba(13,110,253,.10); color:currentColor; }
.rd-menu-section { display:grid; gap: 6px; }
.rd-menu-toggle { justify-content:space-between; padding: 10px 12px; color: var(--rd-text); }
.rd-submenu { display:grid; gap:5px; margin-left: 10px; padding-left: 12px; border-left: 1px solid var(--rd-border); }
.rd-submenu a { padding: 9px 12px; font-size: .84rem; }
.rd-sidebar-footer { margin-top:auto; display:grid; gap:12px; padding-top:18px; }
.rd-mini-card { background: var(--rd-surface); border:1px solid var(--rd-border); border-radius:18px; padding:14px; box-shadow: var(--rd-shadow-soft); }
.rd-mini-card span { display:block; color:var(--rd-muted); font-size:.76rem; }
.rd-mini-card strong { font-size:.9rem; }
.rd-logout { color: var(--rd-danger); border:1px solid rgba(220,38,38,.22); border-radius:14px; padding:10px; text-align:center; text-decoration:none; font-weight:800; }
.rd-logout:hover { background: rgba(220,38,38,.08); }

.rd-main { margin-left: var(--rd-sidebar-width); padding: 34px; }
.rd-topbar { display:flex; justify-content:space-between; align-items:flex-start; gap:20px; margin-bottom:26px; }
.rd-eyebrow { display:inline-flex; padding:6px 10px; border-radius:999px; background:rgba(13,110,253,.1); color:var(--rd-primary); font-weight:900; font-size:.72rem; letter-spacing:.06em; text-transform:uppercase; margin-bottom:10px; }
.rd-topbar h1 { margin:0; font-size: clamp(1.7rem, 3vw, 2.5rem); font-weight:900; letter-spacing:-.05em; }
.rd-topbar p { margin: 8px 0 0; color:var(--rd-muted); max-width:720px; }
.rd-actions { display:flex; gap:10px; flex-wrap:wrap; }
.rd-btn { border:0; min-height:44px; padding:0 16px; border-radius:14px; font-weight:900; font-size:.88rem; text-decoration:none; display:inline-flex; align-items:center; justify-content:center; gap:8px; cursor:pointer; transition:.18s ease; }
.rd-btn:hover { transform: translateY(-1px); }
.rd-btn:disabled { opacity:.65; cursor:not-allowed; transform:none; }
.rd-btn-primary { background: linear-gradient(135deg, var(--rd-primary), var(--rd-primary-2)); color:#fff; box-shadow:0 14px 30px rgba(13,110,253,.24); }
.rd-btn-ghost { background: var(--rd-surface); color: var(--rd-text); border:1px solid var(--rd-border); }
.w-100 { width: 100%; }

.rd-stat-grid { display:grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap:16px; margin-bottom:18px; }
.rd-stat-card, .rd-panel { background: rgba(255,255,255,.90); border:1px solid var(--rd-border); border-radius: var(--rd-radius-lg); box-shadow: var(--rd-shadow); }
[data-theme="dark"] .rd-stat-card, [data-theme="dark"] .rd-panel { background: rgba(15,27,45,.92); }
.rd-stat-card { padding:22px; position:relative; overflow:hidden; }
.rd-stat-card:before { content:""; position:absolute; inset:auto -20px -36px auto; width:96px; height:96px; border-radius:999px; background:rgba(13,110,253,.08); }
.rd-stat-card.primary { background: linear-gradient(135deg, var(--rd-primary), var(--rd-primary-2)); color:#fff; }
.rd-stat-card span { display:block; color:var(--rd-muted); font-weight:800; font-size:.78rem; text-transform:uppercase; letter-spacing:.04em; }
.rd-stat-card.primary span, .rd-stat-card.primary small { color:rgba(255,255,255,.78); }
.rd-stat-card strong { display:block; margin:10px 0 4px; font-size:2rem; line-height:1; letter-spacing:-.05em; }
.rd-stat-card small { color:var(--rd-muted); }
.rd-grid-2 { display:grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap:18px; margin-top:18px; }
.rd-grid-form-table { display:grid; grid-template-columns: 370px minmax(0,1fr); gap:18px; align-items:start; }
.align-start { align-items:start; }
.rd-panel { padding:22px; }
.rd-panel-head { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin-bottom:18px; }
.rd-panel-head h2 { margin:0; font-weight:900; font-size:1.05rem; letter-spacing:-.02em; }
.rd-panel-head p { margin:4px 0 0; color:var(--rd-muted); font-size:.88rem; }
.rd-panel-head a { color:var(--rd-primary); font-weight:850; text-decoration:none; font-size:.86rem; }
.rd-form { display:grid; gap:16px; }
.rd-field { display:grid; gap:8px; }
.rd-field label { color:var(--rd-text); font-size:.82rem; font-weight:850; }
.rd-control { width:100%; border:1px solid var(--rd-border); background:var(--rd-surface); color:var(--rd-text); border-radius:14px; min-height:44px; padding:10px 12px; outline:none; transition:.18s ease; }
.rd-control:focus { border-color:rgba(13,110,253,.55); box-shadow:0 0 0 4px rgba(13,110,253,.10); }
.rd-control.is-invalid { border-color: rgba(220,38,38,.7); }
.rd-field-error { color:var(--rd-danger); font-size:.78rem; font-weight:700; }
.rd-summary-box, .rd-readonly-field { border:1px solid var(--rd-border); background:var(--rd-surface-2); border-radius:18px; padding:15px; display:grid; gap:5px; }
.rd-summary-box span, .rd-readonly-field span { color:var(--rd-muted); font-size:.76rem; font-weight:800; text-transform:uppercase; }
.rd-summary-box strong, .rd-readonly-field strong { font-size:1rem; }
.rd-form-grid { display:grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap:14px; }
.rd-table-wrap { overflow:auto; border-radius:18px; border:1px solid var(--rd-border); }
.rd-table { width:100%; border-collapse:separate; border-spacing:0; min-width:650px; }
.rd-table th { background:var(--rd-surface-2); color:var(--rd-muted); font-size:.75rem; text-transform:uppercase; letter-spacing:.05em; padding:13px 14px; }
.rd-table td { padding:13px 14px; border-top:1px solid var(--rd-border); font-size:.88rem; vertical-align:middle; }
.rd-table code { background:var(--rd-surface-2); color:var(--rd-primary); border-radius:8px; padding:4px 6px; }
.rd-pill, .rd-status { display:inline-flex; align-items:center; border-radius:999px; padding:5px 9px; background:rgba(13,110,253,.1); color:var(--rd-primary); font-weight:850; font-size:.75rem; }
.rd-balance-list, .rd-category-metrics, .rd-info-list { display:grid; gap:12px; }
.rd-balance-row, .rd-metric-line { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:14px; border:1px solid var(--rd-border); border-radius:18px; background:var(--rd-surface); }
.rd-balance-row span { display:block; color:var(--rd-muted); font-size:.78rem; }
.rd-balance-row b { font-size:1.25rem; }
.rd-category-metrics h3 { font-size:.82rem; text-transform:uppercase; letter-spacing:.06em; color:var(--rd-muted); margin:0; }
.rd-empty, .rd-empty-table { text-align:center; color:var(--rd-muted); padding:28px; }
.rd-empty { border:1px dashed var(--rd-border); border-radius:18px; display:grid; place-items:center; gap:6px; }
.rd-empty i { font-size:1.4rem; color:var(--rd-primary); }
.rd-empty strong { color:var(--rd-text); }
.rd-empty.slim { padding:14px; }
.rd-positive { color:var(--rd-success); font-weight:850; }
.rd-negative { color:var(--rd-danger); font-weight:850; }
.rd-info-list p { margin:0; color:var(--rd-muted); display:flex; gap:10px; align-items:flex-start; }
.rd-info-list i { color:var(--rd-success); }
.rd-toast { position: fixed; top: calc(var(--rd-header-height) + 18px); right: 24px; z-index: 9999; min-width:280px; max-width:420px; padding:14px 16px; border-radius:16px; background:var(--rd-text); color:#fff; box-shadow:var(--rd-shadow); transform:translateY(-10px); opacity:0; pointer-events:none; transition:.2s ease; font-weight:750; }
.rd-toast.show { opacity:1; transform:translateY(0); }
.rd-toast.success { background:var(--rd-success); }
.rd-toast.error { background:var(--rd-danger); }
.rd-footer { margin-left:var(--rd-sidebar-width); background:var(--rd-surface); border-top:1px solid var(--rd-border); padding:14px 34px; display:flex; justify-content:space-between; gap:16px; color:var(--rd-muted); font-size:.78rem; }

.auth-page, .auth-page label, .auth-page input, .auth-page select, .auth-page textarea, .auth-page button, .auth-page p, .auth-page a { font-size: .9rem; }
.auth-page h1, .auth-page h2, .auth-page h3, .auth-page h4 { font-size: 1.25rem; }
.auth-page .form-control-lg, .auth-page .form-select-lg, .auth-page .btn-lg { font-size: .9rem; padding: .7rem .9rem; }

@media (max-width: 1180px) { .rd-stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } .rd-grid-form-table { grid-template-columns:1fr; } }
@media (max-width: 992px) { :root { --rd-sidebar-width: 0px; } .rd-sidebar { position:relative; top:auto; width:auto; margin:86px 16px 0; border:1px solid var(--rd-border); border-radius:24px; } .rd-shell { padding-top:0; } .rd-main { margin-left:0; padding:18px; } .rd-grid-2, .rd-stat-grid { grid-template-columns:1fr; } .rd-topbar { flex-direction:column; } .rd-footer { margin-left:0; flex-direction:column; padding:14px 18px; } }
/* RBAC Admin Console */
.rbac-role-list { display: grid; gap: 12px; }
.rbac-role-item { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:14px 16px; border:1px solid var(--rd-border); border-radius:var(--rd-radius-md); background:var(--rd-surface-soft); }
.rbac-role-item strong { display:block; color:var(--rd-text); font-size:14px; }
.rbac-role-item span { display:block; color:var(--rd-muted); font-size:12px; margin-top:3px; }
.rbac-role-item code { color:var(--rd-primary); background:rgba(37,99,235,.08); padding:4px 8px; border-radius:999px; font-size:11px; }
.rbac-chip-list { display:flex; flex-wrap:wrap; gap:8px; }
.rbac-chip { display:inline-flex; align-items:center; padding:7px 10px; border-radius:999px; background:rgba(37,99,235,.08); color:var(--rd-primary); font-size:12px; font-weight:700; }
.rbac-permission-table td small { display:block; color:var(--rd-muted); margin-top:3px; }
.rbac-permission-table input[type="checkbox"] { width:18px; height:18px; accent-color:var(--rd-primary); }
.rd-link { color:var(--rd-primary); font-weight:700; text-decoration:none; }
.rd-link:hover { text-decoration:underline; }
.rd-pill { display:inline-flex; align-items:center; padding:5px 9px; border-radius:999px; background:var(--rd-surface-soft); color:var(--rd-text); font-size:11px; font-weight:800; letter-spacing:.03em; }
.mt-3 { margin-top: 1rem; } .mt-4 { margin-top: 1.5rem; }

/* RBAC session management refinements */
.rd-action-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.rd-action-row.compact { gap:8px; }
.rd-btn-danger { background:#dc2626; color:#fff; box-shadow:0 14px 30px rgba(220,38,38,.18); }
.rd-btn-sm { min-height:34px; padding:0 12px; border-radius:10px; font-size:.78rem; }
.rd-link.danger, button.rd-link.danger { color:#dc2626; border:0; background:transparent; padding:0; font:inherit; cursor:pointer; font-weight:800; }
.rd-link.danger:hover { text-decoration:underline; }

/* Developer module refinements */
.rd-checkbox-grid { display:grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap:10px; }
.rd-check { display:flex; align-items:center; gap:10px; border:1px solid var(--rd-border); background:var(--rd-surface); border-radius:14px; padding:12px; color:var(--rd-text); font-weight:800; font-size:.84rem; cursor:pointer; transition:.18s ease; }
.rd-check:hover { background:var(--rd-surface-2); transform:translateY(-1px); }
.rd-check input { width:17px; height:17px; accent-color:var(--rd-primary); }
.rd-table small { color:var(--rd-muted); }
.rd-summary-box small { color:var(--rd-muted); }
.rd-control[rows] { min-height:auto; resize:vertical; }
@media (max-width: 720px) { .rd-checkbox-grid, .rd-form-grid { grid-template-columns:1fr; } }

/* --------------------------------------------------------------------------
   Dashboard UI Refinement v3: modal-first workflows, responsive tables, polish
   -------------------------------------------------------------------------- */
:root {
    --rd-space-1: 4px;
    --rd-space-2: 8px;
    --rd-space-3: 12px;
    --rd-space-4: 16px;
    --rd-space-5: 20px;
    --rd-space-6: 24px;
    --rd-space-8: 32px;
    --rd-radius-md: 16px;
    --rd-radius-xl: 30px;
    --rd-ease: cubic-bezier(.2,.8,.2,1);
}

.rd-main { max-width: 1480px; }
.rd-topbar {
    border: 1px solid var(--rd-border);
    border-radius: var(--rd-radius-lg);
    background: linear-gradient(135deg, rgba(255,255,255,.9), rgba(238,245,255,.78));
    box-shadow: var(--rd-shadow-soft);
    padding: clamp(20px, 3vw, 32px);
    margin-bottom: 24px;
}
[data-theme="dark"] .rd-topbar { background: linear-gradient(135deg, rgba(15,27,45,.92), rgba(18,36,61,.78)); }
.rd-topbar h1 { letter-spacing: -.04em; line-height: 1; }
.rd-topbar p { max-width: 780px; }
.rd-actions { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.rd-btn {
    min-height: 42px;
    border-radius: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    font-weight: 800;
    transition: transform .18s var(--rd-ease), box-shadow .18s var(--rd-ease), background .18s var(--rd-ease);
}
.rd-btn:hover { transform: translateY(-1px); }
.rd-btn:disabled { opacity: .58; cursor: not-allowed; transform: none; }
.rd-btn-primary { background: linear-gradient(135deg, var(--rd-primary), var(--rd-primary-2)); color:#fff; box-shadow: 0 16px 30px rgba(13,110,253,.22); }
.rd-btn-ghost, .rd-btn-soft { background: var(--rd-surface); border-color: var(--rd-border); color: var(--rd-text); }
.rd-btn-ghost:hover, .rd-btn-soft:hover { background: var(--rd-surface-2); }
.rd-btn-loading { position: relative; pointer-events:none; }
.rd-btn-loading::before { content:""; width:15px; height:15px; border:2px solid currentColor; border-top-color:transparent; border-radius:50%; animation:rdSpin .7s linear infinite; }
@keyframes rdSpin { to { transform: rotate(360deg); } }

.rd-panel {
    border: 1px solid var(--rd-border);
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(18px);
    border-radius: var(--rd-radius-lg);
    box-shadow: var(--rd-shadow-soft);
    overflow: hidden;
}
[data-theme="dark"] .rd-panel { background: rgba(15,27,45,.88); }
.rd-panel-head { padding-bottom: 16px; border-bottom: 1px solid var(--rd-border); margin-bottom: 18px; }
.rd-panel-head h2 { letter-spacing: -.02em; }
.rd-panel-toolbar { display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; margin-bottom:16px; }
.rd-table-toolbar { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.rd-search { max-width: 320px; }
.rd-search .rd-control { min-height: 40px; }

.rd-modal .modal-content {
    border: 1px solid var(--rd-border);
    border-radius: 26px;
    background: var(--rd-surface);
    color: var(--rd-text);
    box-shadow: var(--rd-shadow);
    overflow: hidden;
}
.rd-modal .modal-header { border-bottom: 1px solid var(--rd-border); padding: 20px 24px; }
.rd-modal .modal-title { font-weight: 900; letter-spacing: -.03em; }
.rd-modal .modal-body { padding: 24px; }
.rd-modal .modal-footer { border-top: 1px solid var(--rd-border); padding: 18px 24px; background: var(--rd-surface-2); }
.rd-modal .btn-close { filter: none; }
[data-theme="dark"] .rd-modal .btn-close { filter: invert(1); }
.rd-modal-lead { color: var(--rd-muted); margin: 4px 0 0; font-size: .9rem; }
.rd-modal .rd-form { display:grid; gap:16px; }
.rd-form-grid { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.rd-form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rd-field { display:grid; gap:8px; }
.rd-field label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--rd-muted); font-weight: 900; }
.rd-control {
    border: 1px solid var(--rd-border);
    border-radius: 14px;
    background: var(--rd-surface);
    color: var(--rd-text);
    min-height: 46px;
    padding: 10px 13px;
    outline: none;
    transition: border .18s var(--rd-ease), box-shadow .18s var(--rd-ease), background .18s var(--rd-ease);
}
.rd-control:focus { border-color: rgba(13,110,253,.55); box-shadow: 0 0 0 4px rgba(13,110,253,.12); }
.rd-control.is-invalid { border-color: var(--rd-danger); box-shadow: 0 0 0 4px rgba(220,38,38,.1); }
.rd-field-error { color: var(--rd-danger); font-size: .78rem; font-weight: 800; }
.rd-form-help { color: var(--rd-muted); font-size:.82rem; }

.rd-table-wrap { overflow-x:auto; border-radius: 18px; border: 1px solid var(--rd-border); background: var(--rd-surface); }
.rd-table { min-width: 760px; margin:0; width:100%; border-collapse: separate; border-spacing:0; }
.rd-table th { position: sticky; top: 0; background: var(--rd-surface-2); color: var(--rd-muted); font-size:.72rem; text-transform:uppercase; letter-spacing:.08em; z-index:1; }
.rd-table th, .rd-table td { padding: 15px 16px; vertical-align: middle; border-bottom: 1px solid var(--rd-border); }
.rd-table tbody tr { transition: background .16s var(--rd-ease); }
.rd-table tbody tr:hover { background: rgba(13,110,253,.035); }
.rd-table tbody tr:last-child td { border-bottom:0; }
.rd-table code { background: rgba(13,110,253,.08); color: var(--rd-primary); border-radius: 10px; padding: 4px 7px; font-size:.82em; }
.rd-empty-table, .rd-empty { color: var(--rd-muted); }
.rd-empty-state { display:grid; place-items:center; gap:10px; min-height: 190px; text-align:center; color:var(--rd-muted); }
.rd-empty-state i { font-size: 2rem; color: var(--rd-primary); }
.rd-empty-state strong { color:var(--rd-text); font-size: 1rem; }
.rd-status { display:inline-flex; align-items:center; gap:6px; border-radius:999px; background: rgba(22,163,74,.1); color: var(--rd-success); font-size:.75rem; font-weight:900; padding:6px 10px; }
.rd-pill { white-space:nowrap; }

.rd-summary-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
.rd-summary-card { border:1px solid var(--rd-border); background:var(--rd-surface); border-radius:20px; padding:16px; }
.rd-summary-card span { color:var(--rd-muted); font-size:.76rem; font-weight:850; text-transform:uppercase; letter-spacing:.06em; display:block; }
.rd-summary-card strong { font-size:1.05rem; margin-top:6px; display:block; }

.rd-mobile-bar { display:none; position: sticky; top: calc(var(--rd-header-height) + 8px); z-index: 25; padding: 0 18px 12px; }
.rd-mobile-nav-toggle { width:100%; min-height:44px; }
.rd-sidebar-backdrop { display:none; }

@media (max-width: 992px) {
    .rd-mobile-bar { display:block; }
    .rd-shell { padding-top: var(--rd-header-height); }
    .rd-sidebar { position: fixed; top: var(--rd-header-height); left: 0; bottom: 0; width: min(86vw, 320px); margin: 0; border-radius: 0 24px 24px 0; transform: translateX(-105%); transition: transform .22s var(--rd-ease); z-index: 1040; }
    .rd-sidebar.is-open { transform: translateX(0); }
    .rd-sidebar-backdrop { display:block; position:fixed; inset:var(--rd-header-height) 0 0 0; background:rgba(2,6,23,.45); opacity:0; pointer-events:none; transition:.22s var(--rd-ease); z-index:1030; }
    .rd-sidebar-backdrop.is-open { opacity:1; pointer-events:auto; }
    .rd-main { padding: 18px; }
}
@media (max-width: 720px) {
    .rd-topbar { padding: 20px; }
    .rd-actions, .rd-action-row { width:100%; }
    .rd-actions .rd-btn, .rd-action-row .rd-btn { width:100%; }
    .rd-form-grid, .rd-form-grid.three, .rd-summary-grid { grid-template-columns:1fr; }
    .rd-modal .modal-dialog { margin: 10px; }
    .rd-table-wrap { border: 0; background: transparent; overflow: visible; }
    .rd-table { min-width: 0; border-collapse: collapse; }
    .rd-table thead { display:none; }
    .rd-table, .rd-table tbody, .rd-table tr, .rd-table td { display:block; width:100%; }
    .rd-table tr { background: var(--rd-surface); border:1px solid var(--rd-border); border-radius:18px; padding: 10px 12px; margin-bottom:12px; box-shadow: var(--rd-shadow-soft); }
    .rd-table td { border:0; display:flex; align-items:flex-start; justify-content:space-between; gap:14px; padding: 9px 0; text-align:right; }
    .rd-table td::before { content: attr(data-label); color:var(--rd-muted); font-weight:900; text-align:left; text-transform:uppercase; letter-spacing:.05em; font-size:.68rem; max-width:45%; }
    .rd-table td.rd-empty-table { display:block; text-align:center; }
    .rd-table td.rd-empty-table::before { display:none; }
}
.rd-stats-grid { display:grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap:16px; margin-bottom:24px; }
@media (max-width:1180px){ .rd-stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width:720px){ .rd-stats-grid { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------------------
   Modal overflow fix: keep actions visible and make modal body scrollable
   -------------------------------------------------------------------------- */
.rd-modal {
    --rd-modal-max-height: calc(100dvh - 32px);
}

.rd-modal .modal-dialog {
    max-height: var(--rd-modal-max-height);
    display: flex;
    align-items: center;
}

.rd-modal .modal-content {
    max-height: var(--rd-modal-max-height);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Many dashboard modals place modal-body and modal-footer inside the form.
   The form must also become a flex column so the body can scroll while the
   footer stays visible. */
.rd-modal .modal-content > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
}

.rd-modal .modal-header,
.rd-modal .modal-footer {
    flex: 0 0 auto;
}

.rd-modal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 28px;
}

.rd-modal .modal-footer {
    position: relative;
    z-index: 2;
    box-shadow: 0 -10px 24px rgba(15, 23, 42, .06);
}

[data-theme="dark"] .rd-modal .modal-footer {
    box-shadow: 0 -10px 24px rgba(0, 0, 0, .25);
}

/* Large permission tables inside modals should scroll inside the modal body,
   not push the submit button below the viewport. */
.rd-modal .modal-body .rd-table-wrap {
    max-height: min(58dvh, 560px);
    overflow: auto;
}

.rd-modal .modal-body::-webkit-scrollbar,
.rd-modal .modal-body .rd-table-wrap::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.rd-modal .modal-body::-webkit-scrollbar-thumb,
.rd-modal .modal-body .rd-table-wrap::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, .35);
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: padding-box;
}

@media (max-width: 720px) {
    .rd-modal {
        --rd-modal-max-height: calc(100dvh - 20px);
    }

    .rd-modal .modal-dialog {
        align-items: flex-start;
        margin: 10px;
    }

    .rd-modal .modal-content {
        border-radius: 22px;
    }

    .rd-modal .modal-header,
    .rd-modal .modal-body,
    .rd-modal .modal-footer {
        padding-left: 18px;
        padding-right: 18px;
    }

    .rd-modal .modal-footer {
        gap: 10px;
    }

    .rd-modal .modal-footer .rd-btn {
        flex: 1 1 auto;
    }
}

/* ---------- Action menu (dot / "Menu ›" button) ---------- */
.rd-action-cell { width: 1%; white-space: nowrap; text-align: center; }
.rd-dot-menu { position: relative; display: inline-block; }
.rd-dot-btn {
    /* auto-width so "Menu ›" text isn't clipped */
    width: auto; min-width: 34px; height: 34px;
    padding: 0 10px; border-radius: 10px;
    border: 1px solid var(--rd-border); background: var(--rd-surface);
    color: var(--rd-text); font-size: .84rem; line-height: 1;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    gap: 5px; transition: .15s ease; font-weight: 700; white-space: nowrap;
}
.rd-dot-btn:hover { background: var(--rd-surface-2); border-color: rgba(13,110,253,.35); color: var(--rd-primary); }
.rd-dot-btn[aria-expanded="true"] { background: var(--rd-surface-2); border-color: rgba(13,110,253,.35); color: var(--rd-primary); }
.rd-dot-dropdown {
    position: absolute; right: 0; top: calc(100% + 6px);
    min-width: 170px; background: var(--rd-surface);
    border: 1px solid var(--rd-border); border-radius: 14px;
    box-shadow: var(--rd-shadow); z-index: 9999;
    padding: 6px; display: none; flex-direction: column; gap: 2px;
}
.rd-dot-dropdown.is-open { display: flex; }
.rd-dot-item {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 12px; border-radius: 10px; border: 0;
    background: transparent; color: var(--rd-text);
    font-size: .84rem; font-weight: 600; cursor: pointer;
    text-align: left; width: 100%; transition: .15s ease;
    text-decoration: none;
}
.rd-dot-item:hover { background: var(--rd-surface-2); color: var(--rd-primary); }
.rd-dot-item--danger { color: #c0392b; }
.rd-dot-item--danger:hover { background: #fff5f5; color: #c0392b; }
.rd-dot-divider { height: 1px; background: var(--rd-border); margin: 4px 6px; }

/* ---------- PIN Success Modal ---------- */
.rd-success-pin-preview { background: var(--rd-surface-2); border: 1px solid var(--rd-border); border-radius: 16px; padding: 16px; }
.rd-success-pin-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; max-height: 340px; overflow-y: auto; }
.rd-success-pin-chip {
    background: var(--rd-surface); border: 1px solid var(--rd-border);
    border-radius: 12px; padding: 10px 12px;
    display: flex; flex-direction: column; gap: 4px;
}
.rd-success-pin-chip code { color: var(--rd-primary); font-weight: 900; font-size: .9rem; }
.rd-success-pin-chip small { color: var(--rd-muted); font-size: .72rem; }

/* ---------- Global Search ---------- */
.rd-global-search { margin-bottom: 16px; }
.rd-global-search-wrap { position: relative; display: flex; align-items: center; }
.rd-global-search-icon { position: absolute; left: 12px; color: var(--rd-muted); font-size: .85rem; pointer-events: none; }
.rd-global-search-input { padding-left: 34px !important; padding-right: 34px !important; min-height: 40px; border-radius: 14px; font-size: .85rem; }
.rd-global-search-clear { position: absolute; right: 10px; color: var(--rd-muted); cursor: pointer; display: flex; align-items: center; padding: 2px; border-radius: 50%; transition: .15s ease; }
.rd-global-search-clear:hover { color: var(--rd-text); background: var(--rd-surface-2); }
.rd-global-search-hint { font-size: .74rem; color: var(--rd-muted); margin-top: 5px; min-height: 14px; padding: 0 2px; }
/* Highlight matching text */
.rd-search-highlight { background: rgba(13,110,253,.18); color: var(--rd-primary); border-radius: 3px; font-weight: 900; padding: 0 2px; }
/* Rows hidden by global search */
tr[data-search-hidden] { display: none !important; }

/* ---------- Admin module refinement ---------- */
.admin-stats-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.admin-module-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.admin-module-card { display: grid; gap: 10px; min-height: 172px; padding: 22px; border: 1px solid var(--rd-border); border-radius: var(--rd-radius-lg); background: var(--rd-surface); color: var(--rd-text); text-decoration: none; box-shadow: var(--rd-shadow-soft); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.admin-module-card:hover { transform: translateY(-3px); box-shadow: var(--rd-shadow); border-color: rgba(13,110,253,.32); }
.admin-module-card i { width: 44px; height: 44px; border-radius: 16px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--rd-primary), var(--rd-primary-2)); box-shadow: 0 14px 30px rgba(13,110,253,.22); font-size: 1.25rem; }
.admin-module-card strong { font-size: 1rem; letter-spacing: -.02em; }
.admin-module-card span { color: var(--rd-muted); font-size: .88rem; line-height: 1.45; }
.admin-tool-list { display: grid; gap: 12px; }
.admin-tool-list a { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--rd-border); background: var(--rd-surface-2); color: var(--rd-text); border-radius: 18px; text-decoration: none; transition: .18s ease; }
.admin-tool-list a:hover { transform: translateX(3px); border-color: rgba(13,110,253,.28); }
.admin-tool-list i { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 14px; background: rgba(13,110,253,.11); color: var(--rd-primary); }
.admin-tool-list strong { display: block; }
.admin-tool-list small { display: block; color: var(--rd-muted); margin-top: 2px; }
.rd-filter-bar { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) minmax(160px, 220px) auto auto; gap: 12px; align-items: center; }
.rd-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 18px; flex-wrap: wrap; }
.rd-page-numbers { display: flex; gap: 6px; flex-wrap: wrap; }
.rd-page-link, .rd-page-number { min-width: 38px; min-height: 38px; display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; border: 1px solid var(--rd-border); border-radius: 12px; color: var(--rd-text); text-decoration: none; font-weight: 800; background: var(--rd-surface); transition: .18s ease; }
.rd-page-link:hover, .rd-page-number:hover { border-color: rgba(13,110,253,.32); color: var(--rd-primary); transform: translateY(-1px); }
.rd-page-number.active { background: linear-gradient(135deg, var(--rd-primary), var(--rd-primary-2)); color: #fff; border-color: transparent; box-shadow: 0 12px 24px rgba(13,110,253,.22); }
.rd-page-link.disabled { pointer-events: none; opacity: .45; }
.rd-pagination-meta { text-align: right; color: var(--rd-muted); font-size: .84rem; margin-top: 8px; }
.rd-pill.success { background: rgba(22,163,74,.12); color: var(--rd-success); }
.rd-pill.warning { background: rgba(217,119,6,.12); color: var(--rd-warning); }
.rd-check-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.rd-check { display: flex !important; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--rd-border); border-radius: 14px; background: var(--rd-surface-2); text-transform: none !important; letter-spacing: 0 !important; color: var(--rd-text) !important; }

@media (max-width: 1280px) {
    .admin-stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .admin-module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
    .admin-stats-grid, .admin-module-grid { grid-template-columns: 1fr; }
    .rd-filter-bar { grid-template-columns: 1fr; }
    .rd-pagination { justify-content: flex-start; }
    .rd-pagination-meta { text-align: left; }
    .rd-check-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
    .rd-check-grid { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------------------
   Dashboard layout alignment and background correction
   Fixes: content shifted too far left on large screens, dashboard footer
   alignment, and overly black dark-mode surfaces.
   -------------------------------------------------------------------------- */
:root {
    --rd-dashboard-max-width: 1480px;
}

/* Keep dark mode within the brand direction without turning the dashboard
   into a flat black canvas. */
[data-theme="dark"] {
    --rd-bg: #101f35;
    --rd-surface: #14243a;
    --rd-surface-2: #1a304d;
    --rd-text: #eef5ff;
    --rd-muted: #b3c0d4;
    --rd-border: rgba(191, 219, 254, .16);
}

body {
    min-height: 100vh;
    background: var(--rd-bg) !important;
}

.rd-shell {
    width: 100%;
    min-height: calc(100vh - var(--rd-header-height));
    background:
        radial-gradient(circle at top right, rgba(13,110,253,.13), transparent 30rem),
        linear-gradient(180deg, rgba(255,255,255,.72), rgba(245,248,255,.96)),
        var(--rd-bg) !important;
}

[data-theme="dark"] .rd-shell {
    background:
        radial-gradient(circle at top right, rgba(79,140,255,.22), transparent 30rem),
        linear-gradient(180deg, rgba(16,31,53,.96), rgba(10,23,40,.98)),
        var(--rd-bg) !important;
}

/* Center the dashboard content inside the space that remains after the fixed
   sidebar instead of letting the content hug the sidebar on wide screens. */
.rd-main {
    box-sizing: border-box;
    width: min(var(--rd-dashboard-max-width), calc(100vw - var(--rd-sidebar-width)));
    max-width: var(--rd-dashboard-max-width);
    margin-left: calc(
        var(--rd-sidebar-width) +
        max(0px, (100vw - var(--rd-sidebar-width) - var(--rd-dashboard-max-width)) / 2)
    ) !important;
    margin-right: auto !important;
    padding: clamp(22px, 2.4vw, 38px);
}

.rd-topbar {
    align-items: center;
}

.rd-topbar > div:first-child {
    min-width: 0;
}

.rd-topbar h1,
.rd-topbar p {
    text-align: left;
}

.rd-action-row,
.rd-actions {
    justify-content: flex-end;
}

.rd-stat-card,
.rd-summary-card,
.admin-module-card {
    text-align: left;
}

/* Dashboard footer should align with the dashboard content area, not with the
   public website footer. */
.dashboard-footer {
    box-sizing: border-box;
    width: min(var(--rd-dashboard-max-width), calc(100vw - var(--rd-sidebar-width)));
    max-width: var(--rd-dashboard-max-width);
    margin-left: calc(
        var(--rd-sidebar-width) +
        max(0px, (100vw - var(--rd-sidebar-width) - var(--rd-dashboard-max-width)) / 2)
    ) !important;
    margin-right: auto !important;
    background: var(--rd-surface);
    border-top: 1px solid var(--rd-border);
    color: var(--rd-muted);
    padding: 14px clamp(22px, 2.4vw, 38px);
    font-size: .78rem;
}

.dashboard-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
}

@media (max-width: 992px) {
    .rd-main,
    .dashboard-footer {
        width: 100%;
        max-width: none;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 18px;
        padding-right: 18px;
    }

    .rd-topbar {
        align-items: flex-start;
    }

    .rd-action-row,
    .rd-actions {
        justify-content: flex-start;
    }

    .dashboard-footer-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}

@media (max-width: 720px) {
    .rd-topbar h1,
    .rd-topbar p {
        text-align: left;
    }

    .rd-topbar {
        border-radius: 22px;
    }
}

/* Admin RBAC and user management refinements */
.rd-rbac-layout { display:grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap:24px; align-items:start; }
.rd-role-browser { position:sticky; top:calc(var(--rd-header-height) + 24px); max-height:calc(100vh - var(--rd-header-height) - 48px); overflow:auto; }
.rd-role-list { display:grid; gap:10px; }
.rd-role-card { width:100%; border:1px solid var(--rd-border); background:var(--rd-surface); color:var(--rd-text); border-radius:16px; padding:14px; display:flex; align-items:center; justify-content:space-between; gap:16px; text-align:left; transition:.18s ease; }
.rd-role-card:hover { transform:translateY(-1px); border-color:rgba(13,110,253,.35); box-shadow:var(--rd-shadow-soft); }
.rd-role-card.active { background:linear-gradient(135deg, rgba(13,110,253,.12), rgba(77,163,255,.08)); border-color:rgba(13,110,253,.55); }
.rd-role-card strong { display:block; font-size:.92rem; font-weight:900; }
.rd-role-card small { display:block; color:var(--rd-muted); margin-top:4px; overflow-wrap:anywhere; }
.rd-role-card em { min-width:34px; height:34px; border-radius:999px; display:grid; place-items:center; background:var(--rd-primary); color:#fff; font-style:normal; font-size:.78rem; font-weight:900; }
.rd-text-wrap, .rd-table td, .rd-table small { overflow-wrap:anywhere; word-break:break-word; }
.rd-muted-text { color:var(--rd-muted); font-size:.82rem; font-weight:800; }
.rd-role-chips, .rd-chip-list { display:flex; flex-wrap:wrap; gap:6px; max-width:360px; }
.rd-role-checkbox-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.rd-role-check { align-items:flex-start; }
.rd-role-check span { display:grid; gap:3px; }
.rd-role-check small { color:var(--rd-muted); overflow-wrap:anywhere; }
.rd-role-permission-note { border:1px solid var(--rd-border); border-radius:16px; padding:14px; background:var(--rd-surface-2); display:grid; gap:4px; }
.rd-role-permission-note span { color:var(--rd-muted); font-size:.86rem; overflow-wrap:anywhere; }
.rd-detail-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.rd-detail-grid > div { border:1px solid var(--rd-border); border-radius:16px; padding:14px; background:var(--rd-surface-2); min-width:0; }
.rd-detail-grid span { display:block; color:var(--rd-muted); font-size:.74rem; text-transform:uppercase; letter-spacing:.06em; font-weight:900; margin-bottom:5px; }
.rd-detail-grid strong { display:block; color:var(--rd-text); overflow-wrap:anywhere; }
.rd-pill.success, .rd-status.success { background:rgba(22,163,74,.12); color:#16a34a; }
.rd-pill.warning, .rd-status.warning { background:rgba(245,158,11,.13); color:#b45309; }
.rd-table .rd-action-row { min-width:max-content; }
@media (max-width: 1100px) { .rd-rbac-layout { grid-template-columns:1fr; } .rd-role-browser { position:relative; top:auto; max-height:none; } }
@media (max-width: 720px) { .rd-role-checkbox-list, .rd-detail-grid { grid-template-columns:1fr; } .rd-role-chips { max-width:100%; } }

/* Table overflow and permission switch refinements */
.rd-table-fixed { table-layout: fixed; width: 100%; }
.rd-table td, .rd-table th { vertical-align: top; }
.rd-text-wrap, .rd-table td { overflow-wrap: anywhere; word-break: break-word; }
.rd-user-table th:nth-child(1), .rd-user-table td:nth-child(1) { min-width: 180px; }
.rd-user-table th:nth-child(2), .rd-user-table td:nth-child(2) { min-width: 220px; }
.rd-user-table th:nth-child(4), .rd-user-table td:nth-child(4) { min-width: 220px; }
.rd-chip-list { display: flex; flex-wrap: wrap; gap: 6px; max-width: 100%; }
.rd-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.rd-switch input { position: absolute; opacity: 0; pointer-events: none; }
.rd-switch span { width: 42px; height: 24px; border-radius: 999px; background: #cbd5e1; position: relative; transition: background .2s ease; flex: 0 0 auto; }
.rd-switch span::after { content: ''; width: 18px; height: 18px; border-radius: 50%; background: #fff; position: absolute; top: 3px; left: 3px; box-shadow: 0 2px 5px rgba(15,23,42,.25); transition: transform .2s ease; }
.rd-switch input:checked + span { background: var(--td-primary, #2563eb); }
.rd-switch input:checked + span::after { transform: translateX(18px); }
.rd-switch em { font-style: normal; font-size: 12px; color: var(--td-muted, #64748b); font-weight: 700; }
.rd-filter-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.rd-filter-bar .rd-btn { min-height: 42px; justify-content: center; }
@media (max-width: 768px) {
  .rd-filter-bar { grid-template-columns: 1fr; }
  .rd-user-table td, .rd-user-table th { white-space: normal; }
}

/* ==========================================================================
   Settings Page – Section dividers, repeatable DnD lists, logo upload zone
   ========================================================================== */

/* Section header row: label + action button side-by-side */
.rd-section-divider {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0 10px;
    border-top: 1px solid var(--rd-border);
    margin-top: 8px;
}
.rd-section-divider:first-child { border-top: 0; margin-top: 0; }
.rd-section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .88rem;
    font-weight: 900;
    color: var(--rd-text);
    letter-spacing: -.01em;
    margin: 0;
}
.rd-section-label i { color: var(--rd-primary); }

/* ── Repeatable list container ── */
.rd-repeatable-list {
    display: grid;
    gap: 8px;
}

/* ── A single draggable row ── */
.rd-repeat-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: var(--rd-surface);
    border: 1px solid var(--rd-border);
    border-radius: 16px;
    transition: box-shadow .18s ease, border-color .18s ease, opacity .18s ease;
    position: relative;
}
.rd-repeat-item:hover { border-color: rgba(13,110,253,.28); }

/* dragging state */
.rd-repeat-item.rd-dragging {
    opacity: .45;
    box-shadow: none;
    border-style: dashed;
}
/* drag-over drop target */
.rd-repeat-item.rd-drag-over {
    border-color: var(--rd-primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,.14);
}

/* ── Drag handle ── */
.rd-drag-handle {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 44px;
    color: var(--rd-muted);
    cursor: grab;
    font-size: 1.1rem;
    border-radius: 8px;
    transition: color .15s ease, background .15s ease;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}
.rd-drag-handle:hover { color: var(--rd-primary); background: rgba(13,110,253,.06); }
.rd-drag-handle:active { cursor: grabbing; }

/* ── Field area inside each row ── */
.rd-repeat-fields {
    flex: 1 1 auto;
    min-width: 0;
}

/* ── Remove button ── */
.rd-remove-row {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--rd-border);
    background: transparent;
    color: var(--rd-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: .9rem;
    transition: .15s ease;
    align-self: center;
}
.rd-remove-row:hover {
    background: rgba(220,38,38,.08);
    border-color: rgba(220,38,38,.35);
    color: var(--rd-danger);
}

/* empty-list placeholder shown when all rows removed */
.rd-repeat-empty {
    text-align: center;
    padding: 20px;
    border: 1px dashed var(--rd-border);
    border-radius: 14px;
    color: var(--rd-muted);
    font-size: .84rem;
    display: none;
}
.rd-repeatable-list:empty + .rd-repeat-empty,
.rd-repeatable-list[data-empty] + .rd-repeat-empty { display: block; }

/* ── Logo / file upload drop zone ── */
.rd-upload-zone {
    display: block;
    position: relative;
    border: 2px dashed var(--rd-border);
    border-radius: 20px;
    background: var(--rd-surface);
    cursor: pointer;
    overflow: hidden;
    transition: border-color .2s ease, background .2s ease;
    min-height: 140px;
}
.rd-upload-zone:hover,
.rd-upload-zone.rd-drag-active {
    border-color: var(--rd-primary);
    background: rgba(13,110,253,.04);
}
.rd-upload-zone.rd-drag-active { box-shadow: 0 0 0 4px rgba(13,110,253,.12); }

/* visually hidden native input */
.rd-upload-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
}

/* inner content wrapper */
.rd-upload-zone-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    padding: 20px;
}

/* placeholder (no image yet) */
.rd-upload-zone-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    color: var(--rd-muted);
    pointer-events: none;
}
.rd-upload-zone-placeholder i {
    font-size: 2.2rem;
    color: var(--rd-primary);
    opacity: .7;
}
.rd-upload-zone-placeholder strong { color: var(--rd-text); font-size: .9rem; }
.rd-upload-zone-placeholder span { font-size: .82rem; }
.rd-upload-zone-placeholder small { font-size: .74rem; color: var(--rd-muted); margin-top: 2px; }

/* existing image preview */
.rd-upload-preview {
    max-height: 120px;
    max-width: 100%;
    object-fit: contain;
    border-radius: 10px;
    display: block;
}

/* overlay on top of existing image */
.rd-upload-zone-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: rgba(0,0,0,.52);
    color: #fff;
    opacity: 0;
    transition: opacity .2s ease;
    border-radius: 18px;
    pointer-events: none;
    font-size: .84rem;
    text-align: center;
}
.rd-upload-zone-overlay i { font-size: 1.6rem; }
.rd-upload-zone:hover .rd-upload-zone-overlay,
.rd-upload-zone.rd-drag-active .rd-upload-zone-overlay { opacity: 1; }

/* selected file name badge */
.rd-upload-zone-selected {
    text-align: center;
    padding: 8px 14px;
    font-size: .8rem;
    font-weight: 800;
    color: var(--rd-primary);
    background: rgba(13,110,253,.07);
    border-top: 1px solid var(--rd-border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

/* ── Responsive tweaks ── */
@media (max-width: 640px) {
    .rd-repeat-item { flex-wrap: wrap; }
    .rd-drag-handle { height: 36px; }
    .rd-remove-row  { align-self: flex-start; margin-top: 4px; }
}

/* ==========================================================================
   Pagination Bar – page-size selector + nav row
   ========================================================================== */
.rd-pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 18px;
}
.rd-page-size-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}
.rd-page-size-label {
    font-size: .82rem;
    color: var(--rd-muted);
    white-space: nowrap;
    font-weight: 700;
}
.rd-page-size-select {
    min-height: 36px !important;
    padding: 0 10px !important;
    font-size: .82rem !important;
    width: auto !important;
    min-width: 72px;
    border-radius: 10px !important;
}
@media (max-width: 640px) {
    .rd-pagination-bar { flex-direction: column; align-items: flex-start; }
    .rd-pagination { justify-content: flex-start; }
}

/* ==========================================================================
   Search-only filter bar variant
   ========================================================================== */
.rd-filter-bar--search-only {
    grid-template-columns: 1fr auto auto auto !important;
    align-items: center;
}
.rd-search-input { flex: 1; }
@media (max-width: 640px) {
    .rd-filter-bar--search-only { grid-template-columns: 1fr !important; }
}

/* ==========================================================================
   Export Transactions button – styled green accent
   ========================================================================== */
.rd-btn-export {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: #fff !important;
    border: 0;
    box-shadow: 0 8px 20px rgba(22,163,74,.22);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 14px;
    font-weight: 900;
    font-size: .88rem;
    cursor: pointer;
    transition: .18s ease;
}
.rd-btn-export:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(22,163,74,.30);
    color: #fff !important;
}

/* ==========================================================================
   App Customisation – compact upload-zone variant (--sm)
   ========================================================================== */
.rd-upload-zone--sm {
    min-height: 120px;
    border-radius: 14px;
}
.rd-upload-zone--sm .rd-upload-zone-inner {
    min-height: 110px;
}
.rd-upload-zone--sm .rd-upload-zone-placeholder i {
    font-size: 1.6rem;
}
.rd-upload-zone--sm .rd-upload-zone-placeholder strong { font-size: .82rem; }
.rd-upload-zone--sm .rd-upload-zone-placeholder span  { font-size: .76rem; }
.rd-upload-zone--sm .rd-upload-zone-placeholder small { font-size: .7rem; }

/* ==========================================================================
   Bank Account add-button disabled state
   ========================================================================== */
[data-add-row].rd-add-disabled {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(.6);
}

/* ==========================================================================
   Number formatting helpers
   ========================================================================== */
.rd-positive { color: var(--rd-success, #16a34a); font-weight: 800; }
.rd-negative { color: #dc2626; font-weight: 800; }

/* ==========================================================================
   Detail List — clean key/value rows for all detail modals
   ========================================================================== */
.rd-detail-list { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:0; }
.rd-detail-row { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; padding:12px 0; border-bottom:1px solid var(--rd-border); }
.rd-detail-row:last-child { border-bottom:none; padding-bottom:0; }
.rd-detail-row:first-child { padding-top:0; }
.rd-detail-label { font-size:.75rem; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--rd-muted); white-space:nowrap; min-width:110px; padding-top:2px; flex-shrink:0; }
.rd-detail-value { font-size:.92rem; font-weight:600; color:var(--rd-text, #1e293b); text-align:right; word-break:break-all; flex:1; }
.rd-detail-value code { font-family:ui-monospace,monospace; font-size:.85rem; background:var(--rd-surface-2); padding:3px 7px; border-radius:6px; word-break:break-all; }
.rd-detail-value .rd-pill { font-size:.72rem; }
.rd-detail-section { font-size:.72rem; font-weight:700; text-transform:uppercase; letter-spacing:.07em; color:var(--rd-primary); margin:16px 0 4px; display:flex; align-items:center; gap:6px; }
.rd-detail-section:first-child { margin-top:0; }

/* Modal header badge strip */
.rd-modal-badge-strip { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }

/* Icon-only action button */
.rd-icon-btn { display:inline-flex; align-items:center; justify-content:center; width:30px; height:30px; border:1px solid var(--rd-border); border-radius:8px; background:none; cursor:pointer; color:var(--rd-muted); font-size:.95rem; flex-shrink:0; transition:background .15s,color .15s,border-color .15s; padding:0; }
.rd-icon-btn:hover { background:var(--rd-primary); color:#fff; border-color:var(--rd-primary); }
.rd-action-cell { white-space:nowrap; width:1%; }

/* Settings full-width overrides */
.rd-settings-stack { display:flex; flex-direction:column; gap:18px; }
.rd-api-key-wrap { display:flex; align-items:center; gap:10px; }
.rd-api-key-mask { font-family:ui-monospace,monospace; font-size:.85rem; letter-spacing:.12em; color:var(--rd-muted); flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.rd-api-key-real { font-family:ui-monospace,monospace; font-size:.78rem; word-break:break-all; flex:1; }
.rd-reveal-form { display:flex; gap:8px; margin-top:10px; align-items:center; flex-wrap:wrap; }
.rd-reveal-form input { flex:1; min-width:0; }
.rd-settings-row { display:grid; grid-template-columns:1fr 1fr 1fr; gap:18px; }
@media(max-width:768px) { .rd-settings-row { grid-template-columns:1fr; } }

/* ==========================================================================
   Blog Form – section dividers, slug toggle, tags, image preview, SEO counters
   ========================================================================== */
.rd-form-section { margin: 6px 0 -4px; padding-top: 14px; border-top: 1px solid var(--rd-border); }
.rd-form-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.rd-form-section h6 { display:flex; align-items:center; gap:8px; margin:0 0 2px; font-size:.88rem; font-weight:900; color:var(--rd-text); }
.rd-form-section h6 i { color: var(--rd-primary); }

.rd-input-group { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.rd-input-group .rd-control { flex:1; min-width:160px; }
.rd-checkbox-inline { display:flex; align-items:center; gap:6px; font-size:.78rem; font-weight:700; color:var(--rd-muted); white-space:nowrap; cursor:pointer; }
.rd-checkbox-inline input { width:auto; min-height:auto; }

.rd-tag-suggestions { display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; }
.rd-tag-chip { border:1px solid var(--rd-border); background:var(--rd-surface-2); color:var(--rd-muted); border-radius:999px; padding:4px 10px; font-size:.74rem; font-weight:800; cursor:pointer; transition:.15s ease; }
.rd-tag-chip:hover { border-color:var(--rd-primary); color:var(--rd-primary); background:rgba(13,110,253,.06); }

.rd-image-preview { margin-top:8px; width:100%; max-width:280px; height:120px; border-radius:14px; border:1px solid var(--rd-border); background-color:var(--rd-surface-2); background-size:cover; background-position:center; background-repeat:no-repeat; }

.rd-char-counter { float:right; font-weight:700; color:var(--rd-muted); }
.rd-char-counter.rd-char-over { color: var(--rd-danger); }

.rd-pill.info, .rd-status.info { background:rgba(13,110,253,.12); color:var(--rd-primary); }

/* TinyMCE inside modals: keep the toolbar usable on small screens */
.rd-richtext-wrap .tox-tinymce { border-radius: 14px; border-color: var(--rd-border); }
.rd-modal .tox-tinymce-aux { z-index: 1080; }

/* ==========================================================================
   Blog Preview Modal
   ========================================================================== */
.rd-blog-preview-image { width:100%; height:220px; border-radius:16px; background-color:var(--rd-surface-2); background-size:cover; background-position:center; background-repeat:no-repeat; margin-bottom:14px; }
.rd-blog-preview-title { margin:4px 0 8px; font-weight:900; }
.rd-blog-preview-excerpt { color:var(--rd-muted); font-weight:700; }
.rd-blog-preview-content { line-height:1.7; }
.rd-blog-preview-content img { max-width:100%; border-radius:10px; }
.rd-blog-preview-content table { width:100%; border-collapse:collapse; }
.rd-blog-preview-content table, .rd-blog-preview-content th, .rd-blog-preview-content td { border:1px solid var(--rd-border); padding:6px 10px; }

.rd-seo-card { border:1px solid var(--rd-border); border-radius:14px; padding:14px; background:var(--rd-surface-2); }
.rd-seo-title { color:#1a0dab; font-size:1.05rem; font-weight:700; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.rd-seo-desc { color:var(--rd-muted); font-size:.86rem; margin-top:4px; }
