/* ============================================================
   Myelaplex ERP — Main Stylesheet
   Theme: Dark Navy Glassmorphism
   Brand Cyan:  #33b9cd  |  Brand Navy: #102a6e
   ============================================================ */

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

:root {
    --bg-base:          #030814;
    --bg-surface:       #060f25;
    --sidebar-bg:       rgba(3, 8, 22, 0.95);
    --sidebar-width:    260px;
    --topbar-h:         64px;

    --navy-1:           #0d1b4b;
    --navy-2:           #102a6e;
    --blue-1:           #2b54b8;
    --blue-2:           #23489f;

    --cyan-1:           #d7f7fa;
    --cyan-2:           #7fd9e4;
    --cyan-3:           #33b9cd;
    --cyan-4:           #0fa6bd;
    --cyan-5:           #0e7c92;

    --glass-bg:         rgba(8, 18, 55, 0.60);
    --glass-border:     rgba(51, 185, 205, 0.16);
    --glass-hover:      rgba(8, 18, 55, 0.85);

    --text-primary:     #e4f2f7;
    --text-secondary:   #7fd9e4;
    --text-muted:       rgba(228, 242, 247, 0.42);

    --success:          #27ae60;
    --warning:          #e67e22;
    --danger:           #e74c3c;
    --info:             #33b9cd;

    --shadow:           0 8px 32px rgba(0,0,0,0.45);
    --shadow-lg:        0 16px 48px rgba(0,0,0,0.6);
    --glow-cyan:        0 0 28px rgba(51,185,205,0.30);
    --glow-blue:        0 0 28px rgba(43,84,184,0.30);

    --radius:           12px;
    --radius-sm:        8px;
    --radius-lg:        18px;
    --transition:       all 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================================================================
   LIGHT MODE OVERRIDES  (applied via <html data-theme="light">)
   Sidebar stays dark — only content area lightens.
   ================================================================ */
[data-theme="light"] {
    --bg-base:        #f0f4f8;
    --bg-surface:     #e4eaf4;
    --glass-bg:       rgba(255,255,255,0.92);
    --glass-border:   rgba(51,185,205,0.22);
    --glass-hover:    rgba(255,255,255,1);
    --text-primary:   #0d1b3e;
    --text-secondary: #1a3a7a;
    --text-muted:     rgba(13,27,62,0.48);
    --shadow:         0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg:      0 12px 40px rgba(0,0,0,0.13);
    --glow-cyan:      0 0 24px rgba(51,185,205,0.18);
    --sidebar-bg:     #dce5f0;
}
[data-theme="light"] body::before {
    background:
        radial-gradient(ellipse 70% 55% at 8% 15%,  rgba(51,185,205,0.07) 0%, transparent 60%),
        radial-gradient(ellipse 55% 40% at 92% 85%,  rgba(43,84,184,0.05) 0%, transparent 55%),
        linear-gradient(160deg, #f0f4f8 0%, #e8edf5 50%, #f0f4f8 100%);
}
[data-theme="light"] .topbar {
    background: rgba(228,234,244,0.95);
    border-bottom-color: rgba(51,185,205,0.18);
    color: #0d1b3e;
}
[data-theme="light"] thead th {
    background: rgba(220,228,240,0.60);
    color: rgba(13,27,62,0.55);
    border-bottom-color: rgba(51,185,205,0.14);
}
[data-theme="light"] tbody td { border-bottom-color: rgba(51,185,205,0.08); }
[data-theme="light"] tbody tr:hover td { background: rgba(51,185,205,0.06); }
[data-theme="light"] .form-control {
    background: #fff;
    border-color: rgba(13,27,62,0.18);
    color: #0d1b3e;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}
[data-theme="light"] .form-control:focus {
    background: #fff;
    border-color: var(--cyan-3);
    box-shadow: 0 0 0 3px rgba(51,185,205,0.12);
}
[data-theme="light"] .form-control::placeholder { color: rgba(13,27,62,0.35); }
[data-theme="light"] select.form-control option { background: #fff; color: #0d1b3e; }
[data-theme="light"] .search-input-wrap {
    background: rgba(255,255,255,0.90);
    border-color: rgba(51,185,205,0.22);
}
[data-theme="light"] .search-input-wrap input { color: #0d1b3e; }
[data-theme="light"] .search-input-wrap input::placeholder { color: rgba(13,27,62,0.35); }
[data-theme="light"] .btn-secondary {
    background: rgba(255,255,255,0.85);
    color: #1a3a7a;
    border-color: rgba(51,185,205,0.25);
}
[data-theme="light"] .btn-ghost:hover { background: rgba(0,0,0,0.04); }
[data-theme="light"] .divider { background: rgba(51,185,205,0.12); }
[data-theme="light"] .stat-row { border-bottom-color: rgba(51,185,205,0.10); }
[data-theme="light"] .card-header { border-bottom-color: rgba(51,185,205,0.12); }
[data-theme="light"] .topbar-toggle,
[data-theme="light"] .icon-btn {
    background: rgba(255,255,255,0.85);
    border-color: rgba(51,185,205,0.22);
    color: #1a3a7a;
}
[data-theme="light"] .notif-dot { border-color: var(--bg-base); }
[data-theme="light"] .topbar-divider { background: rgba(51,185,205,0.15); }
[data-theme="light"] .tabs { border-bottom-color: rgba(51,185,205,0.14); }
[data-theme="light"] .tab { color: rgba(13,27,62,0.50); }
[data-theme="light"] .tab:hover { color: #0d1b3e; }

/* Light mode sidebar */
[data-theme="light"] .sidebar { background: var(--sidebar-bg); border-right-color: rgba(51,185,205,0.18); color: #0d1b3e; }
[data-theme="light"] .nav-section-label { color: rgba(13,27,62,0.42); }
[data-theme="light"] .nav-item { color: rgba(13,27,62,0.72); }
[data-theme="light"] .nav-item:hover { background: rgba(51,185,205,0.12); color: #0d1b3e; }
[data-theme="light"] .nav-item.active { background: linear-gradient(90deg, rgba(51,185,205,0.18), rgba(51,185,205,0.06)); color: #0a6d7c; }
[data-theme="light"] .nav-item.active::before { background: var(--cyan-3); }
[data-theme="light"] .nav-sub-item { color: rgba(13,27,62,0.60); }
[data-theme="light"] .nav-sub-item:hover { color: #0d1b3e; background: rgba(51,185,205,0.09); border-left-color: rgba(51,185,205,0.4); }
[data-theme="light"] .nav-sub-item.active { color: #0a6d7c; border-left-color: var(--cyan-3); background: rgba(51,185,205,0.10); }
[data-theme="light"] .sidebar-footer { border-top-color: rgba(13,27,62,0.10); }
[data-theme="light"] .sidebar-user-name { color: #0d1b3e; }
[data-theme="light"] .sidebar-user-role { color: rgba(13,27,62,0.48); }
[data-theme="light"] .sidebar-user-avatar { background: rgba(51,185,205,0.15); color: var(--cyan-3); }
[data-theme="light"] .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(13,27,62,0.15); }
[data-theme="light"] .sidebar-logo-text { background: linear-gradient(135deg, #0a8fa3 0%, var(--cyan-3) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg-base); color: var(--text-primary); font-size: 14px; line-height: 1.5; overflow: hidden; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(51,185,205,0.25); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(51,185,205,0.5); }

/* ── Animated background ── */
body::before {
    content: '';
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(ellipse 70% 55% at 8% 15%,  rgba(43,84,184,0.20)  0%, transparent 60%),
        radial-gradient(ellipse 55% 40% at 92% 85%,  rgba(51,185,205,0.13) 0%, transparent 55%),
        radial-gradient(ellipse 45% 35% at 55% 50%,  rgba(16,42,110,0.12)  0%, transparent 60%),
        linear-gradient(160deg, #030814 0%, #050d22 50%, #030814 100%);
}

/* ── App shell ── */
#app { position: relative; z-index: 1; display: flex; height: 100vh; overflow: hidden; }

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    display: flex; flex-direction: column;
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(51,185,205,0.10);
    backdrop-filter: blur(24px);
    flex-shrink: 0;
    transition: width 0.28s cubic-bezier(0.4,0,0.2,1);
    z-index: 100;
    overflow: hidden;
}

/* Logo area */
.sidebar-logo {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 16px 16px;
    border-bottom: 1px solid rgba(51,185,205,0.10);
    flex-shrink: 0;
    min-height: 68px;
}
.sidebar-logo img { width: 38px; height: 38px; flex-shrink: 0; }
.sidebar-logo-text {
    font-size: 17px; font-weight: 800; letter-spacing: 0.10em;
    background: linear-gradient(135deg, var(--cyan-2) 0%, var(--cyan-3) 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    white-space: nowrap; overflow: hidden;
}

/* Nav */
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 0; }

.nav-section-label {
    font-size: 10px; font-weight: 700; letter-spacing: 0.14em;
    text-transform: uppercase; color: var(--text-muted);
    padding: 14px 20px 5px; white-space: nowrap; overflow: hidden;
}

.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 14px; margin: 2px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: rgba(228,242,247,0.65);
    font-size: 13.5px; font-weight: 500;
    transition: var(--transition);
    position: relative; user-select: none;
    white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: rgba(51,185,205,0.08); color: var(--text-primary); }
.nav-item.active {
    background: linear-gradient(90deg, rgba(51,185,205,0.14), rgba(51,185,205,0.05));
    color: var(--cyan-3);
}
.nav-item.active::before {
    content: ''; position: absolute; left: 0; top: 18%; bottom: 18%;
    width: 3px; background: linear-gradient(180deg, var(--cyan-3), var(--cyan-4));
    border-radius: 0 3px 3px 0;
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.70; transition: var(--transition); }
.nav-item:hover .nav-icon, .nav-item.active .nav-icon { opacity: 1; }
.nav-chevron { margin-left: auto; flex-shrink: 0; transition: transform 0.22s ease; opacity: 0.45; }
.nav-item.open .nav-chevron { transform: rotate(90deg); }

/* Sub nav */
.nav-sub { overflow: hidden; max-height: 0; transition: max-height 0.28s ease; margin-left: 14px; }
.nav-sub.open { max-height: 400px; }
.nav-sub-item {
    display: block; padding: 8px 16px 8px 26px; margin: 1px 8px;
    border-radius: var(--radius-sm); cursor: pointer;
    color: rgba(228,242,247,0.52); font-size: 13px; font-weight: 400;
    transition: var(--transition);
    border-left: 1px solid rgba(51,185,205,0.13);
    white-space: nowrap; overflow: hidden;
}
.nav-sub-item:hover { color: var(--text-primary); border-left-color: rgba(51,185,205,0.4); background: rgba(51,185,205,0.05); }
.nav-sub-item.active { color: var(--cyan-3); border-left-color: var(--cyan-3); background: rgba(51,185,205,0.07); }

/* Footer */
.sidebar-footer {
    padding: 12px; border-top: 1px solid rgba(51,185,205,0.10);
    display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, var(--blue-1), var(--cyan-4));
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: #fff;
}
.user-info { flex: 1; min-width: 0; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }
.logout-btn { width: 30px; height: 30px; border-radius: var(--radius-sm); border: 1px solid var(--glass-border); background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-muted); transition: var(--transition); flex-shrink: 0; }
.logout-btn:hover { color: var(--danger); border-color: rgba(231,76,60,0.4); background: rgba(231,76,60,0.08); }

/* ── Collapsed sidebar ── */
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-item > span,
.sidebar.collapsed .nav-chevron,
.sidebar.collapsed .nav-sub,
.sidebar.collapsed .user-info,
.sidebar.collapsed .logout-btn { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; margin: 2px 8px; }
.sidebar.collapsed .nav-icon { opacity: 0.75; }
.sidebar.collapsed .nav-item:hover .nav-icon { opacity: 1; }
.sidebar.collapsed .sidebar-logo { justify-content: center; padding: 16px 0; }
.sidebar.collapsed .sidebar-footer { justify-content: center; }

/* ================================================================
   MAIN WRAPPER
   ================================================================ */
.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* ── Topbar ── */
.topbar {
    height: var(--topbar-h); display: flex; align-items: center; padding: 0 24px; gap: 16px;
    background: rgba(3,8,22,0.75); border-bottom: 1px solid rgba(51,185,205,0.08);
    backdrop-filter: blur(20px); flex-shrink: 0; z-index: 50;
}
.topbar-toggle {
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border); background: var(--glass-bg);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-secondary); transition: var(--transition);
    flex-shrink: 0;
}
.topbar-toggle:hover { background: rgba(51,185,205,0.1); border-color: rgba(51,185,205,0.35); color: var(--cyan-3); }
.topbar-breadcrumb { flex: 1; font-size: 13.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-breadcrumb .crumb-sep { margin: 0 6px; opacity: 0.4; }
.topbar-breadcrumb .crumb-current { color: var(--text-primary); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.icon-btn {
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border); background: var(--glass-bg);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-secondary); transition: var(--transition); position: relative;
}
.icon-btn:hover { background: rgba(51,185,205,0.10); border-color: rgba(51,185,205,0.35); color: var(--cyan-3); }
.notif-dot {
    position: absolute; top: 7px; right: 7px;
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--cyan-3); border: 1.5px solid var(--bg-base);
}
.topbar-divider { width: 1px; height: 24px; background: rgba(51,185,205,0.12); }

/* ── Content ── */
.content { flex: 1; overflow-y: auto; padding: 28px; }
@keyframes fadeSlideIn { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
.page-wrap { animation: fadeSlideIn 0.3s ease forwards; }

/* ── Page Header ── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 23px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-shrink: 0; flex-wrap: wrap; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px;
    border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600;
    cursor: pointer; transition: var(--transition); border: 1px solid transparent;
    line-height: 1; text-decoration: none; white-space: nowrap; outline: none;
}
.btn-primary {
    background: linear-gradient(135deg, var(--cyan-4) 0%, var(--cyan-3) 100%);
    color: #fff; box-shadow: 0 4px 16px rgba(15,166,189,0.28);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(15,166,189,0.42); }
.btn-secondary { background: var(--glass-bg); color: var(--text-secondary); border-color: var(--glass-border); backdrop-filter: blur(10px); }
.btn-secondary:hover { background: rgba(51,185,205,0.10); border-color: rgba(51,185,205,0.35); color: var(--cyan-3); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.btn-danger { background: rgba(231,76,60,0.12); color: var(--danger); border-color: rgba(231,76,60,0.28); }
.btn-danger:hover { background: rgba(231,76,60,0.22); }
.btn-sm { padding: 6px 13px; font-size: 12.5px; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }

/* ── Glass Card ── */
.card {
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: var(--radius); backdrop-filter: blur(20px); box-shadow: var(--shadow);
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 22px; border-bottom: 1px solid rgba(51,185,205,0.09);
}
.card-title { font-size: 14.5px; font-weight: 600; color: var(--text-primary); }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 22px; }
.card-footer { padding: 14px 22px; border-top: 1px solid rgba(51,185,205,0.09); }

/* ── Nav sub-group divider ── */
.nav-sub-divider { font-size:10px; font-weight:700; letter-spacing:0.07em; text-transform:uppercase; color:var(--text-muted); padding:10px 16px 4px; opacity:0.6; }

/* ── Required field star ── */
.required-star { color: var(--danger); margin-left: 2px; }

/* ── Setup Wizard ── */
.wizard-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.72); backdrop-filter:blur(6px); z-index:900; display:flex; align-items:center; justify-content:center; padding:20px; }
.wizard-card { background:var(--glass-bg); border:1px solid var(--glass-border); border-radius:var(--radius); width:100%; max-width:620px; max-height:90vh; display:flex; flex-direction:column; overflow:hidden; box-shadow:0 24px 64px rgba(0,0,0,0.5); }
.wizard-header { padding:28px 32px 20px; border-bottom:1px solid var(--glass-border); flex-shrink:0; }
.wizard-logo { display:flex; align-items:center; gap:8px; font-weight:700; font-size:15px; color:var(--cyan-3); margin-bottom:12px; }
.wizard-title { font-size:20px; font-weight:700; color:var(--text-primary); }
.wizard-subtitle { font-size:13px; color:var(--text-muted); margin-top:3px; }
.wizard-step-nav { display:flex; align-items:center; padding:18px 32px; border-bottom:1px solid var(--glass-border); flex-shrink:0; overflow-x:auto; gap:0; }
.wizard-step-item { display:flex; flex-direction:column; align-items:center; gap:5px; flex-shrink:0; }
.wizard-step-circle { width:28px; height:28px; border-radius:50%; border:2px solid var(--glass-border); display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:700; color:var(--text-muted); transition:var(--transition); }
.wizard-step-item.active .wizard-step-circle { border-color:var(--cyan-3); background:rgba(51,185,205,0.12); color:var(--cyan-3); }
.wizard-step-item.done .wizard-step-circle { border-color:var(--success); background:rgba(39,174,96,0.15); color:var(--success); }
.wizard-step-label { font-size:10px; font-weight:600; color:var(--text-muted); white-space:nowrap; }
.wizard-step-item.active .wizard-step-label { color:var(--cyan-3); }
.wizard-step-item.done .wizard-step-label { color:var(--success); }
.wizard-step-line { flex:1; height:2px; background:var(--glass-border); min-width:20px; margin-bottom:16px; }
.wizard-body { flex:1; overflow-y:auto; padding:28px 32px; }
.wizard-section-title { font-size:15px; font-weight:700; color:var(--text-primary); margin-bottom:18px; padding-bottom:10px; border-bottom:1px solid var(--glass-border); }
.wizard-footer { display:flex; align-items:center; gap:10px; padding:18px 32px; border-top:1px solid var(--glass-border); flex-shrink:0; }
.btn-ghost { background:transparent; border:none; color:var(--text-muted); padding:8px 12px; cursor:pointer; font-size:13px; border-radius:var(--radius-sm); transition:var(--transition); }
.btn-ghost:hover { color:var(--text-primary); background:rgba(255,255,255,0.05); }
.fy-month-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin-top:8px; }
.fy-month-tile { padding:10px 6px; text-align:center; border:1px solid var(--glass-border); border-radius:var(--radius-sm); cursor:pointer; font-size:13px; color:var(--text-secondary); transition:var(--transition); }
.fy-month-tile:hover { border-color:rgba(51,185,205,0.4); background:rgba(51,185,205,0.05); color:var(--text-primary); }
.fy-month-tile.selected { border-color:var(--cyan-3); background:rgba(51,185,205,0.12); color:var(--cyan-3); font-weight:700; }
.wizard-fy-note { display:flex; align-items:center; gap:8px; margin-top:14px; padding:10px 14px; border-radius:var(--radius-sm); background:rgba(51,185,205,0.07); border:1px solid rgba(51,185,205,0.2); font-size:12px; color:var(--text-secondary); }

/* ── Wizard Country step ── */
.country-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:7px; max-height:360px; overflow-y:auto; padding-right:4px; }
.country-tile { display:flex; align-items:center; gap:9px; padding:9px 11px; border:1px solid var(--glass-border); border-radius:var(--radius-sm); cursor:pointer; transition:var(--transition); }
.country-tile:hover { border-color:rgba(51,185,205,0.4); background:rgba(51,185,205,0.05); }
.country-tile.selected { border-color:var(--cyan-3); background:rgba(51,185,205,0.12); }
.country-tile.selected .country-name { color:var(--cyan-3); font-weight:600; }
.country-flag { font-size:18px; line-height:1; flex-shrink:0; }
.country-name { font-size:12.5px; color:var(--text-secondary); line-height:1.3; }

/* ── Wizard Welcome screen ── */
.wizard-welcome { display:flex; flex-direction:column; align-items:center; text-align:center; padding:40px 32px 32px; flex:1; }
.wizard-welcome-icon { display:flex; align-items:center; justify-content:center; margin-bottom:22px; }
.wizard-welcome-title { font-size:24px; font-weight:700; color:var(--text-primary); margin-bottom:10px; }
.wizard-welcome-sub { font-size:14px; color:var(--text-muted); max-width:380px; line-height:1.6; margin-bottom:32px; }
.wizard-policy-list { display:flex; flex-direction:column; gap:12px; width:100%; max-width:420px; text-align:left; }
.wizard-policy-item { display:flex; align-items:center; gap:14px; padding:14px 16px; border:1px solid var(--glass-border); border-radius:var(--radius-sm); cursor:pointer; transition:var(--transition); }
.wizard-policy-item:hover { border-color:rgba(51,185,205,0.3); background:rgba(51,185,205,0.04); }
.wizard-policy-item.agreed { border-color:rgba(39,174,96,0.35); background:rgba(39,174,96,0.06); }
.wizard-policy-item input[type="checkbox"] { display:none; }
.wizard-policy-text { flex:1; font-size:13px; color:var(--text-secondary); display:flex; flex-wrap:wrap; align-items:center; gap:4px; }
.wizard-policy-check { flex-shrink:0; color:var(--text-muted); transition:var(--transition); }
.wizard-policy-item.agreed .wizard-policy-check { color:var(--success); }
.policy-link { background:none; border:none; padding:0; font-size:13px; font-weight:600; color:var(--cyan-3); cursor:pointer; text-decoration:underline; text-underline-offset:2px; }
.policy-link:hover { color:var(--cyan-2); }

/* ── Policy modal ── */
.policy-modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.6); z-index:1000; display:flex; align-items:center; justify-content:center; padding:20px; }
.policy-modal-card { background:var(--glass-bg); border:1px solid var(--glass-border); border-radius:var(--radius); width:100%; max-width:500px; max-height:70vh; display:flex; flex-direction:column; overflow:hidden; }
.policy-modal-header { display:flex; align-items:center; justify-content:space-between; padding:18px 22px; border-bottom:1px solid var(--glass-border); font-size:15px; font-weight:700; color:var(--text-primary); flex-shrink:0; }
.policy-modal-body { flex:1; overflow-y:auto; padding:24px; }
.policy-placeholder { display:flex; flex-direction:column; align-items:center; text-align:center; gap:14px; padding:20px 0; }
.policy-placeholder-title { font-size:16px; font-weight:700; color:var(--text-primary); }
.policy-placeholder-text { font-size:13px; color:var(--text-muted); line-height:1.7; max-width:360px; }

/* ── Logo upload ── */
.logo-upload-area { border: 2px dashed var(--glass-border); border-radius: var(--radius-sm); min-height: 160px; display:flex; align-items:center; justify-content:center; cursor:pointer; transition:var(--transition); overflow:hidden; }
.logo-upload-area:hover { border-color: rgba(51,185,205,0.5); background: rgba(51,185,205,0.04); }
.logo-upload-placeholder { display:flex; flex-direction:column; align-items:center; gap:10px; color:var(--text-muted); text-align:center; padding:24px; font-size:13px; }
.logo-upload-hint { font-size:11px; color:var(--text-muted); opacity:0.7; }
.logo-preview-img { max-width:100%; max-height:200px; object-fit:contain; padding:16px; }

/* ── Dashboard module grid ── */
.dash-module-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:12px; }
.dash-module-card { display:flex; flex-direction:column; align-items:flex-start; gap:10px; padding:16px; border:1px solid var(--glass-border); border-radius:var(--radius-sm); cursor:pointer; transition:var(--transition); }
.dash-module-card:hover { border-color:rgba(51,185,205,0.35); background:rgba(51,185,205,0.04); transform:translateY(-2px); }
.dash-module-icon { width:42px; height:42px; border-radius:10px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.dash-module-label { font-size:13px; font-weight:600; color:var(--text-primary); line-height:1.3; }
.dash-module-sub { font-size:11px; color:var(--text-muted); line-height:1.4; }

/* ── KPI Cards ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap: 18px; margin-bottom: 28px; }
.kpi-card {
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: var(--radius); backdrop-filter: blur(20px);
    padding: 22px; position: relative; overflow: hidden; transition: var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--glow-cyan); border-color: rgba(51,185,205,0.32); }
.kpi-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, var(--cyan-4), var(--cyan-3));
    opacity: 0.55;
}
.kpi-label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.kpi-value { font-size: 27px; font-weight: 700; color: var(--text-primary); line-height: 1; margin-bottom: 8px; }
.kpi-trend { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }
.kpi-icon {
    position: absolute; right: 18px; top: 18px; width: 44px; height: 44px;
    border-radius: var(--radius-sm); background: rgba(51,185,205,0.10);
    display: flex; align-items: center; justify-content: center; color: var(--cyan-3);
}

/* ── Table ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
    padding: 11px 16px; text-align: left;
    font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
    color: var(--text-muted); border-bottom: 1px solid rgba(51,185,205,0.12);
    white-space: nowrap; background: rgba(4,9,29,0.4);
}
tbody td { padding: 12px 16px; color: var(--text-primary); border-bottom: 1px solid rgba(51,185,205,0.06); }
tbody tr { transition: background 0.15s; }
tbody tr:hover td { background: rgba(51,185,205,0.04); }
tbody tr:last-child td { border-bottom: none; }
td .text-muted { color: var(--text-muted); font-size: 12px; }

/* ── Badge ── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-success { background: rgba(39,174,96,0.15);  color: #2ecc71; }
.badge-warning { background: rgba(230,126,34,0.15); color: #e67e22; }
.badge-danger  { background: rgba(231,76,60,0.15);  color: #e74c3c; }
.badge-info    { background: rgba(51,185,205,0.15); color: var(--cyan-3); }
.badge-muted   { background: rgba(255,255,255,0.07); color: var(--text-muted); }
.badge-navy    { background: rgba(43,84,184,0.20);  color: #7fa6e8; }

/* ── Form ── */
.form-grid  { display: grid; gap: 16px; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.form-control {
    width: 100%; padding: 10px 14px;
    background: rgba(5,11,33,0.75); border: 1px solid rgba(51,185,205,0.18);
    border-radius: var(--radius-sm); color: var(--text-primary); font-size: 14px;
    transition: var(--transition); outline: none; font-family: inherit;
}
.form-control:focus { border-color: var(--cyan-3); box-shadow: 0 0 0 3px rgba(51,185,205,0.10); background: rgba(5,11,33,0.95); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control option { background: #0a1535; color: var(--text-primary); }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint { font-size: 11.5px; color: var(--text-muted); }
.form-section-title { font-size: 13px; font-weight: 700; color: var(--cyan-3); letter-spacing: 0.04em; margin: 4px 0 14px; padding-bottom: 10px; border-bottom: 1px solid rgba(51,185,205,0.12); }

/* ── Toolbar (above tables) ── */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 10px; }
.search-input-wrap { display: flex; align-items: center; gap: 8px; padding: 0 13px; background: rgba(5,11,33,0.75); border: 1px solid var(--glass-border); border-radius: var(--radius-sm); height: 37px; min-width: 230px; }
.search-input-wrap input { flex: 1; background: none; border: none; outline: none; color: var(--text-primary); font-size: 13.5px; }
.search-input-wrap input::placeholder { color: var(--text-muted); }

/* ── Tabs ── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid rgba(51,185,205,0.12); margin-bottom: 24px; }
.tab { padding: 10px 18px; font-size: 13.5px; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: var(--transition); white-space: nowrap; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--cyan-3); border-bottom-color: var(--cyan-3); }

/* ── Divider ── */
.divider { height: 1px; background: rgba(51,185,205,0.09); margin: 22px 0; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state svg { width: 52px; height: 52px; margin: 0 auto 16px; opacity: 0.25; display: block; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state-desc { font-size: 13px; margin-bottom: 20px; }

/* ── Activity list ── */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid rgba(51,185,205,0.06); align-items: flex-start; }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan-3); margin-top: 6px; flex-shrink: 0; box-shadow: 0 0 6px rgba(51,185,205,0.5); }
.activity-dot.warning { background: var(--warning); box-shadow: 0 0 6px rgba(230,126,34,0.5); }
.activity-dot.success { background: var(--success); box-shadow: 0 0 6px rgba(39,174,96,0.5); }
.activity-body { flex: 1; min-width: 0; }
.activity-text { font-size: 13.5px; color: var(--text-primary); line-height: 1.4; }
.activity-time { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ── Grid helpers ── */
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

/* ── Utility ── */
.flex { display: flex; } .flex-col { flex-direction: column; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .justify-end { justify-content: flex-end; }
.gap-1 { gap: 6px; } .gap-2 { gap: 10px; } .gap-3 { gap: 14px; } .gap-4 { gap: 20px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.p-0 { padding: 0 !important; }
.text-muted { color: var(--text-muted) !important; }
.text-cyan { color: var(--cyan-3) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-right { text-align: right; } .text-center { text-align: center; } .text-left { text-align: left; }
.font-bold { font-weight: 700; } .font-semi { font-weight: 600; }
.font-mono { font-family: 'JetBrains Mono','Fira Code','Courier New',monospace; }
.w-full { width: 100%; } .h-full { height: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hidden { display: none !important; }

/* ── Stat row (inside cards) ── */
.stat-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(51,185,205,0.07); font-size: 13.5px; }
.stat-row:last-child { border-bottom: none; padding-bottom: 0; }
.stat-row-label { color: var(--text-muted); }
.stat-row-value { font-weight: 600; color: var(--text-primary); }

/* ── Module coming-soon ── */
.coming-soon {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 420px; text-align: center; gap: 14px;
}
.coming-soon-icon { width: 72px; height: 72px; border-radius: var(--radius-lg); background: rgba(51,185,205,0.08); border: 1px solid var(--glass-border); display: flex; align-items: center; justify-content: center; color: var(--cyan-3); margin-bottom: 6px; }
.coming-soon-title { font-size: 19px; font-weight: 700; color: var(--text-primary); }
.coming-soon-desc { font-size: 13.5px; color: var(--text-muted); max-width: 360px; line-height: 1.6; }

/* ================================================================
   DRAWER (slide-in panel)
   ================================================================ */
.drawer-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.50); z-index:200; opacity:0; pointer-events:none; transition:opacity 0.25s ease; }
.drawer-overlay.open { opacity:1; pointer-events:all; }
.drawer { position:fixed; top:0; right:0; bottom:0; width:520px; max-width:95vw; background:var(--glass-bg); border-left:1px solid var(--glass-border); backdrop-filter:blur(24px); z-index:201; transform:translateX(100%); transition:transform 0.3s cubic-bezier(0.4,0,0.2,1); display:flex; flex-direction:column; color:var(--text-primary); }
.drawer.open { transform:translateX(0); }
.drawer-header { display:flex; align-items:center; justify-content:space-between; padding:20px 24px; border-bottom:1px solid var(--glass-border); flex-shrink:0; }
.drawer-title { font-size:17px; font-weight:700; color:var(--text-primary); }
.drawer-close { width:32px; height:32px; border-radius:8px; border:1px solid var(--glass-border); background:transparent; display:flex; align-items:center; justify-content:center; cursor:pointer; color:var(--text-muted); transition:var(--transition); }
.drawer-close:hover { color:var(--danger); border-color:rgba(231,76,60,0.4); }
.drawer-body { flex:1; overflow-y:auto; padding:24px; }
.drawer-body .form-group { margin-bottom:16px; }

/* Permission tree */
.perm-section { margin-bottom:18px; }
.perm-section-label { font-size:10.5px; font-weight:700; letter-spacing:0.08em; text-transform:uppercase; color:var(--text-muted); margin-bottom:8px; padding-left:2px; }
.perm-module-row { border:1px solid var(--glass-border); border-radius:var(--radius-sm); overflow:hidden; margin-bottom:6px; }
.perm-module-header { display:flex; align-items:center; gap:0; padding:0; background:var(--glass-bg); transition:var(--transition); }
.perm-module-header input[type="checkbox"] { accent-color:var(--cyan-3); width:15px; height:15px; flex-shrink:0; cursor:pointer; margin:0 10px 0 12px; }
.perm-module-toggle { display:flex; align-items:center; gap:10px; flex:1; padding:10px 12px 10px 0; cursor:pointer; }
.perm-module-toggle:hover { background:rgba(51,185,205,0.06); }
.perm-module-toggle strong { flex:1; font-size:13px; color:var(--text-primary); }
.perm-chevron { color:var(--text-muted); flex-shrink:0; transition:transform 0.22s ease; }
.perm-module-row.perm-open .perm-chevron { transform:rotate(90deg); }
.perm-children { border-top:1px solid var(--glass-border); padding:6px 0; background:rgba(0,0,0,0.04); }
.perm-child-row { display:flex; align-items:center; gap:10px; padding:7px 14px 7px 38px; cursor:pointer; transition:background 0.15s; }
.perm-child-row:hover { background:rgba(51,185,205,0.05); }
.perm-child-row input[type="checkbox"] { accent-color:var(--cyan-3); width:14px; height:14px; flex-shrink:0; cursor:pointer; }
.perm-child-row span { font-size:13px; color:var(--text-secondary); }
.role-checkbox-grid { display:flex; flex-direction:column; gap:6px; }
.role-checkbox-item { display:flex; align-items:flex-start; gap:10px; padding:9px 12px; border-radius:var(--radius-sm); border:1px solid var(--glass-border); cursor:pointer; transition:var(--transition); }
.role-checkbox-item:hover { background:rgba(51,185,205,0.06); border-color:rgba(51,185,205,0.3); }
.role-checkbox-item input[type="checkbox"],
.role-checkbox-item input[type="radio"] { margin-top:3px; accent-color:var(--cyan-3); width:15px; height:15px; flex-shrink:0; cursor:pointer; }
.role-checkbox-label { display:flex; align-items:center; gap:10px; flex:1; }
.role-dot { width:8px; height:8px; border-radius:50%; flex-shrink:0; }
.role-checkbox-label span { display:flex; flex-direction:column; gap:2px; }
.role-checkbox-label strong { font-size:13px; color:var(--text-primary); font-weight:600; }
.role-checkbox-label small { font-size:11.5px; color:var(--text-muted); line-height:1.4; }
.role-checkbox-item:has(input:checked) { background:rgba(51,185,205,0.08); border-color:rgba(51,185,205,0.35); }
.drawer-footer { padding:16px 24px; border-top:1px solid var(--glass-border); display:flex; gap:10px; justify-content:flex-end; flex-shrink:0; }

/* Segmented button control */
.seg-btns { display:flex; border:1px solid var(--glass-border); border-radius:var(--radius-sm); overflow:hidden; }
.seg-btn { flex:1; padding:8px 10px; font-size:12.5px; font-weight:600; background:transparent; border:none; border-right:1px solid var(--glass-border); color:var(--text-muted); cursor:pointer; transition:var(--transition); line-height:1.3; }
.seg-btn:last-child { border-right:none; }
.seg-btn:hover { background:rgba(51,185,205,0.07); color:var(--text-secondary); }
.seg-btn.active { background:rgba(51,185,205,0.15); color:var(--cyan-3); }

/* Drawer — wide variant for forms with many fields */
.drawer.drawer-lg { width: min(640px, 95vw); }

/* Form section divider (inside drawers / modals) */
.form-divider { height:1px; background:var(--glass-border); margin:20px -24px; }

/* Toast notification */
#mxToast { position:fixed; bottom:24px; right:24px; z-index:999; border-radius:10px; padding:12px 18px; font-size:14px; font-weight:500; display:flex; align-items:center; gap:10px; box-shadow:0 8px 32px rgba(0,0,0,0.3); max-width:380px; animation:toastIn 0.25s ease; }
@keyframes toastIn  { from { transform:translateY(12px); opacity:0; } to { transform:translateY(0); opacity:1; } }
@keyframes toastOut { to   { transform:translateY(12px); opacity:0; } }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform 0.28s ease, width 0.28s ease; }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-wrapper { width: 100%; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2, .grid-3, .grid-1-2, .grid-2-1 { grid-template-columns: 1fr; }
    .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .content { padding: 18px; }
    .kpi-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
}

/* ================================================================
   DOCUMENT PRINT FRAME  (white A4-style sheet on screen)
   ================================================================ */
.doc-print-frame {
    background: #e0e2e6;
    padding: 28px 20px;
    border-radius: var(--radius);
}
[data-theme="dark"] .doc-print-frame { background: #0e1117; }

.statement-wrap {
    background: #fff !important;
    color: #111 !important;
    border-radius: 3px;
    box-shadow: 0 6px 32px rgba(0,0,0,0.18);
    /* all other styles come from inline template config */
}

/* ================================================================
   PRINT / PDF
   ================================================================ */
@media print {
    @page { size: A4; margin: 15mm 20mm; }

    .sidebar, .topbar, .page-header .page-actions,
    .no-print, .btn, .toolbar, .drawer, .drawer-overlay { display: none !important; }

    body, .main-wrapper, .main-content, .content, #mainContent {
        margin: 0 !important; padding: 0 !important;
        width: 100% !important; background: #fff !important; color: #000 !important;
    }

    /* strip the grey frame and card chrome on print */
    .doc-print-frame {
        background: transparent !important;
        padding: 0 !important;
        border-radius: 0 !important;
    }

    .statement-wrap {
        box-shadow: none !important;
        border-radius: 0 !important;
        display: block !important;
    }

    a { color: inherit !important; text-decoration: none !important; }
    .tpl-editor-wrap, .tpl-preview-chrome { display: none !important; }
    .tpl-print-doc { display: block !important; }
}

/* ================================================================
   TEMPLATE EDITOR
   ================================================================ */
.tpl-editor-wrap {
    display: flex;
    gap: 0;
    height: calc(100vh - 120px);
    min-height: 600px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--glass-border);
    background: var(--bg-secondary);
}

.tpl-settings-panel {
    width: 360px;
    min-width: 320px;
    max-width: 400px;
    overflow-y: auto;
    border-right: 1px solid var(--glass-border);
    background: var(--bg-card);
    flex-shrink: 0;
}

.tpl-settings-top {
    padding: 16px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 2;
}

.tpl-settings-top input {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.tpl-accordion-item { border-bottom: 1px solid var(--glass-border); }
.tpl-accordion-hdr {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: var(--transition);
}
.tpl-accordion-hdr:hover { background: rgba(51,185,205,0.05); }
.tpl-accordion-hdr svg { transition: transform 0.2s; }
.tpl-accordion-hdr.open svg { transform: rotate(90deg); }

.tpl-accordion-body { padding: 8px 16px 16px; display: none; }
.tpl-accordion-body.open { display: block; }

.tpl-field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px dashed rgba(255,255,255,0.04);
}
.tpl-field-row:last-child { border-bottom: none; }

.tpl-toggle {
    position: relative;
    width: 34px;
    height: 18px;
    flex-shrink: 0;
}
.tpl-toggle input { opacity: 0; width: 0; height: 0; }
.tpl-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--glass-border);
    border-radius: 9px;
    cursor: pointer;
    transition: var(--transition);
}
.tpl-toggle-slider::before {
    content: '';
    position: absolute;
    height: 12px; width: 12px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition);
}
.tpl-toggle input:checked + .tpl-toggle-slider { background: var(--cyan-3); }
.tpl-toggle input:checked + .tpl-toggle-slider::before { transform: translateX(16px); }

