/* ========== CSS Variables ========== */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --white: #ffffff;
    --bg: #f1f5f9;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-secondary: #64748b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --sidebar-width: 220px;
}

/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif; font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.6; min-height: 100vh; }

/* ========== Login ========== */
.login-wrapper { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-box { width: 100%; max-width: 400px; background: var(--white); padding: 40px; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,0.08); }
.login-box h1 { font-size: 24px; text-align: center; margin-bottom: 4px; color: var(--primary); }
.login-subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 32px; font-size: 14px; }
.login-hint { text-align: center; color: var(--text-secondary); font-size: 12px; margin-top: 20px; }

/* ========== Sidebar ========== */
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-width); background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; z-index: 100; }
.sidebar-brand { padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-brand h2 { font-size: 17px; color: var(--white); font-weight: 600; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item { display: block; padding: 10px 20px; color: #94a3b8; text-decoration: none; font-size: 14px; transition: all 0.15s; }
.nav-item:hover, .nav-item.active { color: var(--white); background: rgba(255,255,255,0.06); }
.nav-item.active { border-left: 3px solid var(--primary); }
.nav-section { padding: 14px 20px 6px; color: #64748b; font-size: 12px; font-weight: 600; letter-spacing: 0.3px; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.08); display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.logout-btn { color: #94a3b8; text-decoration: none; font-size: 12px; }
.logout-btn:hover { color: var(--white); }

/* ========== Main ========== */
.main { margin-left: var(--sidebar-width); padding: 24px 32px; min-height: 100vh; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 22px; font-weight: 700; }

/* ========== Cards ========== */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 24px; }
.card h3 { font-size: 16px; margin-bottom: 16px; }
.form-card { max-width: 640px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }

/* ========== Stats Grid ========== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-value.green { color: var(--success); }
.stat-value.red { color: var(--danger); }

/* ========== Buttons ========== */
.btn { display: inline-block; padding: 8px 18px; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; text-decoration: none; transition: all 0.15s; font-weight: 500; }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: var(--white); color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-block { display: block; width: 100%; padding: 12px; }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-warn { color: var(--danger); }
.btn-warn:hover { background: #fef2f2; }
.quick-actions { display: flex; gap: 12px; }

/* ========== Notices & Progress ========== */
.notice { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.notice-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.seed-loading { position: fixed; inset: 0; z-index: 300; display: none; align-items: center; justify-content: center; background: rgba(15, 23, 42, 0.42); padding: 20px; }
.seed-loading.show { display: flex; }
.seed-loading-box { width: min(420px, 100%); background: var(--white); border-radius: 8px; padding: 24px; box-shadow: 0 16px 48px rgba(15, 23, 42, 0.2); }
.seed-loading-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.seed-loading-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 18px; }
.progress-bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--primary-light); }
.progress-bar span { display: block; width: 42%; height: 100%; border-radius: inherit; background: var(--primary); animation: seed-progress 1.1s ease-in-out infinite; }
@keyframes seed-progress {
    0% { transform: translateX(-110%); }
    100% { transform: translateX(260%); }
}

/* ========== Forms ========== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; color: var(--text); }
.form-input { display: block; width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; color: var(--text); background: var(--white); transition: border-color 0.15s; }
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; margin-bottom: 16px; }
.required { color: var(--danger); }

/* ========== Table ========== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #f8fafc; font-weight: 600; font-size: 13px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; }
tr:hover td { background: #f8fafc; }
.empty { text-align: center; color: var(--text-secondary); padding: 40px 0 !important; }

/* ========== Badges ========== */
.badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 500; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fef2f2; color: #991b1b; }
.badge-info { background: var(--primary-light); color: #1e40af; }

/* ========== Pagination ========== */
.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 20px; list-style: none; }
.pagination li { display: inline; }
.pagination a, .pagination span { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; text-decoration: none; color: var(--text); }
.pagination .active span { background: var(--primary); color: var(--white); border-color: var(--primary); }
.pagination .disabled span { color: #cbd5e1; }

/* ========== Tabs ========== */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab-item { padding: 10px 20px; color: var(--text-secondary); text-decoration: none; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; }
.tab-item:hover, .tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ========== Filter Bar ========== */
.filter-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.filter-bar .form-input { width: auto; min-width: 150px; }
.filter-bar select.form-input { width: auto; }

/* ========== Modal (simple) ========== */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal-box { background: var(--white); border-radius: 12px; padding: 32px; max-width: 500px; width: 90%; box-shadow: 0 8px 32px rgba(0,0,0,0.15); }
.modal-box h3 { margin-bottom: 16px; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .sidebar { width: 180px; --sidebar-width: 180px; }
    .sidebar-brand h2 { font-size: 15px; }
    .main { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .two-col { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 480px) {
    .sidebar { display: none; }
    .main { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr; }
}
