* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f5f5; color: #333; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Nav */
.nav { background: #1e293b; padding: 0 24px; display: flex; align-items: center; height: 56px; }
.nav-brand { color: #fff; font-weight: 700; font-size: 18px; margin-right: 32px; flex-shrink: 0; }
.nav-links { display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a { color: #94a3b8; padding: 8px 16px; border-radius: 6px; font-size: 14px; white-space: nowrap; }
.nav-links a:hover, .nav-links a.active { color: #fff; background: #334155; text-decoration: none; }
.nav-right { margin-left: auto; flex-shrink: 0; padding-left: 8px; }
.nav-right button { background: none; border: 1px solid #475569; color: #94a3b8; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.nav-right button:hover { color: #fff; border-color: #94a3b8; }

/* Content */
.content { max-width: 1200px; margin: 24px auto; padding: 0 24px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.page-header h1 { font-size: 24px; font-weight: 600; }

/* Cards */
.card { background: #fff; border-radius: 8px; border: 1px solid #e2e8f0; padding: 20px; margin-bottom: 16px; }

/* Stat grids */
.stat-grid { display: grid; gap: 16px; margin-bottom: 16px; }
.stat-grid-5 { grid-template-columns: repeat(5, 1fr); }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-grid-2 { grid-template-columns: repeat(2, 1fr); }
.stat-card { background: #fff; border-radius: 8px; border: 1px solid #e2e8f0; padding: 20px; text-align: center; }
.stat-card .stat-label { color: #94a3b8; font-size: 13px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-card .stat-detail { color: #94a3b8; font-size: 13px; margin-top: 2px; }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600; text-transform: uppercase; color: #64748b; border-bottom: 2px solid #e2e8f0; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
tr:hover td { background: #f8fafc; }

/* Badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-orange { background: #fed7aa; color: #9a3412; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red { background: #fecaca; color: #991b1b; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-blue { background: #dbeafe; color: #1e40af; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; font-size: 14px; font-weight: 500; border: none; cursor: pointer; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: none; color: #64748b; border: 1px solid #e2e8f0; }
.btn-ghost:hover { background: #f8fafc; color: #334155; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: #374151; margin-bottom: 4px; }
.form-group input, .form-group select { width: 100%; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-inline { padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; background: #fff; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 480px; max-width: 90vw; }
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* Alert */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* Utility */
.text-muted { color: #94a3b8; font-size: 13px; }
.hidden { display: none; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.scroll-y-360 { max-height: 360px; overflow-y: auto; border: 1px solid #e2e8f0; border-radius: 6px; }

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Tablet */
@media (max-width: 1024px) {
    .stat-grid-5 { grid-template-columns: repeat(3, 1fr); }
}

/* Mobile */
@media (max-width: 768px) {
    .nav { padding: 0 12px; height: 52px; }
    .nav-brand { margin-right: 16px; font-size: 16px; }
    .nav-links a { padding: 6px 10px; font-size: 13px; }
    .nav-right { padding-left: 6px; }
    .nav-right button { padding: 5px 10px; font-size: 12px; }

    .content { margin: 16px auto; padding: 0 12px; }
    .page-header h1 { font-size: 20px; }
    .page-header > div { flex-wrap: wrap; }

    .card { padding: 14px; border-radius: 6px; }
    .card[style*="padding: 0"] { padding: 0 !important; }

    .stat-grid { gap: 10px; }
    .stat-grid-5 { grid-template-columns: repeat(2, 1fr); }
    .stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
    .stat-card { padding: 14px; }
    .stat-card .stat-value { font-size: 22px; }

    th { padding: 8px 10px; font-size: 11px; }
    td { padding: 8px 10px; font-size: 13px; }

    .form-row { grid-template-columns: 1fr; }
    .modal { padding: 18px; width: 100%; max-width: 100vw; max-height: 100vh; border-radius: 0; overflow-y: auto; }
    .modal-backdrop { padding: 0; }
    .modal-actions { flex-wrap: wrap; }
    .modal-actions .btn { flex: 1; justify-content: center; }

    .btn { padding: 7px 12px; font-size: 13px; }
    .btn-sm { padding: 4px 8px; font-size: 12px; }
}

@media (max-width: 480px) {
    .stat-grid-5, .stat-grid-3 { grid-template-columns: repeat(2, 1fr); }
    .stat-grid-2 { grid-template-columns: 1fr; }
}
