/* xArb CI — application styles.
   Dark, system-font UI built around the brand cyan (--accent). Keep selectors in
   sync with the templates; per-page tweaks live in each template's inline <style>. */

:root {
  --bg: #0b0e12; --panel: #12161d; --panel2: #171c25; --panel3: #1b212c;
  --border: #232a35; --border-strong: #2e3744;
  --text: #e8ebef; --muted: #94a1b3; --faint: #6b7686;
  --accent: #00def0; --accent-2: #3cecf8; --accent-ink: #04181b;
  --ok: #34d399; --fail: #ff6b6b; --warn: #fbbf24; --run: #00def0; --skip: #7c8696;
  --radius: 10px; --radius-lg: 12px;
  --shadow-card: 0 2px 12px rgba(0,0,0,.28);
  --shadow-pop: 0 16px 40px rgba(0,0,0,.5);
  --glow: 0 0 12px rgba(0,222,240,.6);
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--text);
  background:
    radial-gradient(820px 320px at 10% -140px, rgba(0,222,240,.06), transparent 70%),
    var(--bg);
  font: 14px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Top navigation (shared {{template "nav"}}) --- */
header { display: flex; align-items: center; gap: 18px; padding: 0 22px; height: 56px;
  background-color: #11151d;
  background-image:
    radial-gradient(460px 120px at 92px -36px, rgba(0,222,240,.16), transparent 70%),
    linear-gradient(180deg, #141b25, #11151d);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
header form { margin: 0; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 700;
  color: var(--text); letter-spacing: .01em; white-space: nowrap; }
.brand:hover { color: var(--text); text-decoration: none; }
.brand-mark { width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,222,240,.18), var(--glow); }
.topnav { display: flex; align-items: center; gap: 4px; height: 100%; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 9px;
  color: var(--muted); font-weight: 500; font-size: 13px; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap; transition: background-color .14s ease, color .14s ease; }
.tab:hover { color: var(--text); background: var(--panel2); text-decoration: none; }
.tab.active { color: var(--text); background: rgba(0,222,240,.1); border-color: rgba(0,222,240,.34); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nav-right .live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
/* Admin dropdown built on a native <details> disclosure. */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary .caret { font-size: 10px; opacity: .8; }
.menu[open] > summary.tab { color: var(--text); background: var(--panel2); }
.menu.active > summary.tab { color: var(--text); background: rgba(0,222,240,.1); border-color: rgba(0,222,240,.34); }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 188px;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 12px; padding: 6px;
  display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow-pop); z-index: 40; }
.menu-panel a { padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: 13px; }
.menu-panel a:hover { background: var(--panel2); text-decoration: none; }
.btn-logout { display: inline-flex; align-items: center; gap: 8px; }
.btn-logout .user-chip { font-weight: 600; color: var(--text); }
.btn-logout .logout-label { color: var(--muted); }
.btn-logout:hover .logout-label { color: var(--text); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 8px rgba(52,211,153,.75); display: inline-block; animation: pulse 1.7s ease-in-out infinite; }
.live-dot.stale { background: var(--fail); box-shadow: 0 0 8px rgba(255,107,107,.7); animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

main { padding: 24px 22px 44px; max-width: 1200px; margin: 0 auto; }
/* Per-page heading + contextual actions row. */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px;
  flex-wrap: wrap; margin-bottom: 24px; }
