/*
 * PF Agent web UI.
 *
 * Mobile first, system fonts, no external resources. Colours are CSS variables
 * on :root with a dark theme under prefers-color-scheme. The strict CSP
 * (style-src 'self') means this file is the only place where presentation
 * lives: templates never carry style="" attributes.
 */

/* ---- tokens ------------------------------------------------------------ */

:root {
  color-scheme: light dark;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f2f5fa;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --text: #0f172a;
  --muted: #5a6578;
  --border: #dde3ed;
  --border-strong: #c3ccdb;

  --accent: #2457d6;
  --accent-hover: #1c47b3;
  --accent-contrast: #ffffff;
  --accent-soft: #e5ecfd;
  --focus: #2457d6;

  --topbar: #0f172a;
  --topbar-text: #f1f5f9;
  --topbar-muted: #aab6cb;

  --ok: #157f3b;
  --ok-bg: #dcf5e5;
  --warn: #8f5400;
  --warn-bg: #fdefcf;
  --err: #b42318;
  --err-bg: #fde4e1;
  --info: #1d4ed8;
  --info-bg: #e0eafe;
  --neutral: #475467;
  --neutral-bg: #e8ecf2;
  --tx: #c2410c;

  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 2px 8px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --tap: 44px;
  --gutter: 16px;
  --maxw: 1080px;

  --log-bg: #0a0f1e;
  --log-text: #d8e0ef;
  --log-err: #ff9a9a;
  --log-err-bg: rgba(255, 90, 90, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f1d;
    --surface: #131a2d;
    --surface-2: #19223a;
    --text: #e6ebf6;
    --muted: #9ba7bf;
    --border: #263049;
    --border-strong: #37436a;

    --accent: #7aa2ff;
    --accent-hover: #9bb9ff;
    --accent-contrast: #0a0f1d;
    --accent-soft: #1b2850;
    --focus: #9bb9ff;

    --topbar: #060a15;

    --ok: #55d68a;
    --ok-bg: #12301f;
    --warn: #f3b552;
    --warn-bg: #36280d;
    --err: #ff8a80;
    --err-bg: #3b1513;
    --info: #8fb0ff;
    --info-bg: #172552;
    --neutral: #b0bbd0;
    --neutral-bg: #232c44;
    --tx: #fb923c;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 10px rgba(0, 0, 0, 0.35);
    --log-bg: #060a14;
  }
}

/* ---- base -------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-wrap: break-word;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0;
}

p {
  margin: 0 0 12px;
}

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

a:hover {
  text-decoration: underline;
}

code,
pre,
.mono {
  font-family: var(--mono);
}

code {
  font-size: 0.9em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
}

pre {
  margin: 0;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only,
.skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.8125rem;
}

.strong {
  font-weight: 650;
}

.nowrap {
  white-space: nowrap;
}

.wrap {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.pre-wrap {
  white-space: pre-wrap;
}

/* ---- top bar and navigation ---------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--topbar);
  color: var(--topbar-text);
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06), 0 4px 14px rgba(0, 0, 0, 0.18);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 6px max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
  min-height: 52px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--topbar-text);
}

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

.brand-mark {
  border-radius: 7px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.who {
  max-width: 34vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  color: var(--topbar-muted);
}

.topbar .btn-ghost {
  color: var(--topbar-text);
  border-color: rgba(255, 255, 255, 0.18);
}

.topbar .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.nav {
  max-width: var(--maxw);
  margin: 0 auto;
}

.nav ul {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 4px max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.nav ul::-webkit-scrollbar {
  display: none;
}

.nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: 999px;
  color: var(--topbar-muted);
  font-weight: 600;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--topbar-text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.07);
}

.nav a[aria-current="page"] {
  color: var(--topbar-text);
  background: rgba(255, 255, 255, 0.14);
}

.nav-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #f59e0b;
  color: #1c1303;
  font-size: 0.75rem;
  font-weight: 800;
}

/* ---- layout ---------------------------------------------------------------- */

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px max(var(--gutter), env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}

