/* Foreman — operations command console
   Aesthetic: refined industrial. Deep ink surfaces, warm amber signal color,
   per-agent accents, characterful display type. Dark by default. */

:root {
  --bg: #0c0d10;
  --bg-2: #101116;
  --surface: #16171d;
  --surface-2: #1c1e26;
  --surface-3: #23262f;
  --line: #2a2d37;
  --line-soft: #20232b;
  --text: #e9eaee;
  --text-dim: #a4a8b3;
  --text-faint: #6e7280;
  --amber: #e8a23d;
  --amber-soft: #f2c074;
  --amber-deep: #b87a1f;
  --good: #6fae5a;
  --bad: #e8728c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px -12px rgba(0,0,0,.6);
  --mono: "Spline Sans Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--body);
  background:
    radial-gradient(1200px 700px at 78% -8%, rgba(232,162,61,.06), transparent 60%),
    radial-gradient(900px 600px at 0% 100%, rgba(94,194,194,.04), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14.5px;
  line-height: 1.5;
}
button, textarea, input { font-family: inherit; }
::selection { background: rgba(232,162,61,.28); }

/* scrollbars */
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 20px; }
*::-webkit-scrollbar-thumb:hover { background: #31343f; }
*::-webkit-scrollbar-track { background: transparent; }

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; height: 58px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.015), transparent), var(--bg-2);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  color: var(--amber); font-size: 20px;
  background: radial-gradient(circle at 30% 30%, #20222b, #14151a);
  border: 1px solid var(--line); border-radius: 9px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-family: var(--display); font-weight: 800; letter-spacing: .14em; font-size: 16px; }
.brand-sub { font-size: 11px; color: var(--text-faint); letter-spacing: .02em; }
.topbar-meta { display: flex; align-items: center; gap: 10px; }
.chip {
  font-family: var(--mono); font-size: 11px; color: var(--text-dim);
  background: var(--surface); border: 1px solid var(--line);
  padding: 4px 9px; border-radius: 7px; white-space: nowrap;
}
.model-chip { color: var(--amber-soft); }
.status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-dim); }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); box-shadow: 0 0 0 0 rgba(111,174,90,.5); }
.status.online i { background: var(--good); animation: pulse 2.4s infinite; }
.status.offline i { background: var(--bad); }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(111,174,90,.5)} 70%{box-shadow:0 0 0 7px rgba(111,174,90,0)} 100%{box-shadow:0 0 0 0 rgba(111,174,90,0)} }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 264px minmax(0,1fr) 360px;
  flex: 1 1 auto; min-height: 0;
}
.rail { border-right: 1px solid var(--line); overflow-y: auto; padding: 16px 14px; background: var(--bg-2); }
.rail-right { border-right: none; border-left: 1px solid var(--line); padding: 0; display: flex; flex-direction: column; }
.rail-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.rail-title { font-family: var(--display); font-weight: 700; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--text-dim); }
.rail-hint { font-size: 10px; color: var(--text-faint); }

