/* SkyStitch console — cartographic ops aesthetic.
   Dark ink field, editorial serif headings over monospace instrumentation.
   The stitch motif is SEMANTIC: dashed = remote, solid = local. */

@font-face {
  font-family: "Instrument Serif";
  src: url("/static/fonts/instrument-serif.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/static/fonts/instrument-serif-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/jetbrains-mono-500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}

:root {
  /* Tells the browser to paint dark chrome, scrollbars and form controls
     before our CSS is applied — without it, a real page refresh flashes
     white between navigations. */
  color-scheme: dark;

  --ink:        #0a0e13;
  --ink-2:      #10161d;
  --panel:      #131b23;
  --panel-2:    #182129;
  --rule:       #22303c;
  --rule-soft:  #1a242e;
  --text:       #dde6ee;
  --text-dim:   #8fa1b3;
  --text-faint: #5d6f80;

  --brass:      #d9a441;   /* the thread: accent, focus, active nav */
  --brass-dim:  #8a6a2c;
  --local:      #62b587;   /* solid, here */
  --remote:     #6aa5d9;   /* dashed, elsewhere */
  --stale:      #d98a4a;
  --danger:     #d96a6a;

  --serif: "Instrument Serif", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --r: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Graph-paper field + vignette: the cartographic ground. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--rule-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule-soft) 1px, transparent 1px);
  background-size: 56px 56px, 56px 56px;
  opacity: .32;
  mask-image: radial-gradient(ellipse 120% 90% at 30% 0%, #000 25%, transparent 78%);
}

a { color: var(--brass); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

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

.shell { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; position: relative; z-index: 1; }

.rail {
  border-right: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--ink-2), var(--ink) 70%);
  padding: 22px 0 18px;
  display: flex; flex-direction: column;
  position: sticky; z-index: 10; top: 0; height: 100vh;
}

.brand { padding: 0 20px 20px; }
.brand .mark {
  font-family: var(--serif); font-size: 26px; letter-spacing: .2px; line-height: 1;
  color: var(--text); display: block;
}
.brand .mark em { font-style: italic; color: var(--brass); }
.brand .net {
  margin-top: 7px; font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-faint);
}
.brand .net b { color: var(--text-dim); font-weight: 500; }
.net-switcher { position: relative; display: flex; align-items: flex-end; gap: 6px; }
.net-switcher > .net { flex: 1; min-width: 0; }
.brand .net select { width: 100%; margin-top: 4px; padding: 5px 7px; font-size: 10.5px; }
.net-manage { position: relative; margin-bottom: 1px; }
.net-manage > summary {
  list-style: none; cursor: pointer; user-select: none;
  color: var(--brass); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 4px 7px; font-size: 9px; letter-spacing: .07em; text-transform: uppercase;
  background: var(--ink); transition: border-color .15s, color .15s;
}
.net-manage > summary::-webkit-details-marker { display: none; }
.net-manage > summary:hover, .net-manage[open] > summary { border-color: var(--brass-dim); color: #fff; }
.net-menu {
  position: absolute; z-index: 60; top: 0; left: calc(100% + 8px); width: 360px;
  background: var(--panel); border: 1px solid var(--rule); box-shadow: 0 20px 50px rgba(0,0,0,.55);
}
.net-menu-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 11px 13px; border-bottom: 1px solid var(--rule); background: var(--panel-2);
}
.net-menu-head strong { font-family: var(--serif); font-size: 18px; font-weight: 400; }
.net-menu-head span { color: var(--text-faint); font-size: 8.5px; letter-spacing: .12em; text-transform: uppercase; }
.net-create { padding: 12px 13px; border-bottom: 1px solid var(--rule); }
.net-create .field { margin-bottom: 8px; }
.net-create .field .lbl { font-size: 8.5px; }
.net-create input { width: 100%; padding: 6px 8px; font-size: 10.5px; }
.net-list { max-height: 230px; overflow-y: auto; }
.net-list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 13px; border-bottom: 1px dashed var(--rule-soft); }
.net-list-item:last-child { border-bottom: 0; }
.net-list-item b { color: var(--text); font-size: 11px; font-weight: 500; }
.net-list-item .dim { color: var(--brass); font-size: 8.5px; text-transform: uppercase; }
.net-list-item small { display: block; max-width: 235px; margin-top: 2px; color: var(--text-faint); font-size: 9.5px; line-height: 1.35; }

