/* ========================================================================
   PHP Monitor — stylesheet
   Dark theme as default. CSS custom properties drive all colors, spacing,
   and type so future tweaks happen in one place.
   ====================================================================== */

:root {
    --bg:         #0b0f14;
    --surface:    #1a1f2e;
    --surface-2:  #212735;
    --border:     #2b3140;
    --text:       #e5e7eb;
    --muted:      #9ca3af;
    --dim:        #6b7280;
    --accent:     #60a5fa;
    --accent-dk:  #3b82f6;
    --good:       #00c896;
    --warn:       #f0a500;
    --crit:       #e05252;

    --radius:     8px;
    --sp-1:       4px;
    --sp-2:       8px;
    --sp-3:       12px;
    --sp-4:       16px;
    --sp-5:       24px;
    --sp-6:       32px;

    --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
    --mono:  "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --topbar-h:  56px;
    --sidebar-w: 180px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
    font: 14px/1.5 var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
}

a { color: inherit; }

/* ==========================================================================
   Auth pages (login / logout banner) share this card layout.
   ========================================================================== */
body.auth-page {
    padding: 24px;
    display: grid;
    place-items: center;
    background:
        radial-gradient(1200px 600px at 50% -10%, rgba(96,165,250,.08), transparent 60%),
        var(--bg);
}
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 36px 32px 28px;
    box-shadow: 0 20px 60px -20px rgba(0,0,0,.6);
}
.auth-brand {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    color: var(--muted); font-size: 11px; font-weight: 500;
    letter-spacing: 0.08em; text-transform: uppercase;
    margin-bottom: 24px;
}
.auth-icon {
    width: 52px; height: 52px; margin: 0 auto 16px;
    display: grid; place-items: center;
    background: rgba(96,165,250,.10);
    border: 1px solid rgba(96,165,250,.25);
    border-radius: 14px;
    color: var(--accent);
}
.auth-icon svg { width: 24px; height: 24px; }
.auth-card h1 { font-size: 20px; font-weight: 600; text-align: center; margin-bottom: 6px; }
.auth-lede    { color: var(--muted); font-size: 13px; text-align: center; margin-bottom: 24px; }
.auth-banner {
    padding: 10px 12px; border-radius: 8px;
    font-size: 12px; margin-bottom: 16px;
    text-align: center;
    background: rgba(0,200,150,.10);
    border: 1px solid rgba(0,200,150,.30);
    color: #34d399;
}
.auth-banner.error {
    background: rgba(224,82,82,.10);
    border-color: rgba(224,82,82,.30);
    color: #fca5a5;
}
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card .field label {
    display: block;
    color: var(--muted); font-size: 12px; font-weight: 500;
    margin-bottom: 6px;
}
.auth-card .field input {
    width: 100%; padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font: 14px/1.3 inherit;
    transition: border-color .12s, background .12s, box-shadow .12s;
}
.auth-card .field input:focus {
    outline: none;
    border-color: var(--accent);
    background: #1a222c;
    box-shadow: 0 0 0 3px rgba(96,165,250,.15);
}
.auth-footer {
    margin-top: 24px; text-align: center;
    color: var(--dim); font-size: 11px;
}

/* ==========================================================================
   Shared primitives used by both auth pages and dashboard.
   ========================================================================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font: 13px/1 var(--sans); font-weight: 500;
    text-decoration: none; cursor: pointer;
    transition: background .12s, border-color .12s, transform .08s;
}
.btn:hover { background: #283042; border-color: #384154; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary {
    width: 100%; padding: 11px 16px;
    background: var(--accent); color: #0b1220;
    border-color: var(--accent);
    font-weight: 600;
}
.btn-primary:hover  { background: var(--accent-dk); border-color: var(--accent-dk); }
.btn-primary svg    { width: 14px; height: 14px; }
.btn-ghost          { background: transparent; }

.dot {
    display: inline-block;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--good);
    box-shadow: 0 0 8px rgba(0,200,150,.6);
    flex-shrink: 0;
    vertical-align: middle;
}
.dot.good { background: var(--good); box-shadow: 0 0 8px rgba(0,200,150,.6); }
.dot.warn { background: var(--warn); box-shadow: 0 0 8px rgba(240,165,0,.6); }
.dot.crit { background: var(--crit); box-shadow: 0 0 8px rgba(224,82,82,.6); }

.sep { opacity: .4; margin: 0 8px; }
code {
    font-family: var(--mono); font-size: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 2px 6px; border-radius: 4px;
    color: var(--muted);
}

/* ==========================================================================
   Dashboard topbar.
   ========================================================================== */