/* ---------- crew ---------- */
.crew-list { display: flex; flex-direction: column; gap: 7px; }
.crew {
  display: flex; gap: 11px; align-items: flex-start; padding: 10px 11px;
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; position: relative;
  transition: border-color .15s, background .15s, transform .08s;
}
.crew:hover { background: var(--surface-2); border-color: var(--line); }
.crew.active { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: var(--surface-2); }
.crew.active::before { content:""; position:absolute; left:0; top:10px; bottom:10px; width:3px; border-radius:3px; background: var(--accent); }
.crew.chief { background: linear-gradient(180deg, rgba(232,162,61,.07), var(--surface)); border-color: rgba(232,162,61,.25); }
.crew-av {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-size: 15px; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.crew-info { min-width: 0; }
.crew-name { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.crew-name b { font-weight: 700; }
.crew-role { font-size: 10px; font-family: var(--mono); color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.crew-blurb { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; line-height: 1.35; }
.crew.busy .crew-av { animation: spinpulse 1.1s ease-in-out infinite; }
@keyframes spinpulse { 0%,100%{ box-shadow:0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);} 50%{ box-shadow:0 0 0 5px transparent;} }

/* tasks */
.task-list { display: flex; flex-direction: column; gap: 6px; }
.task {
  font-size: 11.5px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line-soft); border-left: 3px solid var(--accent);
}
.task .t-agent { font-family: var(--mono); font-size: 10px; color: var(--accent); text-transform: uppercase; }
.task .t-task { color: var(--text-dim); margin-top: 2px; line-height: 1.3; }
.task.done { opacity: .6; border-left-color: var(--good); }
.empty-mini { font-size: 12px; color: var(--text-faint); padding: 8px 4px; font-style: italic; }

/* ---------- conversation ---------- */
.conversation { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.thread { flex: 1 1 auto; overflow-y: auto; padding: 26px 26px 12px; display: flex; flex-direction: column; gap: 20px; }

.intro { max-width: 640px; margin: auto; text-align: center; color: var(--text-dim); }
.intro h1 { font-family: var(--display); font-weight: 800; font-size: 30px; color: var(--text); margin: 0 0 8px; letter-spacing: -.01em; }
.intro p { margin: 0 auto 22px; max-width: 520px; }
.suggest-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.suggest {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: .15s; font-size: 13px;
}
.suggest:hover { border-color: var(--amber); background: var(--surface-2); transform: translateY(-1px); }
.suggest b { color: var(--amber-soft); display:block; font-size: 11px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }

/* messages */
.msg { display: flex; gap: 13px; max-width: 860px; animation: rise .26s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px);} to { opacity:1; transform:none;} }
.msg.user { flex-direction: row-reverse; margin-left: auto; }
.msg-av {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  font-size: 15px; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
}
.msg.user .msg-av { color: var(--text-dim); background: var(--surface-3); border-color: var(--line); }
.msg-main { min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 4px; }
.msg.user .msg-head { flex-direction: row-reverse; }
.msg-author { font-weight: 700; font-size: 12.5px; color: var(--accent); }
.msg.user .msg-author { color: var(--text); }
.msg-time { font-size: 10.5px; color: var(--text-faint); font-family: var(--mono); }
.bubble {
  background: var(--surface); border: 1px solid var(--line-soft); padding: 13px 15px;
  border-radius: 13px; border-top-left-radius: 4px; font-size: 14px; color: var(--text);
}
.msg.user .bubble { background: var(--surface-2); border-top-left-radius: 13px; border-top-right-radius: 4px; }
.bubble p { margin: 0 0 9px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 6px 0 9px; padding-left: 20px; } .bubble li { margin: 2px 0; }
.bubble code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
.bubble pre { background: var(--bg); border: 1px solid var(--line); padding: 11px; border-radius: 8px; overflow-x: auto; }
.bubble pre code { background: none; padding: 0; }
.bubble h3 { font-family: var(--display); font-size: 15px; margin: 12px 0 6px; } .bubble h3:first-child { margin-top: 0; }
.bubble strong { color: var(--amber-soft); }
.msg.user .bubble strong { color: var(--text); }
.bubble table { border-collapse: collapse; width: 100%; margin: 6px 0; font-size: 12.5px; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; }
.bubble th { background: var(--surface-2); font-family: var(--mono); font-size: 11px; }

/* inline activity chips inside the thread */
.act-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 860px;
  font-size: 12px; color: var(--text-dim); padding: 7px 12px; border-radius: 9px;
  background: var(--surface); border: 1px dashed var(--line); animation: rise .26s ease both;
}
.act-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex:0 0 auto; }
.act-chip .who { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.act-chip.spawn { border-style: solid; }
.act-chip code { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }

.thinking { display: inline-flex; gap: 4px; align-items: center; padding: 10px 14px; }
.thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); animation: blink 1.2s infinite both; }
.thinking span:nth-child(2){ animation-delay: .2s } .thinking span:nth-child(3){ animation-delay: .4s }
@keyframes blink { 0%,80%,100%{ opacity:.25; transform: translateY(0);} 40%{ opacity:1; transform: translateY(-3px);} }