/* The thread: a dashed line running the height of the nav, stitching items. */
.nav { position: relative; padding: 6px 0; flex: 1; }
.nav::before {
  content: ""; position: absolute; left: 20px; top: 12px; bottom: 12px;
  border-left: 1px dashed var(--rule);
}
.nav a {
  display: block; position: relative; padding: 7px 20px 7px 38px;
  color: var(--text-dim); font-size: 12px; letter-spacing: .04em;
  border-left: 2px solid transparent;
}
.nav a::before { /* the stitch tick */
  content: ""; position: absolute; left: 17px; top: 50%; width: 7px; height: 7px;
  margin-top: -3.5px; border-radius: 50%;
  background: var(--ink); border: 1px solid var(--rule);
  transition: background .15s, border-color .15s;
}
.nav a:hover { color: var(--text); text-decoration: none; background: rgba(255,255,255,.02); }
.nav a:hover::before { border-color: var(--brass-dim); }
.nav a.on { color: var(--text); background: rgba(217,164,65,.06); }
.nav a.on::before { background: var(--brass); border-color: var(--brass); box-shadow: 0 0 0 3px rgba(217,164,65,.14); }

.rail-foot { padding: 14px 20px 0; border-top: 1px dashed var(--rule); font-size: 10.5px; color: var(--text-faint); }
.rail-foot .who { color: var(--text-dim); }

/* min-width:0 is required: a grid item defaults to min-width:auto, which
   would let wide tables stretch the column instead of scrolling inside it. */
.main { padding: 30px 38px 70px; max-width: 1500px; min-width: 0; }

/* ---------- headings ---------- */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
h1 {
  font-family: var(--serif); font-weight: 400; font-size: 40px; line-height: 1.02;
  margin: 0; letter-spacing: -.01em;
}
h1 em { font-style: italic; color: var(--brass); }
.sub { color: var(--text-faint); font-size: 11.5px; margin-top: 8px; letter-spacing: .03em; }

h2 {
  font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 0 0 14px;
}

.eyebrow {
  font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--text-faint);
}

/* ---------- stat strip ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px;
  background: var(--rule-soft); border: 1px solid var(--rule); margin-bottom: 30px; }
.stat { background: var(--panel); padding: 15px 17px 14px; position: relative; }
.stat .k { font-size: 9.5px; letter-spacing: .17em; text-transform: uppercase; color: var(--text-faint); }
.stat .v { font-family: var(--serif); font-size: 33px; line-height: 1.1; margin-top: 3px; }
.stat .v small { font-size: 13px; color: var(--text-dim); font-family: var(--mono); margin-left: 4px; }
.stat.accent .v { color: var(--brass); }

/* ---------- panels & tables ---------- */

.panel { border: 1px solid var(--rule); background: var(--panel); margin-bottom: 26px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 16px; border-bottom: 1px solid var(--rule); background: var(--panel-2);
}
.panel-body { padding: 16px; }

