@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ═══════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════ */
:root {
    /* Colors */
    --bg:           #0d1117;
    --bg-secondary: #161b22;
    --surface:      #1c2230;
    --surface-hover:#222d3d;
    --border:       rgba(255, 255, 255, 0.07);
    --border-light: rgba(255, 255, 255, 0.04);

    /* Text */
    --text-primary:  #e6edf3;
    --text-secondary:#8b949e;
    --text-muted:    #484f58;

    /* Accent */
    --accent:        #3b82f6;
    --accent-soft:   rgba(59, 130, 246, 0.1);
    --accent-border: rgba(59, 130, 246, 0.25);

    /* Status */
    --green:       #22c55e;
    --green-soft:  rgba(34, 197, 94, 0.1);
    --red:         #ef4444;
    --red-soft:    rgba(239, 68, 68, 0.1);
    --yellow:      #eab308;
    --yellow-soft: rgba(234, 179, 8, 0.1);

    /* Layout */
    --sidebar-w:   248px;
    --nav-h:       64px;
    --radius-sm:   8px;
    --radius-md:   12px;
    --radius-lg:   16px;
    --shadow:      0 1px 3px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.2);
    --shadow-lg:   0 4px 24px rgba(0,0,0,0.4);
}

/* ═══════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════ */
*, *::before, *::after {
    margin: 0; padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html { scroll-behavior: smooth; font-size: 16px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

/* ═══════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════ */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ═══════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    position: fixed;
    top: 0; left: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform 0.3s ease;
    overflow: hidden;
}

/* Logo / Brand */
.sidebar-brand {
    padding: 1.25rem 1.25rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--nav-h);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.brand-icon {
    width: 32px; height: 32px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
    scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem 0.35rem;
    margin-top: 1rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    margin-bottom: 2px;
}

.nav-link:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-border);
}

.nav-link .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* Close btn (mobile) */
.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 4px;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.sidebar-close-btn:hover { background: var(--surface-hover); }

/* Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 150;
}
.sidebar-overlay.active { display: block; }

/* ═══════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════ */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ═══════════════════════════════════════
   TOP HEADER
   ═══════════════════════════════════════ */
.topbar {
    height: var(--nav-h);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
    flex: 1;
}

.topbar-left > div {
    min-width: 0;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Avatar */
.user-avatar {
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.user-meta {
    text-align: right;
}
.user-meta-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.2;
}
.user-meta-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: capitalize;
}

/* Hamburger */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    flex-direction: column;
    gap: 4px;
}
.hamburger:hover { background: var(--surface-hover); }
.hamburger span {
    display: block;
    width: 18px; height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: all 0.25s;
}

/* ═══════════════════════════════════════
   PAGE CONTENT WRAPPER
   ═══════════════════════════════════════ */
.page-content {
    padding: 1.75rem 2rem;
    flex: 1;
}

/* ═══════════════════════════════════════
   CARDS / SURFACES
   ═══════════════════════════════════════ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body { padding: 1.25rem; }

/* ═══════════════════════════════════════
   STAT CARDS (KPI)
   ═══════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover {
    border-color: rgba(255,255,255,0.12);
    transform: translateY(-1px);
}

.stat-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.stat-icon.blue   { background: var(--accent-soft);  }
.stat-icon.green  { background: var(--green-soft);   }
.stat-icon.red    { background: var(--red-soft);     }
.stat-icon.yellow { background: var(--yellow-soft);  }

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.35rem;
    letter-spacing: 0.01em;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.stat-note {
    margin-top: 0.6rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.stat-bar {
    margin-top: 0.85rem;
    height: 3px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}
.stat-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.8s ease;
}

/* ═══════════════════════════════════════
   SECTION HEADER
   ═══════════════════════════════════════ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}
.section-link {
    font-size: 0.78rem;
    color: var(--accent);
    transition: opacity 0.15s;
}
.section-link:hover { opacity: 0.75; }

/* ═══════════════════════════════════════
   BADGES
   ═══════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 500;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge-blue   { background: var(--accent-soft);  color: var(--accent); border-color: var(--accent-border); }
.badge-green  { background: var(--green-soft);   color: var(--green);  border-color: rgba(34,197,94,0.2); }
.badge-red    { background: var(--red-soft);     color: var(--red);    border-color: rgba(239,68,68,0.2); }
.badge-yellow { background: var(--yellow-soft);  color: var(--yellow); border-color: rgba(234,179,8,0.2); }
.badge-gray   { background: var(--surface-hover);color: var(--text-secondary); }

/* Legacy aliases */
.badge-active  { background: var(--green-soft);  color: var(--green);  border: 1px solid rgba(34,197,94,0.2); }
.badge-pending { background: var(--yellow-soft); color: var(--yellow); border: 1px solid rgba(234,179,8,0.2); }
.badge-paid    { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-border); }
.badge-danger  { background: var(--red-soft);    color: var(--red);    border: 1px solid rgba(239,68,68,0.2); }

