/* commercial-mvp-server — shared stylesheet for gate, MVP, admin pages.
 *
 * Mobile-first; the only breakpoints are at 720px (tablet/laptop) and
 * 1100px (desktop dashboard layout). No CSS framework — these rules
 * are short enough to read top-to-bottom.
 */

:root {
    --bg:        #0b0e13;
    --panel:     #131822;
    --panel-2:   #1a212e;
    --border:    #2a3244;
    --text:      #e7ecf3;
    --muted:     #98a2b3;
    --accent:    #5b9dff;
    --accent-2:  #3a78d6;
    --good:      #4ec98e;
    --warn:      #f0b95b;
    --bad:       #ef5b6c;
    --shadow:    0 6px 24px rgba(0, 0, 0, 0.35);
    --radius:    10px;
    --mono:      ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
    font: inherit;
    color: var(--text);
    background: var(--accent);
    border: 1px solid var(--accent-2);
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: filter 0.1s ease;
}
button:hover { filter: brightness(1.08); }
button:active { filter: brightness(0.95); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
button.danger {
    background: transparent;
    border: 1px solid var(--bad);
    color: var(--bad);
}

input, select, textarea {
    font: inherit;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.8rem;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.muted { color: var(--muted); }
.mono  { font-family: var(--mono); }
.good  { color: var(--good); }
.bad   { color: var(--bad); }
.warn  { color: var(--warn); }

.error {
    background: rgba(239, 91, 108, 0.15);
    color: var(--bad);
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    border: 1px solid rgba(239, 91, 108, 0.4);
    margin-top: 0.75rem;
}

.success {
    background: rgba(78, 201, 142, 0.12);
    color: var(--good);
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    border: 1px solid rgba(78, 201, 142, 0.4);
    margin-top: 0.75rem;
}

/* ----------------- Gate / MVP centered card layout ----------------- */

.center-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.25rem;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.75rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}

.card h1 {
    margin: 0 0 0.25rem 0;
    font-size: 1.5rem;
}

.card p {
    color: var(--muted);
    margin: 0 0 1.25rem 0;
}

.card label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.card .row {
    margin-bottom: 1rem;
}

.card .submit {
    width: 100%;
    margin-top: 0.5rem;
}

/* Password field with inline show/hide toggle (used on login) */
.pw-field {
    position: relative;
}

.pw-field input[type="password"],
.pw-field input[type="text"] {
    padding-right: 3.5rem;
}

.pw-toggle {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 0.72rem;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
    font-weight: 500;
    text-transform: lowercase;
    letter-spacing: 0.02em;
}

.pw-toggle:hover {
    color: var(--accent);
    background: rgba(91, 157, 255, 0.08);
}

.pw-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.gate-input {
    text-align: center;
    letter-spacing: 0.18em;
    font-size: 1.25rem;
    font-family: var(--mono);
    text-transform: uppercase;
}

/* ----------------- MVP shell ----------------- */

.mvp-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
}
.mvp-topbar .brand { font-weight: 600; }

.mvp-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.mvp-topbar .ghost-link {
    font-size: 0.8rem;
    padding: 0.25rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    text-decoration: none;
    line-height: 1;
}
.mvp-topbar .ghost-link:hover {
    color: var(--text);
    background: var(--panel-2);
    text-decoration: none;
}

.mvp-content {
    max-width: 880px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 4rem 1.25rem;
}

.mvp-content h1 { margin-top: 0; }

.mvp-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin: 1rem 0;
}

/* ----------------- Admin dashboard ----------------- */

.admin-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
    gap: 0.75rem;
}

.admin-topbar .brand {
    font-weight: 600;
    letter-spacing: 0.04em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* On phones, drop the "Signed in as ..." label so the two buttons fit. */
@media (max-width: 559.98px) {
    .topbar-actions #who { display: none; }
}

.admin-main {
    flex: 1;
    padding: 1.25rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.metric {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}
.metric .label { color: var(--muted); font-size: 0.85rem; }
.metric .value { font-size: 1.6rem; font-weight: 600; margin-top: 0.25rem; }

.section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.1rem 1.25rem 1.1rem;
    margin-bottom: 1.25rem;
}
.section h2 {
    margin: 0 0 0.75rem 0;
    font-size: 1.1rem;
}
.section .section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.create-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--panel-2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.create-form .row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

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

table.list th,
table.list td {
    text-align: left;
    padding: 0.55rem 0.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

table.list th {
    color: var(--muted);
    font-weight: 500;
    background: var(--panel-2);
}

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

.pill {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    border: 1px solid currentColor;
}
.pill.good { color: var(--good); }
.pill.bad  { color: var(--bad); }

/* Two-column layout from 1100px up. */
@media (min-width: 1100px) {
    .admin-grid {
        display: grid;
        grid-template-columns: 1.2fr 1fr;
        gap: 1.25rem;
        align-items: start;
    }
    .metrics {
        grid-template-columns: repeat(4, 1fr);
    }
    .create-form .row {
        grid-template-columns: 2fr 1fr 1fr auto;
        align-items: end;
    }
}

@media (min-width: 720px) and (max-width: 1099.98px) {
    .metrics { grid-template-columns: repeat(4, 1fr); }
    .create-form .row {
        grid-template-columns: 2fr 1fr 1fr auto;
        align-items: end;
    }
}

/* Long passcodes break the table on phones — let them wrap. */
.code-cell {
    font-family: var(--mono);
    word-break: break-all;
}

/* Visually hidden but available to assistive tech. */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ----------------- Modal dialog ----------------- */

.modal {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.5rem;
    width: min(420px, calc(100vw - 2rem));
    box-shadow: var(--shadow);
}

.modal::backdrop {
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
}

.modal h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.15rem;
}

.modal p {
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
    color: var(--muted);
}

.modal .row {
    margin-bottom: 0.85rem;
}

.modal .row label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}
