:root {
    --bg: #030308;
    --surface: rgba(255,255,255,0.05);
    --surface-hover: rgba(255,255,255,0.08);
    --border: rgba(255,255,255,0.1);
    --border-hover: rgba(255,255,255,0.22);
    --text-1: #ffffff;
    --text-2: #8b8fa8;
    --text-3: #4a4d60;
    --accent: #6366f1;
    --green: #10b981;
    --yellow: #f59e0b;
    --orange: #f97316;
    --red: #ef4444;
    --blue: #3b82f6;
    --purple: #a855f7;
    --ease: cubic-bezier(0.23,1,0.32,1);
    --ease-spring: cubic-bezier(0.34,1.56,0.64,1);
    --sidebar-w: 248px;
}

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

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text-1);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Noise & Orbs ── */
.noise {
    position: fixed; inset: 0; z-index: 9999; pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.04; mix-blend-mode: overlay;
}

.bg-orbs { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }

.orb {
    position: absolute; border-radius: 50%;
    filter: blur(70px);
    animation: drift 14s ease-in-out infinite alternate;
}
.orb-1 {
    width: 650px; height: 650px;
    background: radial-gradient(circle at center, rgba(99,102,241,0.65) 0%, transparent 65%);
    top: -180px; left: -150px;
    animation-delay: 0s;
}
.orb-2 {
    width: 550px; height: 550px;
    background: radial-gradient(circle at center, rgba(168,85,247,0.55) 0%, transparent 65%);
    bottom: -120px; right: -80px;
    animation-delay: -6s;
}
.orb-3 {
    width: 400px; height: 400px;
    background: radial-gradient(circle at center, rgba(16,185,129,0.3) 0%, transparent 65%);
    top: 50%; left: 45%;
    animation-delay: -3s;
}

@keyframes drift {
    0%   { transform: translate(0,0) scale(1); }
    100% { transform: translate(55px,-45px) scale(1.1); }
}

/* ── Glassmorphism ── */
.glass {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow:
        0 32px 64px rgba(0,0,0,0.55),
        inset 0 1px 0 rgba(255,255,255,0.12);
}

/* ── Pages ── */
.page { position: relative; z-index: 1; }
.page.hidden { display: none !important; }
.hidden { display: none !important; }

/* ── Toast ── */
.toast {
    position: fixed; top: 28px; right: 28px; z-index: 10000;
    padding: 14px 22px; border-radius: 14px; font-size: 0.9rem; font-weight: 500;
    background: rgba(10,10,20,0.92);
    border: 1px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(20px);
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
    transform: translateX(130%);
    transition: transform 0.5s var(--ease-spring);
    max-width: 320px;
}
.toast.show   { transform: translateX(0); }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }

/* ════════ LOGIN PAGE ════════ */
#page-login {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center; padding: 24px;
}

