/* ── CSS Variables ─────────────────────────────────────────────── */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
    --md-elevation-1: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --md-elevation-2: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
    --md-elevation-3: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
}

/* ── Material Design Grid (12-column) ──────────────────────────── */
.md-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.md-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.md-col {
    flex: 0 0 100%;
    max-width: 100%;
}

.md-1  { flex: 0 0 calc(8.333%  - 1rem); max-width: calc(8.333%  - 1rem); }
.md-2  { flex: 0 0 calc(16.666% - 1rem); max-width: calc(16.666% - 1rem); }
.md-3  { flex: 0 0 calc(25%     - 1rem); max-width: calc(25%     - 1rem); }
.md-4  { flex: 0 0 calc(33.333% - 1rem); max-width: calc(33.333% - 1rem); }
.md-5  { flex: 0 0 calc(41.666% - 1rem); max-width: calc(41.666% - 1rem); }
.md-6  { flex: 0 0 calc(50%     - 1rem); max-width: calc(50%     - 1rem); }
.md-7  { flex: 0 0 calc(58.333% - 1rem); max-width: calc(58.333% - 1rem); }
.md-8  { flex: 0 0 calc(66.666% - 1rem); max-width: calc(66.666% - 1rem); }
.md-9  { flex: 0 0 calc(75%     - 1rem); max-width: calc(75%     - 1rem); }
.md-10 { flex: 0 0 calc(83.333% - 1rem); max-width: calc(83.333% - 1rem); }
.md-11 { flex: 0 0 calc(91.666% - 1rem); max-width: calc(91.666% - 1rem); }
.md-12 { flex: 0 0 100%; max-width: 100%; }

/* Tablet (≤992px): collapse to 6-col max */
@media (max-width: 992px) {
    .md-1, .md-2, .md-3, .md-4, .md-5  { flex: 0 0 calc(50% - 1rem); max-width: calc(50% - 1rem); }
    .md-6, .md-7, .md-8, .md-9, .md-10, .md-11 { flex: 0 0 100%; max-width: 100%; }
}

/* Mobile (≤768px): everything full width */
@media (max-width: 768px) {
    .md-1, .md-2, .md-3, .md-4, .md-5,
    .md-6, .md-7, .md-8, .md-9, .md-10, .md-11, .md-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    .md-row { gap: 0.75rem; }
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family:
        "Inter",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Layout ────────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.sidebar-brand .logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}

.sidebar-brand h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.sidebar-brand small {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-nav {
    list-style: none;
    flex: 1;
}

.sidebar-nav li {
    margin-bottom: 0.25rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.sidebar-nav a:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.sidebar-nav a.active {
    background: var(--primary);
    color: white;
}

.sidebar-nav a .icon {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

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

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.sidebar-footer .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: white;
}

.sidebar-footer .user-details {
    flex: 1;
    min-width: 0;
}

.sidebar-footer .user-details .name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer .user-details .role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-logout {
    width: 100%;
    padding: 0.6rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.btn-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* ── Main Content ──────────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    max-width: calc(100% - 260px);
}

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

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* ── Cards (Material Design elevation) ─────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--md-elevation-1);
    transition: box-shadow 0.2s ease;
}

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

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

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* ── Stats Grid (md-3 each = 4 per row) ────────────────────────── */
.stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--md-elevation-1);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    flex: 0 0 calc(25% - 1rem);
    max-width: calc(25% - 1rem);
}

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

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
}

.stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

@media (max-width: 992px) {
    .stat-card {
        flex: 0 0 calc(50% - 1rem);
        max-width: calc(50% - 1rem);
    }
}

@media (max-width: 768px) {
    .stat-card {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ── Tables ────────────────────────────────────────────────────── */
.table-container {
    overflow-x: auto;
    margin-top: 1rem;
}

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

thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

tbody tr:hover {
    background: var(--bg-card-hover);
}

/* ── Badges ────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-active {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-inactive {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.badge-admin {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

.badge-user {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

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

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

.btn-success:hover {
    opacity: 0.9;
}

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

.btn-danger:hover {
    opacity: 0.9;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    background: var(--bg-card-hover);
}

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.9rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    cursor: pointer;
}

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.open .modal {
    transform: scale(1);
}

.modal h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* ── Toast Notifications ───────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.85rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast-success {
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid var(--success);
    color: var(--success);
}

.toast-error {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid var(--danger);
    color: var(--danger);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ── Login Page ────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    padding: 2rem;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-card .brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .brand .logo {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 1rem;
}

.login-card .brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.login-card .brand p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
}

/* ── Empty State ───────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--text);
    margin-bottom: 0.5rem;
}

/* ── Loading ───────────────────────────────────────────────────── */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}

/* ── Mobile Header ─────────────────────────────────────────────── */
.mobile-header {
    display: none;
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
        align-items: center;
        gap: 1rem;
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid var(--border);
    }
}

