/* TableShare brand — matches app theme (docs/BRAND-THEME.md, src/theme/brand.ts) */
:root {
    --bg: #F9FAFB;           /* snow */
    --card: #FFFFFF;
    --border: #C8D3DE;       /* mist */
    --text: #1B2A3D;         /* midnight */
    --text-secondary: #3D5066; /* slate */
    --text-tertiary: #8494A7;  /* stone */
    --accent: #E8573D;       /* coral */
    --accent-dark: #C44A33;  /* coral dark (hover) */
    --accent-light: #FDF0EE; /* coral lightest */
    --green: #2E8B6A;        /* sage */
    --green-light: #EEFAF5;   /* sage lightest */
    --blue: #3D5066;         /* slate as secondary accent */
    --blue-light: #EFF3F7;   /* cloud */
    --yellow: #D4920B;       /* amber */
    --yellow-light: #FFF8EB;  /* amber lightest */
    --purple: #7C3AED;
    --purple-light: #F3EEFF;
    --sidebar-active: #EFF3F7; /* cloud */
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', 'SF Mono', monospace;
    --radius: 14px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: all 0.15s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { font-family: var(--font); font-weight: 700; line-height: 1.2; }
h1 { font-size: 22px; letter-spacing: -0.02em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

.subtitle { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }

/* Animations */
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Screen Management */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; animation: fadeIn 0.2s ease-out; }

/* ─── Login Screen ─── */
.login-container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent) 0%, #1A1A2E 100%);
    padding: 2rem;
    position: relative;
}

.login-card {
    background: var(--card);
    padding: 3rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 48px rgba(0,0,0,0.16);
    width: 100%;
    max-width: 420px;
    animation: slideUp 0.4s ease-out;
    position: relative;
    z-index: 1;
}

.login-header { text-align: center; margin-bottom: 2.5rem; }
.login-header h1 {
    font-size: 32px;
    background: linear-gradient(135deg, var(--accent), #F97066);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}
.login-header p { color: var(--text-secondary); font-size: 14px; font-weight: 500; }

/* ─── Forms ─── */
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    font-family: var(--font);
    background: var(--card);
    color: var(--text);
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232, 85, 61, 0.1);
}

.error-message {
    color: var(--accent);
    font-size: 13px;
    margin-top: 16px;
    display: none;
    padding: 12px;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent);
}
.error-message.show { display: block; animation: slideUp 0.2s ease-out; }

/* ─── Sidebar ─── */
.sidebar {
    width: 230px;
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    flex-shrink: 0;
    padding: 24px 0;
}

.sidebar-header { padding: 0 24px; margin-bottom: 32px; }

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #F97066);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFF;
    font-size: 15px;
    font-weight: 800;
}

.sidebar-logo-text { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.sidebar-logo-label { font-size: 10px; color: var(--text-secondary); font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }

.badge-admin, .badge-restaurant { display: none; }

.nav-menu { list-style: none; flex: 1; overflow-y: auto; padding: 0; }
.nav-menu li { margin: 0; }
.nav-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 400;
    font-size: 13px;
    transition: var(--transition);
    border-right: 2px solid transparent;
    border-left: none;
}
.nav-menu a:hover { background: var(--sidebar-active); color: var(--text); }
.nav-menu a.active {
    background: var(--sidebar-active);
    color: var(--text);
    font-weight: 600;
    border-right-color: var(--accent);
}
.nav-menu a .nav-icon { display: flex; align-items: center; }
.nav-menu a .nav-icon svg { width: 17px; height: 17px; }
.nav-menu a.active .nav-icon svg { stroke: var(--accent); }

.sidebar-footer { padding: 0 24px; }

.sidebar-status {
    padding: 14px 16px;
    border-radius: 10px;
    background: var(--accent-light);
}
.sidebar-status-title { font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.sidebar-status-subtitle { font-size: 11px; color: var(--text-secondary); }
.sidebar-status-bar { height: 4px; background: #FDD; border-radius: 2px; margin-top: 8px; }
.sidebar-status-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; }

.btn-ghost {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: var(--transition);
    font-family: var(--font);
    color: var(--text-secondary);
    margin-top: 12px;
}
.btn-ghost:hover { background: var(--bg); border-color: var(--text-secondary); color: var(--text); }

/* ─── Main Content ─── */
.main-content { flex: 1; overflow-y: auto; background: var(--bg); }

.content-header {
    padding: 28px 36px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-actions { display: flex; align-items: center; gap: 16px; }

.header-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
}
.header-search kbd {
    font-size: 10px;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--mono);
}

