/* ==========================================================================
   SwiftCap EAs — Dashboard Design System (shared across all dashboard pages)
   Extracted from the licenses.html redesign as the canonical reference.
   ========================================================================== */

/* ==========================================================================
   Design Tokens
   ========================================================================== */
:root {
    --f-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    --f-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

    --bg:          oklch(0.17 0.008 250);
    --bg-elev:     oklch(0.21 0.010 250);
    --bg-sunk:     oklch(0.14 0.008 250);

    --ink:         oklch(0.96 0.005 85);
    --ink-2:       oklch(0.85 0.008 85);
    --ink-3:       oklch(0.68 0.010 85);
    --ink-4:       oklch(0.52 0.008 85);

    --line:        oklch(0.28 0.010 250);
    --line-2:      oklch(0.34 0.012 250);

    --ember:       oklch(0.78 0.14 75);
    --ember-soft:  oklch(0.28 0.08 75);
    --ember-ink:   oklch(0.14 0.02 75);

    --signal:      oklch(0.76 0.18 150);
    --signal-soft: oklch(0.28 0.06 150);

    --danger:      oklch(0.70 0.20 25);
    --danger-soft: oklch(0.28 0.08 25);

    --r-sm: 4px;
    --r-md: 6px;
    --r-lg: 10px;
    --ease: cubic-bezier(.2,.7,.2,1);
    --t-fast: 140ms;

    --sidebar-w: 252px;
}

/* ==========================================================================
   Reset
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--f-sans);
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }

/* ==========================================================================
   Sidebar (rendered by shared-nav.js)
   ========================================================================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-sunk);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 100;
    overflow-y: auto;
}

.sb-top { padding: 20px 14px 0; }
.sb-bottom { padding: 0 14px 16px; }

/* Brand */
.sb-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    padding: 4px 8px;
    margin-bottom: 20px;
}

.sb-brand-mark img {
    width: 26px;
    height: 26px;
    border-radius: var(--r-sm);
}

.sb-brand-text {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.sb-tm {
    font-size: 0.6em;
    vertical-align: super;
    color: var(--ink-3);
}

/* Section label */
.sb-section-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--ink-4);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 10px;
    margin-bottom: 6px;
}

/* Nav links */
.sb-nav { display: flex; flex-direction: column; gap: 2px; }

.sb-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--r-md);
    color: var(--ink-3);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.sb-link:hover { color: var(--ink); background: var(--line); }

.sb-link.is-active {
    color: var(--ink);
    background: var(--line);
}

.sb-link.is-active .sb-icon { color: var(--ember); }

.sb-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sb-ext { width: 12px; height: 12px; margin-left: auto; color: var(--ink-4); }

.sb-link-ext { margin-top: 0; }
.sb-link-ext:first-child { margin-top: 0; }

/* User block */
.sb-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px;
    border-top: 1px solid var(--line);
    margin-top: 12px;
}

.sb-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--ember-soft);
    color: var(--ember);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.76rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sb-user-info { flex: 1; min-width: 0; }

.sb-user-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-user-email {
    font-size: 0.68rem;
    color: var(--ink-4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-logout {
    background: none;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    color: var(--ink-4);
    padding: 5px;
    cursor: pointer;
    transition: all var(--t-fast) var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sb-logout:hover { border-color: var(--danger); color: var(--danger); }

/* Mobile toggle */
.sb-mobile-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 200;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--ink-3);
    padding: 8px;
    cursor: pointer;
}

.sb-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: oklch(0 0 0 / .55);
    z-index: 99;
}

.sb-overlay.is-open { display: block; }

/* ==========================================================================
   Main content area — offset by sidebar
   ========================================================================== */
.dash-main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    padding: 32px 40px 60px;
}

.dash-wrap {
    max-width: 960px;
}

/* ==========================================================================
   Page header
   ========================================================================== */
.page-hdr {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 32px;
}

.page-hdr h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
}

.page-hdr p {
    color: var(--ink-3);
    font-size: 0.84rem;
    margin-top: 4px;
}

.hdr-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* ==========================================================================
   Shared card
   ========================================================================== */
.dash-card {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 24px;
    margin-bottom: 16px;
    transition: border-color var(--t-fast) var(--ease);
}

.dash-card:hover { border-color: var(--line-2); }

.dash-card h2 {
    font-size: 0.96rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 14px;
    letter-spacing: -0.01em;
}

