/* ========================================================================
   Ethan-Admin — SignalWire dark theme, modelled on tryit.signalwire.com.

   Brand colors locked: blue #044EF4, fuchsia #F72A72, purple #601BE6,
   turquoise #40E0D0, gold #FFD700. On the dark ground, blue fills primary
   buttons, links are turquoise (blue text fails contrast on dark), and
   fuchsia carries the accent: active tab, eyebrow dot, focus on checkboxes.
   Fonts: Instrument Sans (headings), Lexend (body), JetBrains Mono (labels/code).
   ======================================================================== */

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

:root {
    color-scheme: dark;

    /* Brand (locked) */
    --sw-blue: #044EF4;
    --sw-blue-hover: #0a5bff;
    --sw-fuchsia: #F72A72;
    --sw-purple: #601BE6;
    --sw-turquoise: #40E0D0;
    --sw-gold: #FFD700;
    /* On-dark tints of the locked hues, for legible text */
    --sw-blue-lt: #6ea0ff;
    --sw-purple-lt: #a06bff;
    --sw-fuchsia-lt: #ff9ec2;

    /* Dark surfaces / foreground */
    --bg-page: #0e0e18;
    --bg-surface: #181a28;
    --bg-raised: #222436;
    --bg-sunken: #0b0d16;
    --bg-input: #11131e;
    --border-default: #2a2d42;
    --border-strong: #3a3e58;
    --fg-headings: #f0f0f4;
    --fg-default: #e8e8ec;
    --fg-muted: #a0a0aa;
    --fg-subtle: #6f7183;

    /* Sidebar (the tryit nav drawer) */
    --sidebar-bg: #0c0f16;
    --sidebar-line: rgba(122, 167, 255, 0.16);
    --sidebar-fg: rgba(240, 244, 250, 0.78);
    --sidebar-fg-strong: #f0f4fa;
    --sidebar-active: rgba(122, 167, 255, 0.12);

    /* Status */
    --status-ok: #40E0D0;
    --status-bad: #ff4d5e;
    --status-warn: #FFD700;
    --status-info: var(--sw-blue-lt);

    /* Typography */
    --font-heading: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-body: "Lexend", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", Monaco, "Cascadia Code", monospace;

    --shadow-card: 0 10px 30px -18px rgba(0, 0, 0, 0.7);
    --focus-ring: 0 0 0 3px rgba(4, 78, 244, 0.28);
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 15px;
    line-height: 1.55;
    min-height: 100vh;
    color: var(--fg-default);
    -webkit-font-smoothing: antialiased;
    /* The tryit hero glow: blue top-left, fuchsia top-right */
    background:
        radial-gradient(ellipse 60% 45% at 12% 0%, rgba(4, 78, 244, 0.16) 0%, transparent 60%),
        radial-gradient(ellipse 45% 35% at 92% 0%, rgba(247, 42, 114, 0.10) 0%, transparent 60%),
        var(--bg-page);
    background-attachment: fixed;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--fg-headings);
    letter-spacing: -0.015em;
}
h1 { font-size: 1.65rem; line-height: 1.15; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 1.12rem; margin: 30px 0 12px; }
h3 { font-size: 1rem; margin-bottom: 8px; }
p { margin-bottom: 10px; }

a { color: var(--sw-turquoise); text-decoration: none; }
a:hover { color: var(--sw-fuchsia); text-decoration: underline; }

code, pre, .mono { font-family: var(--font-mono); font-size: 0.82rem; }
code { background: rgba(255, 255, 255, 0.06); color: var(--fg-headings); padding: 2px 6px; border-radius: 4px; }
pre { line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
pre.mono { background: var(--bg-sunken); border: 1px solid var(--border-default); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }

.sub, .subtitle { color: var(--fg-muted); font-size: 0.9rem; margin: 6px 0 22px; }
.muted { color: var(--fg-muted); }
.small { font-size: 0.78rem; }
.loading { color: var(--fg-muted); font-size: 0.88rem; }

/* The tryit eyebrow: small caps with a glowing fuchsia dot */
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sw-fuchsia);
    margin: 0;
}
.eyebrow::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--sw-fuchsia);
    box-shadow: 0 0 8px var(--sw-fuchsia);
}

