/* ============================================
   金研院排課系統 - LINE@ Style Design System
   Primary: Green (#00B900)  |  Clean & Modern
   ============================================ */

:root {
    /* Primary - LINE Green */
    --primary: #00B900;
    --primary-light: #2dd42d;
    --primary-dark: #009a00;
    --primary-50: #edfff0;
    --primary-100: #d5f5d9;
    --primary-200: #a8e8ad;

    /* Secondary */
    --secondary: #1b1b1b;

    /* Status */
    --success: #00B900;
    --warning: #ff9500;
    --danger: #ff3b30;
    --info: #007aff;
    --accent: #5856d6;

    /* Neutrals */
    --gray-50: #f7f8fa;
    --gray-100: #f0f2f5;
    --gray-200: #e4e6eb;
    --gray-300: #ccd0d5;
    --gray-400: #a0a4ab;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Sidebar */
    --sidebar-bg: #f7f8fa;
    --sidebar-hover: #e8f5e9;
    --sidebar-active: #00B900;
    --sidebar-width: 260px;
    --sidebar-collapsed: 68px;

    /* Layout */
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei', 'Noto Sans TC', sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    background: var(--sidebar-bg);
    width: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 50;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
    border-right: 1px solid var(--gray-200);
}

.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand-logo {
    width: 38px; height: 38px;
    border-radius: 10px;
    flex-shrink: 0;
    background: #fff;
    padding: 2px;
    object-fit: contain;
}

.sidebar-brand-icon {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand h1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.sidebar-brand p {
    font-size: 0.7rem;
    color: var(--gray-400);
    margin-top: 1px;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
    white-space: nowrap;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: var(--gray-800);
}

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 185, 0, 0.35);
}

.sidebar-nav a .nav-icon {
    width: 20px; height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-section-label {
    padding: 16px 14px 6px;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--gray-200);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    color: var(--gray-700);
    font-size: 0.825rem;
}

.sidebar-user .avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--gray-500);
    font-size: 0.825rem;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: all var(--transition);
}

.sidebar-logout:hover {
    background: rgba(255, 59, 48, 0.12);
    color: #ff6b6b;
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 45;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 24px 28px;
    min-height: 100vh;
    flex: 1;
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease;
}

/* Mobile header bar */
.mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 40;
    background: #fff;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
    align-items: center;
    gap: 12px;
}

.hamburger-btn {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--gray-700);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hamburger-btn:hover { background: var(--gray-100); }

.mobile-header-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-900);
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-body { padding: 20px; }
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--gray-100);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--gray-700);
    background: var(--gray-50);
}

/* Stat cards */
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 2px;
    font-weight: 500;
}

.stat-card.primary::before { background: var(--primary); }
.stat-card.primary .stat-value { color: var(--primary); }
.stat-card.primary .stat-icon { background: var(--primary-50); color: var(--primary); }

