:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
}

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

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

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

.sidebar {
    width: 240px;
    background: var(--text);
    color: #fff;
    padding: 1.5rem 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.sidebar .logo {
    padding: 0 1.5rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 1rem;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1.5rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.sidebar nav a:hover, .sidebar nav a.active {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.sidebar nav .section-label {
    padding: 1rem 1.5rem 0.3rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.4);
}

.sidebar .user-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.85rem;
}

.sidebar .user-info .user-name {
    font-weight: 600;
}

.sidebar .user-info a {
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    font-size: 0.8rem;
}

.main-content {
    margin-left: 240px;
    flex: 1;
    padding: 2rem;
    max-width: 1100px;
}

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

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

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* Stat cards */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

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

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

/* Tables */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

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

tbody td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

tbody tr:hover {
    background: #f1f5f9;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: #f1f5f9; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

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

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check input[type="checkbox"] { width: 1rem; height: 1rem; }

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* Badge */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-muted { background: #f1f5f9; color: #64748b; }

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: end;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.filter-bar .form-group { margin-bottom: 0; }

/* Login page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.login-card {
    background: var(--card);
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

.login-card h1 {
    text-align: center;
    margin-bottom: 0.3rem;
    font-size: 1.5rem;
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

/* Missing hours banner */
.missing-hours-banner {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid var(--danger);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.missing-hours-header {
    margin-bottom: 1rem;
}

.missing-hours-header strong {
    display: block;
    color: #991b1b;
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.missing-hours-header span {
    color: #b91c1c;
    font-size: 0.85rem;
}

.missing-hours-days {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.missing-day {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 0.8rem;
    background: rgba(255,255,255,0.7);
    border-radius: 6px;
}

.missing-day-date {
    font-weight: 600;
    min-width: 100px;
    color: var(--text);
}

.missing-day-detail {
    flex: 1;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 1rem; }
    .filter-bar { flex-direction: column; }
}

/* ===================================================================== */
/* Support Hub additions                                                 */
/* ===================================================================== */

/* Login screen */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 1rem;
}

.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
}

.auth-title { font-size: 1.4rem; font-weight: 700; }
.auth-sub { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1.5rem; }
.auth-card label { display: block; margin: 0.9rem 0 0.3rem; font-size: 0.85rem; font-weight: 600; }
.auth-card label.checkbox { font-weight: 400; display: flex; align-items: center; gap: 0.5rem; }
.auth-card input[type="email"],
.auth-card input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}
.btn-block { width: 100%; margin-top: 1.25rem; }

/* Stat grid (Hub dashboard) */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Helpers */
.muted { color: var(--text-muted); }
.empty { color: var(--text-muted); padding: 1rem 0; }
code {
    background: #f1f5f9;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
}

/* Disabled nav links (features not yet shipped) */
.sidebar nav a.disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

/* Urgency badges */
.badge.urgency-low      { background: #f1f5f9; color: #475569; }
.badge.urgency-normal   { background: #dbeafe; color: #1e40af; }
.badge.urgency-high     { background: #fef3c7; color: #92400e; }
.badge.urgency-critical { background: #fee2e2; color: #991b1b; }

/* ===================================================================== */
/* Phase 3 — ticket list filters & detail                                */
/* ===================================================================== */

.filter-field { display: flex; flex-direction: column; gap: 0.25rem; }
.filter-field label {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-muted); font-weight: 600;
}
.filter-field input, .filter-field select {
    padding: 0.45rem 0.55rem; border: 1px solid var(--border);
    border-radius: 6px; font-size: 0.9rem; background: #fff;
}
.filter-actions { display: flex; gap: 0.5rem; align-items: end; }

/* Clickable table rows */
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f8fafc; }

/* Pagination */
.pagination {
    display: flex; align-items: center; gap: 1rem;
    margin-top: 1rem; justify-content: center;
}

/* Ticket detail */
.detail-grid {
    display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; align-items: start;
}
.meta-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.ticket-body {
    white-space: pre-wrap; line-height: 1.6; padding: 0.5rem 0 1.5rem;
    border-bottom: 1px solid var(--border); margin-bottom: 1rem;
}
.attachment-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.attachment-list li { display: flex; justify-content: space-between; align-items: center;
    padding: 0.5rem 0.75rem; background: #f8fafc; border-radius: 6px; }

.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1rem;
    margin-bottom: 1.5rem; font-size: 0.9rem; }
.detail-list dt { color: var(--text-muted); font-weight: 600; }
.detail-list dd { margin: 0; }

.status-form { display: flex; gap: 0.5rem; }
.status-form select { flex: 1; padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; }

@media (max-width: 768px) {
    .detail-grid { grid-template-columns: 1fr; }
}

/* Account / password form (plain inputs inside a card) */
.card form label {
    display: block; margin: 0.9rem 0 0.3rem; font-size: 0.85rem; font-weight: 600;
}
.card form input[type="password"],
.card form input[type="text"],
.card form input[type="email"] {
    width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--border);
    border-radius: 6px; font-size: 0.95rem;
}

/* Clients: API key display + small buttons */
.key-box {
    background: #0f172a; color: #e2e8f0; padding: 0.75rem 1rem; border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem;
    white-space: pre-wrap; word-break: break-all; margin: 0.4rem 0 1rem;
}
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

/* Push to Studio panel */
.studio-form { display: flex; flex-direction: column; gap: 0.3rem; }
.studio-form label {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-muted); font-weight: 600; margin-top: 0.5rem;
}
.studio-form select, .studio-form input[type="date"] {
    padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.9rem;
}
.studio-pushed { color: #166534; font-weight: 600; margin-bottom: 0.75rem; }
