:root {
    --bg: #f7f8fc;
    --sidebar-bg: #fff;
    --sidebar-w: 220px;
    --card-bg: #fff;
    --text: #1a1d2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --primary: #4f6ef7;
    --primary-hover: #3b5de7;
    --primary-light: #eef2ff;
    --success: #22c55e;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --topbar-h: 60px;
    --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ======== Layout ======== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column;
    z-index: 100;
    transition: transform .25s ease;
}
.sidebar-brand {
    height: var(--topbar-h);
    display: flex; align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    font-size: 16px; font-weight: 700;
    color: var(--text);
    gap: 10px;
}
.sidebar-brand svg { width: 28px; height: 28px; }
.sidebar-menu { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    font-size: 12px; color: var(--text-secondary);
}

.menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px;
    font-size: 13.5px; color: var(--text-secondary);
    cursor: pointer; transition: all .15s;
    border-left: 3px solid transparent;
}
.menu-item:hover { background: var(--primary-light); color: var(--primary); }
.menu-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    border-left-color: var(--primary);
}
.menu-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.menu-divider { height: 1px; background: var(--border); margin: 8px 16px; }

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex; flex-direction: column;
    min-height: 100vh;
}
.topbar {
    height: var(--topbar-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.content { flex: 1; padding: 24px; }

.page-panel { display: none; }
.page-panel.active { display: block; }

/* ======== Card ======== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 600;
}
.card-body { padding: 20px; }

/* ======== Stats ======== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
}
.stat-card .label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .value { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-card .sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ======== Buttons ======== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px;
    font-size: 13px; font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
    transition: all .15s;
    line-height: 1.4;
    white-space: nowrap;
}
.btn:hover { border-color: #d1d5db; background: #f9fafb; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: var(--primary); color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-light); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 24px; font-size: 15px; }

/* ======== Forms ======== */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 13px; font-weight: 500;
    color: var(--text); margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 9px 12px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
    transition: border-color .15s;
    font-family: var(--font);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,110,247,.1);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ======== Table ======== */
.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: #f9fafb;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.data-table tbody tr:hover { background: #fafbfd; }
.data-table .empty-row td {
    text-align: center; padding: 40px;
    color: var(--text-muted);
}

/* ======== Tags / Badges ======== */
.tag {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px; font-weight: 500;
    border-radius: 99px;
    line-height: 1.6;
}
.tag-green { background: var(--success-light); color: #15803d; }
.tag-red { background: var(--danger-light); color: #b91c1c; }
.tag-yellow { background: var(--warning-light); color: #92400e; }
.tag-blue { background: var(--info-light); color: #1d4ed8; }
.tag-gray { background: #f3f4f6; color: #6b7280; }

/* ======== Modal ======== */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1000;
    align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 90%; max-width: 520px;
    max-height: 85vh;
    display: flex; flex-direction: column;
    animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-20px); } }
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 600; font-size: 15px;
}
.modal-close {
    width: 28px; height: 28px;
    border: none; background: none;
    cursor: pointer; font-size: 18px;
    color: var(--text-muted);
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #f3f4f6; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 8px;
}

/* ======== Toast ======== */
.toast-container {
    position: fixed; top: 20px; right: 20px;
    z-index: 2000;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    padding: 12px 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    animation: toastIn .25s ease;
    max-width: 360px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } }

/* ======== Switch / Toggle ======== */
.switch {
    position: relative;
    width: 40px; height: 22px;
    display: inline-block;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
    position: absolute; inset: 0;
    background: #d1d5db;
    border-radius: 99px;
    cursor: pointer;
    transition: .2s;
}
.switch-slider::before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    left: 3px; bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .2s;
}
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }

/* ======== Pagination ======== */
.pagination { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.pagination .page-btn {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
    color: var(--text-secondary);
}
.pagination .page-btn:hover { border-color: var(--primary); color: var(--primary); }
.pagination .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .page-btn:disabled { opacity: .4; cursor: not-allowed; }
.pagination .page-info { padding: 0 8px; color: var(--text-muted); }

/* ======== Filter Bar ======== */
.filter-bar {
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.search-wrap {
    position: relative;
    flex: 1; min-width: 200px;
}
.search-wrap .form-input { padding-left: 36px; }
.search-wrap svg {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--text-muted);
}

/* ======== Empty State ======== */
.empty-state {
    text-align: center; padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ======== Dropdown ======== */
.dropdown-wrap { position: relative; display: inline-block; }
.dropdown-menu {
    display: none;
    position: absolute; right: 0; top: 100%;
    margin-top: 4px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    min-width: 140px;
    z-index: 200;
    padding: 4px 0;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
    display: block; width: 100%;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    border: none; background: none; text-align: left;
}
.dropdown-item:hover { background: var(--primary-light); color: var(--primary); }

/* ======== Utility ======== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-mono { font-family: "SF Mono", "Fira Code", monospace; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ======== Landing Page (index.php) ======== */
.landing-hero {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}
.landing-hero::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(circle at 30% 50%, rgba(255,255,255,.12) 0%, transparent 60%);
}
.landing-container {
    position: relative; z-index: 1;
    max-width: 480px; width: 90%;
}
.landing-title {
    font-size: 32px; font-weight: 800;
    margin-bottom: 8px; text-align: center;
}
.landing-desc {
    font-size: 15px; opacity: .85;
    text-align: center; margin-bottom: 32px;
}
.auth-card {
    background: rgba(255,255,255,.12);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: var(--radius);
    padding: 32px;
}
.auth-card .form-input {
    background: rgba(255,255,255,.15);
    border-color: rgba(255,255,255,.25);
    color: #fff;
}
.auth-card .form-input::placeholder { color: rgba(255,255,255,.5); }
.auth-card .form-input:focus {
    border-color: rgba(255,255,255,.6);
    box-shadow: 0 0 0 3px rgba(255,255,255,.1);
}
.auth-card .form-label { color: rgba(255,255,255,.8); }
.auth-card .btn-primary {
    width: 100%; padding: 11px;
    font-size: 15px; font-weight: 600;
    background: #fff; color: var(--primary);
    border-color: #fff;
}
.auth-card .btn-primary:hover { background: #f0f0ff; }
.auth-tabs {
    display: flex; margin-bottom: 24px;
    border-bottom: 1px solid rgba(255,255,255,.2);
}
.auth-tab {
    flex: 1; padding: 10px;
    text-align: center; font-size: 14px;
    color: rgba(255,255,255,.6);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all .2s;
    background: none; border-left: none; border-right: none; border-top: none;
}
.auth-tab.active {
    color: #fff;
    border-bottom-color: #fff;
    font-weight: 600;
}

/* ======== Mobile ======== */
.sidebar-toggle {
    display: none;
    width: 36px; height: 36px;
    border: none; background: none;
    cursor: pointer; color: var(--text);
}
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.3);
    z-index: 99;
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
    .main { margin-left: 0; }
    .content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { flex-direction: column; }
    .topbar { padding: 0 16px; }
    .landing-title { font-size: 24px; }
}