/* ========================================================================
   Layout
   ======================================================================== */

.app-layout { display: flex; height: 100vh; }

.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-line);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-bottom: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; object-fit: contain; display: block; }
.brand-word {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--sidebar-fg-strong);
}
.brand:hover .brand-word { color: #fff; }

.sidebar-user {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: rgba(240, 244, 250, 0.7);
}
.sidebar-user span::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #58d0c6;
    box-shadow: 0 0 0 3px rgba(88, 208, 198, 0.18);
    margin-right: 9px;
    vertical-align: 1px;
}
.sidebar-user form { margin: 0; }
.sidebar-user button.link { color: var(--fg-muted); font-size: 0.76rem; font-weight: 500; font-family: var(--font-mono); }
.sidebar-user button.link:hover { color: var(--sw-fuchsia); }

.nav-menu { list-style: none; padding: 10px; flex: 1; display: flex; flex-direction: column; gap: 2px; }

.nav-group {
    padding: 16px 12px 6px;
    font-size: 0.64rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(240, 244, 250, 0.4);
}

.nav-menu a {
    display: block;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--sidebar-fg);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}
.nav-menu a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; text-decoration: none; }
.nav-menu a.active { background: var(--sidebar-active); color: #fff; font-weight: 500; box-shadow: inset 2px 0 0 var(--sw-fuchsia); }

.content { flex: 1; overflow-y: auto; padding: 32px 36px; }
.content > * { max-width: 1280px; }
.content-bare { min-height: 100vh; }

/* ========================================================================
   Page header, breadcrumb, tabs
   ======================================================================== */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header .sub { margin-bottom: 0; }
.breadcrumb { font-size: 0.8rem; color: var(--fg-muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--fg-muted); }
.breadcrumb a:hover { color: var(--sw-fuchsia); }

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: 22px;
    overflow-x: auto;
}
.tabs a {
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--fg-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}
.tabs a:hover { color: var(--fg-headings); text-decoration: none; }
.tabs a.active { color: var(--fg-headings); border-bottom-color: var(--sw-fuchsia); font-weight: 600; }
.tab-count {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    background: rgba(255, 255, 255, 0.06);
    color: var(--fg-muted);
    border-radius: 10px;
    padding: 1px 7px;
    margin-left: 4px;
}

/* ========================================================================
   Cards and panels
   ======================================================================== */

