/* AI Explorer dashboard.
 *
 * One palette drives the whole app, the report viewer included. Dark is the
 * default; `data-theme="light"` on <html> switches it, and app.js persists the
 * choice. Every colour below is a token — adding a hard-coded hex here means
 * one of the two themes will be wrong, so don't.
 */

:root {
  color-scheme: dark;

  /* surfaces -- each step is a visible lift, so a card reads as a card */
  --soft: #0f1614;          /* page background */
  --white: #19231f;         /* panels and cards */
  --surface-2: #222d29;     /* insets, chips, table headers */
  --paper: #131e1b;
  --line: #313d39;
  --line-strong: #47544f;
  --field-bg: #131c19;

  /* text */
  --ink: #eaf0ed;
  --muted: #9aa9a4;

  /* accent */
  --green: #4ec39a;
  --green-dark: #6ad3ac;    /* hover: brighter, not darker, on a dark ground */
  --green-soft: #16302a;
  --on-accent: #06201a;     /* text on a filled accent */
  --lime: #dff06a;

  /* status */
  --red: #f2796b;
  --red-soft: #3a1e1b;
  --warn: #e0a84a;
  --warn-soft: #362a15;
  --warn-line: #4d3a1c;
  --blue: #6d9cff;
  --blue-soft: #1b2a47;
  --orange: #f07848;

  /* sidebar keeps its own near-black ground in both themes */
  --sidebar: #0a120f;
  --side-ink: #eff5f1;
  --side-muted: #aebdb8;
  --side-dim: #7d8f8a;

  /* fixed-dark surfaces: a terminal and a media viewer read better this way */
  --term-bg: #0b1512;
  --term-ink: #c9d9d3;
  --term-dim: #71867f;
  --term-error: #ff9d86;
  --media-bg: #0a110f;

  --shadow: 0 14px 40px rgba(0, 0, 0, .38);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .35);
  --focus: rgba(78, 195, 154, .32);

  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
}

:root[data-theme="light"] {
  color-scheme: light;

  --soft: #f3f5f1;
  --white: #ffffff;
  --surface-2: #eef1ed;
  --paper: #fbfcfa;
  --line: #dfe4df;
  --line-strong: #c3cdc7;
  --field-bg: #fcfdfc;

  --ink: #13211f;
  --muted: #66716e;

  --green: #1f6d55;
  --green-dark: #15513f;
  --green-soft: #e5f0eb;
  --on-accent: #ffffff;
  --lime: #dff06a;

  --red: #b64237;
  --red-soft: #f9dfda;
  --warn: #8a5520;
  --warn-soft: #fff0d8;
  --warn-line: #f2d4ad;
  --blue: #17567c;
  --blue-soft: #dbecf7;
  --orange: #f07848;

  --sidebar: #142521;
  --side-ink: #eff5f1;
  --side-muted: #aebdb8;
  --side-dim: #71847e;

  --term-bg: #17241f;
  --term-ink: #c9d9d3;
  --term-dim: #71867f;
  --term-error: #ff9d86;
  --media-bg: #0e1714;

  --shadow: 0 14px 40px rgba(21, 42, 35, 0.08);
  --shadow-sm: 0 2px 8px rgba(21, 42, 35, .08);
  --focus: rgba(31, 109, 85, .22);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--soft); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 30px 18px 22px; display: flex; flex-direction: column; color: var(--side-ink); background: var(--sidebar); }