/* ═══════════════════════════════════════
   TABLES
   ═══════════════════════════════════════ */
.table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; min-width: 480px; }

thead tr {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

th {
    padding: 0.7rem 1.25rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

td {
    padding: 0.85rem 1.25rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-secondary); }

/* ═══════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: #2563eb; border-color: #2563eb; }

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface); border-color: rgba(255,255,255,0.12); }

.btn-danger {
    background: var(--red-soft);
    color: var(--red);
    border-color: rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }

/* ═══════════════════════════════════════
   FORMS
   ═══════════════════════════════════════ */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control option { background: var(--surface); }

/* Legacy selectors */
label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.4rem; }
input, select, textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
select option { background: var(--surface); }

/* ═══════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════ */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    border: 1px solid transparent;
    margin-bottom: 1rem;
}
.alert-success { background: var(--green-soft);  color: var(--green);  border-color: rgba(34,197,94,0.2); }
.alert-danger  { background: var(--red-soft);    color: var(--red);    border-color: rgba(239,68,68,0.2); }
.alert-warning { background: var(--yellow-soft); color: var(--yellow); border-color: rgba(234,179,8,0.2); }
.alert-info    { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-border); }

/* ═══════════════════════════════════════
   DIVIDER
   ═══════════════════════════════════════ */
.divider {
    height: 1px;
    background: var(--border);
    margin: 1.5rem 0;
}

/* ═══════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
}
.empty-state-icon {
    font-size: 2rem;
    margin-bottom: 0.25rem;
    opacity: 0.5;
}

/* ═══════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════ */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeUp 0.35s ease both; }

/* ═══════════════════════════════════════
   BOTTOM NAV (Mobile)
   ═══════════════════════════════════════ */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    height: 60px;
    align-items: center;
    justify-content: space-around;
    z-index: 300;
    padding: 0 0.5rem;
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: color 0.15s;
}

.bottom-nav a .nav-icon { font-size: 1.2rem; line-height: 1; }
.bottom-nav a.active, .bottom-nav a:hover { color: var(--accent); }

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        border-right: 1px solid var(--border);
        border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-close-btn { display: flex; }

    .main-content { margin-left: 0; }
    .hamburger    { display: flex; }
    .bottom-nav   { display: flex; }
    .topbar-right .user-meta { display: none; }

    .page-content {
        padding: 1.25rem;
        padding-bottom: calc(60px + 1.25rem);
    }

    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
    .page-content  { padding: 1rem; padding-bottom: calc(60px + 1rem); }
    .topbar        { padding: 0 1rem; }
    .stats-grid    { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    .stat-value    { font-size: 1.15rem; }
    th, td         { padding: 0.65rem 1rem; }
    .form-card     { padding: 1.5rem !important; }
    .auth-card     { padding: 1.5rem !important; }
}

@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════
   GLASS (legacy compat)
   ═══════════════════════════════════════ */
.glass {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