.card, .panel {
    background: var(--bg-surface);
    border-radius: 16px;
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-card);
    padding: 22px 24px;
}
.panel { margin-bottom: 16px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.card { transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.card:hover {
    border-color: rgba(247, 42, 114, 0.35);
    box-shadow: 0 24px 60px -28px rgba(247, 42, 114, 0.35);
}
.card h3 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card .meta { color: var(--fg-muted); font-size: 0.82rem; }
.card-link { text-decoration: none; color: inherit; display: block; }
.card-link:hover { color: inherit; text-decoration: none; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.grid2 > .panel { margin-bottom: 0; }

.counts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.panel-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-meta .counts { margin-top: 0; }
.panel-meta .muted { font-size: 0.82rem; }

/* Stat strip: the app page's state / last deploy / updated row (tryit detail tiles) */
.status-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.status-strip .stat {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 0.9rem;
    color: var(--fg-headings);
}
.label, .status-strip .label {
    display: block;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-muted);
    margin-bottom: 8px;
}

/* ========================================================================
   Buttons — blue primary, outlined secondary (tryit .btn-primary / .btn-secondary)
   ======================================================================== */

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    min-height: 38px;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    text-decoration: none;
    white-space: nowrap;
    /* Default = secondary */
    background: transparent;
    color: var(--fg-default);
    border: 1px solid var(--border-default);
}
button:hover, .btn:hover { border-color: var(--sw-blue); color: var(--fg-headings); text-decoration: none; }

button.primary, .btn.primary {
    background: var(--sw-blue);
    border-color: var(--sw-blue);
    color: #fff;
    font-weight: 600;
}
button.primary:hover, .btn.primary:hover {
    background: var(--sw-blue-hover);
    border-color: var(--sw-blue-hover);
    color: #fff;
    box-shadow: 0 8px 24px -6px rgba(4, 78, 244, 0.55);
}

button.danger, .btn.danger { border-color: rgba(255, 77, 94, 0.45); color: var(--status-bad); }
button.danger:hover, .btn.danger:hover { background: rgba(255, 77, 94, 0.12); border-color: var(--status-bad); color: #ff7a87; }

button.link {
    background: none;
    border: 0;
    padding: 0;
    min-height: 0;
    color: var(--sw-turquoise);
    font-weight: 500;
}
button.link:hover { background: none; text-decoration: underline; color: var(--sw-fuchsia); }

button:disabled { opacity: 0.5; cursor: default; }

/* A submitted form waiting for its next page (static/app.js): a spinner, and
   the button stays looking pressed rather than greyed out. */
button.is-busy, button.is-busy:disabled { opacity: 0.85; cursor: progress; }
button.is-busy::before,
#job-log .pill.s-running::before {
    content: "";
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    flex: none;
    border-radius: 50%;
    border: 2px solid currentColor;
    border-right-color: transparent;
    animation: spin 0.7s linear infinite;
}
#job-log .pill.s-running::before { width: 0.8em; height: 0.8em; margin-right: 6px; vertical-align: -0.12em; border-width: 1.5px; }
@media (prefers-reduced-motion: reduce) {
    button.is-busy::before, #job-log .pill.s-running::before { animation-duration: 2.4s; }
}

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.page-header .actions { margin: 0; }
td.actions { margin: 0; }
form.inline { display: inline-flex; margin: 0; }

/* Refresh + auto-refresh picker (Grafana style: one joined control) */
.refresh-control { display: inline-flex; align-items: stretch; }
.refresh-control .refresh-button { border-radius: 8px 0 0 8px; }
.refresh-control .refresh-interval {
    width: auto;
    min-width: 0;
    border-radius: 0 8px 8px 0;
    border-left: 0;
    padding: 0 28px 0 10px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}
.refresh-control.is-auto .refresh-interval { color: var(--sw-fuchsia); border-color: var(--sw-fuchsia); }
.refresh-control.is-auto .refresh-button { border-color: var(--sw-fuchsia); }
.refresh-icon { display: inline-block; font-size: 1rem; line-height: 1; }
.refresh-control.htmx-request .refresh-icon { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================================================
   Tables
   ======================================================================== */

.tbl {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    overflow-x: auto;
    margin-bottom: 16px;
}
.panel .tbl { box-shadow: none; border-radius: 10px; background: var(--bg-sunken); }

table { width: 100%; border-collapse: collapse; }

thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-muted);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-default);
    color: var(--fg-default);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
td a { font-weight: 500; }

/* ========================================================================
   Badges (pills) — state colors, tinted for the dark ground
   ======================================================================== */

.pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    vertical-align: middle;
    background: rgba(255, 255, 255, 0.06);
    color: var(--fg-muted);
    border: 1px solid transparent;
}
.s-running, .s-succeeded, .s-ok { background: rgba(64, 224, 208, 0.12); border-color: rgba(64, 224, 208, 0.35); color: var(--sw-turquoise); }
.s-partial, .s-queued, .s-warn, .s-change { background: rgba(255, 215, 0, 0.10); border-color: rgba(255, 215, 0, 0.32); color: var(--sw-gold); }
.s-stopped, .s-failed, .s-down { background: rgba(255, 77, 94, 0.12); border-color: rgba(255, 77, 94, 0.38); color: #ff7a87; }
.s-not_deployed, .s-cancelled, .s-unknown { background: rgba(255, 255, 255, 0.05); border-color: var(--border-default); color: var(--fg-muted); }
.s-info { background: rgba(96, 27, 230, 0.16); border-color: rgba(160, 107, 255, 0.4); color: var(--sw-purple-lt); }
.s-running.job { background: rgba(4, 78, 244, 0.16); border-color: rgba(110, 160, 255, 0.4); color: var(--sw-blue-lt); }
h1 .pill { font-size: 0.62rem; }

/* ========================================================================
   Metrics panel (apps/_metrics.html): SVG charts drawn on the server
   ======================================================================== */

.range-pick { display: inline-flex; gap: 4px; }
.range-pick button { padding: 3px 10px; font-size: 0.8rem; }
.range-pick button[aria-pressed="true"] { background: var(--sw-blue); border-color: var(--sw-blue); color: #fff; }
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.mchart { margin: 0; padding: 10px 12px; min-width: 0; background: var(--bg-sunken); border: 1px solid var(--border-default); border-radius: 10px; }
.mchart.warn { border-color: rgba(255, 215, 0, 0.45); }
.mchart figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.m-label { font-size: 0.82rem; color: var(--fg-muted); }
.m-value { font-size: 1.15rem; font-weight: 700; color: var(--fg-headings); font-variant-numeric: tabular-nums; }
.mchart.warn .m-value { color: var(--sw-gold); }
.spark { display: block; width: 100%; height: 64px; }
.spark polyline { fill: none; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.spark .l0 { stroke: var(--sw-blue-lt); } .spark circle.l0 { fill: var(--sw-blue-lt); }
.spark .l1 { stroke: var(--sw-turquoise); } .spark circle.l1 { fill: var(--sw-turquoise); }
.spark .l2 { stroke: var(--sw-fuchsia-lt); } .spark circle.l2 { fill: var(--sw-fuchsia-lt); }
.spark .l3 { stroke: var(--sw-gold); } .spark circle.l3 { fill: var(--sw-gold); }
.m-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; font-size: 0.75rem; color: var(--fg-subtle); font-variant-numeric: tabular-nums; }
.m-key i { display: inline-block; width: 10px; height: 3px; margin-right: 4px; border-radius: 2px; vertical-align: middle; }
.m-key i.l0 { background: var(--sw-blue-lt); } .m-key i.l1 { background: var(--sw-turquoise); }
.m-key i.l2 { background: var(--sw-fuchsia-lt); } .m-key i.l3 { background: var(--sw-gold); }
.m-key b { color: var(--fg-default); font-weight: 600; }
.m-empty { margin: 8px 0; font-size: 0.82rem; color: var(--fg-muted); }

/* ========================================================================
   Banners
   ======================================================================== */

.flash, .error {
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.88rem;
    white-space: pre-wrap;
}
.flash { background: rgba(4, 78, 244, 0.10); border: 1px solid rgba(110, 160, 255, 0.35); color: #d6e3ff; }
.error { background: rgba(255, 77, 94, 0.08); border: 1px solid rgba(255, 77, 94, 0.40); color: #ffc2c8; }
.error a { color: #fff; font-weight: 600; text-decoration: underline; }
/* Something to do before the page is useful, e.g. an app Sync platform hasn't created yet. */
.notice {
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.88rem;
    background: rgba(255, 215, 0, 0.07);
    border: 1px solid rgba(255, 215, 0, 0.32);
    color: #fbefc0;
}
.notice p { margin: 0 0 10px; }
.notice p:last-child { margin-bottom: 0; }
.notice a { color: #fff; font-weight: 600; text-decoration: underline; }

/* ========================================================================
   Forms
   ======================================================================== */

label {
    display: block;
    font-size: 0.66rem;
    font-weight: 700;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 14px 0 6px;
}

input[type=text], input[type=password], input[type=number], input[type=email], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    background: var(--bg-input);
    color: var(--fg-headings);
    min-height: 38px;
}
input::placeholder, textarea::placeholder { color: var(--fg-subtle); }
textarea { font-family: var(--font-mono); font-size: 0.8rem; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--sw-blue);
    box-shadow: var(--focus-ring);
}
select.compact { width: auto; min-height: 0; padding: 4px 8px; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--sw-blue-lt); outline-offset: 2px; }

/* Checkbox reads as a bordered row so it lines up with the inputs beside it */
label.check {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border-default);
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--fg-default);
    cursor: pointer;
    user-select: none;
    background: rgba(255, 255, 255, 0.02);
    min-height: 38px;
}
label.check:hover { background: rgba(255, 255, 255, 0.05); }
label.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--sw-fuchsia); }
label.check:has(input:checked) { border-color: rgba(247, 42, 114, 0.55); background: rgba(247, 42, 114, 0.06); }