.provisioning-panel > summary {
  list-style: none; cursor: pointer; user-select: none;
}
.provisioning-panel > summary::-webkit-details-marker { display: none; }
.provisioning-panel:not([open]) > summary { border-bottom: 0; }
.provisioning-panel > summary:hover { border-color: var(--brass-dim); }
.provision-summary-copy { margin-top: 3px; font-size: 10.5px; }
.provision-toggle {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  color: var(--brass); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase;
}
.provision-arrow { display: inline-block; transition: transform .15s; }
.provisioning-panel[open] .provision-arrow { transform: rotate(90deg); }
.provisioning-intro {
  padding-top: 11px; padding-bottom: 11px; color: var(--text-dim); font-size: 11px;
  border-bottom: 1px solid var(--rule);
}
.provision-form { display: flex; align-items: flex-end; gap: 8px; margin: 0; flex-wrap: nowrap; }
.provision-form .field { min-width: 210px; margin: 0; }
.provision-form .field .lbl { font-size: 8.5px; }
.provision-form input { width: 100%; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th {
  text-align: left; font-weight: 400; font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-faint); padding: 9px 14px; border-bottom: 1px solid var(--rule);
  background: var(--panel-2); white-space: nowrap;
}
tbody td { padding: 9px 14px; border-bottom: 1px dashed var(--rule-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.022); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .dim { color: var(--text-faint); }

/* ---------- badges: the semantic stitch ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; font-size: 10px; letter-spacing: .06em; border-radius: var(--r);
  border: 1px solid var(--rule); color: var(--text-dim); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* local = solid border, present here */
.badge.local { color: var(--local); border-color: rgba(98,181,135,.4); background: rgba(98,181,135,.07); }
/* remote = DASHED border, lives elsewhere */
.badge.remote { color: var(--remote); border-style: dashed; border-color: rgba(106,165,217,.45); background: rgba(106,165,217,.05); }
.badge.localized { color: var(--brass); border-color: rgba(217,164,65,.45); background: rgba(217,164,65,.08); }
.badge.localized::before { border-radius: 1px; }
.badge.stale { color: var(--stale); border-style: dashed; border-color: rgba(217,138,74,.5); background: rgba(217,138,74,.07); }

.badge.ok { color: var(--local); border-color: rgba(98,181,135,.4); }
.badge.warn { color: var(--stale); border-color: rgba(217,138,74,.45); }
.badge.err { color: var(--danger); border-color: rgba(217,106,106,.45); }
.badge.idle { color: var(--text-faint); }
.badge.plain::before { display: none; }

.cloud {
  font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint);
  border: 1px solid var(--rule); padding: 1px 6px; border-radius: var(--r);
}

/* pulsing dot for live/online */
.badge.live::before { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.82); } }

/* ---------- forms & buttons ---------- */

input[type=text], input[type=password], select, textarea {
  background: var(--ink); color: var(--text); border: 1px solid var(--rule);
  padding: 7px 10px; font-family: var(--mono); font-size: 12px; border-radius: var(--r);
  min-width: 0;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brass-dim); box-shadow: 0 0 0 3px rgba(217,164,65,.11);
}
input:disabled, select:disabled { opacity: .55; cursor: not-allowed; }
/* .field works on <label> and on <div> (the picker field needs a div,
   because a label would steal clicks from the Browse button inside it). */