.stat-card.warning::before { background: var(--warning); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.warning .stat-icon { background: #fff8ed; color: var(--warning); }

.stat-card.success::before { background: var(--success); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.success .stat-icon { background: var(--primary-50); color: var(--success); }

.stat-card.accent::before { background: var(--accent); }
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.accent .stat-icon { background: #f0f0ff; color: var(--accent); }

.stat-card.info::before { background: var(--info); }
.stat-card.info .stat-value { color: var(--info); }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(0, 185, 0, 0.3);
}

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: var(--primary-dark); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #e6342b; }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #e68700; }

.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: #0066d6; }

.btn-outline {
    background: #fff;
    color: var(--gray-700);
    border: 1.5px solid var(--gray-200);
}
.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }

.btn-ghost {
    background: none;
    border: none;
    color: var(--gray-500);
    padding: 6px 10px;
}
.btn-ghost:hover {
    color: var(--gray-700);
    background: var(--gray-100);
}

.btn-icon {
    width: 34px; height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* ============================================
   TABLES
   ============================================ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-100);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    font-size: 0.85rem;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover { background: #f0fdf4; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--gray-800);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 185, 0, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--gray-400);
}

.form-input:disabled,
.form-select:disabled {
    background: var(--gray-50);
    color: var(--gray-400);
    cursor: not-allowed;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.badge-draft { background: var(--gray-100); color: var(--gray-600); }
.badge-invited { background: #fff3cd; color: #856404; }
.badge-confirmed { background: #d4edda; color: #155724; }
.badge-rejected { background: #f8d7da; color: #721c24; }
.badge-completed { background: #cce5ff; color: #004085; }
.badge-cancelled { background: var(--gray-100); color: var(--gray-400); }

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    padding: 16px;
}

.modal-content {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    padding: 24px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   FILTER BAR
   ============================================ */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    margin-bottom: 16px;
}

.filter-bar select,
.filter-bar input[type="text"],
.filter-bar input[type="date"] {
    padding: 7px 12px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--gray-700);
    background: #fff;
    font-family: inherit;
    transition: border-color var(--transition);
}

.filter-bar select:focus,
.filter-bar input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ============================================
   QUICK ACTIONS
   ============================================ */
.quick-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all var(--transition);
    border: 1.5px solid transparent;
}

.quick-action:hover { transform: translateX(4px); }

.quick-action.green {
    background: var(--primary-50);
    color: var(--primary-dark);
    border-color: var(--primary-100);
}

.quick-action.blue {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #dbeafe;
}

.quick-action.amber {
    background: #fffbeb;
    color: #b45309;
    border-color: #fef3c7;
}

.quick-action .qa-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.5;
}

.alert-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.alert-info {
    background: var(--primary-50);
    border: 1px solid var(--primary-100);
    color: var(--primary-dark);
}

.alert-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

/* ============================================
   BATCH BAR
   ============================================ */
.batch-bar {
    background: var(--primary-50);
    border: 1.5px solid var(--primary-100);
    border-radius: var(--radius);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--gray-400);
    font-size: 0.875rem;
}

.empty-state svg {
    margin: 0 auto 12px;
    opacity: 0.4;
}

/* ============================================
   TOAST / NOTIFICATION (future use)
   ============================================ */
.toast {
    position: fixed;
    top: 20px; right: 20px;
    background: var(--gray-800);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 100;
    animation: toastIn 0.3s ease;
}

.toast-success { background: var(--primary); }
.toast-error { background: var(--danger); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   DASHBOARD — Quad Grid Layout
   ============================================ */

/* Full-height container */
.dash-grid-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);
    /* 48px = top padding of main-content */
}

.dash-grid-container .page-header {
    flex-shrink: 0;
}

/* 2x2 Grid */
.dash-quad {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.dash-quad-cell {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.dash-quad-cell .card-header {
    flex-shrink: 0;
}

.dash-quad-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.dash-scroll-body {
    overflow-y: auto;
}

/* Mini stats grid (inside top-left cell) */
.dash-mini-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.dash-mini-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 8px;
    border-radius: var(--radius-sm);
    background: var(--gray-50);
    text-decoration: none;
    transition: all var(--transition);
    cursor: pointer;
}

.dash-mini-stat:hover {
    background: var(--primary-50);
    transform: translateY(-1px);
}

.dash-mini-stat:active {
    transform: translateY(0);
}

.dash-mini-number {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.dash-mini-number.primary { color: var(--primary); }
.dash-mini-number.warning { color: var(--warning); }
.dash-mini-number.success { color: var(--success); }
.dash-mini-number.accent { color: var(--accent); }
.dash-mini-number.info { color: var(--info); }
.dash-mini-number.muted { color: var(--gray-400); }

.dash-mini-label {
    font-size: 0.7rem;
    color: var(--gray-500);
    font-weight: 600;
    margin-top: 4px;
    white-space: nowrap;
}

/* Status progress bar */
.dash-progress-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    gap: 2px;
    margin-bottom: 8px;
}

.dash-progress-segment {
    border-radius: 4px;
    transition: flex 0.7s ease;
}

.seg-draft { background: var(--gray-300); }
.seg-invited { background: #f59e0b; }
.seg-confirmed { background: var(--primary); }
.seg-rejected { background: #ef4444; }
.seg-completed { background: #3b82f6; }
.seg-cancelled { background: var(--gray-200); }

.dash-progress-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.dash-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: var(--gray-500);
}

.dash-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Status breakdown row */
.dash-status-row {
    display: flex;
    align-items: center;
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background var(--transition);
}

.dash-status-row:hover {
    background: var(--gray-50);
}

/* Upcoming course list item */
.dash-course-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--gray-100);
    transition: background var(--transition);
}

.dash-course-item:last-child { border-bottom: none; }
.dash-course-item:hover { background: #f0fdf4; }

.dash-course-date {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--primary-50);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1.5px solid var(--primary-100);
}

.dash-date-day {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary-dark);
    line-height: 1;
}

.dash-date-weekday {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--primary);
    line-height: 1;
    margin-top: 1px;
}