/* Rows of fields */
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }
.row > button, .row > .fixed { flex: 0 0 auto; }
.row > .wide { flex: 3 1 240px; }
.row.head { align-items: center; justify-content: space-between; }

/* A small label wrapped around its input, inline in a toolbar */
.inline-field { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.inline-field input { width: 96px; }

/* Definition lists */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; font-size: 0.88rem; }
.kv dt {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-muted);
    padding-top: 3px;
}
.kv dd { margin: 0; word-break: break-word; color: var(--fg-headings); }
.tab-panel > .kv { margin-bottom: 16px; }

/* ========================================================================
   Logs
   ======================================================================== */

.log-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.log-meta { font-size: 0.78rem; margin-bottom: 6px; }
.log-panel.is-following .log-meta::before {
    content: "";
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--sw-fuchsia);
    box-shadow: 0 0 0 3px rgba(247, 42, 114, 0.2);
    margin-right: 8px;
    vertical-align: 1px;
    animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
pre.log {
    background: #0b1220;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #d8dee6;
    padding: 14px 16px;
    border-radius: 12px;
    max-height: 600px;
    overflow: auto;
    font-size: 0.78rem;
}

/* ========================================================================
   htmx
   ======================================================================== */

.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ========================================================================
   Sign-in pages — the tryit wizard card
   ======================================================================== */