.container > section,
.container > .card,
.container > .stack {
  margin-top: 18px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.page-title {
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title {
  font-size: 1.1rem;
  margin: 0 0 10px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.section-head .section-title {
  margin: 0;
}

.group-title {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 18px 0 8px;
}

.crumbs {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0 0 6px;
}

.lead {
  font-size: 1.02rem;
  margin: 6px 0 4px;
}

.stack > * + * {
  margin-top: 14px;
}

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr));
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  margin-top: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.card.inner {
  box-shadow: none;
  background: var(--surface-2);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.card-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  overflow-wrap: anywhere;
}

.card-title:hover {
  text-decoration: none;
  color: var(--accent);
}

.card.is-offline:not(.is-revoked) {
  background: var(--surface-2);
}

.card.is-revoked,
.card.is-disabled {
  opacity: 0.7;
}

.danger-zone {
  border-color: var(--err);
}

.empty,
.empty-card {
  color: var(--muted);
}

p.empty {
  padding: 14px 4px;
}

.empty-card {
  text-align: center;
  padding: 26px 16px;
}

.card-list,
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.list-row:first-child {
  border-top: 0;
}

.card-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 16px;
}

.list-main {
  min-width: 0;
}

.kv {
  display: grid;
  gap: 12px 20px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin: 0 0 6px;
}

.kv dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.kv dd {
  margin: 2px 0 0;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.pager {
  text-align: center;
  margin: 16px 0 0;
}

.error-page {
  text-align: center;
  padding: 36px 0;
}

.error-code {
  font-size: 4rem;
  font-weight: 800;
  margin: 0;
  color: var(--border-strong);
  line-height: 1;
}

.notes {
  color: var(--muted);
  padding-left: 20px;
}

/* ---- buttons -------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  background: transparent;
  border-color: var(--err);
  color: var(--err);
}

.btn-danger:hover {
  background: var(--err-bg);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.875rem;
}

@media (pointer: coarse) {
  .btn-sm {
    min-height: var(--tap);
  }
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

form.inline {
  display: inline-block;
  margin: 0;
}

/* ---- forms ------------------------------------------------------------------------ */

.field {
  display: block;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field > label,
.field > legend,
fieldset.field > legend {
  display: block;
  font-weight: 650;
  font-size: 0.9rem;
  margin-bottom: 6px;
  padding: 0;
}

fieldset.field {
  min-inline-size: 0;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
select,
textarea {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

textarea {
  resize: vertical;
  line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid var(--accent-soft);
  border-color: var(--accent);
}

input.code-input {
  font-family: var(--mono);
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  text-align: center;
}

input.mono {
  font-family: var(--mono);
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: var(--tap);
  padding: 8px 0;
  font-weight: 500;
  cursor: pointer;
}

.check input[type="checkbox"] {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.field-error {
  display: block;
  margin-top: 4px;
  color: var(--err);
  font-size: 0.8125rem;
  font-weight: 600;
}

.has-error input,
.has-error select,
.has-error textarea {
  border-color: var(--err);
}

.req {
  color: var(--err);
  text-decoration: none;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-row.wrap-row {
  flex-wrap: wrap;
  align-items: flex-end;
}

.form-row .grow {
  flex: 1 1 200px;
}

.form-row .field {
  flex: 0 1 auto;
}

.form-row select {
  width: auto;
  min-width: 120px;
}

.filters {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
  margin-bottom: 14px;
}

.filters .btn-row {
  margin: 0;
}

.rule-row {
  padding: 12px 0;
  border-top: 1px dashed var(--border-strong);
}

.rule-row .field + .field,
.rule-row .form-row + .form-row,
.rule-row .form-row + .field {
  margin-top: 8px;
}

/* ---- alerts, badges, chips ---------------------------------------------------------- */

.alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.95rem;
}

.alert p {
  margin: 0 0 6px;
}

.alert-ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent);
}

.alert-err {
  background: var(--err-bg);
  color: var(--err);
  border-color: color-mix(in srgb, var(--err) 30%, transparent);
}

.alert-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}

.alert-info {
  background: var(--info-bg);
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 30%, transparent);
}

.alert pre.cmd {
  width: 100%;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  background: var(--neutral-bg);
  color: var(--neutral);
}

.badge-queued,
.badge-assigned {
  background: var(--info-bg);
  color: var(--info);
}

.badge-running {
  background: var(--info-bg);
  color: var(--info);
}

.badge-running::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.2s ease-in-out infinite;
}