/* Action items */
.dash-action-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--gray-100);
    text-decoration: none;
    transition: background var(--transition);
    cursor: pointer;
}

.dash-action-item:last-child { border-bottom: none; }
.dash-action-item:hover { background: var(--gray-50); }

.dash-action-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Dashboard Tablet */
@media (max-width: 1024px) {
    .dash-grid-container {
        height: auto;
    }

    .dash-quad {
        grid-template-rows: auto auto;
    }

    .dash-quad-cell {
        min-height: 280px;
    }
}

/* Dashboard Mobile */
@media (max-width: 768px) {
    .dash-grid-container {
        height: auto;
    }

    .dash-quad {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 12px;
    }

    .dash-quad-cell {
        min-height: 0;
    }

    .dash-scroll-body {
        max-height: 320px;
    }

    .dash-mini-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .dash-mini-number {
        font-size: 1.3rem;
    }

    .dash-mini-stat {
        padding: 10px 6px;
    }

    .dash-course-item {
        padding: 10px 16px;
        gap: 10px;
    }

    .dash-action-item {
        padding: 10px 16px;
    }

    .dash-progress-legend {
        gap: 6px;
    }

    .dash-legend-item {
        font-size: 0.65rem;
    }
}

@media (max-width: 480px) {
    .dash-mini-number {
        font-size: 1.1rem;
    }

    .dash-mini-label {
        font-size: 0.62rem;
    }
}

/* ============================================
   FULL-PAGE LIST LAYOUT (for data management pages)
   ============================================ */
.list-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);
}

.list-page .page-header {
    flex-shrink: 0;
}

.list-page .filter-bar {
    flex-shrink: 0;
}

.list-page .batch-bar {
    flex-shrink: 0;
}

.list-page .table-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.list-page .table-wrapper .data-table {
    flex-shrink: 0;
}

.list-page .table-wrapper {
    overflow-y: auto;
}

/* Table columns stretch full width */
.data-table.stretch-cols th,
.data-table.stretch-cols td {
    white-space: nowrap;
}

.data-table.stretch-cols th:first-child,
.data-table.stretch-cols td:first-child {
    width: 25%;
}

/* Mobile cards also fill */
.list-page .mobile-cards {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

@media (max-width: 1024px) {
    .list-page {
        height: auto;
        min-height: calc(100vh - 48px);
    }
}

@media (max-width: 768px) {
    .list-page {
        height: auto;
        min-height: 0;
    }
}

/* ============================================
   MOBILE CARD LIST (replaces tables on mobile)
   ============================================ */
.mobile-cards {
    display: none;
}

.mobile-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
    padding: 16px;
    margin-bottom: 12px;
    transition: box-shadow var(--transition);
}

.mobile-card:active {
    box-shadow: var(--shadow-md);
}

.mobile-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.mobile-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-800);
}

.mobile-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    margin-bottom: 12px;
}

.mobile-card-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mobile-card-field.full-width {
    grid-column: 1 / -1;
}

.mobile-card-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.mobile-card-value {
    font-size: 0.85rem;
    color: var(--gray-700);
}

.mobile-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
}

.mobile-card-actions .btn {
    flex: 1;
    justify-content: center;
}

/* ============================================
   RESPONSIVE: TABLET (769px - 1024px)
   ============================================ */
@media (max-width: 1024px) {
    .main-content {
        padding: 20px;
    }

    .page-header h2 {
        font-size: 1.2rem;
    }

    .filter-bar {
        padding: 10px 12px;
    }
}