.auth {
    max-width: 420px;
    margin: 12vh auto;
    background: linear-gradient(180deg, rgba(4, 78, 244, 0.08) 0%, var(--bg-surface) 55%);
    border: 1px solid rgba(4, 78, 244, 0.3);
    border-radius: 18px;
    box-shadow: 0 24px 60px -20px rgba(4, 78, 244, 0.4), 0 8px 30px -10px rgba(247, 42, 114, 0.15);
    padding: 32px;
}
.auth-mark { width: 36px; height: 36px; display: block; margin-bottom: 18px; }
.auth .eyebrow { margin-bottom: 8px; }
.auth h1 { font-size: 1.7rem; margin-bottom: 18px; }
.auth button { width: 100%; margin-top: 22px; }
.auth .btn { display: flex; justify-content: center; width: 100%; margin-top: 8px; box-sizing: border-box; }
.auth-alt { margin: 16px 0 0; text-align: center; font-size: 0.85rem; }
/* A fieldset that only groups controls (to disable them all for read-only viewers). */
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.qr { display: block; margin: 12px auto; width: 220px; height: 220px; background: #fff; border-radius: 10px; padding: 6px; }
.secret { word-break: break-all; text-align: center; }

/* ========================================================================
   Services and create-app form
   ======================================================================== */

/* A checkbox that shows the block under it, without script. */
.reveal-group:not(:has(.reveal-toggle:checked)) .reveal { display: none; }
.reveal { margin-top: 8px; }
form.panel > h3 { margin-top: 26px; }
form.panel > h3:first-of-type:first-child, form.panel > input[type=hidden] + h3 { margin-top: 0; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.check-grid label.check { margin: 0; }

.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.row-actions select { width: auto; min-width: 120px; }
.link-chip { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; white-space: nowrap; }
.link-chip button.link { font-size: 0.8rem; color: var(--fg-muted); }
.link-chip button.link:hover { color: var(--sw-fuchsia); }
.link-form { margin-top: 12px; }

details.confirm > summary { list-style: none; cursor: pointer; }
details.confirm > summary::-webkit-details-marker { display: none; }
details.confirm[open] > summary { margin-bottom: 8px; }
details.confirm form {
    padding: 12px;
    border: 1px solid rgba(255, 77, 94, 0.45);
    border-radius: 10px;
    background: var(--bg-sunken);
    max-width: 320px;
}
details.confirm form button { margin-top: 8px; }

/* Collapsible panel (the app page's "Build on the server" form) */
details.panel > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 10px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: "▸"; color: var(--fg-muted); }
details.panel[open] > summary::before { content: "▾"; }
details.panel[open] > summary { margin-bottom: 8px; }
.inline-h { display: inline; margin: 0; }

details.cmd > summary { list-style: none; }
details.cmd > summary::-webkit-details-marker { display: none; }
details.cmd[open] { flex-basis: 100%; }

/* Host steps waiting for approval (Dashboard) */
.approval code { display: inline-block; overflow-wrap: anywhere; }
.approval .risk { margin-top: 6px; font-size: 0.8rem; color: var(--sw-gold); }
.approval .risk::before { content: "\26A0\00A0"; }
.approval .actions-cell { white-space: nowrap; }
.approval td .muted { font-size: 0.8rem; margin-top: 4px; }
details.cmd code { display: block; margin-top: 8px; padding: 8px 10px; max-width: 520px; overflow-wrap: anywhere; font-size: 0.74rem; }

/* ========================================================================
   App page (apps/show.html): header, tabs, overview tiles, health strip,
   config and operate layouts
   ======================================================================== */

.app-header { align-items: flex-start; }
.app-title h1 { margin: 0; }
.app-sub { display: flex; flex-wrap: wrap; align-items: center; margin: 8px 0 0; font-size: 0.86rem; color: var(--fg-muted); }
.app-sub .sep::before { content: "\00B7"; margin: 0 10px; color: var(--fg-muted); }
.app-sub > .sep:first-child::before { content: none; margin: 0; }
.tab-count.new { background: rgba(247, 42, 114, 0.14); color: var(--sw-fuchsia-lt); }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    padding: 16px 18px;
    background: var(--bg-raised);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
}
.tile .label { margin-bottom: 0; }
.tile-main { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.tile-num { font-family: var(--font-heading); font-size: 1.2rem; font-weight: 700; color: var(--fg-headings); font-variant-numeric: tabular-nums; }
.tile-none { font-size: 0.95rem; color: var(--fg-muted); }
.tile-sub { font-size: 0.78rem; color: var(--fg-muted); }

.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.panel-head h2, .panel-head h3 { margin: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 30px 0 12px; }
.section-head h2 { margin: 0; }
.overview-grid { align-items: stretch; }
.overview-grid > .panel { margin-bottom: 0; }

.health-strip { display: block; width: 100%; height: 72px; }
.health-strip rect.ok { fill: var(--status-ok); opacity: 0.8; }
.health-strip rect.bad { fill: var(--status-bad); }
.strip-axis { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 0.72rem; color: var(--fg-muted); }
.strip-note { margin: 14px 0 0; }
.fail-list { display: grid; gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; font-size: 0.82rem; }

.config-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.config-grid > .panel { margin-bottom: 0; }
td.actions-cell, th.actions-cell { width: 1%; text-align: right; white-space: nowrap; }

.action-list { display: grid; }
.action-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid var(--border-default); }
.action-list > .action-row:first-child { padding-top: 0; border-top: 0; }
.action-list > .action-row:last-child { padding-bottom: 0; }
.action-row > div { display: grid; gap: 2px; min-width: 0; }
.action-row b { font-weight: 600; color: var(--fg-headings); }
.action-row span { font-size: 0.84rem; color: var(--fg-muted); }
.action-row button { min-width: 120px; }
.danger-zone { margin-top: 16px; border-color: rgba(255, 77, 94, 0.25); }
.actions-cell .row-actions { justify-content: flex-end; }
.danger-zone .action-row { padding: 0; border: 0; }
.toolbar-end { margin-left: auto; font-size: 0.82rem; }
.log-toolbar label.check { margin: 0; min-height: 38px; }

