/* ============================================================
   PBX Console — design tokens
   Dark-first console UI. Change the values below to re-skin.
   ============================================================ */

:root {
    --bg: #0b0d12;
    --bg-elevated: #10131a;
    --surface: #151922;
    --surface-2: #1b212c;
    --surface-hover: #1f2531;
    --border: #262c38;
    --border-strong: #333c4c;

    --text: #eef1f5;
    --text-dim: #9aa3b2;
    --text-faint: #626b7a;

    --accent: #5b8cff;
    --accent-hover: #7aa0ff;
    --accent-soft: rgba(91, 140, 255, 0.14);
    --accent-contrast: #0b0d12;

    --ok: #33c481;
    --ok-soft: rgba(51, 196, 129, 0.14);
    --error: #f2596b;
    --error-soft: rgba(242, 89, 107, 0.14);
    --pending: #e0ab4a;
    --pending-soft: rgba(224, 171, 74, 0.14);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.36);

    --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
    --sidebar-w: 240px;

    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: dark; }

body {
    margin: 0;
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(91, 140, 255, 0.06), transparent 60%),
        var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

::selection { background: var(--accent-soft); color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--bg); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ------------------------------------------------------------
   App shell — fixed sidebar + scrolling content column
   ------------------------------------------------------------ */

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 22px;
    text-decoration: none;
    color: var(--text);
}
.sidebar-brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    box-shadow: 0 2px 10px rgba(91, 140, 255, 0.35);
}
.sidebar-brand-mark svg { width: 16px; height: 16px; }
.sidebar-brand-text { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}
.sidebar-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    padding: 16px 10px 6px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.sidebar-link svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.sidebar-link:hover { background: var(--surface-hover); color: var(--text); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent-hover); }
.sidebar-link.active svg { opacity: 1; }

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 650;
    color: var(--text-dim);
    flex: none;
    text-transform: uppercase;
}
.sidebar-user { min-width: 0; flex: 1; }
.sidebar-user-email {
    font-size: 12.5px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role { font-size: 11.5px; color: var(--text-faint); text-transform: capitalize; }
.sidebar-logout {
    background: none;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.sidebar-logout:hover { color: var(--error); background: var(--error-soft); }
.sidebar-logout svg { width: 16px; height: 16px; }

.content-area { min-width: 0; }
.container { max-width: 1080px; margin: 0 auto; padding: 36px 32px 64px; }

/* No-sidebar (unauthenticated) pages */
.bare-body { min-height: 100vh; }

/* ------------------------------------------------------------
   Typography & layout helpers
   ------------------------------------------------------------ */

h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.015em; margin: 0 0 4px; }
h2 { font-size: 15.5px; font-weight: 650; margin: 0 0 14px; letter-spacing: -0.005em; }
h3 { font-size: 14px; font-weight: 650; margin: 0; }
p { margin: 0 0 10px; }
.subtle { color: var(--text-dim); font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace; font-size: 12.5px; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
}
.page-header .actions { display: flex; align-items: center; gap: 10px; }

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */

.button, button[type="submit"], button:not([class]) {
    background: var(--accent);
    color: white;
    border: 1px solid transparent;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 550;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s var(--ease), transform 0.1s var(--ease), box-shadow 0.15s var(--ease);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.button:hover, button[type="submit"]:hover { background: var(--accent-hover); }
.button:active, button[type="submit"]:active { transform: translateY(1px); }

.button.secondary, button.secondary {
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--text);
    box-shadow: none;
}
.button.secondary:hover, button.secondary:hover { background: var(--surface-hover); border-color: var(--text-faint); }

.link-button {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0;
    font-size: 13px;
    font-family: inherit;
    text-decoration: none;
    font-weight: 500;
}
.link-button:hover { color: var(--accent-hover); text-decoration: underline; }
.link-button.danger { color: var(--error); }
.link-button.danger:hover { color: #ff8291; }

/* ------------------------------------------------------------
   Cards & sections
   ------------------------------------------------------------ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s var(--ease);
}

.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-top: 4px;
}
.plan-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.15s var(--ease), transform 0.15s var(--ease);
}
.plan-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.plan-card-current { border-color: var(--accent); background: var(--accent-soft); }

/* ------------------------------------------------------------
   Tables
   ------------------------------------------------------------ */

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.data-table th, .data-table td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    color: var(--text-faint);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-elevated);
}
.data-table tbody tr { transition: background 0.12s var(--ease); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tr:last-child td { border-bottom: none; }
.data-table.compact th, .data-table.compact td { padding: 8px 12px; font-size: 13px; }
.data-table a { text-decoration: none; font-weight: 500; }
.data-table a:hover { text-decoration: underline; }

/* ------------------------------------------------------------
   Badges
   ------------------------------------------------------------ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-error { background: var(--error-soft); color: var(--error); }
.badge-pending { background: var(--pending-soft); color: var(--pending); }

/* ------------------------------------------------------------
   Empty states
   ------------------------------------------------------------ */

.empty-state {
    color: var(--text-dim);
    text-align: center;
    padding: 48px 24px;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    font-size: 13.5px;
}
.empty-state a { font-weight: 550; }

/* ------------------------------------------------------------
   Tabs
   ------------------------------------------------------------ */

.tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    width: fit-content;
}
.tab-bar button {
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 550;
    font-family: inherit;
    border-radius: var(--radius-sm);
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.tab-bar button:hover { color: var(--text); }
.tab-bar button.active { color: var(--accent-contrast); background: var(--accent); }

/* ------------------------------------------------------------
   Forms
   ------------------------------------------------------------ */

.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 440px;
    box-shadow: var(--shadow-sm);
}
.form-card.inline-form {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    max-width: none;
    background: none;
    border: none;
    padding: 0;
    box-shadow: none;
}
.form-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 550;
    color: var(--text-dim);
}
.form-card input, .form-card select {
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--text);
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.form-card input:focus, .form-card select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-card input::placeholder { color: var(--text-faint); }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 7px !important; }
.checkbox-label input { accent-color: var(--accent); }