.header-bell { position: relative; cursor: pointer; }
.header-bell-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

.header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #F97066);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFF;
    font-size: 12px;
    font-weight: 700;
}

.user-name {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 13px;
}

.content-body { padding: 0 36px 36px; animation: slideUp 0.2s ease-out; }

/* ─── KPI Cards ─── */
.kpi-grid {
    display: flex;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.kpi-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    flex: 1;
    min-width: 200px;
    position: relative;
    overflow: hidden;
}

.kpi-card-inner { display: flex; justify-content: space-between; align-items: flex-start; }
.kpi-card-left { flex: 1; }
.kpi-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.kpi-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--text);
    font-family: var(--font);
    letter-spacing: -0.02em;
}

.kpi-change {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
}
.kpi-change-value { font-size: 12px; font-weight: 600; }
.kpi-change-value.positive { color: var(--green); }
.kpi-change-value.negative { color: var(--accent); }
.kpi-change-label { font-size: 11px; color: var(--text-secondary); }

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

/* ─── Data Table ─── */
.data-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.data-panel-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.data-panel-title { font-size: 14px; font-weight: 600; color: var(--text); }
.data-panel-action { font-size: 12px; color: var(--accent); cursor: pointer; font-weight: 500; text-decoration: none; }
.data-panel-action:hover { text-decoration: underline; }