/* ========================================================================
   Schedules (templates/schedules/)
   ======================================================================== */

.s-skipped { background: rgba(255, 255, 255, 0.05); border-color: var(--border-default); color: var(--fg-muted); }
.nowrap { white-space: nowrap; }
.schedule-list td.call { word-break: break-all; min-width: 220px; }
.schedule-form input.mono { font-family: var(--font-mono); font-size: 0.85rem; }

/* Help tooltips (_macros.html help): a "?" that shows its text on hover or focus. */
.help {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 15px;
    height: 15px;
    margin-left: 6px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    color: var(--fg-muted);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    vertical-align: 1px;
    cursor: help;
}
.help:hover, .help:focus-visible { color: var(--fg-headings); border-color: var(--sw-blue-lt); outline: none; }
.help::after {
    content: attr(data-tip);
    position: absolute;
    left: -8px;
    bottom: calc(100% + 8px);
    width: max-content;
    max-width: 340px;
    padding: 9px 11px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--bg-raised);
    box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.6);
    color: var(--fg-default);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 400;
    line-height: 1.55;
    white-space: pre;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s;
    z-index: 20;
}
.help:hover::after, .help:focus-visible::after { opacity: 1; }
.schedule-form { margin-top: 18px; }
.schedule-form h3 { margin: 26px 0 4px; }
.schedule-form label.check { margin-top: 20px; }
.cron-describe { align-self: center; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding-top: 18px; }
.describe-ok { color: var(--fg-headings); font-weight: 600; }
.describe-error { color: #ff7a87; font-size: 0.85rem; }
.body-pre { margin: 0; white-space: pre-wrap; font-size: 0.8rem; }
.run-error { color: #ff9aa4; margin-top: 4px; max-width: 60ch; white-space: normal; }
.response-row td:empty { padding: 0; border: 0; }
.run-response { display: grid; gap: 6px; padding: 4px 0 8px; }
.run-response pre.log { max-height: 420px; }

@media (max-width: 1024px) {
    .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .config-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ========================================================================
   Responsive
   ======================================================================== */

@media (max-width: 768px) {
    .tiles { grid-template-columns: minmax(0, 1fr); }
    .action-row { flex-direction: column; align-items: stretch; }
    .app-layout { flex-direction: column; height: auto; min-height: 100vh; }
    .sidebar { width: 100%; min-width: 100%; overflow: visible; border-right: 0; border-bottom: 1px solid var(--sidebar-line); }
    .sidebar-header { padding: 14px 16px; }
    .sidebar-user { padding: 8px 16px; }
    .nav-menu { flex-direction: row; overflow-x: auto; padding: 6px 8px; }
    .nav-group { display: none; }
    .nav-menu a { white-space: nowrap; }
    .nav-menu a.active { box-shadow: inset 0 -2px 0 var(--sw-fuchsia); }
    .content { padding: 16px; overflow: visible; }
    .grid2 { grid-template-columns: minmax(0, 1fr); }
    .auth { margin: 6vh 0; padding: 24px; }
}