.field { display: block; margin-bottom: 12px; }
.field .lbl { display: block; font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 5px; }
.field input, .field select { width: 100%; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--rule);
  padding: 6px 13px; font-family: var(--mono); font-size: 11.5px; border-radius: var(--r);
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: var(--brass-dim); color: #fff; text-decoration: none; }
.btn.primary { background: var(--brass); border-color: var(--brass); color: #17120a; font-weight: 500; }
.btn.primary:hover { background: #e7b354; color: #17120a; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(217,106,106,.38); background: rgba(217,106,106,.05); }
.btn.danger:hover { color: #fff; border-color: var(--danger); background: rgba(217,106,106,.14); }
.btn.tiny { padding: 3px 9px; font-size: 10.5px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

.grant-builder {
  display: grid; grid-template-columns: minmax(220px,320px) minmax(520px,680px);
  justify-content: center; align-items: end; gap: 14px;
}
.grant-action-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.grant-action-field .lbl, .field-help {
  color: var(--text-faint); font-size: 9.5px; letter-spacing: .05em;
}
.grant-action-field .lbl { display: block; margin-bottom: 5px; letter-spacing: .16em; text-transform: uppercase; }
.grant-actions {
  display: grid; grid-template-columns: repeat(4, minmax(60px,1fr));
  min-height: 34px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--ink);
}
.grant-actions label {
  display: flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  padding: 6px 9px; border-right: 1px solid var(--rule); color: var(--text-dim); font-size: 11px;
}
.grant-actions label:last-child { border-right: 0; }
.grant-actions label:has(input:checked) { color: var(--text); background: rgba(217,164,65,.08); }
.grant-actions input { accent-color: var(--brass); }
.grant-prefix-field { min-width: 0; grid-column: 1 / -1; }
.grant-prefix-field .picker-field input { min-width: 280px; }
.grant-submit { min-height: 34px; white-space: nowrap; }
.field-help { display: block; margin-top: 5px; }
.field-help code { color: var(--text-dim); }
.browser-head-actions { justify-content: flex-end; }
.grant-modal h2 { margin: 3px 0 0; font-size: 23px; }
.grant-modal-body { padding: 16px; }
.grant-modal-body .field:last-child { margin-bottom: 0; }

@media (max-width: 900px) {
  .grant-builder { grid-template-columns: 1fr; }
  .grant-principal-field, .grant-action-field, .grant-prefix-field { grid-column: auto; }
  .grant-actions { grid-template-columns: repeat(2,1fr); }
  .grant-actions label:nth-child(2) { border-right: 0; }
  .grant-actions label:nth-child(-n+2) { border-bottom: 1px solid var(--rule); }
}

@media (max-width: 680px) {
  .grant-prefix-field .picker-field { align-items: stretch; flex-wrap: wrap; }
  .grant-prefix-field .picker-field input { flex-basis: 100%; min-width: 0; }
}

/* segmented toggle (physical / logical) */
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.seg a {
  padding: 5px 14px; font-size: 11px; color: var(--text-dim); background: var(--panel-2);
  border-right: 1px solid var(--rule);
}
.seg a:last-child { border-right: 0; }
.seg a:hover { color: var(--text); text-decoration: none; }
.seg a.on { background: var(--brass); color: #17120a; font-weight: 500; }

/* ---------- browser ---------- */

.crumbs { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-faint); flex-wrap: wrap; }
.crumbs .sep { color: var(--rule); }
.crumbs a { color: var(--text-dim); }
.crumbs .here { color: var(--text); }

.entry-name { display: flex; align-items: center; gap: 9px; }
.entry-name .glyph { color: var(--text-faint); width: 12px; display: inline-block; text-align: center; }
.entry-name.dir a { color: var(--text); }

/* A filename opens its provenance. It should read as inspectable, not as
   navigation — so it stays the same colour as plain text and only reveals
   the affordance on hover. */
.entry-name.file a {
  color: var(--text);
  text-decoration: underline dotted var(--rule);
  text-underline-offset: 4px;
  transition: color .12s, text-decoration-color .12s;
}
.entry-name.file a:hover {
  color: var(--brass);
  text-decoration: underline solid var(--brass-dim);
}
.origins { font-size: 10px; color: var(--text-faint); letter-spacing: .04em; }

/* Row actions sit on one line and stay put; the column is sized to them. */
.row-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; white-space: nowrap; }

.empty { padding: 42px 16px; text-align: center; color: var(--text-faint); }
.empty .big { font-family: var(--serif); font-size: 22px; color: var(--text-dim); display: block; margin-bottom: 6px; }

/* run progress inline strip */
.runstrip {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border: 1px dashed var(--brass-dim); background: rgba(217,164,65,.06); margin-bottom: 16px;
  font-size: 11.5px; border-radius: var(--r);
}
.spinner {
  width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--brass);
  border-right-color: transparent; animation: spin .7s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- audit ---------- */

.audit-line { display: grid; grid-template-columns: 78px 190px 1fr; gap: 12px; padding: 6px 14px;
  border-bottom: 1px dashed var(--rule-soft); font-size: 11.5px; align-items: baseline; }
.audit-line:hover { background: rgba(255,255,255,.022); }
.audit-line .t { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.audit-line .who { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; }
.audit-line .what b { font-weight: 500; }
.audit-line .what .det { color: var(--text-faint); }
.audit-line.denied .what b { color: var(--danger); }
.audit-line.data .what b { color: var(--remote); }

/* ---------- secret reveal ---------- */

.secret {
  border: 1px dashed var(--brass-dim); background: rgba(217,164,65,.07); padding: 12px 14px;
  margin-bottom: 18px; border-radius: var(--r);
}
.secret code { display: block; word-break: break-all; color: var(--brass); margin-top: 6px; font-size: 12px; }
.secret .warn { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--stale); }

.flash { border: 1px solid var(--danger); color: #f0b8b8; background: rgba(217,106,106,.08);
  padding: 10px 14px; margin-bottom: 18px; border-radius: var(--r); font-size: 11.5px; }
.flash.success { border-color: var(--local); color: #a9dfbf; background: rgba(98,181,135,.09); }

/* ---------- login ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; position: relative; z-index: 1; }
.login {
  width: 400px; border: 1px solid var(--rule); background: var(--panel); padding: 34px 32px 30px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.75);
}
.login .mark { font-family: var(--serif); font-size: 40px; line-height: 1; }
.login .mark em { font-style: italic; color: var(--brass); }
.login .tag { color: var(--text-faint); font-size: 11px; margin: 10px 0 26px; letter-spacing: .04em; }

/* Staggered entrance — one orchestrated load, not scattered fidgets.
   :not([hx-trigger]) is load-bearing: elements that poll and replace
   themselves must NOT re-run this on every swap, or the page flashes on a
   timer. Anything self-refreshing appears without animation. */
.main > *:not([hx-trigger]) { animation: rise .5s cubic-bezier(.22,.61,.36,1) both; }
.main > *:not([hx-trigger]):nth-child(1) { animation-delay: .02s; }
.main > *:not([hx-trigger]):nth-child(2) { animation-delay: .07s; }
.main > *:not([hx-trigger]):nth-child(3) { animation-delay: .12s; }
.main > *:not([hx-trigger]):nth-child(4) { animation-delay: .17s; }
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

/* htmx briefly marks the outgoing/incoming node during a swap; pin these to
   fully opaque so a swap can never read as a blink. */
.htmx-swapping, .htmx-settling, .htmx-added { opacity: 1 !important; transform: none !important; }

@media (prefers-reduced-motion: reduce) {
  .main > *, .spinner, .badge.live::before { animation: none !important; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: column; }
  .net-menu { top: calc(100% + 8px); right: 0; left: auto; width: min(360px, calc(100vw - 40px)); }
  .main { padding: 22px 18px 60px; }
  h1 { font-size: 30px; }
}

/* Wide content scrolls inside itself, never the page.
   Do NOT put min-width:max-content on these tables: combined with a
   percentage column width it inflates the table to its intrinsic size and
   pushes every column after the first out of view. Tables already fill
   their container (width:100% above) and overflow into this scroller only
   when their content genuinely does not fit. */
.scroll-x { overflow-x: auto; max-width: 100%; }
.panel, .stats, .page-head { min-width: 0; }
.row > * { min-width: 0; }

/* ---------- provenance chain ---------- */

.chain { list-style: none; margin: 0; padding: 0 0 0 20px; position: relative; }
/* the thread again, now literally tracing the object's path */
.chain::before {
  content: ""; position: absolute; left: 4px; top: 6px; bottom: 10px;
  border-left: 1px dashed var(--rule);
}
.hop { position: relative; padding: 0 0 20px 14px; }
.hop::before {
  content: ""; position: absolute; left: -20px; top: 5px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--ink); border: 1px solid var(--brass-dim);
}
.hop:last-child::before { background: var(--brass); border-color: var(--brass); box-shadow: 0 0 0 3px rgba(217,164,65,.14); }
.hop-head { display: flex; align-items: center; gap: 10px; }
.hop-when { color: var(--text-faint); font-size: 10.5px; }
.hop-path { margin: 7px 0 5px; font-size: 12px; line-height: 1.7; }
.hop-path .from { color: var(--text-dim); }
.hop-path .arrow { color: var(--brass); margin: 0 8px; }
.hop-path .to { color: var(--text); }
.hop-meta { font-size: 11px; color: var(--text-faint); }
.hop-meta b { color: var(--text-dim); font-weight: 500; }
.hop-basis { font-size: 10.5px; color: var(--text-faint); margin-top: 4px; font-style: italic; }
.hop-warn { font-size: 10.5px; color: var(--stale); margin-top: 5px; }

.badge.upload { color: var(--local); border-color: rgba(98,181,135,.4); }
.badge.localize { color: var(--brass); border-color: rgba(217,164,65,.45); }
.badge.copy { color: var(--remote); border-color: rgba(106,165,217,.45); }
.badge.policy { color: var(--text-dim); }

/* ---------- modal + source picker ---------- */

.modal-back {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(6,9,13,.72); backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center; padding: 8vh 20px;
}
.modal-back[hidden] { display: none; }
.modal {
  width: min(640px, 100%); max-height: 74vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--rule);
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 13px 16px; border-bottom: 1px solid var(--rule); background: var(--panel-2);
}
.modal-crumbs { font-size: 12px; margin-top: 5px; }
.modal-crumbs .sep { color: var(--text-faint); margin: 0 2px; }
.modal-body { overflow-y: auto; padding: 6px 0; }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 11px 16px; border-top: 1px solid var(--rule); background: var(--panel-2);
}
.modal-foot .dim { color: var(--text-faint); font-size: 11px; word-break: break-all; }

