:root {
  --ink: #f2efe7;
  --panel: #fffdf8;
  --panel-2: #f7f3e9;
  --line: #bcb7aa;
  --line-soft: #dfdbd0;
  --paper: #202820;
  --muted: #6c746a;
  --acid: #3f6909;
  --amber: #9a5a00;
  --red: #b53128;
  --green: #18744c;
  --mono: "Cascadia Mono", "IBM Plex Mono", Consolas, monospace;
  --display: "Bodoni 72", "Didot", "Times New Roman", serif;
  --body: "Aptos", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--ink); color: var(--paper); min-width: 320px; }
body { margin: 0; min-height: 100vh; font-family: var(--body); background: radial-gradient(circle at 82% 8%, rgba(128,166,62,.16), transparent 28rem), linear-gradient(135deg, #f8f5ee 0%, #efebe2 62%, #f5f1e8 100%); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

.grain { position: fixed; inset: 0; pointer-events: none; opacity: .07; z-index: 20; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E"); mix-blend-mode: multiply; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px; }
.login-card { width: min(760px, 100%); min-height: 540px; border: 1px solid var(--line); padding: clamp(32px, 7vw, 76px); position: relative; overflow: hidden; background: linear-gradient(140deg, rgba(255,253,248,.98), rgba(244,240,230,.98)); box-shadow: 0 28px 70px rgba(57,62,48,.18); animation: reveal .7s cubic-bezier(.2,.7,.1,1) both; }
.login-card::before { content: ""; position: absolute; width: 340px; height: 340px; border: 1px solid rgba(63,105,9,.22); border-radius: 50%; right: -130px; top: -160px; box-shadow: 0 0 0 54px rgba(63,105,9,.035), 0 0 0 108px rgba(63,105,9,.02); }
.login-card::after { content: "AUTH / 01"; position: absolute; right: 24px; top: 50%; color: #969c91; font: 11px var(--mono); letter-spacing: .22em; transform: rotate(90deg) translateX(50%); transform-origin: right center; }
.eyebrow, .kicker, .panel-heading span, .section-heading span { font: 11px var(--mono); letter-spacing: .17em; color: var(--acid); }
.signal { display: inline-block; width: 7px; height: 7px; background: var(--acid); border-radius: 50%; margin-right: 10px; box-shadow: 0 0 18px var(--acid); animation: pulse 2s infinite; }
.login-card h1 { font: 400 clamp(64px, 11vw, 110px)/.73 var(--display); letter-spacing: -.065em; margin: 62px 0 30px; position: relative; }
.login-card h1 em { color: var(--acid); font-weight: 400; }
.login-card > p { color: var(--muted); font-size: 15px; margin: 0 0 54px; }
.login-card label, .field-pair label, .source-main > label { display: block; color: #4d574d; font: 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; margin-bottom: 10px; }
.login-fields { display: grid; grid-template-columns: .8fr 1.2fr; gap: 22px; }
.login-fields input { width: 100%; min-width: 0; border: 0; border-bottom: 1px solid #8e958a; background: transparent; outline: 0; color: var(--paper); padding: 15px 4px; font: 16px var(--mono); }
.login-fields input:focus { border-color: var(--acid); }
.input-row { display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid #8e958a; }
.input-row input { background: transparent; border: 0; outline: 0; color: var(--paper); min-width: 0; padding: 15px 4px; font: 18px var(--mono); }
.input-row button { border: 0; padding: 0 4px 0 24px; background: transparent; color: var(--acid); font: 700 12px var(--mono); letter-spacing: .08em; cursor: pointer; }
.input-row button span { font-size: 20px; margin-left: 8px; }
.login-action-row { display: flex; justify-content: flex-end; margin-top: 20px; }
.login-action-row button { padding: 13px 4px 13px 24px; }
.login-card footer { position: absolute; left: clamp(32px, 7vw, 76px); right: clamp(32px, 7vw, 76px); bottom: 28px; display: flex; justify-content: space-between; color: #7b8278; font: 9px var(--mono); letter-spacing: .16em; }
.login-card footer a { color: #596354; text-decoration: none; }
.login-card footer a:hover { color: var(--acid); }
.form-error { min-height: 20px; color: var(--red); font: 12px var(--mono); margin: 12px 0 0; }

.app-shell { min-height: 100vh; }
.topbar { height: 82px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(18px, 4vw, 54px); background: rgba(250,248,242,.9); backdrop-filter: blur(20px); position: sticky; top: 0; z-index: 10; }
.brand { color: inherit; text-decoration: none; display: flex; gap: 14px; align-items: center; }
.brand-mark { border: 1px solid var(--acid); color: var(--acid); width: 38px; height: 38px; display: grid; place-items: center; font: 700 12px var(--mono); }
.brand strong, .brand small { display: block; }
.brand strong { font: 700 12px var(--mono); letter-spacing: .1em; }
.brand small { color: var(--muted); font: 8px var(--mono); letter-spacing: .16em; margin-top: 4px; }
.topbar-actions { display: flex; align-items: center; gap: 24px; }
.current-user { color: var(--acid); font: 10px var(--mono); letter-spacing: .08em; }
.system-state { color: #596258; font: 10px var(--mono); letter-spacing: .12em; }
.system-state i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); margin-right: 8px; box-shadow: 0 0 12px var(--green); }
.quiet-button, .icon-button, .danger-button, .download-button { border: 1px solid var(--line); background: rgba(255,255,255,.42); padding: 9px 13px; cursor: pointer; font: 11px var(--mono); text-decoration: none; color: #394438; transition: .18s ease; }
.quiet-button:hover, .icon-button:hover { border-color: #697764; color: #182117; background: #fffdf8; }

.workspace { display: grid; grid-template-columns: 210px minmax(0,1fr); min-height: calc(100vh - 82px); }
.rail { border-right: 1px solid var(--line); padding: 42px 28px; position: relative; }
.rail-index { font: italic 46px var(--display); color: var(--acid); }
.rail-copy { margin-top: 12px; }
.rail-copy span { color: var(--muted); font: 9px var(--mono); letter-spacing: .16em; }
.rail-copy strong { display: block; margin-top: 5px; font-size: 16px; }
.rail-line { width: 1px; height: 74px; background: linear-gradient(var(--acid), transparent); margin: 28px 0; }
.rail-metrics { margin: 0; }
.rail-metrics div { border-top: 1px solid var(--line-soft); padding: 17px 0; }
.rail-metrics dt { color: var(--muted); font: 10px var(--mono); }
.rail-metrics dd { margin: 5px 0 0; font: 28px var(--display); }
.rail-note { position: absolute; bottom: 28px; left: 28px; right: 28px; color: #747b71; font: 10px/1.7 var(--mono); }

.content { padding: 48px clamp(22px, 5vw, 74px) 80px; max-width: 1500px; width: 100%; }
.page-heading, .section-heading, .panel-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-heading { margin-bottom: 34px; }
.page-heading h2 { margin: 6px 0 0; font: 400 clamp(38px, 5vw, 64px)/.95 var(--display); letter-spacing: -.04em; }
.primary-action { border: 0; background: var(--acid); color: #fffdf8; padding: 14px 19px; font: 800 11px var(--mono); letter-spacing: .06em; cursor: pointer; box-shadow: 6px 6px 0 #b8c99b; transition: transform .15s, box-shadow .15s; }
.primary-action:hover { transform: translate(2px,2px); box-shadow: 3px 3px 0 #b8c99b; }
.primary-action span { font-size: 17px; vertical-align: -1px; }
.panel { border: 1px solid var(--line); background: linear-gradient(150deg, rgba(255,253,248,.98), rgba(247,243,233,.98)); box-shadow: 0 14px 35px rgba(75,78,63,.07); margin-bottom: 38px; animation: rise .42s ease both; }
.panel-heading { padding: 22px 25px; border-bottom: 1px solid var(--line); align-items: center; }
.panel-heading h3, .section-heading h3 { margin: 5px 0 0; font: 400 24px var(--display); }
.icon-button { font-size: 20px; border: 0; padding: 4px 8px; }
.composer form { padding: 26px; }
.source-grid { display: grid; grid-template-columns: minmax(0,1.65fr) minmax(260px,.75fr); gap: 30px; }
textarea, select, .field-pair input { width: 100%; border: 1px solid var(--line); background: #fffefb; color: var(--paper); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea:focus, select:focus, .field-pair input:focus { border-color: #678342; box-shadow: 0 0 0 3px rgba(87,126,36,.12); }
textarea { min-height: 242px; resize: vertical; padding: 17px; font: 12px/1.65 var(--mono); }
select, .field-pair input { height: 43px; padding: 0 12px; font: 12px var(--mono); }
.source-meta { display: flex; align-items: center; gap: 16px; margin-top: 12px; color: var(--muted); font: 10px var(--mono); }
.source-meta input { position: absolute; opacity: 0; pointer-events: none; }
.file-action { color: var(--acid); cursor: pointer; border-bottom: 1px solid rgba(200,255,61,.4); padding-bottom: 2px; }
.settings-stack { display: grid; gap: 16px; align-content: start; }
.route-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.provider-route-card { border: 1px solid var(--line-soft); background: rgba(244,241,232,.82); padding: 14px; display: grid; gap: 12px; }
.route-card-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.route-card-heading span, .route-card-heading strong { display: block; }
.route-card-heading span { color: var(--muted); font: 8px var(--mono); letter-spacing: .14em; }
.route-card-heading strong { margin-top: 4px; color: #364036; font: 12px var(--mono); }
.route-card-heading small { color: var(--acid); font: 8px/1.4 var(--mono); text-align: right; max-width: 54%; }
.route-picker { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.route-picker input { grid-column: 1 / -1; width: 100%; height: 39px; border: 1px solid var(--line); background: #fffefb; color: var(--paper); padding: 0 11px; font: 11px var(--mono); outline: 0; }
.route-picker button, .route-priority-actions button { border: 1px solid rgba(63,105,9,.4); background: #fbfcf5; color: var(--acid); cursor: pointer; font: 9px var(--mono); }
.route-picker button { padding: 0 13px; }
.route-priority-list { display: grid; gap: 6px; }
.route-priority-empty { padding: 10px; border: 1px dashed var(--line-soft); color: var(--muted); text-align: center; font: 9px var(--mono); }
.route-priority-item { display: grid; grid-template-columns: 20px minmax(0,1fr) auto; align-items: center; gap: 8px; min-height: 36px; border: 1px solid var(--line-soft); padding: 5px 6px; }
.route-priority-index { color: var(--acid); font: 9px var(--mono); }
.route-priority-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #465045; font: 10px var(--mono); }
.route-priority-actions { display: flex; gap: 4px; }
.route-priority-actions button { width: 25px; height: 24px; padding: 0; }
.route-priority-actions button:disabled { opacity: .25; cursor: default; }
.route-hint { margin: 0; color: #737b71; font: 8px/1.6 var(--mono); }
.fixed-route-card { padding-top: 12px; padding-bottom: 12px; }
.composer-footer { margin-top: 24px; border-top: 1px solid var(--line-soft); padding-top: 20px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.launch-button { border: 0; background: var(--paper); color: #fffdf8; display: flex; align-items: center; gap: 28px; padding: 12px 14px 12px 18px; cursor: pointer; font: 800 11px var(--mono); }
.launch-button b { background: #e4efca; color: #315307; padding: 6px 8px; font-size: 9px; letter-spacing: .12em; }
.launch-button:disabled { opacity: .4; cursor: wait; }

.credentials-panel form { padding: 26px; }
.key-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.key-field { padding: 18px; border: 1px solid var(--line-soft); background: rgba(244,241,232,.82); }
.key-field > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.key-field label { color: #4b554a; font: 11px var(--mono); letter-spacing: .08em; }
.key-field > div label { margin: 0; text-transform: uppercase; }
.key-field > input { width: 100%; height: 43px; border: 1px solid var(--line); background: #fffefb; color: var(--paper); outline: 0; padding: 0 12px; font: 11px var(--mono); }
.key-field > input:focus { border-color: #678342; box-shadow: 0 0 0 3px rgba(87,126,36,.12); }
.key-status { color: var(--muted); font: 9px var(--mono); text-transform: uppercase; }
.key-status.configured { color: var(--green); }
.clear-key { display: flex; align-items: center; gap: 7px; margin-top: 12px; color: #6d756b !important; font-size: 9px !important; cursor: pointer; }
.clear-key input { accent-color: var(--red); }
.credential-note { margin-top: 18px; color: var(--muted); font: 10px/1.6 var(--mono); }
.compact-launch { flex: 0 0 auto; }

.execution-heading { align-items: center; }
.execution-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.status-chip { padding: 8px 10px; border: 1px solid currentColor; font: 9px var(--mono); letter-spacing: .12em; }
.status-chip.running, .status-chip.queued, .status-chip.stopping { color: var(--amber); }
.status-chip.completed { color: var(--green); }
.status-chip.failed, .status-chip.interrupted, .status-chip.stopped { color: var(--red); }
.danger-button { border-color: rgba(255,98,87,.5); color: var(--red); }
.danger-button:hover { background: rgba(255,98,87,.1); }
.download-button { border-color: rgba(200,255,61,.5); color: var(--acid); }
.execution-stats { display: grid; grid-template-columns: 1.3fr repeat(3,1fr); border-bottom: 1px solid var(--line); }
.execution-stats div { padding: 18px 24px; border-right: 1px solid var(--line); min-width: 0; }
.execution-stats div:last-child { border-right: 0; }
.execution-stats span { color: var(--muted); display: block; font: 9px var(--mono); letter-spacing: .08em; }
.execution-stats strong { display: block; margin-top: 7px; overflow: hidden; text-overflow: ellipsis; font: 14px var(--mono); }
.terminal-wrap { margin: 24px; border: 1px solid #c9c5ba; background: #f8f6ef; }
.terminal-bar { height: 38px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-bottom: 1px solid #d8d4c9; background: #eeebe2; color: #697167; font: 9px var(--mono); letter-spacing: .13em; }
.terminal-bar > span { display: flex; gap: 5px; }
.terminal-bar i { width: 7px; height: 7px; border-radius: 50%; background: #a9aea5; }
.terminal-bar i:first-child { background: #cb756b; }
.terminal-bar i:nth-child(2) { background: #d9ab55; }
.terminal-bar i:nth-child(3) { background: #6ea27f; }
.terminal-bar button { border: 0; background: none; color: #626b60; cursor: pointer; font: 9px var(--mono); }
#terminal { margin: 0; padding: 18px; min-height: 290px; max-height: 460px; overflow: auto; white-space: pre-wrap; word-break: break-word; color: #2b382b; font: 11px/1.7 var(--mono); scrollbar-color: #aab1a4 #eeebe2; }

.history { margin-top: 54px; }
.section-heading { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 14px; }
.empty-state { min-height: 160px; display: grid; place-content: center; text-align: center; border: 1px dashed var(--line); color: var(--muted); }
.empty-state strong { color: #485246; font: 20px var(--display); }
.empty-state span { font: 10px var(--mono); margin-top: 8px; }
.history-list { display: grid; }
.history-item { display: grid; grid-template-columns: minmax(200px,1.3fr) .65fr .65fr .7fr auto; align-items: center; gap: 18px; padding: 17px 10px; border-bottom: 1px solid var(--line-soft); cursor: pointer; transition: background .15s; }
.history-item:hover { background: rgba(86,121,42,.07); }
.history-id strong { display: block; font: 12px var(--mono); }
.history-id span, .history-cell span { color: var(--muted); font: 9px var(--mono); }
.history-cell strong { display: block; margin-top: 4px; font: 13px var(--mono); }
.history-arrow { color: var(--acid); font-size: 18px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: min(420px, calc(100vw - 48px)); padding: 13px 16px; background: #e7efd5; color: #263421; border: 1px solid #9caf7a; font: 11px/1.5 var(--mono); box-shadow: 8px 8px 0 rgba(86,121,42,.18); transform: translateY(30px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }

.link-button { display: inline-block; }
.manage-workspace { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 58px 0 90px; }
.manage-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 42px; }
.manage-hero h2 { margin: 7px 0 10px; font: 400 clamp(42px, 7vw, 74px)/.9 var(--display); letter-spacing: -.045em; }
.manage-hero p { margin: 0; color: var(--muted); font: 11px var(--mono); }
.registry-count { min-width: 150px; border-left: 1px solid var(--acid); padding: 10px 0 8px 20px; }
.registry-count span { display: block; color: var(--muted); font: 9px var(--mono); letter-spacing: .13em; }
.registry-count strong { display: block; margin-top: 5px; color: var(--acid); font: 42px var(--display); }
.user-create-panel { padding-bottom: 24px; }
.create-user-form { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 18px; align-items: end; padding: 24px 25px 0; }
.user-create-panel > .form-error { margin-left: 25px; margin-right: 25px; }
.user-registry { margin-top: 54px; }
.users-list { display: grid; }
.user-card { display: grid; grid-template-columns: minmax(220px,1fr) minmax(300px,.9fr) auto; align-items: center; gap: 22px; border-bottom: 1px solid var(--line-soft); padding: 18px 10px; }
.user-card.disabled { opacity: .58; }
.user-identity { min-width: 0; }
.user-identity strong, .user-identity small { display: block; }
.user-identity strong { margin-top: 5px; font: 18px var(--mono); overflow: hidden; text-overflow: ellipsis; }
.user-identity small { margin-top: 6px; color: var(--muted); font: 9px var(--mono); }
.user-state { color: var(--green); font: 8px var(--mono); letter-spacing: .16em; }
.user-card.disabled .user-state { color: var(--red); }
.reset-form { display: grid; grid-template-columns: 1fr auto; }
.reset-form input { min-width: 0; border: 1px solid var(--line); border-right: 0; background: #fffefb; color: var(--paper); outline: 0; padding: 0 12px; font: 11px var(--mono); }

@keyframes reveal { from { opacity: 0; transform: scale(.98) translateY(12px); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes pulse { 50% { opacity: .45; box-shadow: 0 0 4px var(--acid); } }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .rail { display: none; }
  .source-grid { grid-template-columns: 1fr; }
  .execution-stats { grid-template-columns: 1fr 1fr; }
  .execution-stats div:nth-child(2) { border-right: 0; }
  .execution-stats div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .history-item { grid-template-columns: 1.4fr .7fr .7fr auto; }
  .history-item .cost-cell { display: none; }
  .key-grid { grid-template-columns: 1fr; }
  .user-card { grid-template-columns: 1fr auto; }
  .reset-form { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 620px) {
  .login-shell { padding: 0; }
  .login-card { min-height: 100vh; border: 0; padding: 34px 24px; }
  .login-card h1 { margin-top: 90px; font-size: 68px; }
  .login-card footer { left: 24px; right: 24px; }
  .login-fields { grid-template-columns: 1fr; gap: 16px; }
  .input-row { grid-template-columns: 1fr; }
  .input-row button { padding: 13px 0; text-align: left; }
  .topbar { height: 68px; padding: 0 16px; }
  .brand small, .system-state { display: none; }
  .content { padding: 30px 14px 60px; }
  .page-heading { align-items: center; }
  .page-heading h2 { font-size: 39px; }
  .primary-action { padding: 12px; }
  .composer form, .panel-heading { padding: 18px; }
  .route-row { grid-template-columns: 1fr; }
  .composer-footer { align-items: stretch; flex-direction: column; }
  .launch-button { justify-content: space-between; }
  .execution-actions { align-items: flex-end; }
  .execution-stats { grid-template-columns: 1fr; }
  .execution-stats div { border-right: 0; border-bottom: 1px solid var(--line); }
  .terminal-wrap { margin: 12px; }
  #terminal { min-height: 240px; max-height: 55vh; }
  .history-item { grid-template-columns: 1fr auto; }
  .history-item .history-cell { display: none; }
  .current-user { display: none; }
  .topbar-actions { gap: 8px; }
  .manage-workspace { width: calc(100% - 28px); padding-top: 34px; }
  .manage-hero { align-items: flex-start; flex-direction: column; }
  .create-user-form { grid-template-columns: 1fr; padding: 20px 18px 0; }
  .user-card { grid-template-columns: 1fr; padding: 18px 4px; }
  .reset-form { grid-column: auto; grid-row: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