.badge-awaiting_approval,
.badge-interrupted,
.badge-risk-write {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-succeeded,
.badge-risk-read {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-failed,
.badge-timed_out,
.badge-risk-destructive {
  background: var(--err-bg);
  color: var(--err);
}

.badge-cancelled,
.badge-unknown,
.badge-rejected {
  background: var(--neutral-bg);
  color: var(--neutral);
}

.badge-rejected {
  background: var(--err-bg);
  color: var(--err);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

a.chip:hover {
  text-decoration: none;
  background: var(--accent-soft);
}

.chip-ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: transparent;
}

.chip-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: transparent;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
}

.chip-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 6px;
  scrollbar-width: none;
}

.chip-nav .chip {
  min-height: 36px;
  padding: 0 14px;
}

.dot {
  flex: none;
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--neutral);
}

.dot-online {
  background: var(--ok);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 22%, transparent);
}

.dot-offline {
  background: var(--border-strong);
}

/* ---- meters ------------------------------------------------------------------------------- */

.meters {
  display: grid;
  gap: 6px;
  margin: 6px 0;
}

.meters.stale {
  opacity: 0.55;
}

.meter-row {
  display: grid;
  grid-template-columns: 74px 1fr 44px;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.meter-label {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meter-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

meter.meter {
  width: 100%;
  height: 10px;
  border: 0;
  border-radius: 999px;
  background: var(--neutral-bg);
  appearance: none;
  -webkit-appearance: none;
}

meter.meter::-webkit-meter-bar {
  height: 10px;
  border: 0;
  border-radius: 999px;
  background: var(--neutral-bg);
}

meter.meter::-webkit-meter-optimum-value {
  border-radius: 999px;
  background: var(--ok);
}

meter.meter::-webkit-meter-suboptimum-value {
  border-radius: 999px;
  background: #e0a422;
}

meter.meter::-webkit-meter-even-less-good-value {
  border-radius: 999px;
  background: var(--err);
}

meter.meter::-moz-meter-bar {
  border-radius: 999px;
  background: var(--ok);
}

meter.meter:-moz-meter-sub-optimum::-moz-meter-bar {
  background: #e0a422;
}

meter.meter:-moz-meter-sub-sub-optimum::-moz-meter-bar {
  background: var(--err);
}

/* Width utilities for server-rendered bars (steps of 5), usable without inline styles. */
.w-0 { width: 0; }
.w-5 { width: 5%; }
.w-10 { width: 10%; }
.w-15 { width: 15%; }
.w-20 { width: 20%; }
.w-25 { width: 25%; }
.w-30 { width: 30%; }
.w-35 { width: 35%; }
.w-40 { width: 40%; }
.w-45 { width: 45%; }
.w-50 { width: 50%; }
.w-55 { width: 55%; }
.w-60 { width: 60%; }
.w-65 { width: 65%; }
.w-70 { width: 70%; }
.w-75 { width: 75%; }
.w-80 { width: 80%; }
.w-85 { width: 85%; }
.w-90 { width: 90%; }
.w-95 { width: 95%; }
.w-100 { width: 100%; }

/* ---- charts ---------------------------------------------------------------------------------- */

.spark-card {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.spark-card figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 10px;
  margin-bottom: 6px;
}

svg.spark {
  display: block;
  width: 100%;
  height: auto;
}

.spark-line {
  stroke: var(--accent);
}

.spark-grid {
  stroke: var(--border-strong);
}

.spark-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
}

.spark-line-tx {
  stroke: var(--tx);
}

.legend-rx {
  color: var(--accent);
  font-weight: 650;
}

.legend-tx {
  color: var(--tx);
  font-weight: 650;
}

/* ---- screenshots ------------------------------------------------------------------------------- */

.shots {
  display: grid;
  gap: 12px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
}

.shot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.shot-link {
  display: block;
  overflow: hidden;
  border-radius: 6px;
  background: var(--neutral-bg);
  aspect-ratio: 16 / 9;
}

.shot-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.shot-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.temps {
  font-variant-numeric: tabular-nums;
}

/* ---- tables ------------------------------------------------------------------------------------ */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card .table-wrap {
  box-shadow: none;
  border-radius: var(--radius-sm);
  margin-top: 6px;
}

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

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

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.table td .meter-row {
  grid-template-columns: 1fr 44px;
  min-width: 140px;
}

.table td .meter-label {
  display: none;
}

/* ---- job log ------------------------------------------------------------------------------------- */

pre.log,
pre.code,
pre.cmd {
  background: var(--log-bg);
  color: var(--log-text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.8125rem;
  line-height: 1.45;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

pre.log {
  min-height: 140px;
  max-height: 60vh;
}

pre.log:empty::before {
  content: "Çıktı bekleniyor…";
  color: #7a869f;
}

pre.code {
  max-height: 40vh;
}

pre.cmd {
  margin-top: 6px;
  white-space: pre-wrap;
}

pre.log .stderr {
  color: var(--log-err);
  background: var(--log-err-bg);
}

.summary p {
  margin: 0;
}

/* ---- timeline -------------------------------------------------------------------------------------- */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 14px;
  border-left: 2px solid var(--border);
}

.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 4px 10px;
  align-items: baseline;
  padding: 6px 0 6px 10px;
  font-size: 0.9rem;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
}

.timeline .tl-error::before {
  background: var(--err);
}

.timeline .tl-warn::before {
  background: var(--warn);
}

.timeline .tl-status::before {
  background: var(--accent);
}

.tl-time {
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.tl-kind {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

@media (max-width: 520px) {
  .timeline li {
    grid-template-columns: 1fr;
  }
}

/* ---- settings and one-time secrets -------------------------------------------------------------------- */

details.section {
  padding: 0;
  margin-top: 14px;
}

details.section > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--tap);
}

details.section > summary::-webkit-details-marker {
  display: none;
}

details.section > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s;
}