/* ---------- composer ---------- */
.composer { flex: 0 0 auto; border-top: 1px solid var(--line); padding: 12px 20px 16px; background: var(--bg-2); }
.composer-target { font-size: 11.5px; color: var(--text-faint); margin: 0 4px 7px; display:flex; align-items:center; gap:7px; }
.composer-target b { color: var(--accent, var(--amber)); }
.composer-target .pill { font-family: var(--mono); font-size: 10px; padding: 2px 7px; border-radius: 20px; background: var(--surface); border:1px solid var(--line); }
.composer-inputwrap { position: relative; display: flex; align-items: flex-end; gap: 9px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 8px 8px 14px;
  transition: border-color .15s; }
.composer-inputwrap:focus-within { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(232,162,61,.1); }
#composer-input {
  flex: 1 1 auto; resize: none; background: none; border: none; color: var(--text);
  font-size: 14.5px; line-height: 1.5; max-height: 180px; outline: none; padding: 4px 0;
}
#composer-input::placeholder { color: var(--text-faint); }
.send-btn {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; border: none; cursor: pointer;
  background: var(--amber); color: #1a1206; display: grid; place-items: center; transition: .15s;
}
.send-btn:hover { background: var(--amber-soft); }
.send-btn:disabled { background: var(--surface-3); color: var(--text-faint); cursor: default; }

/* mention popup */
.mention-pop {
  position: absolute; bottom: calc(100% + 8px); left: 6px; width: 280px; z-index: 30;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow);
  overflow: hidden; padding: 5px;
}
.mention-item { display: flex; align-items: center; gap: 10px; padding: 8px 9px; border-radius: 8px; cursor: pointer; }
.mention-item:hover, .mention-item.sel { background: var(--surface-3); }
.mention-item .m-av { width: 24px; height: 24px; border-radius: 6px; display:grid; place-items:center; font-size:13px; color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.mention-item .m-name { font-size: 13px; font-weight: 600; }
.mention-item .m-id { font-family: var(--mono); font-size: 10px; color: var(--text-faint); }

/* ---------- right rail tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 12px 12px 0; flex: 0 0 auto; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; background: none; border: none; color: var(--text-faint); font-size: 12px; font-weight: 600;
  padding: 9px 6px; cursor: pointer; border-bottom: 2px solid transparent; letter-spacing: .03em;
  font-family: var(--display);
}
.tab:hover { color: var(--text-dim); }
.tab.active { color: var(--amber); border-bottom-color: var(--amber); }
.tab-body { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.tab-panel { padding: 16px 14px; }

/* pulse / KPIs */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 12px 13px; }
.kpi .k-label { font-size: 10px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); }
.kpi .k-val { font-family: var(--display); font-weight: 800; font-size: 21px; margin-top: 3px; letter-spacing: -.01em; }
.kpi.amber .k-val { color: var(--amber); }

.section-h { font-family: var(--display); font-weight: 700; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim); margin: 18px 0 9px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-bottom: 7px; font-size: 12px; }
.bar-row .b-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-dim); }
.bar-row .b-val { font-family: var(--mono); font-size: 11px; color: var(--text); }
.bar-track { grid-column: 1 / -1; height: 5px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: -3px; margin-bottom: 4px; }
.bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--amber-deep), var(--amber)); }

.spark { width: 100%; height: 58px; margin-top: 4px; }