.tpl-color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    color: var(--text-secondary);
}
.tpl-color-row input[type="color"] {
    width: 36px;
    height: 28px;
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    padding: 2px;
    cursor: pointer;
    background: transparent;
}

/* Preview panel */
.tpl-preview-panel {
    flex: 1;
    overflow: auto;
    background: #e8eaed;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px;
    gap: 16px;
}
[data-theme="dark"] .tpl-preview-panel { background: #111318; }

.tpl-preview-chrome {
    font-size: 12px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 794px;
}

.tpl-a4-wrap {
    width: 794px;
    transform-origin: top center;
    flex-shrink: 0;
}

.tpl-a4-sheet {
    width: 794px;
    min-height: 1123px;
    background: #fff;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    padding: 40px 48px;
    box-sizing: border-box;
    color: #111;
    font-family: Arial, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    border-radius: 2px;
    position: relative;
}

.tpl-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-35deg);
    font-size: 96px;
    font-weight: 900;
    opacity: 0.05;
    pointer-events: none;
    white-space: nowrap;
    text-transform: uppercase;
}

/* ── Draggable block list ─────────────────────────────────── */
.block-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    user-select: none;
    transition: border-color 0.15s, background 0.15s, opacity 0.15s;
    position: relative;
}
.block-item:last-child { margin-bottom: 0; }
.block-item.is-dragging { opacity: 0.35; }
.block-item.drag-target {
    border-color: var(--cyan-3);
    background: rgba(51,185,205,0.08);
}
.block-item.drag-target::before {
    content: '';
    position: absolute;
    top: -4px; left: 0; right: 0;
    height: 2px;
    background: var(--cyan-3);
    border-radius: 1px;
}
.block-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    padding: 2px 4px;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.block-item:hover .block-drag-handle { opacity: 1; }
.block-drag-handle:active { cursor: grabbing; }
.block-item-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); line-height: 1.2; }
.block-item-desc  { font-size: 11px; color: var(--text-muted); }

/* Logo upload zone */
.logo-drop-zone {
    border: 2px dashed var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 12px;
    color: var(--text-muted);
    margin: 8px 0;
}
.logo-drop-zone:hover { border-color: var(--cyan-3); color: var(--cyan-3); }
.logo-drop-zone img { max-height: 60px; max-width: 100%; object-fit: contain; }

/* Template list cards */
.tpl-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.tpl-type-card {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    background: var(--bg-card);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}
.tpl-type-card:hover { border-color: var(--cyan-3); box-shadow: 0 0 0 3px rgba(51,185,205,0.08); }

.tpl-type-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: rgba(51,185,205,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    color: var(--cyan-3);
}
.tpl-type-label { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.tpl-type-count { font-size: 12px; color: var(--text-muted); }
.tpl-type-badge {
    position: absolute;
    top: 12px; right: 12px;
    font-size: 10px;
    font-weight: 700;
    background: rgba(51,185,205,0.15);
    color: var(--cyan-3);
    padding: 2px 7px;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