body.dashboard-page { background: var(--bg); }

.topbar {
    position: sticky; top: 0; z-index: 10;
    display: grid;
    grid-template-columns: minmax(240px, auto) 1fr auto;
    align-items: center;
    gap: 16px;
    height: var(--topbar-h);
    padding: 0 20px;
    background: rgba(11,15,20,.90);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 14px; letter-spacing: -0.01em;
}
.topbar-title strong { font-weight: 600; }
.topbar-center {
    display: flex; align-items: center; justify-content: center;
    gap: 20px;
    color: var(--muted); font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.switcher {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--muted);
}
.switcher-label {
    font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
}
.switcher select {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font: 12px/1 var(--sans);
    cursor: pointer;
}
.meta { font-variant-numeric: tabular-nums; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ==========================================================================
   Sidebar (fixed, far-left of viewport) + content area alignment.
   ========================================================================== */
.sidebar {
    position: fixed;
    top: var(--topbar-h); left: 0; bottom: 0;
    width: var(--sidebar-w);
    overflow-y: auto;
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    z-index: 5;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; }
.sidebar a {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px; font-weight: 500;
    cursor: pointer;
    transition: background .12s, color .12s;
}
.sidebar a:hover  { background: var(--surface); color: var(--text); }
.sidebar a.active { background: var(--surface-2); color: var(--text); }
.sidebar a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.content-area { margin-left: var(--sidebar-w); }

main {
    max-width: 1220px;
    margin: 0 auto;
    padding: 24px;
    min-width: 0;
}

/* ==========================================================================
   Panels (tabs). Only active panel is shown.
   ========================================================================== */
.panel { display: none; margin-bottom: 28px; }
.panel.is-active { display: block; }

.panel > header {
    display: flex; align-items: baseline; gap: 12px;
    margin-bottom: 12px;
}
.panel > header h2 {
    font-size: 12px; font-weight: 600; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--muted);
}
.panel > header .note { color: var(--dim); font-size: 12px; }

/* ==========================================================================
   Metric card grid.
   ========================================================================== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    transition: border-color .12s;
}
.card:hover { border-color: #384154; }
.card .label {
    color: var(--muted); font-size: 11px;
    text-transform: uppercase; letter-spacing: .06em;
    margin-bottom: 6px;
}
.card .value {
    font-family: var(--mono);
    font-size: 22px; font-weight: 500; letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}
.card .pill {
    display: inline-block; margin-top: 8px;
    padding: 2px 8px; border-radius: 4px;
    font-size: 11px; font-weight: 500;
    font-family: var(--mono);
}
.card .pill.good { background: rgba(0,200,150,.15);  color: #34d399; }
.card .pill.warn { background: rgba(240,165,0,.15);  color: #fbbf24; }
.card .pill.crit { background: rgba(224,82,82,.15);  color: #fca5a5; }

.subgrid-note {
    color: var(--dim); font-size: 11px;
    margin: 14px 0 8px;
    letter-spacing: .04em; text-transform: uppercase;
}

.code-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    font: 12px/1.5 var(--mono);
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
    max-height: 320px;
}

/* ==========================================================================
   History chart.
   ========================================================================== */
