:root {
    --bg: #080b10;
    --bg-elevated: #0e131b;
    --sidebar: #0a0e14;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-hover: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.09);
    --text: #f1f5f9;
    --muted: #94a3b8;
    --accent: #f97316;
    --accent-2: #fb923c;
    --accent-dim: rgba(249, 115, 22, 0.14);
    --success: #34d399;
    --success-dim: rgba(52, 211, 153, 0.14);
    --danger: #f87171;
    --danger-dim: rgba(248, 113, 113, 0.14);
    --warn: #fbbf24;
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 260px;
    --font: "DM Sans", system-ui, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, monospace;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

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

/* ——— Login ——— */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem;
    background:
        radial-gradient(ellipse 70% 50% at 50% -10%, rgba(249, 115, 22, 0.16), transparent 55%),
        radial-gradient(ellipse 45% 35% at 100% 80%, rgba(59, 130, 246, 0.06), transparent 50%),
        linear-gradient(180deg, #080b10 0%, #0c1018 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.75rem;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), #ea580c);
    display: grid;
    place-items: center;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 8px 28px rgba(249, 115, 22, 0.35);
    flex-shrink: 0;
}

.login-brand h1 {
    font-size: 1.35rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.login-brand p {
    color: var(--muted);
    font-size: 0.9rem;
}

.login-footer {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
}

.login-footer a { margin: 0 0.25rem; }

/* ——— App shell ——— */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    background:
        radial-gradient(ellipse 50% 40% at 100% 0%, rgba(249, 115, 22, 0.07), transparent 50%),
        var(--bg);
}

.sidebar {
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0.5rem 1.25rem;
    color: inherit;
    text-decoration: none;
}

.sidebar-brand:hover { text-decoration: none; }

.sidebar-brand strong {
    display: block;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.sidebar-brand span {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
}

.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
}

.nav-list a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-weight: 500;
    font-size: 0.92rem;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-list a:hover {
    background: var(--surface-hover);
    color: var(--text);
    text-decoration: none;
}

.nav-list a.active {
    background: var(--accent-dim);
    color: var(--accent-2);
}

.nav-icon {
    width: 1.15rem;
    text-align: center;
    opacity: 0.85;
    font-size: 0.95rem;
}

.sidebar-user {
    margin-top: 1rem;
    padding: 0.85rem 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--muted);
}

.sidebar-user strong {
    display: block;
    color: var(--text);
    font-size: 0.85rem;
    margin-bottom: 0.15rem;
    word-break: break-all;
}

