/* Dilek Pilates — Design System v2 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;650;700&display=swap');

:root {
    /* Brand — warm terracotta */
    --brand-50: #fdf6f3;
    --brand-100: #faece6;
    --brand-200: #f4d4c8;
    --brand-300: #e8b5a3;
    --brand-400: #d98f75;
    --brand-500: #c96f54;
    --brand-600: #b85a42;
    --brand-700: #9a4836;
    --brand-800: #7d3c30;
    --brand-900: #68342b;

    /* Neutrals — warm stone */
    --stone-25: #fcfcfb;
    --stone-50: #f8f7f5;
    --stone-100: #f0eeeb;
    --stone-200: #e4e1dc;
    --stone-300: #cfc9c1;
    --stone-400: #a8a099;
    --stone-500: #7a736c;
    --stone-600: #5c5650;
    --stone-700: #45403b;
    --stone-800: #2e2a27;
    --stone-900: #1a1816;

    /* Semantic */
    --success-50: #ecfdf5;
    --success-500: #10b981;
    --success-600: #059669;
    --warning-50: #fffbeb;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --error-50: #fef2f2;
    --error-500: #ef4444;
    --error-600: #dc2626;
    --info-50: #eff6ff;
    --info-500: #3b82f6;
    --info-600: #2563eb;

    /* Calendar */
    --cal-empty: #10b981;
    --cal-full: #3b82f6;
    --cal-pending: #f59e0b;
    --cal-cancelled: #ef4444;

    /* Layout */
    --sidebar-width: 272px;
    --app-bar-height: 56px;
    --bottom-nav-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-2xl: 28px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(26, 24, 22, 0.04);
    --shadow-sm: 0 2px 8px rgba(26, 24, 22, 0.06), 0 1px 2px rgba(26, 24, 22, 0.04);
    --shadow-md: 0 8px 24px rgba(26, 24, 22, 0.08), 0 2px 6px rgba(26, 24, 22, 0.04);
    --shadow-lg: 0 20px 48px rgba(26, 24, 22, 0.12), 0 4px 12px rgba(26, 24, 22, 0.06);
    --shadow-card: 0 1px 3px rgba(26, 24, 22, 0.04), 0 4px 16px rgba(26, 24, 22, 0.04);

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --transition: 0.2s var(--ease);

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

body.app-body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--stone-50);
    color: var(--stone-800);
    line-height: 1.55;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

a {
    color: var(--brand-600);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--brand-700); }

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    color: var(--stone-900);
    letter-spacing: -0.02em;
}

.display-title {
    font-weight: 600;
    letter-spacing: -0.03em;
}

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.8125rem; }
.text-muted { color: var(--stone-500); }
.text-brand { color: var(--brand-600); }
.text-success { color: var(--success-600); }
.text-warning { color: var(--warning-600); }
.text-error { color: var(--error-600); }

/* ─── App Layout ─── */
.app-layout {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ─── Sidebar (Desktop) ─── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--stone-900);
    color: var(--stone-300);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    border-right: 1px solid rgba(255,255,255,0.06);
}

/* ─── Sidebar brand / logo ─── */
.sidebar-brand {
    display: block;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    text-decoration: none;
    color: inherit;
}

.sidebar-brand:hover {
    color: inherit;
    opacity: 0.92;
}

.sidebar-logo {
    display: block;
    max-width: 100%;
    max-height: 44px;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: left center;
}

.sidebar-brand-text {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

/* Settings sub-nav */
.settings-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.settings-nav-link {
    padding: 8px 14px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--stone-600);
    border: 1px solid var(--stone-200);
    border-radius: var(--radius-sm);
    background: #fff;
    transition: all var(--transition);
}

.settings-nav-link:hover {
    border-color: var(--stone-300);
    color: var(--stone-900);
}

.settings-nav-link.active {
    background: var(--brand-50);
    border-color: var(--brand-200);
    color: var(--brand-700);
    font-weight: 600;
}

.logo-preview-box {
    background: var(--stone-50);
    border: 1px dashed var(--stone-300);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
}

