:root {
  --ink: #f3f6f0;
  --muted: #9da79f;
  --panel: rgba(19, 24, 22, .9);
  --panel-2: #191f1c;
  --line: #303934;
  --lime: #b9f252;
  --lime-dark: #7ca929;
  --orange: #ff9b54;
  --red: #ff7070;
  --bg: #0d110f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: radial-gradient(circle at 80% -10%, #293724 0, transparent 32rem), var(--bg); }
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.noise { position: fixed; inset: 0; opacity: .035; pointer-events: none; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E"); z-index: 10; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.login-card { width: min(100%, 29rem); padding: 3rem; border: 1px solid var(--line); background: rgba(18, 23, 20, .94); box-shadow: 0 24px 80px #0008; position: relative; }
.login-card::before { content: ""; position: absolute; inset: -1px auto auto -1px; height: 3px; width: 36%; background: var(--lime); }
.brand-mark { width: 3.1rem; height: 3.1rem; border: 1px solid #465047; display: flex; align-items: flex-end; gap: 4px; padding: 9px; margin-bottom: 2.1rem; transform: rotate(-3deg); }
.brand-mark span { flex: 1; background: var(--lime); }
.brand-mark span:nth-child(1) { height: 45%; }.brand-mark span:nth-child(2) { height: 95%; }.brand-mark span:nth-child(3) { height: 67%; }
.eyebrow, .section-number { color: var(--lime); letter-spacing: .14em; text-transform: uppercase; font-size: .72rem; font-weight: 750; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.5rem); letter-spacing: -.045em; line-height: 1.04; margin-bottom: 1rem; }
h2 { font-size: 1.35rem; margin-bottom: .25rem; }
.lede { color: var(--muted); line-height: 1.65; margin-bottom: 2rem; }
label { color: #c8cec9; display: block; font-size: .78rem; font-weight: 700; margin: 1rem 0 .5rem; }
input, textarea, select { width: 100%; color: var(--ink); background: #0f1411; border: 1px solid #3a433e; outline: none; transition: border-color .16s, box-shadow .16s; }
input { padding: .85rem 1rem; }
textarea { resize: vertical; min-height: 10rem; padding: 1.25rem; line-height: 1.55; border: 0; background: transparent; }
select { padding: .7rem 2.4rem .7rem .85rem; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--lime) 50%), linear-gradient(135deg, var(--lime) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, textarea:focus, select:focus { border-color: var(--lime); box-shadow: 0 0 0 3px #b9f25218; }
textarea:disabled, select:disabled { cursor: wait; color: #89938c; }
.form-error { color: var(--red); min-height: 1.3rem; font-size: .82rem; margin: .8rem 0; }
.security-note { color: #68736b; text-align: center; font-size: .72rem; margin: 1.5rem 0 0; }

button { border: 0; padding: .75rem 1rem; font-weight: 750; transition: transform .15s, background .15s, opacity .15s; }
button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { cursor: wait; opacity: .5; }
.primary { background: var(--lime); color: #11180d; }
.primary:hover:not(:disabled) { background: #cbff68; }
.wide { width: 100%; display: flex; justify-content: space-between; }
.secondary { color: var(--ink); background: transparent; border: 1px solid #424b46; }
.secondary.accent { border-color: #6f8d3e; color: #d9ff93; }
.secondary.danger { border-color: #874949; color: #ffadad; }
.quiet { color: var(--muted); background: transparent; padding: .6rem; }
.nav-link { text-decoration: none; font-size: .78rem; font-weight: 750; }
.nav-link:hover { color: var(--lime); }

.app-shell { min-height: 100vh; }
.topbar { height: 4.8rem; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(1rem, 4vw, 4rem); border-bottom: 1px solid var(--line); background: #0e1210dd; backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 5; }
.brand { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: .8rem; letter-spacing: -.02em; }
.brand strong { color: var(--lime); }
.brand-mark.small { width: 1.8rem; height: 1.8rem; padding: 5px; margin: 0; gap: 2px; }
.topbar-actions, .systems, .user-chip { display: flex; align-items: center; }
.topbar-actions { gap: 1.3rem; }
.systems { gap: 1rem; color: var(--muted); font-size: .72rem; padding-right: 1.3rem; border-right: 1px solid var(--line); }
.status-dot { display: inline-block; width: 7px; height: 7px; background: #59635d; border-radius: 50%; margin-right: .4rem; box-shadow: 0 0 0 3px #ffffff08; }
.status-dot.online { background: var(--lime); box-shadow: 0 0 0 3px #b9f25218; }
.status-dot.offline { background: var(--red); }
.user-chip { gap: .6rem; }
.user-chip > span { width: 2rem; height: 2rem; display: grid; place-items: center; color: #1a210f; background: #d9ff93; font-weight: 850; }
.user-chip b, .user-chip small { display: block; font-size: .76rem; }
.user-chip small { color: var(--muted); text-transform: capitalize; margin-top: .1rem; }

.workspace { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 4.5rem 0 5rem; }
.hero-row { display: grid; grid-template-columns: 1fr 18rem; gap: 4rem; align-items: end; margin-bottom: 3rem; }
.hero-row h1 { max-width: 13ch; }
.hero-row p:not(.eyebrow) { color: var(--muted); max-width: 44rem; line-height: 1.6; }
.project-control { border-left: 2px solid var(--lime); padding-left: 1rem; }
.project-control label { margin-top: 0; }
.project-control span { display: block; color: #6f7972; font-size: .68rem; margin-top: .45rem; }

.command-card, .run-card, .codex-auth-card { background: var(--panel); border: 1px solid var(--line); }
.codex-auth-card { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.codex-auth-actions { display: flex; gap: .55rem; }
.codex-auth-message { grid-column: 1 / -1; margin: 0; }
.codex-auth-message:empty { display: none; }
.codex-auth-summary { display: flex; align-items: center; gap: .9rem; }
.codex-auth-summary .section-number { margin-bottom: .2rem; }
.codex-auth-summary h2 { margin: 0; font-size: 1rem; }
.codex-auth-summary p:last-child { color: var(--muted); font-size: .76rem; margin: .3rem 0 0; }
.auth-indicator { width: 12px; height: 12px; flex: 0 0 auto; border-radius: 50%; background: #667168; box-shadow: 0 0 0 5px #ffffff08; }
.auth-indicator.connected { background: var(--lime); box-shadow: 0 0 0 5px #b9f25218; }
.auth-indicator.disconnected { background: var(--red); box-shadow: 0 0 0 5px #ff707018; }
.auth-indicator.connecting { border: 2px solid #667168; border-top-color: var(--lime); background: transparent; animation: spin .8s linear infinite; }
.codex-login-flow { grid-column: 1 / -1; padding-top: 1rem; border-top: 1px solid var(--line); }
.codex-login-instruction { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.codex-login-instruction p { color: var(--muted); font-size: .78rem; line-height: 1.5; margin: 0; }
.login-link { display: inline-block; white-space: nowrap; padding: .65rem .85rem; text-decoration: none; font-size: .76rem; }
#codex-login-output { margin: 1rem 0 0; padding: 1rem; max-height: 13rem; overflow: auto; white-space: pre-wrap; word-break: break-word; color: #dbe8dc; background: #0b0f0d; border: 1px solid #29312c; font: .78rem/1.6 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
#codex-login-message { margin-bottom: 0; }
.command-card { box-shadow: 0 24px 65px #0004; }
.command-card.is-running { border-color: #718847; box-shadow: 0 0 0 1px #b9f25218, 0 24px 65px #0004; }
.card-title-row, .section-heading, .run-header { display: flex; justify-content: space-between; align-items: center; }
.card-title-row { padding: 1.4rem 1.5rem; border-bottom: 1px solid var(--line); }
.section-number { margin-bottom: .35rem; color: #82927f; }
.auto-badge { color: #cce99b; background: #b9f25210; border: 1px solid #b9f2523a; padding: .35rem .55rem; font-size: .67rem; text-transform: uppercase; letter-spacing: .08em; }
.auto-badge i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--lime); margin-right: .35rem; }
.prompt-footer { display: flex; align-items: center; justify-content: space-between; padding: .8rem; border-top: 1px solid var(--line); }
.prompt-footer > span { color: #77827a; font-size: .72rem; padding-left: .5rem; }
.run-card { margin-top: 1rem; }
.run-header { padding: .9rem 1rem; border-bottom: 1px solid var(--line); font-size: .78rem; }
.run-header > div { display: flex; align-items: center; gap: .65rem; }
.run-meta { display: flex; align-items: center; gap: 1rem; }
#run-time { color: var(--muted); }
.deployment-link { color: var(--lime); font-weight: 700; text-decoration: none; }
.deployment-link:hover { text-decoration: underline; }
.spinner { width: 10px; height: 10px; border: 2px solid #667168; border-top-color: var(--lime); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.done { border: 0; background: var(--lime); animation: none; }
.spinner.failed { border: 0; background: var(--red); animation: none; }
@keyframes spin { to { transform: rotate(360deg); } }
#run-output { margin: 0; padding: 1rem; max-height: 27rem; overflow: auto; white-space: pre-wrap; word-break: break-word; color: #c8d2ca; background: #0b0f0d; font: .76rem/1.6 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.images-section { margin-top: 5rem; }
.section-heading { margin-bottom: 1.5rem; }
.section-heading p:last-child { color: var(--muted); margin: .4rem 0 0; }
.section-heading code { color: #d7f6a1; font-size: .72rem; }
.image-actions { display: flex; gap: .55rem; }
.inline-message { color: var(--muted); min-height: 1.2rem; font-size: .8rem; }
.inline-message.error { color: var(--red); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: .78rem; }
th { color: #87928a; text-align: left; text-transform: uppercase; letter-spacing: .1em; font-size: .65rem; background: #141916; }
th, td { padding: .95rem 1rem; border-bottom: 1px solid #29312c; }
tbody tr:last-child td { border-bottom: 0; }
td:first-child { color: #e5ffb4; font-family: ui-monospace, monospace; font-weight: 700; }
.empty { color: var(--muted) !important; font-family: inherit !important; text-align: center; padding: 2rem; }
.harbor-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .45rem; border: 1px solid #3a443d; color: var(--muted); }
.harbor-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #6c766f; }
.harbor-pill.pushed { color: #d7f6a1; border-color: #56752c; }.harbor-pill.pushed::before { background: var(--lime); }
.harbor-pill.local-only::before { background: var(--orange); }
.harbor-pill.unknown::before { background: #87918b; }
footer { display: flex; justify-content: space-between; color: #59625d; font-size: .68rem; border-top: 1px solid var(--line); padding: 1.25rem clamp(1rem, 4vw, 4rem); }

.logs-workspace { width: min(1080px, calc(100% - 2rem)); margin: 0 auto; padding: 4rem 0 5rem; }
.logs-heading { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 2rem; }
.logs-heading h1 { margin-bottom: .6rem; }
.logs-heading p:last-child { color: var(--muted); margin-bottom: 0; }
.log-list { display: grid; gap: .75rem; }
.log-entry { border: 1px solid var(--line); background: var(--panel); }
.log-entry summary { display: grid; grid-template-columns: 10rem minmax(12rem, 1fr) 8rem; align-items: center; gap: 1rem; padding: 1rem 1.15rem; cursor: pointer; list-style: none; }
.log-entry summary::-webkit-details-marker { display: none; }
.log-entry summary::after { content: "+"; color: var(--lime); font-size: 1.2rem; justify-self: end; }
.log-entry[open] summary::after { content: "−"; }
.log-time { color: var(--muted); font-size: .72rem; }
.log-action { font-weight: 750; }
.log-status { color: #d7f6a1; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; }
.log-status.failed, .log-status.cancelled { color: var(--red); }
.log-content { border-top: 1px solid var(--line); padding: 1rem 1.15rem; }
.log-meta { color: var(--muted); font-size: .72rem; margin-bottom: .8rem; }
.log-content h3 { color: #87928a; font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; margin: 1rem 0 .45rem; }
.log-content pre { margin: 0; padding: .85rem; max-height: 28rem; overflow: auto; white-space: pre-wrap; word-break: break-word; color: #c8d2ca; background: #0b0f0d; font: .75rem/1.55 ui-monospace, monospace; }
.logs-message { color: var(--muted); padding: 3rem; text-align: center; border: 1px solid var(--line); background: var(--panel); }

@media (max-width: 760px) {
  .systems, .user-chip div, #logout-button { display: none; }
  .hero-row { grid-template-columns: 1fr; gap: 1.5rem; }
  .project-control { max-width: 22rem; }
  .section-heading { align-items: flex-start; gap: 1.2rem; flex-direction: column; }
  .image-actions { width: 100%; flex-wrap: wrap; }
  .image-actions button { flex: 1; }
  .prompt-footer { align-items: flex-end; gap: 1rem; }
  .prompt-footer > span { max-width: 55%; }
  .workspace { padding-top: 3rem; }
  .codex-auth-card { grid-template-columns: 1fr; align-items: stretch; }
  .codex-auth-actions { width: 100%; }
  .codex-auth-actions button { flex: 1; }
  .codex-login-flow { grid-column: 1; }
  .codex-login-instruction { align-items: stretch; flex-direction: column; }
  .login-link { text-align: center; }
  .logs-heading { align-items: flex-start; flex-direction: column; }
  .log-entry summary { grid-template-columns: 1fr auto; }
  .log-time { grid-column: 1 / -1; }
  .log-status { display: none; }
}

@media (max-width: 460px) {
  .login-card { padding: 2rem 1.4rem; }
  .card-title-row { align-items: flex-start; gap: 1rem; }
  .auto-badge { max-width: 8rem; }
  .image-actions button { flex-basis: 45%; }
}