details.section[open] > summary::after {
  transform: rotate(-135deg);
}

details.section > summary .section-title {
  margin: 0;
}

details.section > :not(summary) {
  margin-left: 16px;
  margin-right: 16px;
}

details.section > :last-child {
  margin-bottom: 16px;
}

details.section:target {
  outline: 2px solid var(--accent);
}

.reveal-item + .reveal-item {
  margin-top: 14px;
}

.reveal-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}

.reveal-value {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

code.secret {
  flex: 1 1 240px;
  min-width: 0;
  padding: 10px 12px;
  font-size: 0.9rem;
  user-select: all;
  overflow-wrap: anywhere;
}

code.secret.block {
  display: block;
}

.qr-box {
  text-align: center;
}

.qr {
  display: block;
  margin: 0 auto 8px;
  padding: 8px;
  background: #ffffff;
  border-radius: 12px;
  image-rendering: pixelated;
}

.manual {
  text-align: left;
  font-size: 0.9rem;
}

.manual summary {
  cursor: pointer;
  color: var(--accent);
  min-height: var(--tap);
  display: flex;
  align-items: center;
}

.cron-preview {
  margin-top: 8px;
}

ol.runs {
  margin: 4px 0 0;
  padding-left: 22px;
  font-variant-numeric: tabular-nums;
}

/* ---- auth pages -------------------------------------------------------------------------------------------- */

body.auth {
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.auth-card {
  width: min(100%, 440px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 24px 22px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  font-size: 1.2rem;
  font-weight: 800;
}

.auth-brand img {
  border-radius: 10px;
}

.auth-title {
  font-size: 1.35rem;
  margin-bottom: 10px;
}

/* ---- toast ----------------------------------------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 200;
  max-width: min(92vw, 420px);
  padding: 12px 18px;
  border-radius: 12px;
  background: #111827;
  color: #f9fafb;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  font-weight: 600;
  text-align: center;
}

/* ---- larger screens ------------------------------------------------------------------------------------------------ */

@media (min-width: 720px) {
  .container {
    padding-top: 26px;
  }

  .page-title {
    font-size: 1.85rem;
  }

  .who {
    max-width: 240px;
  }

  .card {
    padding: 20px;
  }

  .meter-row {
    grid-template-columns: 90px 1fr 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