.logo-preview-img {
    max-width: 240px;
    max-height: 64px;
    object-fit: contain;
}

.logo-preview-empty {
    color: var(--stone-400);
    font-size: 0.875rem;
}

.login-logo {
    max-width: 220px;
    max-height: 64px;
    object-fit: contain;
    margin: 0 auto;
    display: block;
}

.login-logo-placeholder {
    width: 120px;
    height: 120px;
    margin: 0 auto 16px;
    border: 2px dashed var(--stone-300);
    border-radius: var(--radius-lg);
    background: var(--stone-50);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--stone-400);
    text-transform: uppercase;
}

.login-brand-label {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--stone-500);
    text-transform: lowercase;
    letter-spacing: 0.02em;
    margin: 0;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--brand-600);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.nav-section { margin-bottom: 24px; }

.nav-section-title {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--stone-500);
    padding: 0 12px;
    margin-bottom: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--stone-400);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.65;
}

.nav-link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}
.nav-link:hover svg { opacity: 1; }

.nav-link.active {
    background: rgba(201, 111, 84, 0.2);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(201, 111, 84, 0.3);
}
.nav-link.active svg { opacity: 1; color: var(--brand-300); }

.nav-link-muted { color: var(--stone-500); margin-top: 8px; }

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.04);
    margin-bottom: 4px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--brand-600);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.user-details { flex: 1; min-width: 0; }

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--stone-500);
    margin-top: 1px;
}

/* ─── Main Content ─── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Mobile App Bar */
.app-bar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(248, 247, 245, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--stone-200);
    padding-top: var(--safe-top);
}

.app-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    min-height: var(--app-bar-height);
}

.app-bar-subtitle {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--brand-600);
}

.app-bar-title {
    font-size: 1.375rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--stone-900);
    line-height: 1.2;
    margin-top: 2px;
}

.brand-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brand-500);
    margin-right: 6px;
    vertical-align: middle;
}

.app-bar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--brand-600);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8125rem;
}

/* Desktop Page Header */
.page-header {
    background: var(--stone-50);
    padding: 28px 36px 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.page-header-eyebrow {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--stone-500);
    margin-bottom: 4px;
}

.page-header h2 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.page-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-bottom: 4px;
}

.page-body {
    padding: 24px 36px 36px;
    flex: 1;
}

/* ─── Bottom Navigation (Mobile) ─── */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 300;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--stone-200);
    padding-bottom: var(--safe-bottom);
    box-shadow: 0 -4px 24px rgba(26, 24, 22, 0.06);
    justify-content: space-around;
    align-items: stretch;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 12px 10px;
    flex: 1;
    max-width: 88px;
    color: var(--stone-400);
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: color var(--transition);
    -webkit-user-select: none;
    user-select: none;
    min-height: var(--bottom-nav-height);
}

.bottom-nav-icon svg {
    width: 22px;
    height: 22px;
    transition: transform 0.2s var(--ease-spring);
}

.bottom-nav-item.active {
    color: var(--brand-600);
}

.bottom-nav-item.active .bottom-nav-icon svg {
    transform: scale(1.08);
}

.bottom-nav-item:active .bottom-nav-icon svg {
    transform: scale(0.92);
}

/* ─── Sheet (Mobile Menu) ─── */
.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 24, 22, 0.5);
    z-index: 400;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s var(--ease), visibility 0.3s;
    backdrop-filter: blur(2px);
}

.sheet-overlay.open {
    opacity: 1;
    visibility: visible;
}

.sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 500;
    background: #fff;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.35s var(--ease);
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
    box-shadow: var(--shadow-lg);
}

.sheet.open {
    transform: translateY(0);
}

.sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--stone-300);
    border-radius: 100px;
    margin: 12px auto 0;
}

.sheet-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--stone-100);
}

.sheet-user {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sheet-section { padding: 8px 0; }

.sheet-section-title {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--stone-400);
    padding: 12px 24px 6px;
}

.sheet-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--stone-800);
    transition: background var(--transition);
}