/* ── Hamburger Menu ────────────────────────────────────────────── */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    position: relative;
    z-index: 1000;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
}

/* ── Sidebar Overlay (mobile backdrop) ─────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

/* ── Copy Button ─────────────────────────────────────────────── */
.btn-copy {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.15rem 0.3rem;
    border-radius: 4px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
    vertical-align: middle;
}

.btn-copy:hover {
    opacity: 1;
    background: var(--bg-card-hover);
}

/* ── Hidden ────────────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

/* ── Docs Page ──────────────────────────────────────────────────── */
.docs-container {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.docs-toc {
    position: sticky;
    top: 2rem;
    min-width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.docs-toc h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.docs-toc a {
    display: block;
    padding: 0.4rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.docs-toc a:hover {
    color: var(--primary-light);
}

.docs-content {
    flex: 1;
    min-width: 0;
}

.docs-content section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.docs-content h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.docs-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.25rem 0 0.5rem;
    color: var(--primary-light);
}

.docs-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.7;
    margin-bottom: 1rem;
}

.docs-content ol {
    margin: 0 0 1rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.9;
}

.docs-content ol li strong {
    color: var(--text);
}

.docs-content pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    font-size: 0.8rem;
    line-height: 1.5;
    margin-bottom: 1rem;
    color: var(--primary-light);
}

.docs-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.docs-content code {
    background: rgba(99, 102, 241, 0.12);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--primary-light);
}

@media (max-width: 768px) {
    .docs-container {
        flex-direction: column;
    }
    .docs-toc {
        position: static;
        width: 100%;
    }
}

/* ── Mobile table scroll ───────────────────────────────────────── */
@media (max-width: 768px) {
    .table-container,
    .card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 0.85rem;
        min-width: 600px;
    }

    .modal {
        width: 95%;
        max-width: none;
        margin: 0.5rem;
        padding: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .form-group + .form-group {
        margin-top: 0.75rem;
    }
}

/* ── Mobile-first Bootstrap-like improvements ───────────────────── */
html, body {
  overflow-x: hidden;
}

@media (max-width: 768px) {
  body {
    font-size: 15px;
  }

  /* Force all 12-column grid classes to stack on mobile */
  .md-1, .md-2, .md-3, .md-4, .md-5, .md-6,
  .md-7, .md-8, .md-9, .md-10, .md-11, .md-12 {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Stat and dashboard cards that combine md-* and card/stat-card */
  [class*="stat-card"],
  .md-row > .card,
  .main-content > .md-container .card {
    flex: unset !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 280px;
    max-width: 85vw;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    border-right: none;
    transition: transform 0.25s ease;
  }

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

  .main-content {
    margin-left: 0 !important;
    max-width: 100%;
    min-width: 0;
    width: 100%;
    padding: 0.75rem;
    overflow-x: hidden;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: -0.75rem -0.75rem 1rem -0.75rem;
    padding: 0.75rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    font-size: 1.25rem;
    cursor: pointer;
  }

  .md-container {
    padding: 0;
    max-width: 100%;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1.25rem;
  }

  .page-header h1 {
    font-size: 1.25rem;
  }

  .page-header .btn,
  .page-header .btn-group,
  .page-header button {
    width: 100%;
  }

  .card {
    padding: 1rem;
    margin-bottom: 1rem;
    width: 100%;
  }

  .stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .stat-card {
    flex: unset;
    max-width: unset;
    width: 100%;
    padding: 1rem;
  }

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

  .md-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .md-row > [class^="md-"] {
    flex: unset !important;
    max-width: 100% !important;
    width: 100%;
  }

  .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
    padding: 0.75rem 1rem;
  }

  .btn-sm {
    width: 100%;
    min-height: 40px;
  }

  .form-control,
  select.form-control,
  input.form-control,
  textarea.form-control {
    min-height: 44px;
    font-size: 16px; /* prevent iOS zoom */
  }

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

  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.75rem 1rem -0.75rem;
    padding: 0 0.75rem;
    width: calc(100% + 1.5rem);
  }

  table {
    min-width: 640px;
  }

  .modal {
    width: calc(100% - 2rem);
    max-width: 100%;
    padding: 1.25rem;
    margin: 1rem;
  }

  .modal-actions {
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .toast-container {
    left: 0.75rem;
    right: 0.75rem;
    top: auto;
    bottom: 1rem;
    align-items: stretch;
  }

  .toast {
    width: 100%;
    font-size: 0.85rem;
  }

  .sidebar-overlay {
    z-index: 35;
  }

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

  .sidebar-nav a {
    min-height: 48px;
    padding: 0.85rem 1rem;
  }
}
