/* ==========================================================================
   ALIF ACADEMY CRM — Apple Human Interface & Minimalist Design System
   Refined, monochrome, sophisticated, minimalist typography & blur
   ========================================================================== */

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

:root {
    /* Apple Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Helvetica Neue", sans-serif;

    /* Apple Dark Palette (Neutral, Monochrome, Deep) */
    --bg-page: #000000;
    --bg-surface: #121214;
    --bg-card: rgba(28, 28, 30, 0.72);
    --bg-card-hover: rgba(38, 38, 42, 0.85);
    --bg-input: rgba(44, 44, 46, 0.6);
    --bg-pill: rgba(255, 255, 255, 0.06);

    /* Apple Hairline Borders */
    --border-hairline: rgba(255, 255, 255, 0.1);
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-focus: #0071e3;

    /* Apple Text Hierarchy */
    --text-primary: #f5f5f7;
    --text-secondary: #86868b;
    --text-tertiary: #636366;

    /* Apple Restrained Accents */
    --apple-blue: #0071e3;
    --apple-blue-hover: #0077ed;
    --apple-green: #30d158;
    --apple-orange: #ff9f0a;
    --apple-red: #ff453a;

    /* Apple Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-pill: 980px;

    /* Shadows & Transitions */
    --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--border-hairline);
    --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Apple Light Theme (Clean, Crisp, Minimalist)
   ========================================================================== */
[data-theme="light"] {
    --bg-page: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-hover: #f1f5f9;
    --bg-input: #ffffff;
    --bg-pill: rgba(0, 0, 0, 0.05);

    --border-hairline: rgba(0, 0, 0, 0.12);
    --border-subtle: rgba(0, 0, 0, 0.07);
    --border-focus: #0071e3;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #64748b;

    --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.05);
    --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] body {
    background-color: var(--bg-page);
    color: var(--text-primary);
}

[data-theme="light"] .app-navbar {
    background: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .brand-logo-icon {
    background: #0f172a;
    color: #ffffff;
}

[data-theme="light"] .brand-badge {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.08);
    color: #475569;
}

