/* Shared workspace design tokens and primitives. Module styles own their layouts. */
:root {
  color-scheme: light;
  --primary: #3a6145;
  --primary-strong: #2c4a35;
  --secondary: #3a6145;
  --accent: #3f6b4b;
  --success: #3f6b4b;
  --attention: #8a550c;
  --background: #f5f4f2;
  --surface: #ffffff;
  --surface-muted: #f1efed;
  --surface-soft: #fbf9f8;
  --text: #312d2a;
  --muted: #5c5651;
  --text-muted: var(--muted);
  --border: #e4e1dd;
  --danger: #a42b31;
  --warning: #8a550c;
  --warning-bg: #fff6e6;
  --success-bg: #e8f5f2;
  --focus: #3a6145;
  --transcript-bg: #f5f4f2;
  --inbound-bg: #fff;
  --outbound-bg: #e9f9ee;
  --outbound-border: #b7d9c2;
  --shadow: 0 1px 3px rgba(22, 21, 19, .05);
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}
body { color: var(--text); background: var(--background); line-height: 1.5; }
.app-shell { grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { padding: 22px 14px; color: var(--text); background: #f1efed; border-right: 1px solid var(--border); overflow-y: auto; }
.sidebar-brand { padding: 0 6px 20px; border-bottom: 1px solid var(--border); }
.brand-mark { width: 36px; height: 36px; border: 0; border-radius: 9px; background: var(--primary); color: #fff; box-shadow: none; }
.brand strong { color: var(--text); }
.brand small { color: var(--muted); }
.sidebar-brand .brand-title { font-size: 15px; }
.nav-list { gap: 3px; margin-top: 18px; }
.nav-item { min-height: 42px; padding: 5px 9px; gap: 10px; border-radius: 7px; color: #47423e; font-size: 14px; font-weight: 600; }
.nav-item::before { display: none; }
.nav-item:hover { transform: none; color: var(--text); border-color: transparent; background: #e4e1dd; }
.nav-item.active { color: var(--primary-strong); border-color: #b7d9c2; background: #e0f5e7; box-shadow: none; }
.nav-icon-wrap { width: 28px; height: 28px; border: 0; border-radius: 6px; color: #665f5b; background: transparent; }
.nav-item:hover .nav-icon-wrap { color: var(--text); border: 0; background: transparent; }
.nav-item.active .nav-icon-wrap { color: var(--primary); border: 0; background: transparent; }
.nav-item:focus-visible, :where(button, input, select, textarea, a, summary, [tabindex]):focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.nav-group-label { margin: 14px 10px 4px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.main-content { padding: 0 clamp(20px, 3vw, 38px) 48px; }
.topbar { min-height: 88px; gap: 18px; }
h1 { font-size: clamp(22px, 2vw, 26px); line-height: 1.2; }
h2 { font-size: clamp(20px, 1.8vw, 24px); line-height: 1.25; }
h3 { font-size: 17px; line-height: 1.35; }
p { line-height: 1.55; }
.eyebrow { color: var(--muted); font-size: 11px; letter-spacing: .09em; }
.view { padding-top: 24px; }
.section-heading { margin-bottom: 18px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border-radius: 7px; font-size: 14px; font-weight: 650; text-decoration: none; }
.button:hover, .button:active { transform: none; }
.button.primary { color: #fff; background: var(--primary); }
.button.primary:hover { background: var(--primary-strong); }
.button.secondary { color: var(--primary-strong); border-color: #b7d9c2; background: #e9f9ee; }
.button.secondary:hover { background: #e0f5e7; }
.button.ghost { color: #47423e; border-color: var(--border); background: var(--surface); }
.button.danger { color: var(--danger); border-color: #e8c5c6; background: #fff5f4; }
.button.small { font-size: 13px; }
.badge { min-height: 26px; font-size: 11px; letter-spacing: .025em; }
.badge.success { color: #075c55; background: var(--success-bg); }
.badge.error { color: #8d2329; background: #fcebea; }
.badge.warning { color: #754500; background: var(--warning-bg); }
.badge.neutral { color: #514c47; background: #f1efed; }
.panel, .metric, .connection-card, .table-wrap { border-color: var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel { padding: 20px; }
.metric { min-height: 112px; padding: 18px; }
.metric strong { margin: 7px 0 3px; font-size: 26px; }
.accent-panel { background: var(--surface-soft); border-color: var(--border); }
.connection-card:hover { border-color: #bcb6b1; box-shadow: var(--shadow); }
.connection-card-footer { background: var(--surface-soft); }
.connection-metadata > div, td { border-color: #f1efed; }
.connection-callback code { color: var(--text); }
.table-wrap { overflow-x: auto; }
table { font-size: 14px; }
th { color: var(--muted); background: var(--surface-soft); font-size: 12px; }
td { padding: 13px 16px; }
.callout { border-left-color: var(--primary); background: #e9f9ee; }
.callout.warning { color: #754500; border-left-color: #ae741d; background: var(--warning-bg); }
.field label, fieldset legend { font-size: 14px; font-weight: 650; }
.field input, .field select, .field textarea { border-color: #bcb6b1; border-radius: 7px; color: var(--text); background: var(--surface); }
.field input, .field select, .field textarea { min-width: 0; font-size: 14px; line-height: 1.45; }
.field textarea { min-height: 96px; }
.field small, .check-row, .advanced-settings p, .advanced-settings summary { font-size: 14px; line-height: 1.5; }
.check-row { align-items: flex-start; }
.check-row input { flex: 0 0 18px; margin-top: 2px; }
.advanced-settings, .provider-fields { border-color: var(--border); }
.form-error-summary { color: var(--danger); background: #fff2f1; }
.modal { border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 18px 48px rgba(22, 21, 19, .2); }
.modal::backdrop { background: rgba(22, 21, 19, .48); backdrop-filter: none; }
.dialog-card { color: var(--text); background: var(--surface); }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand > span:last-child { display: grid; gap: 2px; }
.login-brand .brand-mark { display: grid; flex: 0 0 36px; place-items: center; }
.dialog-card > .field + .field { margin-top: 16px; }
#login-form h2, #setup-form h2 { margin: 4px 0 20px; }
#login-form .field-error, #setup-form .field-error { margin-top: 12px; }
.table-wrap:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (min-width: 901px) {
  .agents-table { min-width: 900px; }
  .agents-table th:nth-child(1), .agents-table td:nth-child(1) { width: 180px; }
  .agents-table th:nth-child(5), .agents-table td:nth-child(5) { width: 250px; }
  .agents-table td:last-child .button { white-space: nowrap; }
}
.toast { color: white; background: #312d2a; }
code { color: inherit; }
.database-access { --db-border: var(--border); --db-muted: var(--muted); --db-accent: var(--primary); }
.feature-test-lab { --ft-surface: var(--surface); --ft-text: var(--text); --ft-muted: var(--muted); --ft-border: var(--border); --ft-accent: var(--primary); }
@media (max-width: 1080px) and (min-width: 721px) {
  .app-shell { grid-template-columns: 88px minmax(0,1fr); }
  .sidebar-brand .brand-title { display: none; }
  .nav-item { font-size: 11px; }
  .nav-group-label { margin-inline: 0; text-align: center; font-size: 10px; }
}
@media (max-width: 720px) {
  .main-content { padding: 0 16px 32px; }
  .topbar-actions .badge { display: inline-flex; }
  .topbar { min-height: 0; padding: 18px 0; }
  .connection-grid, .form-grid { grid-template-columns: 1fr; }
  .responsive-table tr { box-shadow: none; }
}
@media (pointer: coarse) {
  .button, .button.small, .connection-card-footer .button.small, .nav-item { min-height: 44px; }
  .copy-button { min-width: 44px; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Navigation groups and the compact navigation drawer. */
.nav-group { display: grid; gap: 3px; min-width: 0; }
.nav-group-label { display: block; }
.nav-toggle { display: none; min-width: 44px; min-height: 44px; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px; color: var(--text); background: var(--surface); font: inherit; font-size: 20px; cursor: pointer; }
.page-description { margin: 4px 0 0; font-size: 14px; }
@media (max-width: 900px) {
  .app-shell { display: block; }
  #sidebar-navigation { display: none; position: static; width: 100%; height: auto; max-height: 50vh; padding: 16px; overflow: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .app-shell.nav-open #sidebar-navigation { display: flex; flex-direction: column; align-items: stretch; }
  .sidebar .brand { display: flex; justify-content: flex-start; padding: 0 0 12px; }
  .sidebar-brand .brand-title { display: block; }
  .nav-list { display: grid; width: 100%; margin-top: 8px; gap: 3px; }
  .nav-list::after { content: none; }
  .nav-group { display: grid; gap: 3px; }
  .nav-group-label { margin: 10px 9px 3px; text-align: left; font-size: 11px; }
  .nav-item { width: 100%; min-width: 0; min-height: 44px; flex-direction: row; justify-content: flex-start; padding: 5px 9px; text-align: left; font-size: 14px; }
  .nav-toggle { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; }
  .topbar { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .topbar { flex-direction: row; align-items: flex-start; justify-content: flex-start; }
  .topbar > div:not(.topbar-actions) { flex: 1 1 190px; min-width: 0; }
  .topbar-actions { width: 100%; }
  .dialog-card { padding: 20px 16px; overflow-wrap: anywhere; }
  .dialog-card .field input, .dialog-card .field select, .dialog-card .field textarea { font-size: 16px; }
  .dialog-actions { flex-wrap: wrap; }
  .dialog-actions .button { max-width: 100%; white-space: normal; }
}

/* Operator pages outside the application shell. */
.workspace-standalone .main-content { width: 100%; max-width: 1100px; margin-inline: auto; padding: 24px clamp(16px, 3vw, 32px) 48px; }
.workspace-standalone .main-content > a:first-child { display: inline-block; margin-bottom: 16px; color: var(--primary-strong); }
.workspace-standalone .main-content > h1 { margin-bottom: 12px; }
.workspace-standalone .form-stack { min-width: 0; }
.workspace-standalone fieldset { min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.workspace-standalone fieldset legend { padding-inline: 6px; }
.workspace-standalone label:not(.check-row):has(> input:not([type="checkbox"]):not([type="radio"])),
.workspace-standalone label:not(.check-row):has(> select),
.workspace-standalone label:not(.check-row):has(> textarea) { display: grid; gap: 6px; min-width: 0; font-size: 14px; font-weight: 650; }
.workspace-standalone label > input:not([type="checkbox"]):not([type="radio"]),
.workspace-standalone label > select,
.workspace-standalone label > textarea { width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid #bcb6b1; border-radius: 7px; color: var(--text); background: var(--surface); font: inherit; }
.workspace-standalone label:has(> input[type="checkbox"]),
.workspace-standalone label:has(> input[type="radio"]) { display: flex; align-items: flex-start; gap: 8px; line-height: 1.5; }
.workspace-standalone input[type="checkbox"], .workspace-standalone input[type="radio"] { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 3px; accent-color: var(--primary); }
.workspace-standalone [hidden] { display: none !important; }

/* Match native-control specificity so the legacy blue outline cannot override Redwood. */
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Channel setup keeps provider-specific choices compact and easy to scan. */
#connection-dialog .connection-intro { margin: 0 0 18px; color: var(--muted); }
#connection-dialog .connection-identity-fields { margin-bottom: 16px; }
#connection-dialog #group-policy-container { margin: 0 0 18px; }
#connection-dialog .provider-fields { margin: 0 0 16px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-soft); }
#connection-dialog .provider-fields legend { padding: 0 6px; }
#connection-dialog .connection-optional { margin-top: 14px; border-top: 1px solid var(--border); }
#connection-dialog .connection-optional > summary { padding: 12px 0; color: var(--primary-strong); font-size: 14px; font-weight: 650; cursor: pointer; }
#connection-dialog .connection-optional[open] > .field, #connection-dialog .connection-optional[open] > .form-grid { padding-bottom: 4px; }
#connection-dialog .connection-next-step { margin: 0 0 16px; padding: 10px 14px; border-left: 3px solid var(--primary); background: var(--surface-soft); font-size: 14px; }

/* Compact only the active chat's surrounding workspace. */
.main-content:has(#view-chat.active) #view-chat { padding-top: 12px; }
@media (max-width: 600px) {
  .main-content:has(#view-chat.active) { padding-inline: 12px; padding-bottom: 16px; }
  .main-content:has(#view-chat.active) .topbar { gap: 8px 12px; padding-block: 10px; }
  .main-content:has(#view-chat.active) .topbar > div:not(.topbar-actions) { flex: 1 1 170px; }
  .main-content:has(#view-chat.active) .topbar .eyebrow { margin-bottom: 3px; font-size: 10px; }
  .main-content:has(#view-chat.active) #page-description { font-size: 12px; line-height: 1.4; }
  .main-content:has(#view-chat.active) .topbar-actions { gap: 8px; }
  .main-content:has(#view-chat.active) .topbar-actions .button { min-height: 44px; }
}