.sheet-link:hover,
.sheet-link.active {
    background: var(--brand-50);
    color: var(--brand-700);
}

.sheet-link-danger { color: var(--error-600); }
.sheet-link-danger:hover { background: var(--error-50); }

/* ─── Cards ─── */
.card {
    background: #fff;
    border: 1px solid var(--stone-200);
    border-radius: var(--radius-lg);
    box-shadow: none;
}

.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--stone-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.card-body { padding: 22px; }

.card-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--stone-100);
    background: var(--stone-25);
}

/* ─── Stats ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border: 1px solid var(--stone-200);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-card);
    transition: transform var(--transition), box-shadow var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before { display: none; }

.stat-card:hover {
    box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
    font-size: 0.8125rem;
    color: var(--stone-500);
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-card .stat-value {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--stone-900);
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.stat-card .stat-change {
    font-size: 0.8125rem;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.stat-icon.brand { background: var(--brand-50); color: var(--brand-600); }
.stat-icon.success { background: var(--success-50); color: var(--success-600); }
.stat-icon.warning { background: var(--warning-50); color: var(--warning-600); }
.stat-icon.info { background: var(--info-50); color: var(--info-600); }

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1.4;
    -webkit-user-select: none;
    user-select: none;
}

.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
    background: var(--brand-600);
    color: #fff;
    border-color: var(--brand-600);
}

.btn-primary:hover:not(:disabled) {
    background: var(--brand-700);
    border-color: var(--brand-700);
}

.btn-secondary {
    background: #fff;
    color: var(--stone-700);
    border-color: var(--stone-300);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--stone-50);
    border-color: var(--stone-400);
}

.btn-ghost {
    background: transparent;
    color: var(--stone-600);
    border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--stone-100); }

.btn-danger {
    background: var(--error-600);
    color: #fff;
    border-color: var(--error-600);
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-sm { padding: 7px 13px; font-size: 0.8125rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 13px 24px; font-size: 1rem; border-radius: var(--radius-md); }
.btn-icon { padding: 9px; width: 38px; height: 38px; }

/* ─── Forms ─── */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--stone-700);
    margin-bottom: 6px;
}

.form-label .required { color: var(--error-500); }

.form-control {
    width: 100%;
    padding: 11px 15px;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--stone-800);
    background: #fff;
    border: 1.5px solid var(--stone-200);
    border-radius: var(--radius-md);
    transition: border-color var(--transition), box-shadow var(--transition);
    line-height: 1.5;
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: 0 0 0 3px rgba(201, 111, 84, 0.12);
}

.form-control::placeholder { color: var(--stone-400); }
.form-control:disabled { background: var(--stone-50); color: var(--stone-500); }

textarea.form-control { min-height: 100px; resize: vertical; }

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a736c' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: var(--brand-600);
    cursor: pointer;
}

.form-check label {
    font-size: 0.9375rem;
    color: var(--stone-700);
    cursor: pointer;
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--stone-500);
    margin-top: 5px;
}

.form-error {
    font-size: 0.8125rem;
    color: var(--error-600);
    margin-top: 5px;
}

