/* FibotAI panel. One stylesheet, no build step, no external resource. */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-side: #fafafa;
  --card: #ffffff;
  --border: #e6e6e8;
  --border-strong: #d4d4d8;
  --text: #0a0a0a;
  --muted: #5c5c63;
  --hover: #f3f3f4;
  --active: #ececee;
  --chip: #f4f4f5;
  --primary-bg: #0a0a0a;
  --primary-fg: #ffffff;
  --primary-hover: #26262a;
  --prompt-bg: #0a0a0a;
  --prompt-border: #0a0a0a;
  --prompt-fg: #ffffff;
  --prompt-muted: #b4b4bb;
  --danger: #c41d2a;
  --danger-bg: #fff5f5;
  --danger-border: #e5484d;
  --amber-bg: #fde4c3;
  --amber-fg: #1c1306;
  --amber-border: #f6cf99;
  --amber-soft: #fff5e8;
  --amber-strong: #b8500b;
  --amber-dot: #f08c1a;
  --green-dot: #1fa44e;
  --green-bg: #f1fbf4;
  --green-border: #8fd6a6;
  --green-fg: #14522b;
  --grey-dot: #9a9aa2;
  --red-dot: #dc2f3c;
  --bubble-in: #ededee;
  --bubble-out: #0a0a0a;
  --bubble-out-fg: #ffffff;
  --focus: #1d4ed8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --toggle-on: #ffffff;
  --toggle-track: #f1f1f2;
  --radius: 10px;
  --radius-sm: 8px;
  --sidebar: 284px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    "Noto Sans", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0b0d;
    --bg-side: #0f0f11;
    --card: #141416;
    --border: #28282c;
    --border-strong: #3a3a40;
    --text: #fafafa;
    --muted: #a5a5ad;
    --hover: #1b1b1e;
    --active: #242428;
    --chip: #1d1d20;
    --primary-bg: #fafafa;
    --primary-fg: #0a0a0a;
    --primary-hover: #dedee2;
    --prompt-bg: #18181b;
    --prompt-border: #2e2e33;
    --prompt-fg: #fafafa;
    --prompt-muted: #a5a5ad;
    --danger: #ff7a7f;
    --danger-bg: #1f1112;
    --danger-border: #b5383f;
    --amber-bg: #2f2210;
    --amber-fg: #f6bd62;
    --amber-border: #8f5e16;
    --amber-soft: #231a0d;
    --amber-strong: #f5a742;
    --amber-dot: #f5a742;
    --green-dot: #2fce6b;
    --green-bg: #0f2216;
    --green-border: #25663c;
    --green-fg: #8fe3ac;
    --grey-dot: #74747c;
    --red-dot: #ff5c66;
    --bubble-in: #222226;
    --bubble-out: #fafafa;
    --bubble-out-fg: #0a0a0a;
    --focus: #8fb4ff;
    --shadow: none;
    --toggle-on: #2a2a2f;
    --toggle-track: #141416;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0d;
  --bg-side: #0f0f11;
  --card: #141416;
  --border: #28282c;
  --border-strong: #3a3a40;
  --text: #fafafa;
  --muted: #a5a5ad;
  --hover: #1b1b1e;
  --active: #242428;
  --chip: #1d1d20;
  --primary-bg: #fafafa;
  --primary-fg: #0a0a0a;
  --primary-hover: #dedee2;
  --prompt-bg: #18181b;
  --prompt-border: #2e2e33;
  --prompt-fg: #fafafa;
  --prompt-muted: #a5a5ad;
  --danger: #ff7a7f;
  --danger-bg: #1f1112;
  --danger-border: #b5383f;
  --amber-bg: #2f2210;
  --amber-fg: #f6bd62;
  --amber-border: #8f5e16;
  --amber-soft: #231a0d;
  --amber-strong: #f5a742;
  --amber-dot: #f5a742;
  --green-dot: #2fce6b;
  --green-bg: #0f2216;
  --green-border: #25663c;
  --green-fg: #8fe3ac;
  --grey-dot: #74747c;
  --red-dot: #ff5c66;
  --bubble-in: #222226;
  --bubble-out: #fafafa;
  --bubble-out-fg: #0a0a0a;
  --focus: #8fb4ff;
  --shadow: none;
  --toggle-on: #2a2a2f;
  --toggle-track: #141416;
}