.page-titles { min-width: 0; }
.page-title { font-size: 21px; font-weight: 650; margin: 0; line-height: 1.2; }
.page-sub { color: var(--muted); font-size: 12px; margin-top: 5px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.breadcrumb { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }
/* Back-to-dashboard link at the top of detail pages. */
.back-link { display: inline-flex; align-items: center; gap: 7px; width: fit-content;
  color: var(--muted); font-size: 13px; font-weight: 500; margin-bottom: 16px; }
.back-link:hover { color: var(--accent); text-decoration: none; }
.back-link .ic { width: 16px; height: 16px; transition: transform .14s ease; }
.back-link:hover .ic { transform: translateX(-3px); }
@media (max-width: 720px) {
  header { gap: 10px; padding: 0 14px; }
  .btn-logout .logout-label { display: none; }
}
section { margin-bottom: 28px; }
h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600; margin: 0 0 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 17px; box-shadow: var(--shadow-card); }
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 27px; font-weight: 650; margin-top: 5px; }
.card .value.accent { color: var(--accent); }
table { width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
th, td { text-align: left; padding: 10px 13px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  background: var(--panel2); }
tr:last-child td { border-bottom: none; }
.table-scroll { position: relative; max-width: 100%; overflow-y: auto; overflow-x: hidden; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius-lg); }
.table-scroll { scrollbar-color: #3a434f #0c0f14; scrollbar-width: thin; }
.table-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.table-scroll::-webkit-scrollbar-track { background: #0c0f14; }
.table-scroll::-webkit-scrollbar-thumb { background: #3a434f; border-radius: 999px; border: 2px solid #0c0f14; }
.table-scroll::-webkit-scrollbar-thumb:hover { background: #4e5969; }
.table-scroll::-webkit-scrollbar-corner { background: #0c0f14; }
.table-scroll table { border: 0; border-radius: 0; border-collapse: separate; border-spacing: 0; }
.table-scroll thead th { position: sticky; top: 0; z-index: 2; background: var(--panel2);
  background-clip: padding-box; box-shadow: 0 1px 0 var(--border); }
.table-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.table-toolbar label { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; }
.table-toolbar select { width: auto; min-width: 128px; padding: 6px 28px 6px 10px; font-size: 12px; }
.recent-runs-frame { --runs-scrollbar-space: 13px; max-width: 100%; overflow: hidden; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius-lg); }
.recent-runs-frame table { border: 0; border-radius: 0; border-collapse: separate; border-spacing: 0; }
.recent-runs-head { width: calc(100% - var(--runs-scrollbar-space)); table-layout: fixed; }
.recent-runs-head th { border-bottom: 1px solid var(--border); }
.recent-runs-scroll { max-height: calc(min(68vh, 760px) - 40px); border: 0; border-radius: 0; }
.recent-runs-table { table-layout: fixed; }
.recent-runs-head .col-status, .recent-runs-table .col-status { width: 105px; }
.recent-runs-head .col-type, .recent-runs-table .col-type { width: 120px; }
.recent-runs-head .col-repo, .recent-runs-table .col-repo { width: 190px; }
.recent-runs-head .col-author, .recent-runs-table .col-author { width: 118px; }
.recent-runs-head .col-target, .recent-runs-table .col-target { width: 220px; }
.recent-runs-head .col-commit, .recent-runs-table .col-commit { width: 115px; }
.recent-runs-head .col-created, .recent-runs-table .col-created { width: 100px; }
.recent-runs-head .col-duration, .recent-runs-table .col-duration { width: 86px; }
.recent-runs-head .col-action, .recent-runs-table .col-action { width: 86px; }
/* Deployments recent table columns (same frame/sticky-head/sort as runs). */
.recent-runs-head .dep-col-status, .recent-runs-table .dep-col-status { width: 100px; }
.recent-runs-head .dep-col-env, .recent-runs-table .dep-col-env { width: 150px; }
.recent-runs-head .dep-col-ref, .recent-runs-table .dep-col-ref { width: 220px; }
.recent-runs-head .dep-col-commit, .recent-runs-table .dep-col-commit { width: 120px; }
.recent-runs-head .dep-col-by, .recent-runs-table .dep-col-by { width: 130px; }
.recent-runs-head .dep-col-created, .recent-runs-table .dep-col-created { width: 110px; }
.recent-runs-head .dep-col-duration, .recent-runs-table .dep-col-duration { width: 90px; }
.recent-runs-head .dep-col-action, .recent-runs-table .dep-col-action { width: 96px; }
/* Ansible recent table columns (same frame/sticky-head/sort as runs). */
.recent-runs-head .ans-col-status, .recent-runs-table .ans-col-status { width: 100px; }
.recent-runs-head .ans-col-host, .recent-runs-table .ans-col-host { width: 200px; }
.recent-runs-head .ans-col-env, .recent-runs-table .ans-col-env { width: 88px; }
.recent-runs-head .ans-col-ref, .recent-runs-table .ans-col-ref { width: 160px; }
.recent-runs-head .ans-col-resolved, .recent-runs-table .ans-col-resolved { width: 120px; }
.recent-runs-head .ans-col-by, .recent-runs-table .ans-col-by { width: 130px; }
.recent-runs-head .ans-col-created, .recent-runs-table .ans-col-created { width: 110px; }
.recent-runs-head .ans-col-duration, .recent-runs-table .ans-col-duration { width: 90px; }
.table-sort { display: inline-flex; align-items: center; gap: 5px; margin: -4px -6px; padding: 4px 6px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; font: inherit;
  text-transform: inherit; letter-spacing: inherit; }
.table-sort:hover, .table-sort:focus { color: var(--text); outline: none; }
.click-row { cursor: pointer; }
.click-row:hover td { background: rgba(0,222,240,.05); }
.click-row:focus { outline: none; }
.click-row:focus-visible td { background: rgba(0,222,240,.08); box-shadow: inset 0 1px 0 var(--accent), inset 0 -1px 0 var(--accent); }
.run-repo { color: var(--accent); font-weight: 500; overflow-wrap: anywhere; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 10.5px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.st-success, .st-created, .st-uploaded, .st-open, .st-merged { background: rgba(52,211,153,.14); color: var(--ok); }
.st-failure, .st-errored, .st-timed-out, .st-failed, .st-closed { background: rgba(255,107,107,.14); color: var(--fail); }
.st-running, .st-pending { background: rgba(0,222,240,.13); color: var(--run); }
.st-queued { background: rgba(251,191,36,.13); color: var(--warn); }
.st-shutdown { background: rgba(249,115,22,.24); color: var(--ok); }
.st-skipped, .st-canceled, .st-not-attempted, .st-not-configured, .st-no-broadcast { background: rgba(124,134,150,.18); color: var(--skip); }
pre.log { background: #07090d; border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px; overflow: auto; max-height: 520px; font-size: 12px; white-space: pre-wrap; }

/* --- Buttons --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: var(--panel2);
  border: 1px solid var(--border-strong); color: var(--text); padding: 7px 13px; border-radius: 9px;
  cursor: pointer; font-size: 12.5px; font-weight: 500; line-height: 1.45; text-decoration: none;
  transition: background-color .14s ease, border-color .14s ease, box-shadow .14s ease, transform .12s ease; }
.btn:hover, .btn:focus-visible { border-color: var(--accent); text-decoration: none; outline: none; }
.btn:active { transform: translateY(1px); }
.btn .ic { width: 15px; height: 15px; flex: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  font-weight: 650; box-shadow: 0 6px 16px rgba(0,222,240,.22); }
.btn.primary:hover, .btn.primary:focus-visible { background: var(--accent-2); border-color: var(--accent-2);
  box-shadow: 0 9px 20px rgba(0,222,240,.30); transform: translateY(-1px); }
.btn.primary:active { transform: translateY(0); box-shadow: 0 3px 10px rgba(0,222,240,.20); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--fail); border-color: rgba(255,107,107,.4); }
.btn.danger:hover, .btn.danger:focus-visible { background: rgba(255,107,107,.12); border-color: var(--fail); }
.btn.danger-solid { background: var(--fail); border-color: var(--fail); color: #220707; font-weight: 650; }
.btn.danger-solid:hover, .btn.danger-solid:focus-visible { background: #ff8585; border-color: #ff8585; }
.btn.compact { padding: 4px 9px; font-size: 11px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.inline-form { display: inline; margin: 0; }
.meta { color: var(--muted); font-size: 12px; }
.st-active { background: rgba(52,211,153,.14); color: var(--ok); }
.st-pending { background: rgba(251,191,36,.13); color: var(--warn); }

/* --- Forms / panels --- */
.page-narrow { max-width: 520px; margin: 8vh auto 0; }
.form-panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; box-shadow: var(--shadow-card); }
.form-panel label { display: block; margin: 15px 0 6px; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em; }
input[type=text], input[type=password], select, textarea { width: 100%; padding: 9px 11px; background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: 8px; color: var(--text); font-size: 14px;
  font-family: inherit; transition: border-color .14s ease, box-shadow .14s ease; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,222,240,.16); }
.form-actions { margin-top: 18px; display: flex; align-items: center; gap: 10px; }
.notice { background: rgba(52,211,153,.1); border: 1px solid rgba(52,211,153,.32);
  color: var(--ok); border-radius: 9px; padding: 10px 13px; margin-bottom: 14px; }
.error { background: rgba(255,107,107,.1); border: 1px solid rgba(255,107,107,.32);
  color: var(--fail); border-radius: 9px; padding: 10px 13px; margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.invite-link { display: block; overflow-wrap: anywhere; background: #07090d; border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; color: var(--text); }
.login-actions { justify-content: center; }
.login-actions .btn { min-width: 104px; padding: 9px 20px; border-radius: 9px; font-size: 14px; }

/* --- Confirm / modal dialogs (native <dialog>) --- */
.app-dialog { border: 1px solid var(--border-strong); background: var(--panel); color: var(--text);
  border-radius: 14px; padding: 0; width: 400px; max-width: calc(100vw - 32px);
  box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(0,222,240,.05); }
.app-dialog::backdrop { background: rgba(4,7,11,.62); backdrop-filter: blur(2px); }
.app-dialog[open] { animation: dlg-in .16s ease; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
.dlg-body { padding: 22px; }
.dlg-title { display: flex; align-items: center; gap: 11px; font-size: 16px; font-weight: 650; margin: 0; }
.dlg-icon { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center;
  justify-content: center; flex: none; background: rgba(255,107,107,.14); color: var(--fail); }
.dlg-icon.accent { background: rgba(0,222,240,.13); color: var(--accent); }
.dlg-icon.danger { background: rgba(255,107,107,.13); color: var(--fail); }
.dlg-text { color: var(--muted); font-size: 13.5px; line-height: 1.55; margin: 13px 0 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 15px 22px;
  border-top: 1px solid var(--border); background: var(--panel2); border-radius: 0 0 14px 14px; }
.dlg-field { margin-top: 14px; }
.dlg-field label { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; margin-bottom: 6px; }
/* Form modals (e.g. New run) reuse the dialog shell at a wider size. */
.app-dialog.wide { width: 560px; }
.app-dialog.wide .dlg-body { max-height: 68vh; overflow: auto; }
.app-dialog .dlg-body > label { display: block; margin: 16px 0 6px; color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.app-dialog .dlg-body > label:first-of-type { margin-top: 0; }
.stage-opt { display: flex; align-items: center; gap: 8px; padding: 6px 0;
  text-transform: none; letter-spacing: 0; color: var(--text); font-size: 14px; }

/* --- Toasts --- */
.toast-stack { position: fixed; top: 18px; right: 18px; display: flex; flex-direction: column;
  gap: 10px; z-index: 80; max-width: calc(100vw - 36px); }
.toast { display: flex; align-items: center; gap: 10px; min-width: 230px; background: var(--panel2);
  border: 1px solid var(--border-strong); border-left: 3px solid var(--muted); border-radius: 11px;
  padding: 11px 14px; font-size: 13px; color: var(--text); box-shadow: var(--shadow-pop);
  animation: toast-in .22s ease; }
.toast.ok { border-left-color: var(--ok); }
.toast.ok .t-ic { color: var(--ok); }
.toast.err { border-left-color: var(--fail); }
.toast.err .t-ic { color: var(--fail); }
.toast .t-ic { flex: none; display: flex; }
.toast.hide { animation: toast-out .2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
.toast-seed { display: none; }