.data-row {
    display: grid;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    align-items: center;
    transition: background 0.15s;
}
.data-row:last-child { border-bottom: none; }
.data-row:not(.data-row-header):hover { background: #F7F7FA; cursor: pointer; }
.data-row-header { padding: 10px 20px; background: var(--bg); }
.data-row-header .data-cell {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.data-cell { font-size: 13px; color: var(--text); }
.data-cell.mono { font-family: var(--mono); }
.data-cell.bold { font-weight: 500; }

/* ─── Badge ─── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-confirmed, .badge-active, .badge-success { color: var(--green); background: var(--green-light); }
.badge-pending, .badge-warning { color: var(--yellow); background: var(--yellow-light); }
.badge-completed, .badge-inactive { color: var(--text-secondary); background: #F3F4F6; }
.badge-matching, .badge-info, .badge-integrated { color: var(--blue); background: var(--blue-light); }
.badge-accent { color: var(--accent); background: var(--accent-light); }

/* ─── Buttons ─── */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: var(--font);
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: #D44A33; }

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #0B8A5E; }

.btn-danger { background: #EF4444; color: white; }
.btn-danger:hover { background: #DC2626; }

.btn-info { background: var(--blue); color: white; }
.btn-info:hover { background: #2F5AD4; }

/* ─── Filter Pills ─── */
.filter-pills { display: flex; gap: 8px; }
.filter-pill {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    transition: var(--transition);
}
.filter-pill.active { background: var(--text); color: #FFF; border-color: var(--text); }

/* ─── Hero Revenue Card ─── */
.hero-card {
    background: linear-gradient(135deg, var(--text) 0%, #2D2D4A 100%);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    margin-bottom: 24px;
    color: #FFF;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.hero-card-label {
    font-size: 12px;
    font-weight: 500;
    opacity: 0.65;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.hero-card-value { font-size: 36px; font-weight: 700; letter-spacing: -0.02em; }
.hero-card-sub { font-size: 13px; opacity: 0.6; margin-top: 4px; }
.hero-card-right { text-align: right; }
.hero-card-change { font-size: 14px; font-weight: 600; color: #6EE7B7; }
.hero-card-note { font-size: 11px; opacity: 0.45; margin-top: 8px; }

/* ─── Toggle Switch ─── */
.toggle-switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle-track {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: #D1D5DB;
    position: relative;
    transition: background 0.25s;
}
.toggle-track.active { background: var(--green); }
.toggle-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #FFF;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: left 0.25s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-track.active .toggle-thumb { left: 23px; }
.toggle-label { font-size: 13px; color: var(--text); font-weight: 500; }

/* ─── Time Slot Cards ─── */
.slot-grid { display: flex; gap: 12px; flex-wrap: wrap; }
.slot-card {
    flex: 1 0 130px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
}
.slot-time { font-size: 14px; font-weight: 600; color: var(--text); }
.slot-info { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* ─── Mini Bar Chart ─── */
.mini-bar-chart { display: flex; align-items: flex-end; gap: 6px; padding: 0 4px; }
.mini-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mini-bar-value { font-size: 10px; font-family: var(--mono); color: var(--text-secondary); }
.mini-bar-bar { width: 100%; border-radius: 4px; transition: height 0.6s cubic-bezier(.4,0,.2,1); }
.mini-bar-label { font-size: 9px; color: var(--text-secondary); }

/* ─── Cards (generic) ─── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px 24px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }

/* ─── Old Stats Grid (for compatibility) ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 22px 24px;
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
}
.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.stat-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1;
}
.stat-change {
    margin-top: 6px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}
.stat-change.positive { color: var(--green); }
.stat-change.negative { color: var(--accent); }

/* ─── Chart Container ─── */
.chart-container { position: relative; height: 280px; margin: 16px 0; }

/* ─── Tables (for CRUD screens) ─── */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg); }
th {
    padding: 10px 20px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}
td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
tbody tr { transition: var(--transition); }
tbody tr:hover { background: var(--sidebar-active); }
tbody tr:last-child td { border-bottom: none; }

/* ─── Status Badges (table compat) ─── */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.status-active { color: var(--green); background: var(--green-light); }
.status-pending { color: var(--yellow); background: var(--yellow-light); }
.status-inactive { color: var(--text-secondary); background: #F3F4F6; }

/* ─── Loading / Empty States ─── */
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px; color: var(--text-secondary); }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 12px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }

/* ─── Modal ─── */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; backdrop-filter: blur(4px); }
.modal-overlay.active { display: flex; align-items: center; justify-content: center; }
.modal-content {
    background: var(--card);
    border-radius: var(--radius-lg);
    max-width: 560px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 48px rgba(0,0,0,0.16);
    animation: slideUp 0.25s ease-out;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 18px; }
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 24px; }

/* ─── Subscription Tiers ─── */
.subscription-tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; margin: 24px 0; }
.tier-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    transition: var(--transition);
}
.tier-card.current { border-color: var(--accent); box-shadow: 0 4px 16px rgba(232,85,61,0.15); }
.tier-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
.tier-name { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.tier-price { font-size: 36px; font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.tier-price small { font-size: 14px; color: var(--text-secondary); }
.tier-features { list-style: none; margin: 20px 0; text-align: left; }
.tier-features li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.tier-features li:last-child { border-bottom: none; }

/* ─── Premium Banner ─── */
.premium-banner {
    padding: 20px 24px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.premium-banner-icon { font-size: 32px; }
.premium-banner-content h3 { font-size: 16px; margin-bottom: 4px; }
.premium-banner-content p { font-size: 13px; opacity: 0.9; }

/* ─── Callout card ─── */
.callout {
    padding: 16px 20px;
    background: var(--bg);
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 16px;
}

/* ─── Toast ─── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: #FFF;
    font-size: 13px;
    font-weight: 500;
    z-index: 2000;
    animation: slideUp 0.3s ease-out;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

/* ─── Responsive (Phase 5: Mobile polish) ─── */
@media (max-width: 768px) {
    .sidebar { width: 100%; height: auto; position: relative; border-right: none; border-bottom: 1px solid var(--border); padding: 16px 0; }
    .sidebar .nav-menu { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; padding: 0 12px; }
    .sidebar .nav-menu li { flex: 1 1 auto; min-width: 100px; }
    .sidebar .nav-menu a { padding: 10px 12px; font-size: 12px; }
    .sidebar .nav-icon { display: none; }
    .screen.active { flex-direction: column; }
    .content-header { padding: 16px 20px; flex-direction: column; align-items: flex-start; gap: 12px; }
    .content-body { padding: 16px 20px; }
    .kpi-grid { grid-template-columns: 1fr; gap: 12px; }
    .hero-card { flex-direction: column; text-align: center; gap: 20px; }
    .data-row { grid-template-columns: 1fr 1fr !important; font-size: 12px; }
    .data-row-header .data-cell { font-size: 11px; }
    .data-panel-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .login-card { padding: 24px; margin: 16px; }
    .toast { left: 16px; right: 16px; bottom: 16px; }
}
@media (max-width: 480px) {
    .content-header h1 { font-size: 18px; }
    .btn { padding: 8px 14px; font-size: 12px; }
    .modal-content { margin: 16px; max-width: calc(100% - 32px); }
}

/* ─── Utility ─── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
