/* Design tokens lifted from the Claude Design handoff
   (design-chat-ticket-management-interface). Every colour here appears
   literally in those prototypes; nothing was invented. */

:root {
  --bg:        #08090C;  /* page */
  --panel:     #0E1116;  /* rail, cards */
  --surface:   #151A21;  /* inputs, hover, chips */
  --line:      #1F252E;  /* hairline border */
  --line-2:    #2C3440;  /* emphasised border */

  --text:      #E4E8EF;
  --muted:     #8B94A3;
  --dim:       #566070;

  --accent:    #35D6C4;  /* flux teal */
  --red:       #FF5C57;  /* P1 / down */
  --amber:     #E3B341;  /* P2 / noisy */
  --green:     #3FCF7F;  /* healthy / resolved */
  --violet:    #A78BFA;  /* AI-authored */
  --pink:      #FF7AC6;  /* security */

  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

#root { height: 100%; }

a { color: var(--muted); text-decoration: none; }
a:hover { color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
input, select, textarea {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px 11px;
  outline: none;
  width: 100%;
}
/* A checkbox is not a text field. The rule above sets `width: 100%` and a
   9px/11px padding on EVERY input, which stretches a checkbox to fill its
   flex row and centres the glyph -- the acknowledgement rows in the security
   dialogs rendered as a lone box floating in the middle of the row, a long
   way from the sentence it belongs to. Scoped by type so nothing else moves. */
input[type=checkbox], input[type=radio] {
  width: auto; flex: none; padding: 0; margin: 0;
  accent-color: var(--accent); cursor: pointer;
}
input:focus, select:focus, textarea:focus { border-color: var(--line-2); }
input::placeholder, textarea::placeholder { color: var(--dim); }
select { appearance: none; cursor: pointer; padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%),
                    linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
textarea { resize: vertical; min-height: 72px; line-height: 1.6; }

.boot {
  height: 100%; display: flex; align-items: center; justify-content: center;
  gap: 10px; color: var(--dim); font-family: var(--mono); font-size: 12px;
}

/* ---- primitives ---- */
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }
.spacer { margin-left: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

.eyebrow {
  font-family: var(--mono); font-size: 10px; letter-spacing: .08em;
  color: var(--dim); text-transform: uppercase;
}

.card { border: 1px solid var(--line); border-radius: 4px; }
.card-pad { padding: 16px 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 4px;
  padding: 7px 13px; font-size: 13px; color: var(--text);
  white-space: nowrap; cursor: pointer;
}
.btn:hover { background: var(--surface); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn[disabled]:hover { background: none; }
.btn-primary { background: var(--text); color: var(--bg); font-weight: 600; border-color: var(--text); }
.btn-primary:hover { background: #fff; }
.btn-accent { background: var(--accent); color: var(--bg); font-weight: 600; border-color: var(--accent); }
.btn-accent:hover { filter: brightness(1.08); }
.btn-ghost { border-color: var(--line); color: var(--muted); }
.btn-danger { border-color: rgba(255,92,87,.4); color: var(--red); }
.btn-danger:hover { background: rgba(255,92,87,.1); }
.btn-sm { padding: 4px 9px; font-size: 11px; font-family: var(--mono); }

.chip {
  border: 1px solid var(--line); background: transparent; border-radius: 4px;
  padding: 5px 10px; font-size: 12px; color: var(--muted);
  cursor: pointer; white-space: nowrap;
}
.chip.on { border-color: var(--line-2); background: var(--surface); color: var(--text); }

.segment { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; flex-shrink: 0; }
.segment > * { padding: 5px 12px; font-size: 12px; white-space: nowrap; cursor: pointer; color: var(--dim); }
.segment > * + * { border-left: 1px solid var(--line); }
.segment > .on { background: var(--surface); color: var(--text); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px;
  padding: 3px 8px; border-radius: 4px;
}

.avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 10px; color: var(--muted);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ---- shell ---- */
.shell { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
.shell-body { flex: 1; display: flex; min-height: 0; position: relative; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-scroll { flex: 1; overflow: auto; }
.content { padding: 28px 28px 48px; }
.content-narrow { max-width: 1000px; margin: 0 auto; }

.topbar {
  min-height: 56px; flex-shrink: 0; display: flex; align-items: center;
  gap: 10px; padding: 0 20px; border-bottom: 1px solid var(--line);
}
.subbar {
  flex-shrink: 0; display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; border-bottom: 1px solid var(--line);
}
.hintbar {
  flex-shrink: 0; padding: 6px 28px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; color: var(--dim);
}
/* The bulk-action bar shares the hint slot but is not a hint: it is a live
   control surface, and at hintbar's 11px dim mono it read as a caption people
   did not click. The design gives it a surface, a heavier rule and real
   buttons. */
.hintbar.bulkbar {
  padding: 10px 20px; background: var(--surface); border-top: 1px solid var(--line-2);
  font-family: var(--sans); font-size: 12px; color: var(--text);
}
.hintbar.bulkbar .btn { font-family: var(--sans); font-size: 12px; padding: 6px 12px; }

.search {
  display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 10px; width: 230px;
}
.search input { background: none; border: none; padding: 6px 0; }

/* ---- rail ---- */
.rail {
  width: 220px; height: 100%; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  padding: 16px 0; overflow-y: auto;
}
.rail-brand { display: flex; align-items: center; gap: 8px; padding: 0 16px 20px; }
.rail-brand span { font-family: var(--mono); font-size: 15px; letter-spacing: -.02em; color: var(--text); }
.rail-section {
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em;
  /* The design writes these literally as WORK / INFRASTRUCTURE / ORGANISATION.
     Uppercasing in CSS rather than in the strings keeps the nav labels
     readable in the source and translatable later. */
  text-transform: uppercase; color: var(--dim); padding: 16px 8px 4px;
}
.rail-section:first-of-type { padding-top: 8px; }
.rail-link {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px;
  border-radius: 4px; font-size: 13px; color: var(--muted); cursor: pointer;
}
.rail-link:hover { background: var(--surface); color: var(--text); }
.rail-link.on { background: var(--surface); color: var(--text); }
.rail-link svg { flex-shrink: 0; opacity: .9; }
.rail-count { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--dim); }
.rail-pill {
  margin-left: auto; min-width: 15px; height: 15px; border-radius: 8px;
  background: var(--red); color: var(--bg); font-family: var(--mono);
  font-size: 9px; font-weight: 600; display: flex; align-items: center;
  justify-content: center; padding: 0 4px;
}
.rail-foot { margin-top: auto; padding: 12px 16px 0; border-top: 1px solid var(--line); }

/* ---- status bar ---- */
.statusbar {
  height: 24px; width: 100%; flex-shrink: 0; background: var(--panel);
  border-top: 1px solid var(--line); display: flex; align-items: center;
  gap: 16px; padding: 0 12px; overflow: hidden;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.statusbar span { white-space: nowrap; flex-shrink: 0; }

/* ---- tables / rows ---- */
.rows { border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.trow {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  border-top: 1px solid var(--surface); background: var(--panel);
  color: var(--text); cursor: pointer;
}
.rows > .trow:first-child { border-top: none; }
/* The event stream wraps each row so it can expand in place underneath. The
   wrapper must not break the "no rule above the first row" rule. */
.rows > .erow:first-child > .trow { border-top: none; }
.trow:hover { background: var(--surface); }
.trow.sel { background: rgba(53,214,196,.06); }
/* Keyboard cursor. A left rule rather than a background, so it reads as
   "you are here" without competing with .sel, which means "this is chosen". */
.trow.cursor { box-shadow: inset 2px 0 0 var(--accent); }

.group-head { display: flex; align-items: center; gap: 8px; padding: 6px 2px; }
.group-head b { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.group-head .n { font-family: var(--mono); font-size: 11px; color: var(--dim); }

.checkbox {
  width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line-2);
  flex-shrink: 0; cursor: pointer; background: transparent;
}
.checkbox.on { background: var(--accent); border-color: var(--accent); }

/* ---- kanban board ---- */
/* Board cards are HTML5-draggable <a> elements; the dropzone under each
   column header is the drag target. Both react to the same gesture so the
   affordance reads as one system rather than a card floating over a static
   column. */
.board-card {
  display: block; background: var(--panel); border: 1px solid var(--line);
  border-radius: 0 4px 4px 0; padding: 11px 12px; color: var(--text);
  cursor: grab; transition: background .12s ease, opacity .12s ease, border-color .12s ease;
}
.board-card:hover { background: var(--surface); }
.board-card:active { cursor: grabbing; }
/* Dimmed rather than hidden -- a dragged card that vanishes from its column
   makes the column look one item shorter mid-gesture, which reads as the
   drop having already happened. */
.board-card.dragging { opacity: .35; }

.board-dropzone {
  border-radius: 4px; transition: background-color .12s ease, box-shadow .12s ease;
}
.board-dropzone.drag-over {
  background: rgba(53,214,196,.05);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.board-dropzone .empty { transition: border-color .12s ease, color .12s ease; height: 100%; }
.board-dropzone.drag-over .empty { border-color: var(--accent); color: var(--accent); }
/* A column with nothing in it and somewhere it can still be used from ("open"
   dropped into "P1 only", say) reads as inert otherwise -- a faint permanent
   tint says "this is a target" before the person even starts dragging. */
.board-dropzone.empty-target { background: rgba(139,148,163,.025); }
.board-dropzone.empty-target .empty { border-style: dashed; }

/* ---- log / code ---- */
.logbox {
  background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  font-family: var(--mono); font-size: 12px; line-height: 1.7; overflow-x: auto;
}
.logline { display: flex; gap: 12px; padding: 1px 10px; border-left: 2px solid transparent; white-space: pre; }
.logline .no { color: var(--dim); width: 34px; text-align: right; flex-shrink: 0; }
.logline .ts { color: var(--dim); flex-shrink: 0; }
.logline.hit { background: rgba(255,92,87,.07); border-left-color: var(--red); color: var(--text); }

.codeblock {
  display: flex; align-items: flex-start; gap: 10px; background: var(--bg);
  border: 1px solid var(--line); border-left: 2px solid var(--green);
  border-radius: 0 4px 4px 0; padding: 9px 10px; margin-top: 8px;
}
.codeblock code {
  flex: 1; font-family: var(--mono); font-size: 12px; color: var(--green);
  white-space: pre-wrap; word-break: break-word;
}

.meter { height: 4px; background: var(--surface); border-radius: 2px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--muted); border-radius: 2px; }

/* ---- toast / modal ---- */
#toast-root { position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 14px; background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 4px; padding: 10px 14px;
  font-size: 13px; animation: toast-in .2s ease-out;
}
.toast.err { border-color: rgba(255,92,87,.5); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* A dialog taller than the viewport used to run off the bottom of the screen
   with its footer -- i.e. its Confirm and Cancel buttons -- unreachable, and
   nothing scrolled: the scrim is `position: fixed` and `.modal` had no height
   bound. Any dialog with more than a few paragraphs hit it (the security
   ones, which have to explain what they are about to do to a production box,
   hit it first). The fix bounds the modal to the viewport and scrolls the
   BODY, so the title and the buttons stay pinned and visible. */
.modal-scrim {
  position: fixed; inset: 0; background: rgba(8,9,12,.72); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center;
  padding: min(110px, 7vh) 16px min(40px, 4vh);
}
.modal {
  width: 480px; max-width: calc(100vw - 32px); background: var(--panel);
  border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden;
  /* Bounded by whatever the scrim's padding left over. */
  max-height: 100%; display: flex; flex-direction: column; min-height: 0;
}
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 14px; font-weight: 600; flex: none; }
.modal .body { padding: 18px; overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.modal footer { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex: none; }

/* ---- misc ---- */
.empty {
  border: 1px dashed var(--line); border-radius: 4px; padding: 30px 16px;
  font-family: var(--mono); font-size: 12px; color: var(--dim); text-align: center;
}
.field { margin-bottom: 14px; }
.field > label { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: .06em; color: var(--dim); margin-bottom: 6px; text-transform: uppercase; }
.field .help { font-size: 11px; color: var(--dim); margin-top: 5px; line-height: 1.5; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; }
.tile .k { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; color: var(--dim); text-transform: uppercase; }
.tile .v { font-family: var(--mono); font-size: 22px; margin-top: 6px; }
.tile .s { font-size: 11px; color: var(--dim); margin-top: 3px; }

.band { border: 1px solid var(--line-2); border-left: 3px solid var(--muted); border-radius: 0 4px 4px 0; padding: 20px 24px; margin-bottom: 16px; }
.band.critical { border-left-color: var(--red); }
.band.degraded { border-left-color: var(--amber); }
.band.ok { border-left-color: var(--green); }

.auth-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 400px; max-width: 100%; }
.auth-box { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 28px; }

@keyframes ecg-sweep { from { stroke-dashoffset: 1200; } to { stroke-dashoffset: 0; } }
@keyframes led-ok { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes led-warn { 0%,100% { opacity: .85; } 50% { opacity: .35; } }

/* --- incident LEDs -------------------------------------------------------
 *
 * These belong to the SECOND lamp on the chassis, never the first.
 *
 * The first lamp answers "is the agent alive" — that is the whole reason the
 * fleet view exists, and its three states (ok / warn / dead) are already spent.
 * A P1 is a different axis: the box can be reporting perfectly and still be on
 * fire. Overloading one lamp with both would mean a green box that starts
 * flashing red is ambiguous — did the agent die, or did the app break? Real
 * hardware solved this long ago with a power lamp and a separate fault lamp,
 * and that is what the chassis drawing already had room for: a second circle
 * that was permanently dark.
 *
 * P1 is deliberately faster and harsher than anything else on the screen —
 * it is the only thing allowed to be urgent, so urgency keeps its meaning.
 * P2 is slower and amber: present, not shouting.
 */
@keyframes led-p1 {
  0%, 100% { opacity: 1; }
  45%      { opacity: .15; }
  55%      { opacity: .15; }
}
@keyframes led-p2 { 0%,100% { opacity: .9; } 50% { opacity: .25; } }

/* The halo. A 3.4px lamp on a 96px chassis is not enough to catch an eye
 * crossing a wall-mounted dashboard, and "grab attention" was the requirement.
 * Only P1 gets one — if two severities both pulled focus, neither would. */
@keyframes fault-halo {
  0%   { r: 4;  opacity: .55; }
  70%  { r: 13; opacity: 0; }
  100% { r: 13; opacity: 0; }
}
@keyframes blink { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 12px; height: 12px; border: 1.5px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* Ticket-detail terminal + AI panel animations, from the design handoff. */
@keyframes live-dot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes scanline { 0% { top: -40px; } 100% { top: 100%; } }