[data-theme="light"] .nav-links {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .nav-link {
    color: #64748b;
}

[data-theme="light"] .nav-link:hover {
    color: #0f172a;
}

[data-theme="light"] .nav-link.active {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .user-profile-badge {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.08);
    color: #0f172a;
}

[data-theme="light"] .user-avatar {
    background: #0f172a;
    color: #ffffff;
}

[data-theme="light"] .metric-card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .metric-value {
    color: #0f172a !important;
}

[data-theme="light"] .metric-sub {
    color: #64748b;
}

[data-theme="light"] .metric-icon-wrap {
    background: rgba(0, 113, 227, 0.08);
    color: #0071e3;
}

[data-theme="light"] .filter-card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .search-box {
    background: #f8fafc;
    border-color: rgba(0, 0, 0, 0.1);
    color: #0f172a;
}

[data-theme="light"] .search-input {
    color: #0f172a;
}

[data-theme="light"] .search-input::placeholder {
    color: #94a3b8;
}

[data-theme="light"] .select-filter {
    background-color: #f8fafc;
    border-color: rgba(0, 0, 0, 0.1);
    color: #0f172a;
}

[data-theme="light"] .table-card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .table-header-title {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .table-header-title h3 {
    color: #0f172a !important;
}

[data-theme="light"] .custom-table th {
    background: #f8fafc;
    color: #475569;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .custom-table td {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    color: #334155;
}

[data-theme="light"] .custom-table tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .student-avatar {
    background: #f1f5f9;
    color: #0f172a;
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .student-name {
    color: #0f172a !important;
}

[data-theme="light"] .course-tag {
    background: rgba(0, 113, 227, 0.08);
    color: #0071e3;
    border-color: rgba(0, 113, 227, 0.18);
}

[data-theme="light"] .progress-track {
    background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .status-partial {
    background: rgba(0, 0, 0, 0.06);
    color: #334155;
}

[data-theme="light"] .status-upcoming {
    background: rgba(0, 0, 0, 0.05);
    color: #64748b;
}

[data-theme="light"] .btn-secondary {
    background: #f1f5f9;
    color: #0f172a;
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .btn-secondary:hover {
    background: #e2e8f0;
    color: #000000;
}

[data-theme="light"] .modal-backdrop {
    background: rgba(15, 23, 42, 0.45);
}

[data-theme="light"] .modal-dialog {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.15);
    color: #0f172a;
}

[data-theme="light"] .modal-header {
    border-bottom-color: rgba(0, 0, 0, 0.07);
}

[data-theme="light"] .modal-title {
    color: #0f172a !important;
}

[data-theme="light"] .modal-close {
    background: rgba(0, 0, 0, 0.05);
    color: #64748b;
}

[data-theme="light"] .modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #0f172a;
}

[data-theme="light"] .modal-footer {
    border-top-color: rgba(0, 0, 0, 0.07);
    background: #f8fafc;
}

[data-theme="light"] .form-label {
    color: #334155;
}

[data-theme="light"] .form-control {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.15);
    color: #0f172a;
}

[data-theme="light"] .form-control:focus {
    background: #ffffff;
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

[data-theme="light"] .calc-box {
    background: rgba(0, 113, 227, 0.06);
    border-color: rgba(0, 113, 227, 0.2);
}

[data-theme="light"] .calc-val {
    color: #0071e3;
}

[data-theme="light"] .app-bottom-nav {
    background: rgba(255, 255, 255, 0.94);
    border-top-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .bottom-nav-item.active {
    color: #0071e3;
}

[data-theme="light"] .toast {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(0, 0, 0, 0.1);
    color: #0f172a;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .page-title {
    color: #0f172a !important;
}

[data-theme="light"] .page-subtitle {
    color: #475569 !important;
}

[data-theme="light"] h1, 
[data-theme="light"] h2, 
[data-theme="light"] h3, 
[data-theme="light"] h4, 
[data-theme="light"] h5, 
[data-theme="light"] h6 {
    color: #0f172a;
}

[data-theme="light"] .calc-label {
    color: #64748b;
}

[data-theme="light"] .calc-val {
    color: #0f172a !important;
}

[data-theme="light"] .custom-table tr {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .custom-table td {
    color: #1e293b;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .modal-header::before {
    background: rgba(0, 0, 0, 0.15);
}

/* Theme Toggle Button */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-pill);
    background: var(--bg-pill);
    border: 1px solid var(--border-hairline);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
    flex-shrink: 0;
}
.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.05);
}
[data-theme="light"] .theme-toggle-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #0f172a;
}
[data-theme="light"] .theme-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.09);
}

/* Operator Badge */
.badge-operator {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.725rem;
    font-weight: 500;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-pill);
    background: rgba(0, 113, 227, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(0, 113, 227, 0.3);
}
[data-theme="light"] .badge-operator {
    background: rgba(0, 113, 227, 0.08);
    color: #0071e3;
    border-color: rgba(0, 113, 227, 0.2);
}


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.45;
    letter-spacing: -0.01em;
}

/* ==========================================================================
   Apple Translucent Navigation Bar
   ========================================================================== */

.app-navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(18, 18, 20, 0.75);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.75rem 2rem;
}

.navbar-container {
    max-width: 1360px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.brand-logo-icon {
    width: 32px;
    height: 32px;
    background: #ffffff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000000;
    font-size: 0.95rem;
}

.brand-info h1 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.brand-badge {
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.08);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-hairline);
}

.brand-info p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    list-style: none;
    background: rgba(255, 255, 255, 0.04);
    padding: 0.25rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.95rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.815rem;
    font-weight: 500;
    border-radius: var(--radius-pill);
    transition: var(--transition);
}

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

.nav-link.active {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-hairline);
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    color: var(--text-primary);
}

