/* Accordemy Command Center
   Palette carried over from the developer response document so the tool and the
   paperwork read as one project: navy ink, teal accent, semantic status colours
   kept separate from the accent so "needs attention" never competes with
   "this is a link". */

:root {
  --ground:      #f4f5f8;
  --surface:     #ffffff;
  --surface-2:   #eceef3;
  --line:        #d5d9e2;
  --line-soft:   #e4e7ee;
  --ink:         #141b2b;
  --ink-2:       #414b62;
  --ink-3:       #6d7689;
  --accent:      #0d6a76;
  --accent-2:    #e2f0f1;
  --good:        #1b6650;
  --good-2:      #e0efe8;
  --warn:        #8f5c0d;
  --warn-2:      #f7ecd9;
  --risk:        #96382f;
  --risk-2:      #f8e6e3;
  --radius:      6px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground:    #0f131d;
    --surface:   #171d2a;
    --surface-2: #1e2532;
    --line:      #2e3646;
    --line-soft: #252c3a;
    --ink:       #e3e7f0;
    --ink-2:     #a8b0c2;
    --ink-3:     #7b8497;
    --accent:    #4fb2bd;
    --accent-2:  #14313a;
    --good:      #5fbf9c;
    --good-2:    #133029;
    --warn:      #d3a055;
    --warn-2:    #322715;
    --risk:      #e08a80;
    --risk-2:    #33191a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---------------- topbar ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .75rem 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .75rem; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 5px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--ink));
}
.brand h1 { font-size: .98rem; font-weight: 650; margin: 0; letter-spacing: -.01em; }
.brand p { margin: 0; font-size: .74rem; color: var(--ink-3); }

.health {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .04em;
  padding: .25rem .6rem; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.health.ok   { background: var(--good-2); color: var(--good); border-color: transparent; }
.health.bad  { background: var(--risk-2); color: var(--risk); border-color: transparent; }

/* ---------------- shell ---------------- */
.shell { display: grid; grid-template-columns: 268px 1fr; min-height: calc(100vh - 49px); }
@media (max-width: 820px) { .shell { grid-template-columns: 1fr; } }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 1rem .75rem; overflow-y: auto;
}
.sidebar-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 .5rem .6rem;
}
.sidebar-head h2 { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-3); margin: 0; font-weight: 600; }
.count { font-family: var(--mono); font-size: .7rem; color: var(--ink-3); }

.dept {
  font-family: var(--mono); font-size: .64rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3);
  padding: .9rem .5rem .3rem;
}
.agent-btn {
  display: flex; align-items: center; gap: .55rem; width: 100%;
  background: none; border: 0; text-align: left; cursor: pointer;
  padding: .45rem .5rem; border-radius: var(--radius); color: var(--ink-2);
}
.agent-btn:hover { background: var(--surface-2); }
.agent-btn.on { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.agent-btn .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ink-3); }
.agent-btn .dot.active  { background: var(--good); }
.agent-btn .dot.blocked { background: var(--warn); }
.agent-btn .nm { flex: 1; display: flex; flex-direction: column; gap: .05rem; }
.agent-btn .persona { font-size: .875rem; line-height: 1.25; }
.agent-btn .role {
  font-size: .7rem; color: var(--ink-3); line-height: 1.25;
}
.agent-btn.on .role { color: var(--accent); opacity: .8; }

.role-tag {
  font-size: .82rem; color: var(--ink-3); font-weight: 400;
  border-left: 1px solid var(--line); padding-left: .6rem;
}

/* ---------------- main ---------------- */
.main { padding: 1.25rem 1.5rem 3rem; max-width: 1000px; }

.agent-head { padding-bottom: .9rem; }
.agent-title { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.agent-title h2 { margin: 0; font-size: 1.3rem; letter-spacing: -.015em; }
.agent-meta { margin: .35rem 0 0; font-size: .8rem; color: var(--ink-3); font-family: var(--mono); }

.pill {
  font-family: var(--mono); font-size: .64rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  padding: .16rem .45rem; border-radius: 3px;
  background: var(--surface-2); color: var(--ink-2);
}
.pill.active  { background: var(--good-2); color: var(--good); }
.pill.blocked { background: var(--warn-2); color: var(--warn); }
.pill.edited  { background: var(--accent-2); color: var(--accent); }

.blocked-help {
  margin: .5rem 0 0; font-size: .82rem; color: var(--ink-3); max-width: 62ch;
}

.blocked-note {
  margin: .8rem 0 0; padding: .7rem .9rem; font-size: .85rem;
  background: var(--warn-2); color: var(--warn);
  border-radius: var(--radius); border-left: 3px solid var(--warn);
}

/* ---------------- tabs ---------------- */
.tabs { display: flex; gap: .15rem; border-bottom: 1px solid var(--line); margin: .25rem 0 1.1rem; flex-wrap: wrap; }
.tabs button {
  background: none; border: 0; cursor: pointer; color: var(--ink-3);
  padding: .55rem .75rem; font-size: .87rem; border-bottom: 2px solid transparent;
  display: flex; align-items: center; gap: .4rem;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.badge {
  font-family: var(--mono); font-size: .62rem; font-weight: 700;
  background: var(--risk); color: #fff; border-radius: 999px; padding: .05rem .38rem;
}

.panel { display: none; }
.panel.on { display: block; }
.panel-intro { font-size: .87rem; color: var(--ink-2); margin: 0 0 1rem; max-width: 62ch; }

/* ---------------- forms ---------------- */
.field { display: block; margin-bottom: .7rem; }
.label { display: block; font-size: .74rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-3); font-weight: 600; margin-bottom: .35rem; }

textarea, input[type=text], input:not([type]) {
  width: 100%; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .6rem .7rem; resize: vertical;
}
#instructions { font-family: var(--mono); font-size: .82rem; line-height: 1.6; }

.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }
.task-new input { flex: 1; min-width: 180px; }