.dash-card p {
    font-size: 0.84rem;
    color: var(--ink-3);
    line-height: 1.65;
    margin-bottom: 14px;
}

.dash-card p:last-child { margin-bottom: 0; }

/* Danger variant */
.dash-card-danger {
    border-color: oklch(0.36 0.10 25);
}

.dash-card-danger h2 { color: var(--danger); }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-active  { background: var(--signal-soft); color: var(--signal); }
.badge-expired { background: var(--danger-soft); color: var(--danger); }
.badge-revoked { background: var(--danger-soft); color: var(--danger); }
.badge-ember   { background: var(--ember-soft); color: var(--ember); }

/* ==========================================================================
   Filter / select inputs
   ========================================================================== */
.filter-select {
    padding: 7px 30px 7px 12px;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--ink-2);
    font-family: var(--f-sans);
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
    transition: border-color var(--t-fast) var(--ease);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23888' stroke-width='1.5'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.filter-select:focus { border-color: var(--ember); }

/* ==========================================================================
   Form elements (shared)
   ========================================================================== */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--ink-4);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-sunk);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--ink);
    font-family: var(--f-sans);
    font-size: 0.88rem;
    outline: none;
    transition: border-color var(--t-fast) var(--ease);
}

.form-input:focus { border-color: var(--ember); }
.form-input::placeholder { color: var(--ink-4); }
.form-input:disabled { opacity: 0.5; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: var(--ember);
    color: var(--ember-ink);
    border: none;
    border-radius: var(--r-md);
    font-family: var(--f-sans);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--t-fast) var(--ease);
    text-decoration: none;
}

.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: var(--bg-sunk);
    border: 1px solid var(--line);
    color: var(--ink-2);
    border-radius: var(--r-md);
    font-family: var(--f-sans);
    font-size: 0.84rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--t-fast) var(--ease);
    text-decoration: none;
}

.btn-secondary:hover { border-color: var(--line-2); color: var(--ink); }

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: var(--danger-soft);
    border: 1px solid oklch(0.36 0.10 25);
    color: var(--danger);
    border-radius: var(--r-md);
    font-family: var(--f-sans);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--t-fast) var(--ease);
    text-decoration: none;
}

.btn-danger:hover { background: oklch(0.32 0.10 25); }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-dl {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--ember-soft);
    border: 1px solid oklch(0.36 0.08 75);
    color: var(--ember);
    border-radius: var(--r-md);
    font-family: var(--f-sans);
    font-size: 0.76rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--t-fast) var(--ease);
}

.btn-dl:hover { background: oklch(0.32 0.09 75); }
.btn-dl svg { width: 14px; height: 14px; }

.btn-copy {
    background: var(--bg-sunk);
    border: 1px solid var(--line);
    color: var(--ink-3);
    padding: 10px 14px;
    border-radius: var(--r-md);
    font-family: var(--f-sans);
    font-size: 0.76rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--t-fast) var(--ease);
    white-space: nowrap;
}

.btn-copy:hover { border-color: var(--line-2); color: var(--ink); }
.btn-copy.copied { border-color: var(--signal); color: var(--signal); }

/* ==========================================================================
   Meta grid (reusable stat cells)
   ========================================================================== */
.meta-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.meta-cell {
    background: var(--bg-sunk);
    border-radius: var(--r-md);
    padding: 10px 12px;
}

.meta-label {
    font-size: 0.66rem;
    font-weight: 600;
    color: var(--ink-4);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 3px;
}

.meta-val {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--ink);
}

.meta-val-ember { color: var(--ember); }
.meta-val-signal { color: var(--signal); }

/* ==========================================================================
   Tables
   ========================================================================== */
.dash-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.dash-table thead th {
    background: var(--bg-sunk);
    color: var(--ink-4);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

.dash-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--ink-2);
}

.dash-table tbody tr:last-child td { border-bottom: none; }

.dash-table tbody tr:hover td {
    background: oklch(0.19 0.008 250);
}

.table-note {
    font-size: 0.76rem;
    color: var(--ink-4);
    font-style: italic;
    margin-top: 12px;
}

/* ==========================================================================
   Steps / How-It-Works
   ========================================================================== */
.steps-row {
    display: flex;
    gap: 16px;
}

.step {
    flex: 1;
    text-align: center;
    background: var(--bg-sunk);
    border-radius: var(--r-md);
    padding: 20px 16px;
}