.user-avatar {
    width: 22px;
    height: 22px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: #ffffff;
}

/* ==========================================================================
   Page Layout
   ========================================================================== */

.app-main {
    max-width: 1360px;
    margin: 0 auto;
    padding: 2.25rem 2rem 5rem;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

/* ==========================================================================
   Apple Buttons (Pill / Minimal / Refined)
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1.15rem;
    font-family: var(--font-sans);
    font-size: 0.815rem;
    font-weight: 500;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: #0071e3;
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--apple-blue-hover);
    transform: scale(1.01);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-hairline);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.14);
}

.btn-success {
    background: rgba(48, 209, 88, 0.15);
    border: 1px solid rgba(48, 209, 88, 0.3);
    color: #30d158;
}

.btn-success:hover {
    background: #30d158;
    color: #000000;
}

.btn-danger {
    background: rgba(255, 69, 58, 0.12);
    border: 1px solid rgba(255, 69, 58, 0.25);
    color: #ff453a;
}

.btn-danger:hover {
    background: #ff453a;
    color: #ffffff;
}

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

.btn-icon {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
}

/* ==========================================================================
   Apple Metrics Cards (Monochrome Minimalist)
   ========================================================================== */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--bg-card);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.35rem;
    box-shadow: var(--shadow-subtle);
    transition: var(--transition);
}

.metric-card:hover {
    border-color: var(--border-hairline);
    background: var(--bg-card-hover);
}

.metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
}

.metric-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.metric-icon-wrap {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.metric-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.metric-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.45rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* ==========================================================================
   Search & Filter Toolbar
   ========================================================================== */

.filter-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.15rem;
    margin-bottom: 1.25rem;
}

.filter-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.85rem;
}

.search-box {
    position: relative;
    flex: 1 1 300px;
}

.search-box i {
    position: absolute;
    left: 0.95rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

.search-input {
    width: 100%;
    padding: 0.55rem 0.95rem 0.55rem 2.4rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    color: var(--text-primary);
    font-size: 0.825rem;
    font-family: var(--font-sans);
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-hairline);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.select-filter {
    padding: 0.55rem 0.95rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    color: var(--text-primary);
    font-size: 0.815rem;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: var(--transition);
}

.select-filter:focus {
    outline: none;
    border-color: var(--border-hairline);
}

/* ==========================================================================
   Minimalist Data Grid / Table
   ========================================================================== */

.table-card {
    background: var(--bg-card);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 2rem;
}

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

.table-header-title h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.015em;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.825rem;
}

.custom-table th {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.725rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.custom-table td {
    padding: 0.95rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

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

.custom-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.custom-table tbody tr.clickable-row {
    cursor: pointer;
}

.custom-table tbody tr.clickable-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .custom-table tbody tr.clickable-row:hover {
    background: rgba(0, 0, 0, 0.035);
}

.custom-table tbody tr.clickable-row:hover .student-name {
    color: var(--apple-blue);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Student Cell */
.student-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.student-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.775rem;
    flex-shrink: 0;
}

.student-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    letter-spacing: -0.01em;
}

.student-phone {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Course Tag */
.course-tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 500;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Minimal Progress Track */
.progress-bar-wrap {
    width: 120px;
    margin-top: 0.35rem;
}

.progress-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #ffffff;
    border-radius: var(--radius-pill);
    transition: width 0.3s ease;
}

/* Apple Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-pill);
    font-size: 0.725rem;
    font-weight: 500;
    white-space: nowrap;
}

.status-paid {
    background: rgba(48, 209, 88, 0.12);
    color: #30d158;
}

.status-partial {
    background: rgba(255, 255, 255, 0.08);
    color: #e5e5ea;
}

.status-overdue {
    background: rgba(255, 69, 58, 0.15);
    color: #ff453a;
}

.status-today {
    background: rgba(255, 159, 10, 0.15);
    color: #ff9f0a;
}

.status-upcoming {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

.actions-cell {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

/* ==========================================================================
   Apple Modals (Sheet Dialogues)
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    background: #1c1c1e;
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.96);
    transition: var(--transition);
}

.modal-backdrop.active .modal-dialog {
    transform: scale(1);
}

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

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.modal-close {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-secondary);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

.modal-body {
    padding: 1.4rem 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
}

/* Forms */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
    margin-bottom: 0.85rem;
}