.cron-modal { width: min(940px, 100%); max-height: 84vh; }
.cron-body { padding: 16px; }
.cron-preview {
  display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 5px 16px;
  padding: 13px 15px; border: 1px solid var(--rule); background: var(--ink);
}
.cron-preview code { color: var(--brass); font-size: 18px; white-space: nowrap; }
.cron-preview span { color: var(--text); font-size: 13px; }
.cron-preview .cron-error { grid-column: 1 / -1; color: var(--danger); font-size: 10.5px; }
.cron-presets { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin: 14px 0; }
.cron-presets > .lbl { margin-right: 4px; color: var(--text-faint); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; }
.cron-fields { display: grid; grid-template-columns: repeat(5, minmax(105px, 1fr)); gap: 8px; }
.cron-fields label {
  display: grid; grid-template-rows: auto auto auto; gap: 4px;
  padding: 9px; border: 1px solid var(--rule); background: var(--panel-2);
}
.cron-fields label > span { color: var(--text); font-size: 10.5px; }
.cron-fields input { width: 100%; text-align: center; color: var(--brass); font-size: 13px; }
.cron-fields small { color: var(--text-faint); font-size: 8.5px; }
.cron-cheat-heading {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  margin: 17px 0 7px; color: var(--text-faint); font-size: 10px;
}
.cron-cheat-heading .lbl { display: block; color: var(--text-dim); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; }
.cron-operators { text-align: right; white-space: nowrap; }
.cron-operators b { color: var(--text-dim); font-weight: 500; }
.cron-operators code { color: var(--brass); }
.cron-cheats {
  display: grid; grid-template-columns: repeat(5, minmax(145px, 1fr)); gap: 1px;
  border: 1px solid var(--rule); background: var(--rule);
}
.cron-cheats section { min-width: 0; padding: 9px; background: var(--panel-2); }
.cron-cheats h3 {
  display: flex; justify-content: space-between; gap: 6px; margin: 0 0 7px;
  color: var(--text); font-size: 10px; font-weight: 500;
}
.cron-cheats h3 code { color: var(--text-faint); font-weight: 400; }
.cron-cheats button {
  width: 100%; display: grid; grid-template-columns: 45px 1fr; gap: 6px;
  margin: 0; padding: 5px 3px; text-align: left; cursor: pointer;
  color: var(--text-dim); background: transparent; border: 0; border-top: 1px dashed var(--rule-soft);
  font-family: var(--mono); font-size: 8.5px;
}
.cron-cheats button:hover { color: #fff; background: rgba(255,255,255,.025); }
.cron-cheats button code { color: var(--brass); }

@media (max-width: 760px) {
  .cron-fields, .cron-cheats { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .cron-cheat-heading { align-items: flex-start; flex-direction: column; }
  .cron-operators { text-align: left; white-space: normal; }
}

.picker-list { list-style: none; margin: 0; padding: 0; }
.picker-list li {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 16px; border-bottom: 1px dashed var(--rule-soft); font-size: 12px;
}
.picker-list li:hover { background: rgba(255,255,255,.025); }
.picker-list li.is-file { color: var(--text-faint); }
.picker-list .glyph { color: var(--text-faint); }
.picker-list .pick-nav { color: var(--text); flex: 1; }
.picker-list .pick-nav:hover { color: var(--brass); }
.picker-list .pick-meta { margin-left: auto; color: var(--text-faint); font-size: 10.5px; white-space: nowrap; }
.picker-list .pick-use { opacity: 0; transition: opacity .12s; }
.picker-list li:hover .pick-use { opacity: 1; }

/* source field: readonly display + browse button on one line */
.picker-field { display: flex; gap: 8px; align-items: center; }
.picker-field[hidden] { display: none; }
.picker-field input[readonly] { flex: 1; cursor: default; color: var(--text); }
.destination-picker { flex: 1 1 540px; min-width: min(480px, 100%); }
.destination-picker input { flex: 1 1 480px; width: 100%; }
.schedule-field { display: flex; gap: 8px; align-items: center; }
.schedule-field input[readonly] { flex: 1; min-width: 145px; cursor: default; color: var(--text); }

.policy-builder-grid {
  display: grid; align-items: end; gap: 14px;
  grid-template-columns:
    minmax(150px, 1.1fr)
    minmax(310px, 2.2fr)
    minmax(180px, 1.15fr)
    minmax(270px, 1.75fr)
    minmax(180px, 1.1fr)
    minmax(120px, .75fr);
}
.policy-builder-grid .field { min-width: 0; margin: 0; }
.policy-builder-actions {
  display: flex; align-items: center; gap: 12px; min-height: 34px; margin-top: 16px;
}
.policy-builder-actions > .btn.primary { flex: 0 0 auto; margin-left: auto; }

.check { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-dim); cursor: pointer; }
.check input { accent-color: var(--brass); }
.realtime-toggle { min-height: 32px; white-space: nowrap; }
.realtime-toggle:has(input:disabled) { opacity: .55; cursor: not-allowed; }

@media (max-width: 1740px) {
  .policy-builder-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .policy-name-field { grid-column: 1 / span 2; grid-row: 1; }
  .policy-source-field { grid-column: 3 / span 5; grid-row: 1; }
  .policy-destination-field { grid-column: 8 / span 3; grid-row: 1; }
  .policy-executor-field { grid-column: 11 / span 2; grid-row: 1; }
  .policy-schedule-field { grid-column: 1 / span 8; grid-row: 2; }
  .policy-events-field { grid-column: 9 / span 4; grid-row: 2; }
}

@media (max-width: 900px) {
  .policy-builder-grid { grid-template-columns: 1fr; }
  .policy-builder-grid > .field { grid-column: 1; grid-row: auto; }
  .policy-builder-actions { align-items: stretch; flex-direction: column; }
  .policy-builder-actions > .btn.primary { align-self: flex-end; margin-left: 0; }
  .destination-picker { min-width: 0; width: 100%; }
}