.chart-wrap {
    margin-top: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.chart-wrap h3 {
    color: var(--muted); font-size: 11px; font-weight: 600;
    letter-spacing: .08em; text-transform: uppercase;
    margin-bottom: 10px;
}
.chart-wrap canvas {
    width: 100%;
    max-width: 100%;
    height: 260px;
    display: block;
}
.chart-legend {
    display: flex; gap: 18px; margin-top: 10px;
    color: var(--muted); font-size: 12px;
}
.chart-legend .swatch {
    display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    margin-right: 6px; vertical-align: middle;
}

/* ==========================================================================
   Recommendations list.
   ========================================================================== */
.reco-title {
    color: var(--muted); font-size: 11px; font-weight: 600;
    letter-spacing: .08em; text-transform: uppercase;
    margin: 20px 0 8px;
}
.reco-list { display: flex; flex-direction: column; gap: 6px; }
.reco {
    display: grid;
    grid-template-columns: 16px 1fr auto;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 13px;
}
.reco .reco-dot {
    width: 10px; height: 10px; border-radius: 50%;
    align-self: center;
}
.reco .reco-dot.warn     { background: var(--warn); }
.reco .reco-dot.critical { background: var(--crit); }
.reco .reco-setting { font-family: var(--mono); color: var(--text); }
.reco .reco-note    { color: var(--muted); font-size: 12px; }
.reco .reco-action  { color: var(--accent); font-family: var(--mono); font-size: 12px; }

/* ==========================================================================
   Page footer.
   ========================================================================== */
.page-footer {
    max-width: 1220px;
    margin: 16px auto 0;
    padding: 16px 24px 24px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    gap: 16px;
    color: var(--dim); font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.page-footer strong { color: var(--muted); font-weight: 500; }

/* ==========================================================================
   Billing page.
   ========================================================================== */
.billing-wrap {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 24px;
}
.billing-wrap h1 {
    font-size: 20px; font-weight: 600;
    margin-bottom: 4px;
}
.billing-wrap .lede {
    color: var(--muted);
    margin-bottom: 24px;
    font-size: 13px;
}
.plan-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 24px;
}
.plan-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    display: flex; flex-direction: column; gap: 10px;
}
.plan-card.current { border-color: var(--accent); }
.plan-name  { font-size: 15px; font-weight: 600; }
.plan-price { font-family: var(--mono); font-size: 24px; font-weight: 500; }
.plan-price small { color: var(--muted); font-size: 12px; font-weight: 400; }
.plan-feats { color: var(--muted); font-size: 13px; list-style: none; }
.plan-feats li { padding: 3px 0; }
.plan-card .btn { margin-top: auto; }
.plan-card .badge {
    font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
    color: var(--accent);
}
.plan-card .btn.disabled {
    opacity: .6; cursor: default;
}
.plan-card .btn.unavailable {
    opacity: .5; cursor: not-allowed;
}
.manage-row {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.manage-row .k { color: var(--muted); font-size: 12px; }
.manage-row .v { font-family: var(--mono); font-size: 13px; }
.manage-row .btn-manage { margin-left: auto; }

.change-plan-heading { margin-top: 32px; }

/* ==========================================================================
   Responsive.
   ========================================================================== */
@media (max-width: 900px) {
    .topbar {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        height: auto;
        gap: 8px;
        padding: 10px 16px;
    }
    .topbar-center {
        grid-column: 1 / -1;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}
@media (max-width: 720px) {
    .sidebar {
        position: static;
        width: auto; height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 8px 12px;
    }
    .sidebar nav { flex-direction: row; overflow-x: auto; gap: 4px; padding: 0; }
    .sidebar nav::-webkit-scrollbar { display: none; }
    .sidebar a { white-space: nowrap; padding: 6px 10px; }
    .content-area { margin-left: 0; }
    main { padding: 16px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .page-footer { flex-direction: column; align-items: flex-start; gap: 6px; }
}