.form-group {
    margin-bottom: 0.85rem;
}

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

.form-label span.req {
    color: var(--apple-red);
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.825rem;
    font-family: var(--font-sans);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--apple-blue);
    background: rgba(0, 0, 0, 0.55);
}

textarea.form-control {
    resize: vertical;
    min-height: 70px;
}

.calc-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.calc-label {
    font-size: 0.775rem;
    color: var(--text-secondary);
}

.calc-val {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ==========================================================================
   Apple Toasts
   ========================================================================== */

#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: rgba(28, 28, 30, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-pill);
    padding: 0.65rem 1.15rem;
    color: #ffffff;
    font-size: 0.815rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    animation: toastIn 0.25s ease forwards;
}

.toast-success { color: #ffffff; }
.toast-error { color: #ff453a; }

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

/* ==========================================================================
   Grids & Layout Helpers
   ========================================================================== */

.stats-charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stats-tables-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

/* ==========================================================================
   Apple iOS Bottom Tab Bar (Mobile / Smartphones)
   ========================================================================== */

.app-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(18, 18, 20, 0.92);
    backdrop-filter: saturate(180%) blur(25px);
    -webkit-backdrop-filter: saturate(180%) blur(25px);
    border-top: 1px solid var(--border-subtle);
    padding: 0.45rem 0.5rem max(0.45rem, env(safe-area-inset-bottom));
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    flex: 1;
    max-width: 72px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item i {
    font-size: 1.15rem;
    transition: var(--transition);
}

.bottom-nav-item:hover,
.bottom-nav-item:active {
    color: var(--text-primary);
}

.bottom-nav-item.active {
    color: var(--text-primary);
    font-weight: 600;
}

.bottom-nav-item.active i {
    transform: scale(1.1);
    color: var(--apple-blue);
    filter: drop-shadow(0 0 8px rgba(0, 113, 227, 0.6));
}

/* ==========================================================================
   Comprehensive Tablet & Mobile Responsive Design
   ========================================================================== */

/* --- TABLETS (Landscape & Portrait: 769px - 1024px) --- */
@media (max-width: 1024px) {
    .app-navbar {
        padding: 0.75rem 1.25rem;
    }
    .navbar-container {
        gap: 1rem;
    }
    .nav-links {
        gap: 0.2rem;
    }
    .nav-link {
        padding: 0.35rem 0.65rem;
        font-size: 0.76rem;
    }
    .app-main {
        padding: 1.75rem 1.25rem 4rem;
    }
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    .stats-charts-grid,
    .stats-tables-grid,
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
}

/* --- MOBILE PHONES & SMALL TABLETS (<= 768px) --- */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    .app-navbar {
        padding: 0.65rem 1rem;
    }
    .nav-links {
        display: none !important; /* Managed by bottom tab bar */
    }
    .app-bottom-nav {
        display: flex;
    }
    .brand-info p {
        display: none;
    }
    .brand-badge {
        display: none;
    }
    .user-profile-badge span {
        display: none;
    }
    .user-profile-badge {
        padding: 0;
        background: transparent;
        border: none;
    }
    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
    .app-main {
        padding: 1.25rem 1rem max(5.5rem, calc(4.5rem + env(safe-area-inset-bottom)));
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.85rem;
        margin-bottom: 1.25rem;
    }
    .page-title {
        font-size: 1.4rem;
    }
    .page-subtitle {
        font-size: 0.8rem;
    }
    .header-actions {
        width: 100%;
        display: flex;
        gap: 0.5rem;
    }
    .header-actions .btn,
    .header-actions a.btn {
        flex: 1;
        font-size: 0.8rem;
        padding: 0.65rem 0.85rem;
        text-align: center;
        justify-content: center;
    }

    /* Filters on Mobile */
    .filter-card {
        padding: 0.85rem;
        margin-bottom: 1rem;
        border-radius: var(--radius-sm);
    }
    .filter-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }
    .search-box {
        flex: 1 1 100%;
        width: 100%;
    }
    .search-input {
        width: 100%;
        padding: 0.65rem 0.95rem 0.65rem 2.4rem;
        font-size: 16px !important; /* iOS zoom prevention */
        height: 42px;
    }
    .filter-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
        gap: 0.5rem;
    }
    .filter-group #filter-course {
        grid-column: span 2;
    }
    .select-filter {
        width: 100%;
        font-size: 16px !important; /* iOS zoom prevention */
        height: 42px;
        padding: 0.55rem 0.85rem;
    }

    /* Transform Tables into Apple Cards for Touch Screens */
    .table-card {
        background: transparent;
        border: none;
        box-shadow: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        overflow: visible;
        margin-bottom: 1.25rem;
    }
    .table-header-title {
        padding: 0 0 0.85rem 0;
        border-bottom: none;
    }
    .table-header-title h3 {
        font-size: 1.05rem;
    }

    .custom-table,
    .custom-table tbody,
    .custom-table tr,
    .custom-table td {
        display: block;
        width: 100%;
    }
    .custom-table thead {
        display: none;
    }
    .custom-table tr {
        background: var(--bg-card);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid var(--border-hairline);
        border-radius: var(--radius-md);
        padding: 1rem;
        margin-bottom: 0.85rem;
        box-shadow: var(--shadow-subtle);
    }
    .custom-table td {
        padding: 0.5rem 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: left;
    }
    .custom-table td[data-label]::before {
        content: attr(data-label);
        font-size: 0.72rem;
        font-weight: 500;
        color: var(--text-tertiary);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-right: 0.75rem;
        flex-shrink: 0;
    }
    .custom-table td[data-label="O'quvchi"]::before,
    .custom-table td[data-label="Amallar"]::before {
        display: none;
    }
    .custom-table td:first-child {
        padding-top: 0;
        padding-bottom: 0.75rem;
        margin-bottom: 0.35rem;
        border-bottom: 1px solid var(--border-subtle);
    }
    .custom-table td:last-child {
        border-bottom: none;
        padding-bottom: 0;
        padding-top: 0.75rem;
        margin-top: 0.35rem;
        border-top: 1px solid var(--border-subtle);
        display: flex;
        justify-content: stretch;
    }
    .student-cell {
        width: 100%;
    }
    .student-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
    }
    .student-name {
        font-size: 0.95rem;
    }
    .progress-bar-wrap {
        width: 100px;
    }
    .actions-cell {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.45rem;
        justify-content: space-between;
    }
    .actions-cell .btn {
        flex: 1;
        min-height: 40px;
        font-size: 0.825rem;
    }
    .actions-cell .btn-primary {
        flex: 2 1 100%;
        font-weight: 600;
        margin-bottom: 0.25rem;
        font-size: 0.875rem;
    }
    .actions-cell .btn-icon {
        width: 40px;
        height: 40px;
        flex: 1;
        border-radius: var(--radius-sm);
    }

    /* iOS Bottom Sheet Modals */
    .modal-backdrop {
        padding: 0;
        align-items: flex-end;
    }
    .modal-dialog {
        max-width: 100%;
        width: 100%;
        max-height: 92vh;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-top-left-radius: 24px;
        border-top-right-radius: 24px;
        transform: translateY(100%);
        border-bottom: none;
        margin: 0;
    }
    .modal-backdrop.active .modal-dialog {
        transform: translateY(0);
    }
    .modal-header {
        padding: 1.25rem 1.25rem 0.85rem;
        position: relative;
    }
    .modal-header::before {
        content: '';
        position: absolute;
        top: 0.5rem;
        left: 50%;
        transform: translateX(-50%);
        width: 38px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: var(--radius-pill);
    }
    .modal-body {
        padding: 1rem 1.25rem;
        max-height: 68vh;
        overflow-y: auto;
    }
    .modal-footer {
        padding: 0.85rem 1.25rem max(0.85rem, env(safe-area-inset-bottom));
        flex-direction: column-reverse;
        gap: 0.5rem;
    }
    .modal-footer .btn {
        width: 100%;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        min-height: 44px;
    }
    .form-row {
        grid-template-columns: 1fr;
        gap: 0.65rem;
    }
    .form-control,
    .form-control:focus,
    input[type="text"],
    input[type="number"],
    input[type="date"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px !important; /* Strict iOS Safari auto-zoom prevention */
        min-height: 42px;
    }

    /* iOS Top Dynamic Toast */
    #toast-container {
        top: 1rem;
        bottom: auto;
        left: 1rem;
        right: 1rem;
        align-items: center;
    }
    .toast {
        width: 100%;
        max-width: 380px;
        justify-content: center;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    }
}