button.primary {
  background: var(--accent); color: #fff; border: 0; cursor: pointer;
  padding: .5rem 1.05rem; border-radius: var(--radius); font-weight: 600;
}
button.primary:disabled { opacity: .5; cursor: not-allowed; }
button.ghost {
  background: var(--surface); color: var(--ink-2); cursor: pointer;
  border: 1px solid var(--line); padding: .45rem .8rem; border-radius: var(--radius);
}
button.ghost:hover { border-color: var(--accent); color: var(--accent); }
.check { display: flex; align-items: center; gap: .35rem; font-size: .82rem; color: var(--ink-2); }
.hint { font-size: .8rem; color: var(--ink-3); }
.hint.err { color: var(--risk); }
.hint.ok  { color: var(--good); }

/* ---------------- model choices ---------------- */
.choices { display: flex; flex-direction: column; gap: .7rem; margin-bottom: .6rem; }
.choice {
  display: grid; grid-template-columns: 1.4rem 1fr; gap: .1rem .8rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1.05rem; cursor: pointer;
  align-items: start;
}
.choice:hover { border-color: var(--accent); }
.choice.on { border-color: var(--accent); background: var(--accent-2); }
.choice input { margin: .25rem 0 0; }
.choice .hd { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem; }
.choice .lb { font-weight: 600; font-size: .98rem; }
.choice .price {
  font-family: var(--mono); font-size: .72rem; color: var(--accent);
  background: var(--surface-2); padding: .1rem .45rem; border-radius: 3px;
}
.choice.on .price { background: var(--surface); }
.choice .sm { grid-column: 2; font-size: .88rem; color: var(--ink-2); margin-top: .25rem; }
.choice .cau { grid-column: 2; font-size: .82rem; color: var(--ink-3); margin-top: .25rem; }
.choice .cur {
  font-family: var(--mono); font-size: .62rem; text-transform: uppercase;
  letter-spacing: .07em; background: var(--good-2); color: var(--good);
  padding: .12rem .4rem; border-radius: 3px;
}

/* ---------------- run ---------------- */
.run { margin-top: 1.1rem; border: 1px solid var(--line); border-radius: var(--radius);
       background: var(--surface); overflow: hidden; }
.run-head {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .9rem; border-bottom: 1px solid var(--line-soft); background: var(--surface-2);
}
.status {
  font-family: var(--mono); font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; padding: .16rem .5rem; border-radius: 3px;
  background: var(--accent-2); color: var(--accent);
}
.status.completed { background: var(--good-2); color: var(--good); }
.status.error, .status.refused { background: var(--risk-2); color: var(--risk); }
.status.waiting_approval { background: var(--warn-2); color: var(--warn); }
.status.running::after { content: "…"; }
.run-meta { font-family: var(--mono); font-size: .72rem; color: var(--ink-3); }

.steps { list-style: none; margin: 0; padding: .5rem 0; }
.steps li { padding: .3rem .9rem .3rem 1.9rem; position: relative; font-size: .85rem; color: var(--ink-2); }
.steps li::before {
  position: absolute; left: .9rem; font-family: var(--mono); font-size: .75rem; color: var(--ink-3);
}
.steps li.thought::before { content: "·"; }
.steps li.tool { color: var(--ink); }
.steps li.tool::before { content: "→"; color: var(--accent); }

.result {
  padding: .9rem; border-top: 1px solid var(--line-soft);
  white-space: pre-wrap; font-size: .89rem; line-height: 1.6;
}

/* ---------------- lists ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: .7rem;
}
.card h4 { margin: 0 0 .2rem; font-size: .92rem; }
.card .who { font-family: var(--mono); font-size: .7rem; color: var(--ink-3); }
.card pre {
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 4px;
  padding: .6rem .7rem; overflow-x: auto; font-size: .78rem; margin: .6rem 0 0;
  white-space: pre-wrap; word-break: break-word;
}

table { border-collapse: collapse; width: 100%; font-size: .83rem; }
thead th {
  text-align: left; font-family: var(--mono); font-size: .64rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-3); padding: .45rem .6rem;
  border-bottom: 1px solid var(--line); font-weight: 600;
}
tbody td { padding: .45rem .6rem; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); vertical-align: top; }
tbody td.mono { font-family: var(--mono); font-size: .76rem; white-space: nowrap; }
.out { font-family: var(--mono); font-size: .68rem; padding: .1rem .4rem; border-radius: 3px;
       background: var(--surface-2); color: var(--ink-2); }
.out.updated, .out.completed, .out.ok, .out.sent, .out.created, .out.logged, .out.linked { background: var(--good-2); color: var(--good); }
.out.error, .out.refused, .out.failed { background: var(--risk-2); color: var(--risk); }
.out.awaiting { background: var(--warn-2); color: var(--warn); }

.empty { text-align: center; padding: 3.5rem 1rem; color: var(--ink-3); }
.empty h3 { margin: 0 0 .4rem; font-size: 1.05rem; color: var(--ink-2); font-weight: 600; }
.empty p { margin: 0; font-size: .88rem; max-width: 40ch; margin-inline: auto; }

.wrap-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