/* ------------------------------------------------------------
   Auth pages (no sidebar)
   ------------------------------------------------------------ */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(900px 500px at 15% 10%, rgba(91, 140, 255, 0.1), transparent 60%),
        radial-gradient(900px 500px at 85% 90%, rgba(139, 92, 246, 0.08), transparent 60%),
        var(--bg);
}

.login-box {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
}
.login-box .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    box-shadow: 0 4px 14px rgba(91, 140, 255, 0.35);
}
.login-box .brand-mark svg { width: 20px; height: 20px; }
.login-box h1 { font-size: 19px; margin-bottom: 6px; }
.login-box form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.login-box label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 550;
    color: var(--text-dim);
}
.login-box input {
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--text);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.login-box input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-box button[type="submit"] { justify-content: center; padding: 10px 16px; font-size: 13.5px; margin-top: 2px; }

/* ------------------------------------------------------------
   Misc
   ------------------------------------------------------------ */

.user-row {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }
.user-row-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.error {
    color: var(--error);
    background: var(--error-soft);
    border: 1px solid rgba(242, 89, 107, 0.3);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 14px;
}

.notice {
    color: var(--accent-hover);
    background: var(--accent-soft);
    border: 1px solid rgba(91, 140, 255, 0.3);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 14px;
}

.sync-error-banner {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}
.sync-error-banner strong { color: var(--error); }
.sync-error-banner .mono { font-size: 12px; opacity: 0.9; }

.btn-icon-sync {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}
.btn-icon-sync:hover { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent); }
.btn-icon-sync svg { width: 13px; height: 13px; }

@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: relative;
        height: auto;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
        padding: 12px 14px;
    }
    .sidebar-brand { padding: 0 14px 0 0; }
    .sidebar-nav { flex-direction: row; flex: none; }
    .sidebar-section-label { display: none; }
    .sidebar-footer { border-top: none; border-left: 1px solid var(--border); margin: 0 0 0 10px; padding: 0 0 0 14px; }
    .container { padding: 24px 18px 48px; }
    .form-card.inline-form { flex-direction: column; align-items: stretch; }
}