.main {
    min-width: 0;
    padding: 1.5rem 1.75rem 3rem;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.topbar h1 {
    font-size: 1.55rem;
    letter-spacing: -0.03em;
    font-weight: 700;
}

.topbar .lead {
    color: var(--muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.menu-toggle {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}

.flash.success {
    background: var(--success-dim);
    border: 1px solid rgba(52, 211, 153, 0.35);
    color: var(--success);
}

.flash.error {
    background: var(--danger-dim);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: var(--danger);
}

.flash.info {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
    border-color: rgba(249, 115, 22, 0.35);
    transform: translateY(-1px);
}

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

.stat-card .value {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 0.25rem 0;
}

.stat-card .hint {
    color: var(--muted);
    font-size: 0.8rem;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
    margin-bottom: 1.25rem;
}

.panel h2 {
    font-size: 1.05rem;
    margin-bottom: 0.35rem;
    letter-spacing: -0.02em;
}

.panel .note {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover { background: #ea580c; color: #fff; }

.btn-secondary {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-danger {
    background: var(--danger-dim);
    border-color: rgba(248, 113, 113, 0.35);
    color: var(--danger);
}

.btn-block { width: 100%; }

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

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    max-width: 420px;
    padding: 0.7rem 0.9rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.table-wrap { overflow-x: auto; }

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

table.data th,
table.data td {
    text-align: left;
    padding: 0.75rem 0.65rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.badge-ok { background: var(--success-dim); color: var(--success); }
.badge-off { background: rgba(148, 163, 184, 0.2); color: var(--muted); }
.badge-bad { background: var(--danger-dim); color: var(--danger); }
.badge-accent { background: var(--accent-dim); color: var(--accent-2); }

.mono {
    font-family: var(--mono);
    font-size: 0.85rem;
    background: rgba(0, 0, 0, 0.25);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

.empty {
    color: var(--muted);
    padding: 0.75rem 0;
    font-size: 0.95rem;
}

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

.product-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.product-card.featured {
    border-color: rgba(249, 115, 22, 0.45);
}

.product-card h3 {
    font-size: 1.05rem;
}

.product-card .tagline {
    color: var(--muted);
    font-size: 0.88rem;
}

.product-card .price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-2);
    margin-top: auto;
    padding-top: 0.5rem;
}

.product-card ul {
    list-style: none;
    font-size: 0.85rem;
    color: var(--muted);
}

.product-card ul li::before {
    content: "· ";
    color: var(--accent);
}

.deep-link-note {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.75rem;
}

.muted-sm {
    color: var(--muted);
    font-size: 0.8rem;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
}

.inline-form { display: inline; }

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
}

.form-row .form-group { flex: 1 1 160px; }

.form-group textarea {
    width: 100%;
    max-width: 560px;
    min-height: 140px;
    padding: 0.7rem 0.9rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.input-suffix {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    max-width: 420px;
}

.input-suffix input { flex: 1; max-width: none; }
.input-suffix span { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }

.steps {
    margin: 0.75rem 0 0 1.15rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.steps li { margin-bottom: 0.45rem; }
.steps strong { color: var(--text); }

.subhead {
    font-size: 0.95rem;
    margin: 1.1rem 0 0.5rem;
    color: var(--text);
}

td.wrap { word-break: break-word; max-width: 28rem; }

.nav-list a { font-size: 0.88rem; padding: 0.52rem 0.7rem; }

.domain-select {
    margin-bottom: 1rem;
}

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

.gauge-card {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.9rem 1rem;
}

.gauge-card .label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.55rem;
    word-break: break-all;
}

.gauge-track {
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.gauge-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    min-width: 2px;
    transition: width 0.35s ease;
}

.gauge-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.45rem;
    font-size: 0.78rem;
    color: var(--muted);
}

.log-view {
    margin-top: 1rem;
    max-height: 28rem;
    overflow: auto;
    padding: 0.9rem 1rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 0.78rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    color: #cbd5e1;
}

/* ——— Apps catalog ——— */
.apps-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.apps-toolbar h2 { margin: 0; }

.apps-filters {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    flex: 1 1 240px;
    max-width: 520px;
    margin-left: auto;
}

.app-search {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
}

.app-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.app-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.app-cat {
    appearance: none;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    color: var(--muted);
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.app-cat:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.18); }

.app-cat.active {
    background: var(--accent-dim);
    border-color: rgba(249, 115, 22, 0.45);
    color: var(--accent-2);
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.9rem;
}

.app-card {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.05rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-height: 100%;
}

.app-card-top {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.app-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #fff;
    background: linear-gradient(135deg, #ea580c, #f97316);
    box-shadow: 0 8px 20px rgba(249, 115, 22, 0.22);
}

.app-card h3 {
    font-size: 1.05rem;
    line-height: 1.25;
    margin: 0 0 0.25rem;
}

.app-cat-pill {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--muted);
}

.app-desc {
    color: var(--muted);
    font-size: 0.88rem;
    flex: 1;
}

.app-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.65rem;
    font-size: 0.78rem;
    color: var(--muted);
}

.app-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.15rem;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1rem;
}

.app-empty-filter { margin-top: 0.75rem; }

.sidebar-backdrop {
    display: none;
}

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

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 40;
        width: min(var(--sidebar-w), 86vw);
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        box-shadow: 16px 0 48px rgba(0, 0, 0, 0.4);
    }

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

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 30;
    }

    .app.nav-open .sidebar-backdrop {
        display: block;
    }

    .menu-toggle { display: inline-flex; }

    .main { padding: 1.15rem 1rem 2.5rem; }

    .topbar h1 { font-size: 1.3rem; }
}