.brand { display: flex; align-items: center; gap: 12px; margin: 0 10px 44px; color: inherit; text-decoration: none; }
.brand-mark, .dialog-mark { width: 42px; height: 42px; display: grid; place-items: center; background: var(--lime); color: #142521; font-weight: 900; letter-spacing: -.04em; border-radius: 12px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { color: var(--side-muted); margin-top: 2px; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
nav { display: grid; gap: 6px; }
.nav-link { appearance: none; border: 0; display: flex; align-items: center; gap: 11px; width: 100%; padding: 12px 13px; color: var(--side-muted); background: transparent; text-align: left; border-radius: 10px; cursor: pointer; }
.nav-link span { font: 700 10px/1 ui-monospace, monospace; color: var(--side-dim); }
.nav-link b { margin-left: auto; min-width: 22px; padding: 3px 6px; text-align: center; color: #142521; background: var(--lime); border-radius: 999px; font-size: 10px; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.055); }
.nav-link.active { color: #fff; background: rgba(255,255,255,.09); }
.nav-link.active span { color: var(--lime); }
.sidebar-foot { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 10px; }
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: 12px; }
.sidebar-foot small { margin-top: 2px; color: var(--side-dim); font-size: 11px; }
.status-dot, .signal { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #82908d; box-shadow: 0 0 0 4px rgba(130,144,141,.14); }
.status-dot.ok, .signal.ok { background: #67d09e; box-shadow: 0 0 0 4px rgba(103,208,158,.14); }
.status-dot.bad, .signal.bad { background: #ee755d; box-shadow: 0 0 0 4px rgba(238,117,93,.14); }

/* One theme switch for the whole app, parked in the sidebar. */
.theme-toggle { flex: none; margin-left: auto; width: 30px; height: 30px; display: grid; place-items: center; padding: 0; color: var(--side-muted); background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 8px; cursor: pointer; font-size: 13px; line-height: 1; }
.theme-toggle:hover { color: #fff; background: rgba(255,255,255,.12); }
.theme-toggle .theme-dark { display: none; }
:root[data-theme="light"] .theme-toggle .theme-dark { display: block; }
:root[data-theme="light"] .theme-toggle .theme-light { display: none; }

main { min-width: 0; padding: 28px clamp(24px, 4vw, 58px) 54px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.eyebrow, .kicker { margin: 0 0 6px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
h1 { margin: 0; font-size: clamp(28px, 3vw, 42px); letter-spacing: -.045em; }
h2, h3 { margin: 0; letter-spacing: -.025em; }
h2 { font-size: 23px; }
h3 { font-size: 16px; }
.top-status, .button-row, .primary-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.pill, .tag, .input-kind { display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.pill.neutral { background: var(--surface-2); color: var(--muted); }
.pill.good { background: var(--green-soft); color: var(--green); }
.pill.warn { background: var(--red-soft); color: var(--red); }
.tag { background: var(--surface-2); color: var(--muted); }

.notice, .warning-bar { margin: -8px 0 20px; padding: 13px 16px; border-radius: 9px; font-size: 13px; }
.notice { background: var(--green-soft); color: var(--green); }
.notice.error { background: var(--red-soft); color: var(--red); }
.warning-bar { color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn-line); }
.view { display: none; }
.view.active { display: block; animation: enter .18s ease-out; }
@keyframes enter { from { opacity: .25; transform: translateY(4px); } }

.control-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 18px; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.mission-panel, .provider-panel, .readiness-panel { padding: 25px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.target-details { display: grid; grid-template-columns: 1.3fr 1fr .7fr; gap: 18px; margin: 30px 0; }
.target-details div { min-width: 0; }
dt { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
dd { margin: 6px 0 0; overflow: hidden; color: var(--ink); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.primary-actions { margin-top: 7px; }
.microcopy { margin: 14px 0 0; color: var(--muted); font-size: 11px; }
.provider-panel .endpoint { min-height: 18px; margin: 13px 0 24px; color: var(--muted); font: 12px ui-monospace, monospace; overflow-wrap: anywhere; }

.button { border: 0; min-height: 39px; padding: 9px 14px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 12px; transition: transform .12s, background .12s, opacity .12s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .42; cursor: not-allowed; }
.button.primary { color: var(--on-accent); background: var(--green); }
.button.primary:hover:not(:disabled) { background: var(--green-dark); }
.button.primary span { margin-left: 22px; }
.button.secondary { color: var(--green); background: var(--green-soft); }
.button.secondary:hover:not(:disabled) { background: var(--surface-2); }
.button.ghost { color: var(--muted); background: transparent; border: 1px solid var(--line); }
.button.danger { color: var(--red); background: var(--red-soft); }
.button.linklike { margin-top: 18px; padding: 0; min-height: auto; color: var(--green); background: none; }
.text-button { padding: 0; border: 0; color: var(--green); background: none; cursor: pointer; font-size: 11px; font-weight: 750; text-decoration: none; }

.log-panel { grid-row: span 2; min-height: 405px; padding: 24px 0 0; overflow: hidden; }
.log-panel .panel-heading { padding: 0 24px 17px; }
.log-output { height: 330px; padding: 17px 24px 28px; overflow: auto; color: var(--term-ink); background: var(--term-bg); font: 11px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; }
.log-output p { display: grid; grid-template-columns: 68px 1fr; gap: 12px; margin: 0 0 5px; }
.log-output time { color: var(--term-dim); }
.log-output .error { color: var(--term-error); }
.log-output .empty { display: block; color: var(--term-dim); }
.check-list { display: grid; gap: 19px; margin: 24px 0 0; padding: 0; list-style: none; }
.check-list li { display: flex; gap: 12px; align-items: flex-start; }
.check-list li > span { width: 25px; height: 25px; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--line); border-radius: 50%; font-weight: 900; }
.check-list li > span.ok { color: var(--green); background: var(--green-soft); border-color: var(--green); }
.check-list strong, .check-list small { display: block; }
.check-list strong { font-size: 13px; }
.check-list small { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.35; }

.section-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 5px 0 24px; }
.section-intro h2 { font-size: 29px; }
.section-intro p:not(.eyebrow) { max-width: 660px; margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.info-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; padding: 15px 18px; color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: 11px; }
.info-card p { margin: 3px 0 0; font-size: 12px; }
.input-list { display: grid; gap: 14px; }
.input-group { overflow: hidden; }
.input-group-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 22px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.input-group-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.input-group-count { flex: 0 0 auto; padding: 5px 9px; color: var(--green); background: var(--green-soft); border-radius: 999px; font-size: 10px; font-weight: 800; }
.input-group-note { margin: 0; padding: 10px 22px; border-bottom: 1px solid var(--line); font-size: 11px; line-height: 1.45; }
.input-group-note.ready { color: var(--green); background: var(--green-soft); }
.input-group-note.pending { color: var(--warn); background: var(--warn-soft); }
.input-group-fields { display: grid; }
.input-card { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 10px 20px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.input-card:last-child { border-bottom: 0; }
.input-card-head { display: flex; justify-content: space-between; gap: 20px; }
.input-kind { margin-bottom: 7px; padding: 4px 8px; color: var(--green); background: var(--green-soft); text-transform: uppercase; font-size: 9px; letter-spacing: .1em; }
.input-context { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.input-visual { grid-column: 2; grid-row: 1 / span 3; min-height: 112px; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: var(--surface-2); cursor: pointer; }
.input-visual img { display: block; width: 100%; height: 100%; min-height: 110px; max-height: 145px; object-fit: cover; }
.input-visual span { display: block; padding: 32px 10px; font-size: 10px; }
.input-visual.available span { display: none; }
.input-visual:hover { border-color: var(--line-strong); }
.input-fields { display: grid; grid-template-columns: 190px minmax(240px, 1fr); gap: 14px; margin-top: 18px; }
.input-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 14px; }
.input-card-foot > div { display: flex; align-items: center; gap: 16px; }
.input-help { margin: 0; color: var(--muted); font-size: 11px; }

label { display: grid; gap: 7px; color: var(--ink); font-size: 11px; font-weight: 700; }
input:not([type=checkbox]), select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; color: var(--ink); background: var(--field-bg); font-size: 12px; }
textarea { resize: vertical; line-height: 1.5; }
input:not([type=checkbox]):focus, select:focus, textarea:focus { border-color: var(--green); }
option { color: var(--ink); background: var(--white); }
.switch, .toggle-row { display: flex; grid-template-columns: none; align-items: center; cursor: pointer; }
.switch { gap: 8px; font-size: 10px; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: relative; width: 34px; height: 19px; background: var(--line-strong); border-radius: 999px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 13px; height: 13px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(15px); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.config-tabs { display: inline-flex; gap: 4px; margin: -6px 0 18px; padding: 4px; background: var(--surface-2); border-radius: 10px; }
.config-tab { padding: 8px 14px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; font-weight: 800; }
.config-tab.active { color: var(--green); background: var(--white); box-shadow: var(--shadow-sm); }
.config-pane { display: none; }
.config-pane.active { display: grid; }
.form-panel { min-width: 0; display: grid; align-content: start; gap: 15px; padding: 23px; }
.form-panel.wide { grid-column: 1 / -1; }
fieldset { border: 0; margin: 0; }
legend { width: 100%; margin-bottom: 19px; padding: 0 0 14px; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 16px; font-weight: 800; }
legend span { margin-right: 8px; color: var(--green); font: 700 10px ui-monospace, monospace; }
.inline-fields { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 14px; }
.advanced-numbers { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
.advanced-numbers label small, .form-panel > label small { color: var(--muted); font-weight: 400; line-height: 1.35; }
.toggle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.toggle-row { grid-template-columns: auto 1fr; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.toggle-row input { margin-top: 3px; accent-color: var(--green); }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row small { margin-top: 4px; color: var(--muted); font-weight: 400; line-height: 1.35; }
.setting-intro { margin: -5px 0 2px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.preset-sliders { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.range-setting { padding: 17px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; }
.range-setting > span { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.range-setting > span strong { color: var(--ink); font-size: 13px; }
.range-setting > span b { color: var(--green); font-size: 11px; }
.range-setting input { padding: 0; margin: 18px 0 12px; border: 0; background: transparent; accent-color: var(--green); }
.range-setting small { min-height: 45px; color: var(--muted); font-weight: 400; line-height: 1.4; }
.profile-summary { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 2px; border: 1px solid var(--line); border-radius: 10px; }
.profile-summary div { padding: 13px 15px; border-right: 1px solid var(--line); }
.profile-summary div:last-child { border-right: 0; }
.profile-summary span, .profile-summary strong { display: block; }
.profile-summary span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.profile-summary strong { margin-top: 5px; font-size: 12px; }

/* Regular expressions edited as pills. The raw expression is still there,
   inside a disclosure, and is what the form submits; these are a view of it. */
.regex-field { display: grid; gap: 9px; font-size: 12px; font-weight: 700; }
.regex-field-title { color: var(--ink); }
.regex-field > small { color: var(--muted); font-weight: 400; line-height: 1.4; }
.regex-pills { display: grid; gap: 10px; padding: 11px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.regex-group { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.regex-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 11px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 750; }
.regex-pill-remove { width: 17px; height: 17px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; color: inherit; background: transparent; cursor: pointer; font-size: 13px; line-height: 1; }
.regex-pill-remove:hover { background: var(--green); color: var(--on-accent); }
.regex-pill-input { flex: 1 1 130px; min-width: 130px; padding: 6px 10px; border: 1px dashed var(--line-strong); border-radius: 999px; background: transparent; color: var(--ink); font-size: 11px; }
.regex-pill-input::placeholder { color: var(--muted); }
.regex-flag { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 700; }
.regex-flag input { width: auto; margin: 0; accent-color: var(--green); }
.regex-note { margin: 0; color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.45; }
.regex-field[data-regex-mode="source"] .regex-source { border-color: var(--line-strong); }
.regex-source summary { font-size: 11px; }

.empty-state { padding: 40px; color: var(--muted); text-align: center; font-size: 13px; }

dialog { width: min(440px, calc(100vw - 32px)); padding: 0; color: var(--ink); background: var(--white); border: 0; border-radius: 16px; box-shadow: 0 30px 100px rgba(0,0,0,.5); }
dialog::backdrop { background: rgba(4, 10, 8, .72); backdrop-filter: blur(3px); }
dialog form { padding: 30px; }
dialog .dialog-mark { margin-bottom: 24px; }
dialog h2 { font-size: 27px; }
dialog p:not(.eyebrow):not(.field-error) { color: var(--muted); font-size: 12px; line-height: 1.55; }
dialog label { margin: 22px 0 14px; }
dialog .button { width: 100%; margin-top: 4px; }
.image-dialog { width: min(1100px, calc(100vw - 40px)); background: var(--media-bg); }
.image-dialog .image-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 17px 20px; color: #fff; }
.image-dialog .image-dialog-head .eyebrow { color: var(--lime); }
.image-dialog .image-dialog-head .button { width: auto; margin: 0; color: #d8e3df; border-color: #42534d; }
.image-stage { max-height: calc(100vh - 150px); padding: 0 16px 16px; overflow: auto; text-align: center; }
.image-stage img { max-width: 100%; height: auto; border-radius: 6px; }
.field-error { min-height: 17px; margin: 0 0 6px; color: var(--red); font-size: 11px; }
code { padding: 2px 5px; background: var(--surface-2); border-radius: 4px; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .brand { margin-inline: 5px; }
  .brand > span:last-child, .nav-link:not(.active) b, .nav-link { font-size: 0; }
  .nav-link { justify-content: center; }
  .nav-link span { font-size: 10px; }
  .sidebar-foot span:last-child:not(.theme-toggle) { display: none; }
  .sidebar-foot { flex-wrap: wrap; justify-content: center; }
  .control-grid { grid-template-columns: 1fr; }
  .log-panel { grid-row: auto; }
  .toggle-grid { grid-template-columns: 1fr; }
  .preset-sliders, .advanced-numbers { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Application switching --------------------------------------- */

.application-switch { margin: 4px 0 18px; padding: 12px 12px 13px; background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.1); border-radius: 11px; }
.application-switch label { display: block; margin-bottom: 7px; color: var(--side-muted); font-size: 9px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.application-switch select { width: 100%; padding: 8px 9px; color: #fff; background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.16); border-radius: 8px; font: inherit; font-size: 12px; }
.application-switch select option { color: var(--ink); background: var(--white); }
.application-switch select:focus-visible { outline: 2px solid var(--lime); outline-offset: 1px; }
.application-switch p { margin: 8px 0 0; color: var(--side-dim); font-size: 10px; line-height: 1.4; }

.pill.kind { color: #142521; background: var(--lime); }
body[data-kind="web"] .pill.kind { color: var(--blue); background: var(--blue-soft); }

.new-application { margin-bottom: 20px; padding: 20px 22px 22px; }
.new-application h3 { margin: 0 0 16px; font-size: 17px; }
.new-application-fields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; align-items: end; gap: 14px; }
.new-application-fields .button { min-height: 42px; }

.application-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.application-card { padding: 18px 20px 16px; background: var(--white); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.application-card.active { border-color: var(--green); box-shadow: 0 0 0 1px var(--green), var(--shadow); }
.application-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.application-card h3 { margin: 0 0 4px; font-size: 16px; overflow-wrap: anywhere; }
.application-kind { display: inline-flex; margin-bottom: 7px; padding: 4px 8px; border-radius: 999px; color: var(--green); background: var(--green-soft); text-transform: uppercase; font-size: 9px; font-weight: 750; letter-spacing: .1em; }
.application-kind.web { color: var(--blue); background: var(--blue-soft); }
.application-target { margin: 0; color: var(--muted); font: 11px/1.45 ui-monospace, monospace; overflow-wrap: anywhere; }
.application-active-tag { flex: none; padding: 5px 9px; color: var(--on-accent); background: var(--green); border-radius: 999px; font-size: 10px; font-weight: 750; }
.application-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 16px 0 0; padding: 13px 0 0; border-top: 1px solid var(--line); }
.application-facts > div:last-child { grid-column: 1 / -1; }
.application-facts dd { margin: 4px 0 0; font-size: 12px; overflow-wrap: anywhere; }
.application-facts .application-evidence { color: var(--muted); font: 11px/1.45 ui-monospace, monospace; }
.application-card-actions { display: flex; align-items: center; gap: 14px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.application-card-actions .button { min-height: 34px; padding: 0 14px; font-size: 12px; }
.text-button.danger-text { margin-left: auto; color: var(--red); }
.text-button:disabled { color: var(--muted); cursor: not-allowed; }
.sidebar-signout { color: var(--side-muted); font-size: 10px; }
#managed-model-actions { display: contents; }
.access-form { display: grid; grid-template-columns: minmax(160px, 1.25fr) repeat(4, minmax(140px, 1fr)) auto; align-items: end; gap: 14px; margin-bottom: 18px; padding: 20px 22px; }
.access-form h3 { margin: 0; }
.access-users { padding: 20px 22px; }
.table-scroll { overflow-x: auto; }
.access-users table { width: 100%; border-collapse: collapse; font-size: 12px; }
.access-users th, .access-users td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.access-users th { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }


.kind-fields { display: contents; }
.kind-fields[hidden] { display: none; }
.kind-fields .toggle-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kind-fields .inline-fields { grid-template-columns: repeat(2, minmax(120px, 1fr)); }

@media (max-width: 700px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px 14px; flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { margin: 0 12px 0 0; }
  .brand-mark { width: 34px; height: 34px; border-radius: 9px; }
  nav { display: flex; gap: 4px; }
  .nav-link { width: auto; padding: 10px; }
  .sidebar-foot { display: flex; margin: 0 0 0 auto; padding: 0; border: 0; }
  .sidebar-foot > span:not(.theme-toggle), .sidebar-foot > strong { display: none; }
  main { padding: 22px 16px 40px; }
  .topbar, .section-intro, .input-card-foot { align-items: flex-start; flex-direction: column; }
  .target-details, .form-grid, .inline-fields, .input-fields, .preset-sliders, .advanced-numbers, .profile-summary { grid-template-columns: 1fr; }
  .form-panel.wide { grid-column: auto; }
  .target-details { gap: 12px; }
  .top-status { align-self: stretch; }
  .info-card { align-items: flex-start; flex-direction: column; }
  .input-card { grid-template-columns: 1fr; }
  .new-application-fields, .application-facts { grid-template-columns: 1fr; }
  .access-form { grid-template-columns: 1fr; }
  .application-list { grid-template-columns: 1fr; }
  .text-button.danger-text { margin-left: 0; }
  .input-visual { grid-column: 1; grid-row: auto; }
  .profile-summary div { border-right: 0; border-bottom: 1px solid var(--line); }
  .profile-summary div:last-child { border-bottom: 0; }
}

/* Prefills are saved for the whole page at once, so the page needs to show what
   is unsaved: a per-card flag for which field, and a count on the Save button. */
.input-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.live-run-line { display: flex; align-items: baseline; gap: 12px; padding: 14px 16px; margin-top: 0;
  background: var(--term-bg); color: var(--term-dim); font: 12px/1.6 ui-monospace, Consolas, monospace; border-top: 1px solid var(--line); }
.live-run-line.active { color: var(--green); }
#activity-spinner { width: 1ch; flex-shrink: 0; font-weight: 700; }
#activity-detail { flex: 1; overflow-wrap: anywhere; }
#activity-elapsed { white-space: nowrap; color: var(--term-dim); }
.activity-progress { font: 11px/1.5 ui-monospace, Consolas, monospace; color: var(--muted); margin: 8px 0 0; }
.activity-progress:empty { display: none; }
.settings-details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.settings-details summary, .advanced-section summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.settings-details summary { font-size: 12px; }
.settings-details[open] summary, .advanced-section[open] > summary { margin-bottom: 16px; }
.settings-details label + label { margin-top: 12px; }
.advanced-section { display: block; }
.advanced-section > summary { font-size: 16px; }
.advanced-section > summary span { color: var(--muted); font-weight: 400; }
.model-strategy-summary { background: var(--green-soft); color: var(--green); border: 1px solid var(--line);
  border-radius: 8px; padding: 13px; margin: 12px 0; font-size: 12px; line-height: 1.7; }
.config-save-bar { position: sticky; top: 0; z-index: 5; background: var(--soft); padding: 16px 0; border-bottom: 1px solid var(--line); }
#config-save-state { color: var(--muted); display: block; margin-top: 10px; }
#config-save-state.dirty { color: var(--warn); }
.input-dirty-note { margin: 0 0 12px; padding: 9px 14px; border-radius: 7px; font-size: 11px;
  color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn-line); }
.input-card.dirty { border-color: var(--warn-line); box-shadow: 0 0 0 1px var(--warn-line) inset; }
.input-dirty-flag { font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: 999px; padding: 3px 9px; }