/* ─── Tables ─── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
}

table.data-table th {
    text-align: left;
    padding: 11px 16px;
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--stone-500);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--stone-50);
    border-bottom: 1px solid var(--stone-200);
    white-space: nowrap;
}

table.data-table td {
    padding: 14px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--stone-100);
    vertical-align: middle;
}

table.data-table tbody tr { transition: background var(--transition); }
table.data-table tbody tr:hover { background: var(--stone-25); }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* ─── Badges ─── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 100px;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.badge-success { background: var(--success-50); color: var(--success-600); }
.badge-warning { background: var(--warning-50); color: var(--warning-600); }
.badge-error { background: var(--error-50); color: var(--error-600); }
.badge-info { background: var(--info-50); color: var(--info-600); }
.badge-neutral { background: var(--stone-100); color: var(--stone-600); }
.badge-brand { background: var(--brand-50); color: var(--brand-700); }

/* ─── Alerts ─── */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: slideDown 0.3s var(--ease);
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert-success { background: var(--success-50); color: var(--success-600); border: 1px solid #a7f3d0; }
.alert-error { background: var(--error-50); color: var(--error-600); border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-50); color: var(--warning-600); border: 1px solid #fde68a; }
.alert-info { background: var(--info-50); color: var(--info-600); border: 1px solid #bfdbfe; }

/* ─── Tabs ─── */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--stone-100);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-link {
    padding: 9px 16px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--stone-500);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab-link:hover { color: var(--stone-700); }

.tab-link.active {
    background: #fff;
    color: var(--brand-700);
    box-shadow: var(--shadow-xs);
}

/* ─── Filters ─── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    background: #fff;
    border: 1px solid var(--stone-200);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    box-shadow: var(--shadow-xs);
}

.search-input { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search-input input { padding-left: 40px; }
.search-input svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--stone-400);
    width: 18px;
    height: 18px;
}

/* ─── Empty State ─── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--stone-500);
}

.empty-state svg {
    width: 56px;
    height: 56px;
    color: var(--stone-300);
    margin-bottom: 14px;
}

.empty-state h3 {
    font-size: 1rem;
    color: var(--stone-700);
    margin-bottom: 6px;
}

/* ─── Login ─── */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--stone-900);
    padding: 24px;
    padding-top: calc(24px + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(201, 111, 84, 0.25) 0%, transparent 60%),
        radial-gradient(ellipse 60% 50% at 80% 90%, rgba(184, 90, 66, 0.15) 0%, transparent 50%);
    pointer-events: none;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: var(--radius-2xl);
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.login-brand { text-align: center; margin-bottom: 32px; }

/* ─── Attendance ─── */
.attendance-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.attendance-btn {
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    border: 1.5px solid var(--stone-200);
    background: #fff;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.attendance-btn:active { transform: scale(0.97); }
.attendance-btn.active.attended { background: var(--success-50); border-color: var(--success-500); color: var(--success-600); }
.attendance-btn.active.no-show { background: var(--error-50); border-color: var(--error-500); color: var(--error-600); }
.attendance-btn.active.makeup { background: var(--info-50); border-color: var(--info-500); color: var(--info-600); }
.attendance-btn.active.excused { background: var(--warning-50); border-color: var(--warning-500); color: var(--warning-600); }

/* ─── Calendar Page ─── */
.calendar-legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    background: #fff;
    border: 1px solid var(--stone-200);
    border-radius: var(--radius-md);
    padding: 10px 14px;
}

.calendar-filters {
    background: #fff;
    border: 1px solid var(--stone-200);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-xs);
}

.calendar-filters-primary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.calendar-date-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 200px;
}

.calendar-date-input {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-weight: 600;
}

.calendar-filters-toggle { display: none; }

.calendar-filters-advanced {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--stone-100);
}

.calendar-filters-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

/* Time slot chips */
.occupancy-time-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 2px 12px;
    margin-bottom: 12px;
    scroll-snap-type: x mandatory;
}

.occupancy-time-strip::-webkit-scrollbar { display: none; }

.occupancy-time-chip {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 14px;
    min-width: 72px;
    background: #fff;
    border: 1.5px solid var(--stone-200);
    border-radius: var(--radius-md);
    color: var(--stone-700);
    scroll-snap-align: start;
    transition: all var(--transition);
}

.occupancy-time-chip:hover {
    border-color: var(--brand-300);
    color: var(--brand-700);
}

.occupancy-time-chip.active {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #fff;
    box-shadow: 0 4px 12px rgba(184, 90, 66, 0.3);
}

.occupancy-time-chip-time {
    font-weight: 800;
    font-size: 0.9375rem;
    letter-spacing: -0.02em;
}

.occupancy-time-chip-meta {
    font-size: 0.6875rem;
    font-weight: 600;
    opacity: 0.85;
}

.occupancy-time-chip-all {
    min-width: 88px;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8125rem;
}