.step-number {
    width: 36px;
    height: 36px;
    background: var(--ember-soft);
    color: var(--ember);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.84rem;
    font-weight: 700;
    margin: 0 auto 10px;
    font-family: var(--f-mono);
}

.step-title {
    color: var(--ink);
    font-size: 0.84rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.step-desc {
    color: var(--ink-3);
    font-size: 0.78rem;
    line-height: 1.55;
}

/* ==========================================================================
   FAQ (dashboard variant)
   ========================================================================== */
.dash-faq-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.dash-faq-item:last-child { border-bottom: none; padding-bottom: 0; }
.dash-faq-item:first-child { padding-top: 0; }

.dash-faq-q {
    color: var(--ink);
    font-size: 0.84rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.dash-faq-a {
    color: var(--ink-3);
    font-size: 0.8rem;
    line-height: 1.65;
}

.dash-faq-a a { color: var(--ember); text-decoration: none; }
.dash-faq-a a:hover { text-decoration: underline; }

/* ==========================================================================
   Loading / empty states
   ========================================================================== */
.loading-state, .empty-state {
    text-align: center;
    padding: 64px 20px;
    color: var(--ink-3);
    font-size: 0.9rem;
}

.empty-state h2 {
    color: var(--ink);
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.empty-state a { color: var(--ember); text-decoration: none; }
.empty-state a:hover { text-decoration: underline; }

/* Loading spinner */
.loader {
    width: 24px;
    height: 24px;
    border: 2px solid var(--line);
    border-top-color: var(--ember);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 14px;
}

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

/* ==========================================================================
   Toast notifications
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--r-md);
    font-size: 0.8rem;
    font-weight: 500;
    animation: toastSlideIn 0.3s var(--ease), toastFadeOut 0.3s ease 3.7s;
    max-width: 360px;
    box-shadow: 0 4px 16px oklch(0 0 0 / .25);
}

.toast-success {
    background: var(--signal-soft);
    border: 1px solid oklch(0.38 0.08 150);
    color: var(--signal);
}

.toast-error {
    background: var(--danger-soft);
    border: 1px solid oklch(0.38 0.10 25);
    color: var(--danger);
}

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

@keyframes toastFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ==========================================================================
   Modal (confirmation dialog)
   ========================================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: oklch(0 0 0 / .6);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal-box {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 28px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 8px;
}

.modal-message {
    color: var(--ink-3);
    font-size: 0.84rem;
    line-height: 1.55;
    margin-bottom: 22px;
}

.modal-actions { display: flex; gap: 10px; justify-content: center; }

.modal-btn {
    padding: 9px 22px;
    border-radius: var(--r-md);
    font-family: var(--f-sans);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--t-fast) var(--ease);
    border: none;
}

.modal-btn-cancel {
    background: var(--bg-sunk);
    border: 1px solid var(--line);
    color: var(--ink-3);
}

.modal-btn-cancel:hover { background: var(--line); color: var(--ink); }

.modal-btn-confirm {
    background: var(--danger-soft);
    border: 1px solid oklch(0.36 0.10 25);
    color: var(--danger);
}

.modal-btn-confirm:hover { background: oklch(0.32 0.10 25); }

/* ==========================================================================
   Footer link
   ========================================================================== */
.billing-link {
    text-align: center;
    margin-top: 28px;
    font-size: 0.8rem;
    color: var(--ink-4);
}

.billing-link a {
    color: var(--ember);
    text-decoration: none;
    font-weight: 500;
}

.billing-link a:hover { text-decoration: underline; }

/* ==========================================================================
   Utility / list styles
   ========================================================================== */
.dash-list {
    list-style: none;
    margin-bottom: 16px;
}

.dash-list li {
    font-size: 0.84rem;
    color: var(--ink-3);
    padding: 5px 0 5px 18px;
    position: relative;
    line-height: 1.55;
}

.dash-list li::before {
    content: '→';
    color: var(--ember);
    position: absolute;
    left: 0;
    font-size: 0.8rem;
}

/* ==========================================================================
   Responsive — mobile
   ========================================================================== */
@media (max-width: 860px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.28s var(--ease);
    }

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

    .sb-mobile-toggle { display: flex; }

    .dash-main {
        margin-left: 0;
        padding: 60px 20px 40px;
    }
}

@media (max-width: 640px) {
    .meta-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-hdr {
        flex-direction: column;
        gap: 12px;
    }

    .hdr-actions { width: 100%; }
    .filter-select { flex: 1; }

    .steps-row {
        flex-direction: column;
    }
}