/* --- SMALL PHONES (<= 540px) --- */
@media (max-width: 540px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.65rem;
        margin-bottom: 1.25rem;
    }
    .metric-card {
        padding: 0.85rem 0.95rem;
        border-radius: var(--radius-sm);
    }
    .metric-header {
        margin-bottom: 0.45rem;
    }
    .metric-label {
        font-size: 0.675rem;
    }
    .metric-icon-wrap {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }
    .metric-value {
        font-size: 1.2rem;
    }
    .metric-sub {
        font-size: 0.675rem;
        margin-top: 0.25rem;
    }
}

/* --- EXTRA COMPACT SCREENS (<= 360px: e.g. iPhone SE 1st, small Androids) --- */
@media (max-width: 360px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    .filter-group {
        grid-template-columns: 1fr;
    }
    .filter-group #filter-course {
        grid-column: span 1;
    }
    .page-title {
        font-size: 1.25rem;
    }
}

/* ==========================================================================
   Apple Receipt Upload & Viewer Styles
   ========================================================================== */
.receipt-upload-box {
    border: 1.5px dashed var(--border-hairline);
    border-radius: var(--radius-md);
    background: var(--bg-pill);
    padding: 0.85rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}
.receipt-upload-box:hover {
    border-color: var(--apple-blue);
    background: rgba(0, 113, 227, 0.05);
}
.receipt-drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem;
}
.receipt-drop-icon {
    font-size: 1.8rem;
    color: var(--apple-blue);
    opacity: 0.85;
    margin-bottom: 0.2rem;
}
.receipt-drop-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}
.receipt-drop-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.receipt-preview-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-sm);
    text-align: left;
}
.receipt-preview-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
    flex: 1;
}
.receipt-preview-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-hairline);
    flex-shrink: 0;
}
.receipt-preview-icon {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.receipt-file-name {
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.receipt-file-size {
    font-size: 0.725rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.receipt-img-view {
    max-width: 100%;
    max-height: 60vh;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    object-fit: contain;
}
.receipt-pdf-view {
    width: 100%;
    height: 60vh;
    border: none;
    border-radius: var(--radius-sm);
}

/* ==========================================================================
   Excel Export Customization Modal
   ========================================================================== */
.export-preset-btn {
    transition: var(--transition);
}
.export-preset-btn.active {
    background: var(--apple-blue) !important;
    border-color: var(--apple-blue) !important;
    color: #ffffff !important;
}
.export-col-label {
    transition: background 0.15s ease;
}
.export-col-label:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}
[data-theme="light"] .export-col-label:hover {
    background: rgba(0, 0, 0, 0.05) !important;
}
@media (max-width: 640px) {
    .export-columns-grid {
        grid-template-columns: 1fr !important;
    }
    .export-col-label {
        grid-column: span 1 !important;
    }
}