/* ------------------------------------------------------------------ base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

svg.icon {
  flex: none;
  display: block;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--primary-bg);
  color: var(--primary-fg);
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 12px;
}

.muted {
  color: var(--muted);
}

.nowrap {
  white-space: nowrap;
}

.mono {
  font-family: var(--mono);
  font-size: 0.9em;
}

/* User-written text: shown exactly as typed, never interpreted. */
.user-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- layout */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 12px 14px;
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 2px 10px 26px;
}

.brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 12px;
  background: #0a0a0a;
  color: #ffffff;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

:root[data-theme="dark"] .brand-mark {
  background: #1c1c1f;
  border: 1px solid #2e2e33;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-mark {
    background: #1c1c1f;
    border: 1px solid #2e2e33;
  }
}

.brand-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-sub {
  color: var(--muted);
  font-size: 15px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 17px;
  color: var(--text);
}

.nav-link:hover {
  background: var(--hover);
}

.nav-link[aria-current="page"] {
  background: var(--active);
  font-weight: 650;
}

.nav-link[aria-current="page"] svg.icon {
  stroke-width: 2.2;
}

.nav-link .count {
  margin-left: auto;
}

.sidebar-spacer {
  flex: 1;
  min-height: 16px;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-rule {
  height: 1px;
  margin: 8px 0 4px;
  background: var(--border);
  border: 0;
}

.theme-toggle {
  display: none;
  gap: 4px;
  padding: 5px;
  margin: 0 2px 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--toggle-track);
}

.js .theme-toggle {
  display: flex;
}

.theme-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
}

.theme-btn[aria-pressed="true"] {
  background: var(--toggle-on);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.account {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px 4px 8px;
}

.account-link {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
  min-height: 46px;
  border-radius: var(--radius-sm);
}

.account-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
}

.account-host {
  color: var(--muted);
  font-size: 13px;
}

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--active);
  color: var(--text);
  font-size: 20px;
  font-weight: 650;
  line-height: 1;
}

.avatar.sm {
  width: 44px;
  height: 44px;
  font-size: 14px;
}

.avatar.lg {
  width: 62px;
  height: 62px;
  font-size: 24px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 69px;
  padding: 0 20px 0 30px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  font-size: 17px;
  color: var(--muted);
}

.crumbs strong {
  color: var(--text);
  font-weight: 500;
}

.topbar-spacer {
  flex: 1;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  width: 254px;
  max-width: 100%;
}

.search svg.icon {
  position: absolute;
  left: 14px;
  color: var(--text);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 42px;
  padding: 0 12px 0 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-side);
  font-size: 16px;
}

.search input::placeholder,
.field input::placeholder,
.field textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

.search.wide {
  width: 100%;
}

.search.wide input {
  height: 46px;
  background: var(--card);
  border-radius: var(--radius);
}

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
}

.icon-btn:hover {
  background: var(--hover);
}

.icon-btn.bordered {
  border-color: var(--border);
  background: var(--chip);
}

.icon-btn .dot {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--bg);
  box-sizing: content-box;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--chip);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.menu-btn,
.nav-backdrop,
#nav-toggle {
  display: none;
}

.content {
  flex: 1;
  width: 100%;
  max-width: 1500px;
  padding: 26px 22px 40px 28px;
}

/* ----------------------------------------------------------- page header */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.page-title {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.12;
}

.page-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 22px;
  letter-spacing: -0.01em;
}

.page-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  padding-top: 4px;
}

.agent-state {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px 26px;
}

.state-label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  white-space: nowrap;
}

.page-date {
  color: var(--muted);
  font-size: 16px;
}

/* ------------------------------------------------------------- primitives */

.dot {
  flex: none;
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--grey-dot);
}

.dot.green {
  background: var(--green-dot);
}

.dot.amber {
  background: var(--amber-dot);
}