.login-card {
    width: 100%; max-width: 430px;
    border-radius: 28px; padding: 48px 44px;
    animation: slideUp 0.7s var(--ease) both;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(32px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Brand */
.login-brand { text-align: center; margin-bottom: 40px; }

.brand-icon {
    width: 68px; height: 68px; border-radius: 20px;
    background: linear-gradient(135deg, #6366f1, #a78bfa);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Space Grotesk', sans-serif; font-size: 2rem; font-weight: 800;
    margin: 0 auto 22px;
    box-shadow: 0 12px 40px rgba(99,102,241,0.5);
}

.login-brand h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2.2rem; font-weight: 700; letter-spacing: -0.04em; margin-bottom: 8px;
}

.gradient-text {
    background: linear-gradient(135deg, #a78bfa, #818cf8);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-brand p { color: var(--text-2); font-size: 0.95rem; }

/* Fields */
.field { margin-bottom: 18px; }

label {
    display: block; margin-bottom: 9px;
    font-size: 0.75rem; font-weight: 600; color: var(--text-2);
    text-transform: uppercase; letter-spacing: 0.12em;
}

input, select {
    width: 100%; padding: 15px 18px;
    border-radius: 13px; border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text-1); font-size: 0.95rem;
    font-family: 'DM Sans', sans-serif;
    outline: none; transition: all 0.3s var(--ease);
}

input:focus, select:focus {
    border-color: rgba(99,102,241,0.7);
    background: rgba(99,102,241,0.06);
    box-shadow: 0 0 0 4px rgba(99,102,241,0.15);
}

input::placeholder { color: var(--text-3); }
select option { background: #111; color: #fff; }

.form-row { display: flex; gap: 14px; }
.form-row .field { flex: 1; }

/* ── Password Wrap ── */
.pass-wrap {
    position: relative; /* CRITICAL — keeps eye button inside */
}

.pass-wrap input {
    padding-right: 52px;
    width: 100%;
}

.eye-btn {
    position: absolute;
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
    background: none; border: none; cursor: pointer;
    color: var(--text-2);
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; padding: 0; z-index: 2;
    transition: color 0.2s;
}
.eye-btn:hover { color: var(--text-1); }

/* Buttons */
.btn-primary {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 16px 24px; margin-top: 8px;
    border-radius: 13px; border: none; cursor: pointer;
    background: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    color: #fff; font-size: 0.95rem; font-weight: 700;
    font-family: 'Space Grotesk', sans-serif; letter-spacing: 0.02em;
    box-shadow: 0 8px 28px rgba(99,102,241,0.45);
    transition: all 0.3s var(--ease-spring); position: relative; overflow: hidden;
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 14px 36px rgba(99,102,241,0.6); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
    display: flex; align-items: center; justify-content: center;
    padding: 14px 22px; border-radius: 13px;
    border: 1px solid var(--border); background: none;
    color: var(--text-1); cursor: pointer; font-size: 0.95rem; font-weight: 500;
    font-family: 'DM Sans', sans-serif; transition: all 0.3s var(--ease);
}
.btn-ghost:hover { border-color: var(--border-hover); background: var(--surface-hover); }

.w-full { width: 100%; }

/* Spinner */
.spinner {
    width: 20px; height: 20px; border-radius: 50%;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    animation: spin 0.8s linear infinite; display: none;
}
.loading .btn-label { opacity: 0; }
.loading .spinner   { display: block; position: absolute; inset: 0; margin: auto; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ════════ DASHBOARD PAGE ════════ */
#page-dashboard { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w); min-height: 100vh;
    position: fixed; left: 0; top: 0;
    border-radius: 0; border-left: none; border-top: none; border-bottom: none;
    display: flex; flex-direction: column;
    padding: 28px 16px; z-index: 100;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 0 8px; margin-bottom: 40px;
}

.brand-icon-sm {
    width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Space Grotesk', sans-serif; font-weight: 800; font-size: 1.1rem;
    box-shadow: 0 6px 20px rgba(99,102,241,0.4);
}

.sidebar-brand span {
    font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 0.95rem;
}

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 12px 14px; border-radius: 11px;
    border: 1px solid transparent; background: none; cursor: pointer;
    color: var(--text-2); font-size: 0.88rem; font-weight: 500;
    font-family: 'DM Sans', sans-serif; transition: all 0.25s var(--ease); text-align: left;
}
.nav-item:hover { color: var(--text-1); background: var(--surface); }
.nav-item.active {
    color: #a78bfa; background: rgba(99,102,241,0.1);
    border-color: rgba(99,102,241,0.2);
}
.nav-item.active svg { stroke: #a78bfa; }

/* Sidebar user footer */
.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border-radius: 12px;
    border: 1px solid var(--border); background: var(--surface);
    margin-top: 16px;
}

.user-avatar {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 0.95rem;
}

.user-info { flex: 1; overflow: hidden; }
.user-info > span:first-child {
    display: block; font-size: 0.82rem; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.role-badge { font-size: 0.68rem; color: #818cf8; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; }

.logout-icon-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-2); padding: 5px; display: flex; align-items: center;
    border-radius: 7px; transition: all 0.2s; flex-shrink: 0;
}
.logout-icon-btn:hover { color: var(--red); background: rgba(239,68,68,0.1); }

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1; padding: 36px 32px 60px;
    min-height: 100vh;
}

/* Stats */
.stats-row {
    display: grid; grid-template-columns: repeat(4,1fr);
    gap: 16px; margin-bottom: 26px;
}

.stat-card {
    border-radius: 16px; padding: 20px 22px;
    display: flex; align-items: center; gap: 16px;
    transition: transform 0.3s var(--ease), box-shadow 0.3s;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: 0 20px 50px rgba(0,0,0,0.4); }

.stat-icon {
    width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; font-weight: 700;
}
.stat-icon-blue   { background: rgba(59,130,246,0.15); color: var(--blue); }
.stat-icon-green  { background: rgba(16,185,129,0.15); color: var(--green); }
.stat-icon-purple { background: rgba(168,85,247,0.15); color: var(--purple); }
.stat-icon-orange { background: rgba(249,115,22,0.15); color: var(--orange); }

.stat-value {
    display: block; font-family: 'Space Grotesk', sans-serif;
    font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em;
}
.stat-label { font-size: 0.76rem; color: var(--text-2); margin-top: 3px; display: block; }

/* Section cards */
.section-card {
    border-radius: 20px; padding: 26px 28px; margin-bottom: 20px;
}

.section-title {
    display: flex; align-items: center; gap: 10px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.95rem; font-weight: 600; margin-bottom: 20px; color: var(--text-1);
}

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-yellow { background: var(--yellow); box-shadow: 0 0 8px rgba(245,158,11,0.7); animation: blink 1.6s ease-in-out infinite; }
.dot-green  { background: var(--green); }

@keyframes blink { 0%,100%{opacity:1; transform:scale(1)} 50%{opacity:0.4; transform:scale(1.5)} }

.count-badge {
    margin-left: auto; padding: 3px 10px; border-radius: 20px;
    font-size: 0.72rem; font-weight: 700;
    background: rgba(245,158,11,0.12); color: var(--yellow);
}
.count-badge-green { background: rgba(16,185,129,0.12); color: var(--green); }

/* Payment list */
.payment-list { display: flex; flex-direction: column; gap: 10px; }

.payment-item {
    display: flex; align-items: center; gap: 16px;
    padding: 16px 20px; border-radius: 13px;
    border: 1px solid var(--border); background: rgba(255,255,255,0.025);
    transition: all 0.25s var(--ease);
}
.payment-item:hover { border-color: rgba(255,255,255,0.18); background: rgba(255,255,255,0.05); }

.pay-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.pay-icon-cash   { background: rgba(16,185,129,0.12); }
.pay-icon-online { background: rgba(168,85,247,0.12); }

.pay-info { flex: 1; min-width: 0; }
.pay-note { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pay-meta { font-size: 0.76rem; color: var(--text-2); margin-top: 3px; }

.pay-amount {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem; font-weight: 700; letter-spacing: -0.02em; flex-shrink: 0;
}

.pay-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

.btn-sm {
    padding: 7px 14px; border-radius: 8px; font-size: 0.8rem; font-weight: 600;
    cursor: pointer; border: none; font-family: 'Space Grotesk', sans-serif;
    transition: all 0.25s var(--ease);
}
.btn-sm-edit { background: rgba(255,255,255,0.06); color: var(--text-1); border: 1px solid var(--border); }
.btn-sm-edit:hover { border-color: rgba(99,102,241,0.5); color: #a78bfa; }
.btn-sm-accept { background: rgba(16,185,129,0.12); color: var(--green); border: 1px solid rgba(16,185,129,0.2); }
.btn-sm-accept:hover { background: var(--green); color: #000; box-shadow: 0 4px 16px rgba(16,185,129,0.35); }

.lock-icon { font-size: 0.9rem; }

.empty-state { text-align: center; color: var(--text-3); font-size: 0.9rem; padding: 36px 20px; }

/* Tab content */
.tab-content { display: none; animation: fadeIn 0.4s var(--ease); }
.tab-content.active { display: block; }

@keyframes fadeIn { from{opacity:0;transform:translateY(12px)} to{opacity:1;transform:translateY(0)} }

/* Profile tab */
.profile-info-card {
    display: flex; align-items: center; gap: 18px; margin-bottom: 28px;
}

.profile-avatar-lg {
    width: 64px; height: 64px; border-radius: 18px; flex-shrink: 0;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    display: flex; align-items: center; justify-content: center;
    font-family: 'Space Grotesk', sans-serif; font-weight: 800; font-size: 1.6rem;
    box-shadow: 0 8px 24px rgba(99,102,241,0.4);
}

.profile-name { font-family: 'Space Grotesk', sans-serif; font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; }
.profile-role-tag {
    display: inline-block; padding: 4px 12px; border-radius: 20px;
    font-size: 0.75rem; font-weight: 600;
    background: rgba(99,102,241,0.15); color: #a78bfa; border: 1px solid rgba(99,102,241,0.25);
}

.divider { border: none; border-top: 1px solid var(--border); margin: 26px 0; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; z-index: 500;
    background: rgba(0,0,0,0.75); backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center; padding: 20px;
    opacity: 0; pointer-events: none; transition: opacity 0.3s var(--ease);
}
.modal-overlay:not(.hidden) { opacity: 1; pointer-events: auto; }
.modal-overlay.hidden { display: flex !important; }

.modal-box {
    width: 100%; max-width: 470px; border-radius: 22px; padding: 34px;
    transform: scale(0.9) translateY(20px);
    transition: all 0.45s var(--ease-spring);
}
.modal-overlay:not(.hidden) .modal-box { transform: scale(1) translateY(0); }

.modal-box h3 { font-family: 'Space Grotesk', sans-serif; font-size: 1.15rem; font-weight: 600; margin-bottom: 24px; }

.modal-footer { display: flex; gap: 12px; margin-top: 26px; justify-content: flex-end; }
.modal-footer .btn-ghost   { width: auto; margin-top: 0; }
.modal-footer .btn-primary { width: auto; margin-top: 0; }

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

@media (max-width: 768px) {
    .sidebar { 
        width: 100%; 
        height: 70px; 
        min-height: auto; 
        top: auto; 
        bottom: 0; 
        left: 0; 
        flex-direction: row; 
        padding: 0 12px; 
        align-items: center; 
        border-right: none; 
        border-top: 1px solid var(--border); 
        background: rgba(3,3,8,0.95);
        backdrop-filter: blur(28px);
        -webkit-backdrop-filter: blur(28px);
        z-index: 1000;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
    }
    .sidebar-brand { display: none; }
    .sidebar-nav { flex-direction: row; flex: 1; justify-content: space-evenly; gap: 4px; margin: 0; }
    .nav-item { width: auto; padding: 10px; border-radius: 12px; justify-content: center; flex: 1; max-width: 65px; }
    .nav-item span { display: none; }
    .sidebar-user { margin: 0; padding: 0; border: none; background: transparent; display: flex; align-items: center; justify-content: center; }
    .user-info { display: none; }
    .user-avatar { display: none; } /* Hide avatar to save space on mobile nav */
    .logout-icon-btn { margin-left: 5px; background: rgba(239,68,68,0.1); color: var(--red); padding: 10px; border-radius: 12px; }
    
    .main-content { 
        margin-left: 0; 
        margin-bottom: 70px; 
        padding: 20px 14px; 
        min-height: calc(100vh - 70px); 
    }
    
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 24px; }
    .stat-card { padding: 16px 14px; flex-direction: column; align-items: flex-start; gap: 10px; border-radius: 14px; }
    .stat-icon { width: 36px; height: 36px; font-size: 0.9rem; border-radius: 10px; }
    .stat-icon svg { width: 16px; height: 16px; }
    .stat-value { font-size: 1.15rem; }
    .stat-label { font-size: 0.7rem; }
    
    .form-row { flex-direction: column !important; gap: 12px !important; }
    .section-card { padding: 20px 16px; border-radius: 20px; margin-bottom: 16px; }
    .section-title { font-size: 0.9rem; margin-bottom: 16px; }
    
    .payment-item { padding: 14px; gap: 12px; border-radius: 14px; }
    .payment-item-header { flex-direction: column !important; align-items: flex-start !important; gap: 8px !important; }
    .payment-item-header > div { text-align: left !important; width: 100%; align-items: flex-start !important; }
    .pay-amount { font-size: 1.35rem !important; margin-bottom: 4px; }
    
    .pay-actions { flex-direction: column; width: 100%; gap: 8px; margin-top: 8px; }
    .pay-actions .btn-sm { width: 100%; justify-content: center; padding: 12px; font-size: 0.9rem; margin: 0 !important; }
    
    .toast { 
        right: 16px; left: 16px; top: 16px; max-width: none; width: auto; 
        transform: translateY(-150%);
        transition: transform 0.5s var(--ease-spring);
    }
    .toast.show { transform: translateY(0); }
    
    #page-login { padding: 16px; }
    .login-card { padding: 32px 20px; width: 100%; max-width: 100%; margin: 0; border-radius: 24px; }
    .login-brand h1 { font-size: 1.8rem; }
    
    .modal-box { padding: 24px 20px; border-radius: 20px; width: calc(100% - 32px); max-width: 100%; }
    .modal-overlay { padding: 16px; }
    .modal-footer { flex-direction: column-reverse; gap: 10px; }
    .modal-footer button { width: 100% !important; }
    
    #global-notes-container { padding: 12px !important; }
    #global-notes-form { flex-direction: column; gap: 10px; }
    #send-note-btn { width: 100% !important; padding: 14px !important; }
    
    .profile-info-card { flex-direction: column; text-align: center; gap: 12px; }
    .profile-avatar-lg { margin: 0 auto; width: 70px; height: 70px; font-size: 1.8rem; }
    .profile-name { font-size: 1.3rem; }
}

@media (max-width: 480px) {
    .stats-row { grid-template-columns: 1fr; }
    .stat-card { flex-direction: row; align-items: center; justify-content: flex-start; }
    .stat-icon { margin-right: 4px; }
}