/* Mobile occupancy cards */
.calendar-mobile-only { display: none; }
.calendar-desktop-only { display: block; }

.occupancy-mobile-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.occupancy-mobile-header h3 {
    font-size: 1.0625rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.occupancy-mobile-header p {
    font-size: 0.8125rem;
    color: var(--stone-500);
    margin-top: 2px;
}

.occupancy-slot-card {
    background: #fff;
    border: 1px solid var(--stone-200);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-xs);
}

.occupancy-slot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--stone-100);
}

.occupancy-slot-time {
    font-size: 1.125rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--stone-900);
}

.occupancy-slot-stats {
    display: flex;
    align-items: center;
    gap: 8px;
}

.occupancy-machine-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.occupancy-machine-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--stone-200);
    background: var(--stone-25);
    min-height: 64px;
    transition: transform var(--transition);
}

.occupancy-machine-item:active { transform: scale(0.98); }

.occupancy-machine-item.cal-empty {
    background: rgba(16, 185, 129, 0.06);
    border-color: rgba(16, 185, 129, 0.2);
}

.occupancy-machine-item.cal-full {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.25);
    color: inherit;
}

.occupancy-machine-item.cal-pending {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.25);
    color: inherit;
}

.occupancy-machine-item.cal-cancelled {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.2);
    color: inherit;
}

.occupancy-machine-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--stone-500);
}

.occupancy-machine-name {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--stone-900);
    line-height: 1.3;
    word-break: break-word;
}

.occupancy-machine-meta {
    font-size: 0.6875rem;
    color: var(--stone-500);
    line-height: 1.35;
}

.occupancy-machine-empty {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--success-600);
    margin-top: 4px;
}

/* Desktop table scroll */
.calendar-table-wrap {
    padding: 0 !important;
    overflow: hidden;
}

.calendar-scroll-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.calendar-scroll-hint {
    display: none;
    padding: 8px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--stone-500);
    text-align: center;
    background: var(--stone-50);
    border-bottom: 1px solid var(--stone-100);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--stone-600);
}

.legend-dot { width: 10px; height: 10px; border-radius: 3px; }
.legend-dot.empty { background: var(--cal-empty); }
.legend-dot.full { background: var(--cal-full); }
.legend-dot.pending { background: var(--cal-pending); }
.legend-dot.cancelled { background: var(--cal-cancelled); }

/* ─── Pagination ─── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
}

.pagination a, .pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 8px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--stone-600);
    transition: all var(--transition);
}

.pagination a:hover { background: var(--stone-100); color: var(--stone-800); }
.pagination .active { background: var(--brand-600); color: #fff; }

/* ─── Modal ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 24, 22, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 600;
    padding: 0;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s var(--ease);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: #fff;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(100%);
    transition: transform 0.35s var(--ease);
    padding-bottom: var(--safe-bottom);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--stone-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--stone-100);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ─── Schedule ─── */
.schedule-toolbar { margin-bottom: 16px; }

.schedule-week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
    padding: 20px !important;
    overflow-x: auto;
}

.week-day-column {
    min-width: 140px;
    background: var(--stone-25);
    border-radius: var(--radius-md);
    border: 1px solid var(--stone-200);
    padding: 12px;
}

.week-day-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--stone-200);
}

.week-day-empty {
    font-size: 0.875rem;
    color: var(--stone-400);
    text-align: center;
    padding: 20px 0;
}

.lesson-card {
    display: block;
    background: #fff;
    border: 1px solid var(--stone-200);
    border-left: 3px solid var(--brand-500);
    border-radius: var(--radius-md);
    padding: 11px;
    margin-bottom: 8px;
    transition: box-shadow var(--transition), transform var(--transition);
    color: inherit;
}

.lesson-card:active { transform: scale(0.98); }
.lesson-card:hover { box-shadow: var(--shadow-sm); color: inherit; }

.lesson-card.status-completed { border-left-color: var(--success-500); }
.lesson-card.status-no_show,
.lesson-card.status-cancelled { border-left-color: var(--error-500); }
.lesson-card.status-pending { border-left-color: var(--warning-500); }
.lesson-card.status-makeup { border-left-color: var(--info-500); }