/* ledger table */
.ledger-tools { display: flex; gap: 8px; margin-bottom: 10px; }
.ledger-search { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; color: var(--text); font-size: 12.5px; outline: none; }
.ledger-search:focus { border-color: var(--amber); }
.ltable { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.ltable th { position: sticky; top: 0; background: var(--bg-2); text-align: left; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); padding: 6px 6px; border-bottom: 1px solid var(--line); }
.ltable td { padding: 7px 6px; border-bottom: 1px solid var(--line-soft); color: var(--text-dim); vertical-align: top; }
.ltable tr:hover td { background: var(--surface); cursor: pointer; }
.ltable .c-num { font-family: var(--mono); color: var(--text); white-space: nowrap; text-align: right; }
.ltable .c-cust { color: var(--text); max-width: 120px; }
.ltable .c-edited { color: var(--amber); }
.l-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 11.5px; color: var(--text-faint); }
.pager { display: flex; gap: 6px; }
.pager button { background: var(--surface); border: 1px solid var(--line); color: var(--text-dim); border-radius: 7px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.pager button:disabled { opacity: .4; cursor: default; }

/* activity log */
.log-item { display: flex; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
.log-item .l-glyph { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.log-item .l-text { color: var(--text-dim); line-height: 1.35; }
.log-item .l-text b { color: var(--accent); font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing:.04em; }
.log-item .l-time { font-family: var(--mono); font-size: 10px; color: var(--text-faint); margin-top: 2px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(4,5,7,.62); display: grid; place-items: center; z-index: 100; backdrop-filter: blur(3px); }
.modal[hidden] { display: none; }
.modal-card { width: 440px; max-width: calc(100vw - 40px); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); font-family: var(--display); font-weight: 700; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 11px; max-height: 60vh; overflow-y: auto; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 10.5px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.field input { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; color: var(--text); font-size: 13px; outline: none; }
.field input:focus { border-color: var(--amber); }
.modal-foot { display: flex; gap: 9px; align-items: center; padding: 13px 16px; border-top: 1px solid var(--line); background: var(--bg-2); }
.icon-btn { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 15px; }
.btn { border-radius: 9px; padding: 8px 15px; font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); }
.btn.primary { background: var(--amber); color: #1a1206; border-color: var(--amber); }
.btn.primary:hover { background: var(--amber-soft); }
.btn.ghost { background: none; color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); border-color: var(--line); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 220px minmax(0,1fr); }
  .rail-right { display: none; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .rail-left { display: none; }
}

.banner {
  margin: 0 26px; padding: 10px 14px; border-radius: 10px; font-size: 12.5px;
  background: color-mix(in srgb, var(--bad) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  color: var(--amber-soft);
}

/* ---------------------------------------------------------------- auth */
.user-slot { display: inline-flex; align-items: center; gap: 10px; margin-left: 4px; }
.user-name {
  font-family: var(--mono); font-size: 12px; color: var(--text-dim);
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.logout-btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: .03em;
  color: var(--text-dim); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 5px 10px; cursor: pointer; transition: all .15s ease;
}
.logout-btn:hover { color: var(--text); border-color: var(--amber-deep); background: var(--surface-3); }

.login-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--amber) 10%, transparent), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 32px 28px;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
}
.login-mark {
  font-size: 30px; color: var(--amber); text-align: center; line-height: 1;
  text-shadow: 0 0 24px color-mix(in srgb, var(--amber) 50%, transparent);
}
.login-title {
  text-align: center; font-family: var(--mono); font-weight: 700;
  letter-spacing: .28em; font-size: 18px; color: var(--text); padding-left: .28em;
}
.login-sub { text-align: center; color: var(--text-faint); font-size: 13px; margin-top: -6px; }
.login-field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-dim); }
.login-field input {
  font-family: var(--mono); font-size: 14px; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 12px; outline: none; transition: border-color .15s ease;
}
.login-field input:focus { border-color: var(--amber-deep); }
.login-err { color: var(--amber-soft); font-size: 12px; min-height: 16px; text-align: center; }
.login-btn {
  margin-top: 4px; font-family: var(--mono); font-weight: 600; font-size: 14px;
  color: #1a1205; background: linear-gradient(180deg, var(--amber-soft), var(--amber));
  border: none; border-radius: var(--radius-sm); padding: 12px; cursor: pointer;
  transition: filter .15s ease;
}
.login-btn:hover { filter: brightness(1.06); }
.login-btn:disabled { filter: grayscale(.4) brightness(.8); cursor: default; }