/* ============================================
   RESPONSIVE: MOBILE (< 769px)
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: min(85vw, 300px);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 0 0 24px;
    }

    .mobile-header {
        display: flex;
    }

    .page-header {
        margin-bottom: 16px;
    }

    .page-header h2 {
        font-size: 1.15rem;
    }

    /* Make page content have padding on mobile */
    .page-content-padded {
        padding: 0 16px;
    }

    /* Filter bar stacks vertically */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .filter-bar select,
    .filter-bar input[type="text"],
    .filter-bar input[type="date"] {
        width: 100%;
        min-height: 44px;
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    /* Date range stack */
    .filter-date-range {
        flex-direction: column;
        width: 100%;
    }

    .filter-date-range input[type="date"] {
        width: 100%;
    }

    /* Table hidden on mobile, show cards */
    .desktop-table {
        display: none;
    }

    .mobile-cards {
        display: block;
    }

    /* Table horizontal scroll (fallback) */
    .table-wrapper {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    /* Cards */
    .card {
        border-radius: var(--radius-sm);
    }

    .card-body { padding: 16px; }
    .card-header { padding: 12px 16px; }

    /* Stat cards */
    .stat-card { padding: 16px; }
    .stat-card .stat-value { font-size: 1.5rem; }

    /* Touch-friendly buttons */
    .btn {
        padding: 10px 16px;
        font-size: 0.84rem;
        min-height: 44px;
    }

    .btn-sm {
        padding: 8px 14px;
        min-height: 40px;
    }

    .btn-icon {
        width: 44px;
        height: 44px;
    }

    /* Touch-friendly checkboxes */
    input[type="checkbox"] {
        width: 20px;
        height: 20px;
        cursor: pointer;
    }

    /* Touch-friendly form inputs */
    .form-input,
    .form-select,
    .form-textarea {
        padding: 12px 16px;
        font-size: 16px; /* prevents iOS zoom */
        min-height: 44px;
    }

    /* Modal fullscreen-ish on mobile */
    .modal-overlay {
        padding: 8px;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) var(--radius) var(--radius);
        padding: 20px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        margin: 0;
        max-height: calc(100vh - 32px);
    }

    /* Batch bar */
    .batch-bar {
        flex-wrap: wrap;
        gap: 10px;
    }

    .batch-bar .btn {
        flex: 1;
        justify-content: center;
    }

    /* Form button group stack */
    .form-actions-mobile {
        flex-direction: column;
    }

    .form-actions-mobile .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   RESPONSIVE: SMALL MOBILE (< 480px)
   ============================================ */
@media (max-width: 480px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-card .stat-value { font-size: 1.3rem; }

    .mobile-card-body {
        grid-template-columns: 1fr;
    }

    .page-content-padded {
        padding: 0 12px;
    }
}

/* ============================================
   SIDEBAR GUIDE BUTTON
   ============================================ */
.sidebar-guide-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-size: 0.825rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition);
    margin-bottom: 4px;
}

.sidebar-guide-btn:hover {
    background: var(--primary-50);
}

/* ============================================
   AI ASSISTANT FLOATING PANEL
   ============================================ */
.ai-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 185, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 70;
    transition: all 0.3s ease;
}

.ai-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 185, 0, 0.45);
}

.ai-fab-active {
    background: var(--gray-700);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.ai-chat-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    z-index: 70;
    overflow: hidden;
}

.ai-chat-header {
    padding: 14px 18px;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 200px;
    max-height: 360px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.85rem;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}

.ai-msg-user {
    background: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-msg-bot {
    background: var(--gray-100);
    color: var(--gray-800);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ai-thinking {
    opacity: 0.6;
    animation: aiPulse 1.5s ease-in-out infinite;
}

@keyframes aiPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

.ai-chat-input {
    padding: 12px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .ai-fab {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
    }

    .ai-chat-panel {
        bottom: 76px;
        right: 8px;
        left: 8px;
        width: auto;
        max-height: 70vh;
    }
}

/* ============================================
   UTILITIES
   ============================================ */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: rgba(0, 185, 0, 0.15);
}

/* Print */
@media print {
    .sidebar, .mobile-header, .sidebar-overlay { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; }
}