.lesson-card-time { font-weight: 700; font-size: 0.9375rem; color: var(--stone-900); }
.lesson-card-member { font-size: 0.875rem; margin: 4px 0; color: var(--stone-700); }
.lesson-card-meta { display: flex; flex-direction: column; font-size: 0.75rem; color: var(--stone-500); gap: 2px; }

/* ─── Occupancy ─── */
.occupancy-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.occupancy-summary-card {
    background: #fff;
    border: 1px solid var(--stone-200);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-xs);
}

.occupancy-summary-time { font-weight: 800; font-size: 1.0625rem; margin-bottom: 6px; letter-spacing: -0.02em; }
.occupancy-summary-stats { display: flex; gap: 12px; font-size: 0.875rem; margin-bottom: 8px; }
.stat-full { color: var(--info-600); font-weight: 600; }
.stat-empty { color: var(--success-600); font-weight: 600; }

.occupancy-bar {
    height: 5px;
    background: var(--success-50);
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 6px;
}

.occupancy-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--info-500), var(--brand-500));
    border-radius: 100px;
    transition: width 0.4s var(--ease);
}

table.calendar-grid {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

table.calendar-grid th,
table.calendar-grid td {
    border: 1px solid var(--stone-200);
    padding: 0;
    text-align: center;
    vertical-align: middle;
}

table.calendar-grid th {
    background: var(--stone-50);
    padding: 10px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--stone-600);
}

.cal-time-col { width: 70px; background: var(--stone-25); padding: 10px !important; }
.cal-summary-col { width: 80px; padding: 8px !important; background: var(--stone-25); }
.cal-cell { height: 72px; min-width: 90px; position: relative; }
.cal-cell.cal-empty { background: rgba(16, 185, 129, 0.07); }
.cal-cell.cal-full { background: rgba(59, 130, 246, 0.1); }
.cal-cell.cal-pending { background: rgba(245, 158, 11, 0.1); }
.cal-cell.cal-cancelled { background: rgba(239, 68, 68, 0.08); }

.cal-cell-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 6px;
    color: inherit;
    font-size: 0.75rem;
    line-height: 1.3;
}

.cal-cell-link:hover { background: rgba(0,0,0,0.03); color: inherit; }
.cal-cell-name { font-weight: 700; color: var(--stone-800); }
.cal-cell-meta, .cal-cell-type { color: var(--stone-500); font-size: 0.7rem; }
.cal-empty-label { font-size: 0.75rem; color: var(--success-600); font-weight: 600; }

.working-hours-table td { padding: 10px 16px !important; }
.working-hours-table .form-control { padding: 7px 11px; font-size: 0.875rem; }

/* ─── Revenue Charts ─── */
.revenue-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 200px;
    padding-top: 20px;
}

.chart-bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    min-width: 0;
}

.chart-bar {
    width: 100%;
    max-width: 24px;
    background: linear-gradient(180deg, var(--brand-400), var(--brand-600));
    border-radius: 6px 6px 0 0;
    transition: height 0.4s var(--ease);
    min-height: 2px;
}

.chart-label { font-size: 0.625rem; color: var(--stone-400); margin-top: 4px; }

.weekly-bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.weekly-bar-label { width: 70px; font-size: 0.875rem; font-weight: 600; color: var(--stone-600); }
.weekly-bar-track { flex: 1; height: 10px; background: var(--stone-100); border-radius: 100px; overflow: hidden; }
.weekly-bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand-400), var(--brand-600)); border-radius: 100px; }
.weekly-bar-value { width: 90px; text-align: right; font-size: 0.875rem; font-weight: 700; }

/* ─── Searchable Select ─── */
.searchable-select { position: relative; }

.searchable-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--stone-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
    display: none;
    margin-top: 4px;
}

.searchable-select-dropdown.open { display: block; }

.searchable-select-option {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 0.9375rem;
    transition: background var(--transition);
}