.dot.red {
  background: var(--red-dot);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.btn:hover {
  background: var(--hover);
}

.btn.primary {
  border-color: var(--primary-bg);
  background: var(--primary-bg);
  color: var(--primary-fg);
  font-weight: 650;
}

.btn.primary:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.btn.danger {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.btn.danger:hover {
  filter: brightness(0.97);
}

.btn.sm {
  min-height: 38px;
  padding: 0 14px;
  font-size: 15px;
  gap: 8px;
}

.btn.block {
  width: 100%;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  font-size: 15px;
  white-space: nowrap;
}

.link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link.inline {
  min-height: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
}

.count {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f6b756;
  color: #1c1306;
  font-size: 15px;
  font-weight: 650;
  line-height: 1;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  padding: 3px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  line-height: 1.25;
  white-space: nowrap;
}

.badge.amber {
  border-color: var(--amber-border);
  background: var(--amber-bg);
  color: var(--amber-fg);
}

.badge.green {
  border-color: var(--green-border);
  background: var(--green-bg);
  color: var(--green-fg);
}

.badge.grey {
  border-color: var(--border);
  background: var(--chip);
  color: var(--muted);
}

.badge.red {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.sm {
  min-height: 26px;
  padding: 2px 10px;
  font-size: 13.5px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card {
  min-width: 0;
  padding: 20px 20px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.card-note {
  color: var(--muted);
  font-size: 15px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack > .card + .card {
  margin-top: 0;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.row-actions form {
  display: contents;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 15.5px;
}

.empty svg.icon {
  color: var(--muted);
  opacity: 0.8;
}

.empty strong {
  color: var(--text);
  font-size: 16.5px;
  font-weight: 600;
}

.empty.compact {
  padding: 16px 8px;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--chip);
  font-size: 16px;
}

.notice svg.icon {
  margin-top: 1px;
}

.notice.amber {
  border-color: var(--amber-border);
  background: var(--amber-soft);
}

.notice.amber svg.icon {
  color: var(--amber-strong);
}

.notice.red {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.notice.green {
  border-color: var(--green-border);
  background: var(--green-bg);
  color: var(--green-fg);
}

.flash {
  margin-bottom: 18px;
}

.footnote {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 12px 20px;
  border-radius: var(--radius);
  background: var(--chip);
  color: var(--muted);
  font-size: 15px;
}

/* ------------------------------------------------------------------ forms */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > label,
.field > .label,
fieldset > legend {
  font-size: 15px;
  font-weight: 600;
}

.field .help {
  color: var(--muted);
  font-size: 14px;
}

.field .error {
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
}

.field input[type="text"],
.field input[type="search"],
.field input[type="password"],
.field input[type="number"],
.field input[type="datetime-local"],
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 16px;
}

.field textarea {
  min-height: 120px;
  line-height: 1.5;
  resize: vertical;
}

.field input[aria-invalid="true"],
.field select[aria-invalid="true"] {
  border-color: var(--danger-border);
}

.input-unit {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-unit input {
  max-width: 160px;
}

.input-unit span {
  color: var(--muted);
  font-size: 15px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset > legend {
  padding: 0;
  margin-bottom: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.choice + .choice {
  margin-top: 8px;
}

.choice input {
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--text);
}

.choice strong {
  display: block;
  font-weight: 600;
}

.choice span span {
  color: var(--muted);
  font-size: 14.5px;
}

.choice:has(input:checked) {
  border-color: var(--text);
  background: var(--chip);
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--chip);
}

.segmented form {
  display: contents;
}

.segmented .seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 15px;
  text-align: center;
}

.segmented .seg[aria-pressed="true"],
.segmented .seg[aria-current="true"] {
  background: var(--primary-bg);
  color: var(--primary-fg);
  font-weight: 650;
}

details.disclosure > summary {
  list-style: none;
  cursor: pointer;
}

details.disclosure > summary::-webkit-details-marker {
  display: none;
}

details.menu {
  position: relative;
}

details.menu > .menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 270px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: none;
  font-size: 15px;
  text-align: left;
}

.menu-item:hover {
  background: var(--hover);
}

.menu-item.danger {
  color: var(--danger);
}

/* --------------------------------------------------------------- dashboard */

.prompt {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 64px;
  margin-bottom: 16px;
  padding: 0 12px 0 22px;
  border: 1px solid var(--prompt-border);
  border-radius: 12px;
  background: var(--prompt-bg);
  color: var(--prompt-fg);
}

.prompt input {
  flex: 1;
  min-width: 0;
  height: 62px;
  border: 0;
  background: transparent;
  color: var(--prompt-fg);
  font-size: 17px;
  outline: none;
}

.prompt input::placeholder {
  color: var(--prompt-muted);
  opacity: 1;
}

.prompt:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.prompt button {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #ffffff;
  color: #0a0a0a;
}

.counters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.counter {
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 104px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.counter:hover {
  border-color: var(--border-strong);
}

.tile {
  flex: none;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--chip);
}

.tile.sm {
  width: 50px;
  height: 50px;
}

.tile.round {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.counter-label {
  color: var(--muted);
  font-size: 14.5px;
}

.counter-value {
  font-size: 31px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.counter-value.amber {
  color: var(--amber-strong);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr);
  gap: 16px;
  align-items: start;
}

.rows > li,
.rows > .row {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.rows > li:last-child,
.rows > .row:last-child {
  padding-bottom: 2px;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  font-size: 17px;
  font-weight: 650;
  line-height: 1.3;
}

.row-title.plain {
  font-size: 15.5px;
  font-weight: 500;
}

.row-sub {
  color: var(--muted);
  font-size: 15px;
}

.row-sub.sm {
  font-size: 13.5px;
}

.row-time {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.approval-row .badges {
  flex: 0 1 200px;
}

.plan li {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 58px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  font-size: 16px;
}

.plan li:first-child {
  border-top: 0;
}

.plan form {
  display: flex;
}

.plan .plan-title {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.plan .done .plan-title {
  color: var(--muted);
  text-decoration: line-through;
}

.check {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 8px 0;
  padding: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 6px;
  background: var(--card);
  color: transparent;
}

.check.on {
  border-color: var(--primary-bg);
  background: var(--primary-bg);
  color: var(--primary-fg);
}

.check.static {
  border-style: dashed;
  color: var(--muted);
}

.status-list li {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 44px;
  border-bottom: 1px solid var(--border);
  font-size: 15.5px;
}

.status-list .status-name {
  flex: 1;
}

.status-list .status-value {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.progress-block {
  padding-top: 14px;
}

.progress-line {
  display: flex;
  align-items: center;
  gap: 16px;
}

progress {
  flex: 1;
  width: 100%;
  height: 9px;
  border: 0;
  border-radius: 999px;
  background: var(--active);
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
}

progress::-webkit-progress-bar {
  background: var(--active);
  border-radius: 999px;
}

progress::-webkit-progress-value {
  background: var(--text);
  border-radius: 999px;
}

progress::-moz-progress-bar {
  background: var(--text);
  border-radius: 999px;
}

/* ------------------------------------------------------------------ chats */

.chat-layout {
  display: grid;
  grid-template-columns: 344px minmax(0, 1fr) 340px;
  gap: 10px;
  align-items: start;
}

.chat-layout > .card + .card,
.chat-layout .card + .card {
  margin-top: 0;
}

.chat-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.chat-list-card {
  padding: 16px 8px 8px;
}

.chat-list-card .search,
.chat-list-card .chips {
  margin: 0 10px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--chip);
  font-size: 15px;
  white-space: nowrap;
}

.chip:hover {
  background: var(--active);
}

.chip[aria-current="true"] {
  background: var(--primary-bg);
  color: var(--primary-fg);
  font-weight: 600;
}

.chat-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 12px;
  border-radius: var(--radius);
}

.chat-items li + li .chat-item {
  box-shadow: 0 -1px 0 var(--border);
}

.chat-item:hover,
.chat-item[aria-current="true"] {
  background: var(--hover);
  box-shadow: none;
}

.chat-item-main {
  flex: 1;
  min-width: 0;
}

.chat-item-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.chat-item-name {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  font-weight: 700;
}

.chat-item-bottom {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-item-preview {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 15px;
}

.chat-item-note {
  color: var(--muted);
  font-size: 14px;
  text-align: right;
  white-space: nowrap;
}

.conv-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.conv-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.back-link {
  display: none;
}

.day-sep {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.day-sep::before,
.day-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: min(78%, 640px);
  scroll-margin-top: 90px;
}

.msg.out {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-sender {
  margin: 0 0 3px 6px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
}

.bubble {
  min-width: 0;
  max-width: 100%;
  padding: 12px 18px 10px 22px;
  border-radius: 14px 14px 14px 4px;
  background: var(--bubble-in);
  font-size: 17px;
  line-height: 1.5;
}

.msg.out .bubble {
  border-radius: 14px 14px 4px 14px;
  background: var(--bubble-out);
  color: var(--bubble-out-fg);
}

.msg:target .bubble {
  outline: 2px solid var(--amber-dot);
  outline-offset: 2px;
}

.bubble-meta {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
  font-size: 13px;
  opacity: 0.72;
}

.bubble .deleted {
  font-style: italic;
  opacity: 0.75;
}

.attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 15px;
}

.attachment + .user-text {
  margin-top: 6px;
}

.attachment-note {
  margin-top: 4px;
  font-size: 13.5px;
  opacity: 0.8;
}

.transcript {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-strong);
  font-size: 15px;
}

.msg-tools {
  margin-top: 2px;
}

.msg-tools .link-button {
  color: var(--muted);
  font-size: 13px;
  min-height: 28px;
}

.draft {
  margin-top: 18px;
  padding: 18px 20px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.draft-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.draft-title {
  font-size: 18px;
  font-weight: 700;
}

.draft-state {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13.5px;
}

.draft-text {
  min-height: 96px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 17px;
  line-height: 1.55;
}

.draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.draft-actions .btn {
  min-height: 52px;
}

.draft-actions form {
  display: contents;
}

.edit-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.kv {
  display: flex;
  flex-direction: column;
}

.kv > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  font-size: 15.5px;
}

.kv dt {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
}

.kv dd {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.kv.boxed {
  padding: 2px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.kv.boxed > div:first-child {
  border-top: 0;
}

.kv.left dd {
  text-align: left;
}

.kv.left > div {
  justify-content: flex-start;
}

.kv.left dt {
  flex: 0 0 42%;
}

.contact-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 12px 0 14px;
}

.contact-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.section-title {
  margin: 18px 0 6px;
  font-size: 18px;
  font-weight: 700;
}

.hint {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14.5px;
}

/* -------------------------------------------------------------- approvals */

.approval {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px 28px;
}

.approval-who {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.approval-context {
  margin-bottom: 12px;
  padding: 10px 16px;
  border-radius: 12px 12px 12px 4px;
  background: var(--bubble-in);
  font-size: 15.5px;
}

.approval-context .label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 13px;
}

pre.payload {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--chip);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.reasons li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  font-size: 15px;
}

.reasons svg.icon {
  margin-top: 2px;
  color: var(--amber-strong);
}

/* ----------------------------------------------------------------- tables */

.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  max-width: 100%;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 38px;
  border-right: 1px solid var(--border);
  font-size: 16px;
  white-space: nowrap;
}

.tab:last-child {
  border-right: 0;
}

.tab:hover {
  background: var(--hover);
}

.tab[aria-current="page"] {
  background: var(--primary-bg);
  color: var(--primary-fg);
  font-weight: 650;
}

.tab .count {
  min-width: 28px;
  height: 28px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15.5px;
}

.table th {
  padding: 8px 12px 10px 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: 12px 12px 12px 0;
  border-top: 1px solid var(--border);
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.table td:last-child,
.table th:last-child {
  padding-right: 0;
}

.table .actions {
  text-align: right;
  white-space: nowrap;
}

.table .actions > * {
  display: inline-flex;
  vertical-align: middle;
}

.table tr[aria-current="true"] td {
  background: var(--hover);
}

.fact-cell {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.fact-key {
  font-weight: 600;
  line-height: 1.3;
}

.fact-value {
  color: var(--muted);
  font-size: 14.5px;
}

.selected-label {
  margin: 14px 0 2px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.selected-title {
  margin-bottom: 10px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.filters .field {
  flex: 1 1 170px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.stat-label {
  color: var(--muted);
  font-size: 14px;
}

.stat-value {
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.stat-note {
  color: var(--muted);
  font-size: 13.5px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.two-col > .card + .card {
  margin-top: 0;
}

/* ------------------------------------------------------------------ login */

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px 16px;
  background: var(--bg-side);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 32px 30px 30px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.auth-card .brand {
  padding: 0 0 24px;
}

.auth-title {
  margin-bottom: 4px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 22px;
}

.error-code {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 1320px) {
  .chat-layout {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .chat-layout > .chat-side {
    grid-column: 2;
  }

  .tab {
    padding: 0 22px;
  }
}

@media (max-width: 1180px) {
  .split,
  .approval {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-title {
    font-size: 40px;
  }

  .page-sub {
    font-size: 19px;
  }
}

@media (max-width: 980px) {
  .shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(var(--sidebar), 86vw);
    height: 100%;
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform 0.18s ease, visibility 0.18s;
  }

  #nav-toggle {
    display: block;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 25;
    width: 46px;
    height: 46px;
    margin: 0;
    opacity: 0;
    cursor: pointer;
  }

  #nav-toggle:checked ~ .sidebar {
    transform: none;
    visibility: visible;
  }

  #nav-toggle:checked ~ .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.45);
  }

  #nav-toggle:focus-visible ~ .main .menu-btn {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }

  .menu-btn {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 46px;
    height: 46px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--chip);
    pointer-events: none;
  }

  .topbar {
    min-height: 70px;
    padding: 0 12px;
    gap: 8px;
  }

  .crumbs {
    flex: 1;
    gap: 8px;
    font-size: 16px;
  }

  .crumbs .crumb-root,
  .crumbs .crumb-sep {
    display: none;
  }

  .crumbs strong {
    font-weight: 650;
  }

  .topbar-spacer,
  .topbar .search {
    display: none;
  }

  .topbar .search-link {
    display: inline-grid;
  }

  .mode-badge {
    padding: 0 10px;
    font-size: 12px;
  }

  .content {
    padding: 20px 14px 40px;
  }

  .page-head {
    flex-direction: column;
    gap: 14px;
    margin-bottom: 18px;
  }

  .page-title {
    font-size: 34px;
  }

  .page-sub {
    font-size: 17px;
  }

  .page-side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    padding-top: 0;
  }

  .agent-state {
    justify-content: flex-start;
    gap: 10px 16px;
  }

  .counters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .counter {
    gap: 12px;
    min-height: 88px;
    padding: 12px;
  }

  .counter .tile {
    width: 44px;
    height: 44px;
  }

  .counter-value {
    font-size: 26px;
  }

  .counter-label {
    font-size: 13.5px;
  }

  .card {
    padding: 16px 14px;
  }

  .chat-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .chat-layout > .chat-side {
    grid-column: auto;
  }

  .chat-layout.has-chat > .chat-list-card,
  .chat-placeholder {
    display: none;
  }

  .back-link {
    display: inline-grid;
  }

  .msg {
    max-width: 88%;
  }

  .two-col,
  .form-grid,
  .stat-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .tab {
    min-height: 46px;
    padding: 0 8px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
  }

  .tab:nth-child(2n) {
    border-right: 0;
  }

  .tab:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .approval-row {
    flex-wrap: wrap;
  }

  .approval-row .row-main {
    flex: 1 1 calc(100% - 72px);
  }

  .approval-row .badges {
    flex: 1 1 auto;
    order: 3;
    padding-left: 70px;
  }

  .approval-row .link {
    order: 4;
    margin-left: auto;
  }

  .draft-actions .btn {
    flex: 1 1 100%;
  }

  .btn {
    white-space: normal;
  }

  /* Tables turn into stacked cards: nothing scrolls sideways. */
  .table.reflow thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .table.reflow,
  .table.reflow tbody,
  .table.reflow tr,
  .table.reflow td {
    display: block;
    width: 100%;
  }

  .table.reflow tr {
    padding: 12px 0;
    border-top: 1px solid var(--border);
  }

  .table.reflow td {
    padding: 4px 0;
    border: 0;
  }

  .table.reflow td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 13px;
  }

  .table.reflow .actions {
    text-align: left;
  }

  details.menu > .menu-panel {
    min-width: min(270px, 80vw);
  }
}

@media (max-width: 420px) {
  .mode-badge {
    display: none;
  }

  .kv.left > div {
    flex-direction: column;
    gap: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------- utilities */

[hidden] {
  display: none !important;
}

.search-link {
  display: none;
}

.draft-actions details[open] {
  flex: 1 1 100%;
  order: 10;
}

.draft-actions details > summary.btn {
  height: 100%;
}

.edit-panel .form-actions {
  margin-top: 12px;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-gap {
  margin-top: 16px;
}

.inline-form {
  display: inline;
}

/* ------------------------------------------------------ layout refinements */

.chat-list-card .search.wide {
  width: auto;
}

.chat-list-card .chip {
  padding: 0 15px;
}

@media (min-width: 1321px) {
  .chat-layout {
    grid-template-columns: 330px minmax(0, 1fr) 320px;
  }
}

@media (hover: hover) {
  .msg .msg-tools {
    opacity: 0;
  }

  .msg:hover .msg-tools,
  .msg:focus-within .msg-tools {
    opacity: 1;
  }
}

@media (min-width: 981px) {
  .fact-table {
    table-layout: fixed;
  }

  .fact-table th:first-child {
    width: 44%;
  }

  .fact-table th:last-child {
    width: 150px;
  }

  .review-table th:first-child {
    width: 40%;
  }

  .review-table th:last-child {
    width: 190px;
  }
}

.draft-actions .btn {
  padding: 0 18px;
}

.draft-actions {
  gap: 10px;
}