.searchable-select-option:hover { background: var(--brand-50); }

.searchable-select-empty {
    padding: 14px;
    color: var(--stone-500);
    font-size: 0.875rem;
    text-align: center;
}

/* ─── Utilities ─── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-right { text-align: right; }
.w-100 { width: 100%; }

.content-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.content-grid-3-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

/* ─── Responsive: Mobile App Mode ─── */
@media (max-width: 1023px) {
    .sidebar { display: none; }

    .main-content {
        margin-left: 0;
        padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
        overflow-x: hidden;
    }

    .app-bar { display: block; }
    .page-header { display: none; }

    .bottom-nav { display: flex; }

    .page-body {
        padding: 16px 16px 24px;
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Calendar mobile */
    .calendar-mobile-only { display: block; }
    .calendar-desktop-only { display: none !important; }

    .calendar-filters-primary {
        flex-direction: column;
        align-items: stretch;
    }

    .calendar-date-nav { min-width: 0; }

    .calendar-filters-toggle {
        display: inline-flex;
        width: 100%;
        justify-content: center;
    }

    .calendar-filters-advanced {
        display: none;
        flex-direction: column;
        align-items: stretch;
    }

    .calendar-filters-advanced.open {
        display: flex;
    }

    .calendar-filters-actions {
        margin-left: 0;
        width: 100%;
    }

    .calendar-filters-actions .btn { flex: 1; }

    .calendar-legend {
        gap: 8px;
        padding: 8px 12px;
    }

    .legend-item { font-size: 0.75rem; }

    .content-grid-2,
    .content-grid-3-1 {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        border-radius: var(--radius-md);
        padding: 12px;
    }

    .filter-bar .form-control {
        width: 100% !important;
        max-width: none !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 16px;
        border-radius: var(--radius-md);
    }

    .stat-card .stat-value { font-size: 1.5rem; }
    .stat-card .stat-icon { width: 36px; height: 36px; margin-bottom: 10px; }

    .card { border-radius: var(--radius-md); }
    .card-header { padding: 14px 16px; }
    .card-body { padding: 16px; }

    /* Horizontal scroll tables with fade hint */
    .card-body[style*="padding: 0"] {
        position: relative;
    }

    table.data-table { min-width: 560px; }

    .tabs { margin-left: -4px; margin-right: -4px; border-radius: var(--radius-md); }

    .btn-lg { width: 100%; }

    .page-body > div[style*="grid-template-columns"] {
        display: block !important;
    }

    .page-body > div[style*="grid-template-columns"] > * + * {
        margin-top: 16px;
    }

    /* Modal centered on desktop, bottom sheet on mobile */
    .modal-overlay {
        align-items: flex-end;
    }
}

@media (max-width: 640px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }

    .schedule-week-grid { grid-template-columns: 1fr; }
    .occupancy-summary-grid { grid-template-columns: repeat(2, 1fr); }

    .login-card {
        padding: 32px 24px;
        border-radius: var(--radius-xl);
    }
}

@media (min-width: 1024px) {
    .bottom-nav { display: none !important; }
    .app-bar { display: none !important; }

    .calendar-scroll-hint { display: block; }

    .calendar-scroll-container {
        max-width: 100%;
    }

    .cal-time-col {
        position: sticky;
        left: 0;
        z-index: 2;
        box-shadow: 2px 0 6px rgba(26, 24, 22, 0.06);
    }

    .modal-overlay {
        align-items: center;
        padding: 20px;
    }

    .modal {
        border-radius: var(--radius-xl);
        transform: translateY(20px) scale(0.97);
        padding-bottom: 0;
    }

    .modal-overlay.active .modal {
        transform: translateY(0) scale(1);
    }
}

@media (min-width: 1200px) {
    .schedule-week-grid { grid-template-columns: repeat(7, 1fr); }
}

@media (max-width: 1199px) and (min-width: 769px) {
    .schedule-week-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 768px) and (min-width: 641px) {
    .schedule-week-grid { grid-template-columns: repeat(2, 1fr); }
}
