/* Dashboard Core CSS */
:root {
  --bg-main: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --brand-red: #ba2025;
  --brand-red-light: #d32f2f;
  --brand-red-glow: rgba(186, 32, 37, 0.15);
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-dark: #cbd5e1;
  --accent-emerald: #059669;
  --accent-blue: #2563eb;
  /* ADDED 2026-08-11. `--brand-blue` was referenced in twelve places - four in the
     markup and eight in the script - and defined in none. An undefined custom property
     makes the whole declaration invalid at computed-value time, so the property falls
     back to its INITIAL value, not to the rule underneath it. The "Sync Billing Rates
     Now" button therefore rendered with a transparent background and the white text
     that `.btn-primary` gives it, on a white panel: present, clickable, and invisible.
     Dov reported it as a missing button on 2026-08-11. The value matches the second
     stop of that button's gradient (#1d4ed8) and the existing `--accent-blue`. */
  /* Points at the accent above rather than repeating its value: DECISIONS 6.5, one
     value defined in one place. Two blues that must be kept equal by hand are a future
     contradiction, not a backup. */
  --brand-blue: var(--accent-blue);
  --accent-purple: #7c3aed;
  --sidebar-width: 280px;
}

.email-templates .card { background: var(--bg-card, #fff); border: 1px solid var(--border); border-radius: 12px; padding: 24px; min-width: 0; }
.email-templates [hidden] { display: none !important; }
.email-templates .heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 16px 0; }
.email-templates h2 { font-size: 20px; margin: 0; }
.email-templates h3 { font-size: 16px; margin: 0; }
.email-templates p { margin: 5px 0 14px; }
.email-templates .muted, .email-templates .hint { color: var(--text-muted); }
.email-templates .grid { display: grid; grid-template-columns: minmax(0, 1fr) 295px; gap: 26px; align-items: start; }
.email-templates .field { margin-bottom: 18px; }
.email-templates label { display: block; font-weight: 600; margin-bottom: 6px; }
.email-templates input, .email-templates textarea, .email-templates select { box-sizing: border-box; width: 100%; font: inherit; color: inherit; line-height: 1.6; padding: 10px 12px; border: 1px solid var(--border-dark); border-radius: 7px; background: white; }
.email-templates textarea { min-height: 355px; resize: vertical; }
.email-templates .hint { font-size: 12px; margin: 5px 0 0; }
.email-templates button { font: inherit; cursor: pointer; }
.email-templates button:disabled { cursor: default; opacity: .55; }
.email-templates .primary { background: var(--brand-red); color: white; border: 0; border-radius: 7px; font-weight: bold; padding: 10px 22px; }
.email-templates .link { border: 0; padding: 0; background: none; color: var(--brand-red); text-decoration: underline; text-underline-offset: 3px; }
.email-templates .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 20px; margin-top: 14px; }
.email-templates :focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 3px; }
.email-templates .pill { background: #f1f4f8; border-radius: 20px; padding: 2px 10px; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.email-templates .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 5px; font-size: 13px; color: var(--text-muted); }
.email-templates .library { padding-left: 24px; border-left: 1px solid var(--border); }
.email-templates .library p { font-size: 13px; margin-bottom: 14px; }
.email-templates .variable { padding: 12px 0; border-top: 1px solid var(--border); }
.email-templates .variable button { color: var(--brand-red); background: #fcf3f4; border: 1px solid #efdadd; border-radius: 5px; padding: 5px 9px; font: 13px Consolas, monospace; max-width: 100%; overflow-wrap: anywhere; }
.email-templates .variable small { display: block; font-size: 12px; line-height: 1.45; color: var(--text-muted); margin-top: 4px; overflow-wrap: anywhere; }
.email-templates .variable .description { color: var(--text-main); margin-top: 7px; font-size: 13px; }
.email-templates .status { min-height: 24px; margin: 8px 0; font-size: 13px; }
.email-templates .status.error { color: var(--brand-red); }
.email-templates .table-wrap { overflow: auto; }
.email-templates table { border-collapse: collapse; width: 100%; text-align: left; }
.email-templates th, .email-templates td { border-bottom: 1px solid var(--border); padding: 16px 12px; font-size: 14px; }
.email-templates th { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.email-templates td:last-child { text-align: right; }
.email-templates .new-form { max-width: 520px; margin: 20px 0; }
.email-templates .preview { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 20px; }
.email-templates .preview-subject { font-weight: 600; overflow-wrap: anywhere; margin: 14px 0; }
.email-templates .preview-body { width: 100%; min-height: 390px; white-space: pre-wrap; overflow-wrap: anywhere; box-sizing: border-box; padding: 16px; border: 1px solid var(--border); border-radius: 7px; background: white; color: var(--text-main); line-height: 1.5; }
.email-templates .footer { font-size: 12px; color: var(--text-muted); margin: 18px 0; }
@media (max-width: 1000px) {
  .email-templates .grid { grid-template-columns: 1fr; }
  .email-templates .library { border-left: 0; border-top: 1px solid var(--border); padding: 18px 0 0; }
  .email-templates .variables { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
  .email-templates .card { padding: 16px; }
  .email-templates .heading { align-items: flex-start; flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .email-templates .variables { grid-template-columns: 1fr; }
  .email-templates .actions { gap: 16px; }
}

.workspace-assistant-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: calc(100vh - 150px);
  min-height: 520px;
}
.workspace-assistant-header,
.workspace-assistant-header-actions,
.workspace-assistant-composer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.workspace-assistant-header {
  justify-content: space-between;
}
.workspace-assistant-header p,
.workspace-assistant-status {
  color: var(--text-muted);
  font-size: 0.85rem;
}
.workspace-assistant-status[data-kind="error"] {
  color: var(--brand-red);
}
.workspace-assistant-status[data-kind="recording"] {
  color: var(--accent-blue);
  font-weight: 600;
}
.workspace-assistant-org {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.workspace-assistant-org[hidden],
[data-requires-workspace-assistant][hidden] {
  display: none !important;
}
.workspace-assistant-org select {
  min-width: 190px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
}
.workspace-assistant-messages {
  flex: 1;
  min-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.workspace-assistant-message {
  max-width: min(78%, 760px);
  padding: 11px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.workspace-assistant-message.user {
  align-self: flex-end;
  background: var(--brand-red);
  color: #fff;
}
.workspace-assistant-message.assistant {
  align-self: flex-start;
  background: #f1f5f9;
  color: var(--text-main);
}
.workspace-assistant-approval {
  padding: 14px;
  border: 2px solid var(--brand-red);
  border-radius: 12px;
  background: #fff7f7;
}
.workspace-assistant-approval[hidden] {
  display: none;
}
.workspace-assistant-approval h3,
.workspace-assistant-approval p {
  margin: 0 0 8px;
}
.workspace-assistant-approval pre {
  max-height: 220px;
  overflow: auto;
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.workspace-assistant-approval-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.workspace-assistant-composer {
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.workspace-assistant-composer textarea {
  width: 100%;
  resize: none;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
}
.workspace-assistant-composer-actions {
  justify-content: flex-end;
  margin-top: 8px;
}
.workspace-assistant-attachment {
  margin-bottom: 8px;
  color: var(--accent-blue);
  font-size: 0.8rem;
  font-weight: 600;
}
.workspace-assistant-send {
  min-width: 90px;
}
@media (max-width: 720px) {
  .workspace-assistant-page {
    height: calc(100dvh - 126px);
    min-height: 430px;
  }
  .workspace-assistant-header,
  .workspace-assistant-header-actions {
    align-items: stretch;
    flex-direction: column;
  }
  .workspace-assistant-org,
  .workspace-assistant-org select,
  .workspace-assistant-header-actions .btn-secondary {
    width: 100%;
  }
  .workspace-assistant-message {
    max-width: 92%;
  }
  .workspace-assistant-composer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1.4fr;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  overflow: hidden; /* Prevent full body scroll, handle scroll in content area */
}

h1, h2, h3, h4, .brand-font {
  font-family: 'Outfit', sans-serif;
}

/* Auth Overlay */
.auth-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-main);
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-modal {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--border-dark);
  border-radius: 18px;
  width: 100%;
  max-width: 440px;
  padding: 28px;
  margin: auto;
  min-width: 0;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
  text-align: center;
}

.auth-google-btn {
  width: 100%;
  background: #ffffff;
  border: 1.5px solid var(--border-dark);
  border-radius: 30px;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  margin-top: 24px;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.auth-modal [hidden] { display: none !important; }
.auth-modal h2 { font-size: 1.4rem; margin-block: 0 9px; }
#authAccount { color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; overflow-wrap: anywhere; }
.auth-close { position: absolute; inset-block-start: 5px; inset-inline-end: 5px; width: 44px; height: 44px; display: grid; place-items: center; font-size: 24px; color: var(--text-muted); text-decoration: none; border-radius: 8px; }
.auth-modal a:focus-visible, .auth-modal summary:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 2px; }
#authManualKey { margin-block: 12px; text-align: start; }
#authManualKey summary { cursor: pointer; min-height: 40px; padding-block: 8px; font-size: 0.85rem; }
.auth-actions .auth-primary-btn { margin-block-start: 0; }
.auth-modal form { text-align: start; }
.auth-modal label { display: block; margin-block: 18px 7px; font-size: 0.85rem; font-weight: 600; }
.auth-modal input { width: 100%; min-width: 0; height: 46px; padding-inline: 13px; border: 1px solid var(--border-dark); border-radius: 10px; font: inherit; }
.auth-primary-btn { width: 100%; min-height: 46px; margin-block-start: 12px; padding: 10px; border: 0; border-radius: 10px; background: var(--brand-red); color: #ffffff; font: inherit; font-weight: 600; cursor: pointer; }
.auth-primary-btn:disabled { opacity: 0.62; cursor: wait; }
.auth-secondary-btn { color: var(--text-main); background: #fff; border: 1px solid var(--border-dark); }
.auth-text-btn { display: block; min-height: 40px; margin: 3px auto 0; padding: 8px 2px; border: 0; background: transparent; color: var(--brand-red); font: inherit; font-size: 0.82rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.auth-text-btn:disabled { opacity: 0.62; cursor: wait; }
.auth-text-right { margin-inline-end: 0; }
.auth-reset-message { padding: 14px; border: 1px solid var(--border); border-radius: 10px; text-align: start; font-size: 0.9rem; line-height: 1.5; }
.auth-modal input:focus-visible, .auth-modal button:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 2px; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin-block-start: 20px; color: var(--text-muted); font-size: 0.8rem; }
.auth-divider::before, .auth-divider::after { content: ''; height: 1px; background: var(--border); flex: 1; }
.auth-provider-btn {
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid #747775;
  border-radius: 10px;
  background: #fff;
  color: #1f1f1f;
  font-family: Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  box-shadow: none;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}
.auth-provider-btn > img,
.auth-provider-icon { width: 20px; height: 20px; flex: 0 0 20px; }
.auth-provider-icon--facebook { fill: #1877f2; }
#authCode { text-align: center; font-size: 1.5rem; letter-spacing: 0.3em; }
#authQr { display: block; width: 148px; height: 148px; margin: 16px auto; image-rendering: pixelated; }
#authSetupKey { padding: 10px; background: var(--bg-main); border: 1px solid var(--border); border-radius: 8px; overflow-wrap: anywhere; font: 0.8rem monospace; }

.auth-actions[hidden],
.auth-recovery[hidden] {
  display: none;
}

.auth-provider-btn:hover:not(:disabled) {
  border-color: #747775;
  background: #f8faff;
}

.auth-provider-btn:disabled {
  cursor: wait;
  opacity: 0.62;
}

.auth-recovery {
  margin-top: 6px;
}

.auth-retry-btn {
  border: 0;
  background: transparent;
  color: var(--brand-red);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  min-height: 40px;
  padding: 8px 2px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-retry-btn:hover {
  text-decoration-thickness: 2px;
}

.auth-status-msg {
  margin: 8px 0 14px;
  line-height: 1.5;
  font-size: 0.85rem;
  color: var(--brand-red);
  font-weight: 600;
}

.auth-status-msg.is-neutral {
  color: var(--text-muted);
}

/* Application Layout */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: width 0.3s ease, transform 0.3s ease;
}

/* Collapsed Sidebar (Icon-Only Mode) */
.sidebar.collapsed {
  width: 70px !important;
}

.sidebar.collapsed .sidebar-header {
  padding: 0;
  justify-content: center;
}

.sidebar.collapsed .logo-container {
  padding: 0;
  justify-content: center;
}

.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .menu-section-title,
.sidebar.collapsed .menu-item span,
.sidebar.collapsed .sidebar-footer {
  display: none !important;
}

.sidebar.collapsed .menu-item {
  justify-content: center;
  padding: 12px;
}

.sidebar.collapsed .menu-item svg {
  margin-right: 0;
}

.sidebar-toggle-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar.collapsed .sidebar-toggle-row {
  justify-content: center;
  padding: 8px 0;
}

#sidebarToggleBtn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

#sidebarToggleBtn:hover {
  background: var(--bg-main);
  color: var(--brand-red);
}

.sidebar-header {
  height: 72px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  gap: 12px;
}

.logo-container { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.logo-main-sign { width: 36px; height: 36px; display: block; object-fit: contain; }
.logo-brand-block { display: flex; flex-direction: column; justify-content: center; }
.logo-subtext {
  font-size: 0.60rem; font-weight: 700; color: var(--brand-red);
  letter-spacing: 1.1px; text-transform: none; margin-top: 1px;
}
  color: var(--text-main);
  line-height: 1;
}

.sidebar-brand-text .subname {
  font-size: 0.65rem;
  color: var(--brand-red);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-menu {
  flex: 1;
  padding: 24px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.menu-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 16px 0 8px 12px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.menu-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: stroke 0.2s ease, fill 0.2s ease;
}

.menu-item:hover {
  background: rgba(241, 245, 249, 0.8);
  color: var(--text-main);
}

.menu-item.active {
  background: rgba(186, 32, 37, 0.08);
  color: var(--brand-red);
  font-weight: 600;
}

/* Make icons match active state */
.menu-item.active svg {
  stroke: var(--brand-red);
}
.menu-item.active svg.fill-icon {
  fill: var(--brand-red);
  stroke: none;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-main);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-email {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--brand-red);
  font-weight: 600;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: rgba(0,0,0,0.05);
  color: var(--brand-red);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 72px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  z-index: 5;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.tenant-badge {
  background: rgba(186, 32, 37, 0.08);
  color: var(--brand-red);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(186, 32, 37, 0.2);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lang-switch {
  display: flex;
  background: var(--bg-main);
  border-radius: 20px;
  padding: 4px;
  border: 1px solid var(--border);
}

.lang-btn {
  background: transparent;
  border: none;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.lang-btn.active {
  background: #ffffff;
  color: var(--text-main);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.content-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Card Boxes */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.01);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-icon.red { background: rgba(186, 32, 37, 0.1); color: var(--brand-red); }
.card-icon.blue { background: rgba(37, 99, 235, 0.1); color: var(--accent-blue); }
.card-icon.emerald { background: rgba(5, 150, 105, 0.1); color: var(--accent-emerald); }
.card-icon.purple { background: rgba(124, 58, 237, 0.1); color: var(--accent-purple); }

.card-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  color: var(--text-main);
  margin-bottom: 4px;
}

.card-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Wide panel */
.panel {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
  margin-bottom: 32px;
  overflow: hidden;
}

.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(248, 250, 252, 0.5);
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.panel-body {
  padding: 24px;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th, .data-table td {
  padding: 16px 24px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(248, 250, 252, 0.8);
}

.data-table td {
  font-size: 0.95rem;
  color: var(--text-main);
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}

.empty-icon {
  width: 64px;
  height: 64px;
  background: rgba(241, 245, 249, 1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.empty-icon svg {
  width: 32px; height: 32px;
}

.empty-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.empty-desc {
  color: var(--text-muted);
  max-width: 400px;
  font-size: 0.95rem;
  margin-bottom: 24px;
}

/* Buttons */
.btn-primary {
  background: var(--brand-red);
  color: white;
  border: 1px solid transparent;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--brand-red-light);
  transform: translateY(-1px);
}

.btn-secondary {
  background: white;
  color: var(--text-main);
  border: 1px solid var(--border-dark);
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--bg-main);
  border-color: var(--text-muted);
}

/* Voice Recorder UI */
.voice-recorder-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(241, 245, 249, 0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}

.btn-record {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-record:hover {
  background: #ef4444;
  color: white;
}

.btn-record.recording {
  animation: pulse 1.5s infinite;
  background: #ef4444;
  color: white;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Responsive */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    height: 100vh;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .topbar {
    padding: 0 16px;
  }
  .content-scrollable {
    padding: 20px 16px;
  }
}

/* Toast Notifications */
#toastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: white;
  border-left: 4px solid var(--brand-red);
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 400px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.4;
}

.toast.success {
  border-left-color: var(--accent-emerald);
}

.toast.error {
  border-left-color: var(--brand-red);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(10px); }
}

/* Tooltips */
.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface-alt, #f1f5f9);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  margin-left: 6px;
  position: relative;
  border: 1px solid var(--border);
}
.tooltip-icon:hover {
  background: var(--brand-red);
  color: white;
  border-color: var(--brand-red);
}
.tooltip-box {
  display: none;
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  background: #1e293b;
  color: #fff;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 400;
  width: 250px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  text-align: left;
  line-height: 1.4;
  white-space: normal;
}
.tooltip-box::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #1e293b transparent transparent transparent;
}
.tooltip-icon:hover .tooltip-box {
  display: block;
}

/* Tags Input */
.tags-input-container {
  position: relative;
  width: 100%;
}
.tags-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  min-height: 40px;
  cursor: text;
}
.tag-badge {
  background: rgba(186, 32, 37, 0.08);
  color: var(--brand-red);
  border: 1px solid rgba(186, 32, 37, 0.2);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.tag-badge .remove {
  cursor: pointer;
  color: var(--text-muted);
}
.tag-badge .remove:hover {
  color: var(--brand-red);
}
.tags-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  margin-top: 4px;
  display: none;
}
.tags-dropdown-item {
  padding: 8px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}
.tags-dropdown-item:hover {
  background: rgba(248, 250, 252, 1);
}


/* Workspace filter on the finance screen.
   ADDED 2026-08-12 (S19, Claude) with the chip field that replaced the blue pills,
   docs/OPEN_DEFECTS.md row 99. Geometry follows the approved mockup
   docs/mockups/S18_workspace_filter_2026-08-12.html. Colours are the variables already
   defined at the top of this file, with four literals taken from the mockup and named
   here rather than left to be found: the chip background #f1f5f9, which has no variable
   in this project; the focus ring rgba(37, 99, 235, 0.12), which is --accent-blue at
   twelve percent; the dropdown shadow rgba(15, 23, 42, 0.12); and #fff on the hovered
   cross. A custom property cannot be given an alpha channel without a colour function
   this stylesheet does not otherwise use, so the two translucent values are written out.
   If --accent-blue is ever changed, the focus ring has to move with it. */
.ws-filter-caption {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.ws-filter-wrap {
  position: relative;
}
.ws-chipfield {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-dark);
  border-radius: 10px;
  cursor: text;
}
.ws-chipfield.focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.ws-chipfield-input {
  flex: 1;
  min-width: 150px;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.86rem;
  padding: 6px 2px;
  background: transparent;
  color: var(--text-main);
}
.ws-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  border: 1px solid var(--border-dark);
  color: var(--text-main);
  border-radius: 8px;
  padding: 5px 8px 5px 10px;
  font-size: 0.82rem;
  white-space: nowrap;
}
.ws-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.ws-chip-x:hover {
  background: var(--brand-red);
  color: #fff;
}
.ws-filter-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}
.ws-filter-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.ws-filter-clear {
  font-size: 0.78rem;
  color: var(--accent-blue);
  cursor: pointer;
}
.ws-filter-clear:hover {
  text-decoration: underline;
}
/* The list starts hidden in the markup, so a script that never runs leaves it closed
   rather than open over the page. */
.ws-droplist.ws-hidden {
  display: none;
}
.ws-droplist {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-card);
  border: 1px solid var(--border-dark);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
}
.ws-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 0.86rem;
  cursor: pointer;
}
.ws-opt:hover {
  background: var(--bg-main);
}
.ws-opt-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.ws-opt.chosen {
  color: var(--text-muted);
  cursor: default;
}
.ws-opt.chosen:hover {
  background: transparent;
}
.ws-opt.chosen .ws-opt-meta {
  color: var(--accent-emerald);
}
.ws-droplist-empty {
  padding: 12px 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* A workspace name is text a tenant writes. Without a ceiling, a very long one pushes
   the field and the list out of shape on the operator screen. */
.ws-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.ws-opt-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}
/* The line under the field when the last refresh failed: the figures on screen are not
   the ones the chips ask for, and that has to look different from a normal count. */
.ws-filter-count-stale {
  color: var(--brand-red);
  font-weight: 600;
}

/* Approved S28 Platform Settings tabs. */
.platform-settings-tabs-wrap {
  position: sticky;
  top: 0;
  z-index: 8;
  margin-bottom: 20px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border);
}

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

/* A native date picker is positioned at its visible button immediately before
   showPicker(). Unlike a clipped 1 px accessibility helper, this gives Chromium
   a real viewport anchor and prevents the calendar from opening off-screen. */
.native-date-picker-anchor {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: -1;
  width: 2px;
  height: 2px;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  border: 0;
}

.system-audit-table-wrap {
  max-width: 100%;
  overscroll-behavior-inline: contain;
}
.platform-settings-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-top: 3px;
  scrollbar-width: thin;
}
.platform-settings-tab {
  position: relative;
  flex: 0 0 auto;
  padding: 12px 16px 14px;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}
.platform-settings-tab:hover {
  color: var(--text-main);
  background: var(--bg-card);
}
.platform-settings-tab[aria-selected="true"] {
  color: var(--brand-red);
}
.platform-settings-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 3px;
  background: var(--brand-red);
  border-radius: 3px 3px 0 0;
}
.platform-settings-tab:focus-visible {
  outline: 3px solid rgba(186, 32, 37, 0.22);
  outline-offset: -2px;
}
.platform-settings-panel[hidden] {
  display: none;
}
.platform-settings-panel {
  min-width: 0;
}
.platform-settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 0 20px;
}

.integration-status-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.platform-integration-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

#platformInfrastructureFields {
  padding: 24px;
}

.platform-integration-field {
  min-width: 0;
}

.platform-integrations-title {
  margin: 0 0 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  font-size: 1rem;
}

.platform-integration-value {
  box-sizing: border-box;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text-main);
  font: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
}

.platform-integration-output {
  display: block;
  cursor: text;
  user-select: text;
  white-space: nowrap;
}

.integration-secret-status {
  box-sizing: border-box;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text-main);
  font-size: 0.85rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.integration-secret-status[data-state="configured"] {
  border-color: #86c89a;
  background: #f0faf3;
}

.integration-secret-status[data-state="binding_pending"],
.integration-secret-status[data-state="not_configured"],
.integration-secret-status[data-state="unknown"] {
  border-color: #e2b86b;
  background: #fff9ed;
}
.profile-logo-layout {
  display: flex;
  align-items: center;
  gap: 14px;
}
.profile-logo-controls {
  flex: 1;
  min-width: 0;
}
.profile-logo-input-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
}

/* Approved S28 platform AI model screen. */
.ai-model-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.ai-model-header p,
.ai-model-section-head p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}
.ai-model-platform-badge,
.ai-model-source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(186, 32, 37, 0.08);
  color: var(--brand-red);
  border: 1px solid rgba(186, 32, 37, 0.2);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}
.ai-model-panel {
  padding: 24px;
  margin-bottom: 20px;
}
.ai-model-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.ai-model-section-head h3 {
  margin: 0;
  font-size: 1.08rem;
}
.ai-model-form-row,
.ai-model-add-row,
.ai-model-pagination {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.ai-model-table {
  min-width: 760px;
}
.ai-model-panel button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}
.ai-model-panel button:disabled:hover {
  transform: none;
  box-shadow: none;
}
.ai-model-panel .btn-primary:disabled:hover {
  background: var(--brand-red);
  border-color: transparent;
}
.ai-model-panel .btn-secondary:disabled:hover {
  background: white;
  border-color: var(--border-dark);
}
.ai-model-field {
  min-width: 220px;
}
.ai-model-field-grow {
  flex: 1;
}
.ai-model-field label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
}
.ai-model-field .settings-input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.9rem;
  line-height: 1.25;
}
.operator-timezone-row {
  max-width: 680px;
}
.operator-timezone-field {
  flex: 0 1 500px;
  min-width: 300px;
}
.operator-timezone-field .settings-input {
  width: 100%;
}
.ai-model-add-row {
  max-width: 820px;
}
.ai-model-add-row .ai-model-field {
  flex: 0 1 650px;
}
.context-log-scroll {
  max-height: 320px;
  overflow: auto;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.context-log-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  table-layout: fixed;
  text-align: left;
}
.context-log-time-col {
  width: 160px;
}
.context-log-status-col {
  width: 84px;
}
.context-log-action-col {
  width: 92px;
}
.context-log-detail-cell {
  padding: 14px;
  overflow: hidden;
}
.context-log-payload-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.context-log-payload-table code {
  overflow-wrap: anywhere;
  white-space: normal;
}
.context-log-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.context-log-raw {
  display: none;
  width: 100%;
  margin-top: 8px;
}
.context-log-code {
  box-sizing: border-box;
  width: 100%;
  max-height: 220px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  background: #1e293b;
  border-radius: 8px;
  color: #dbeafe;
  font-size: 0.72rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ai-model-form-row .btn-primary,
.ai-model-add-row .btn-primary {
  min-height: 42px;
  white-space: nowrap;
}
.ai-model-meta,
.ai-model-status,
.ai-model-empty {
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}
.ai-model-status {
  min-height: 20px;
}
.ai-model-error {
  color: var(--brand-red);
  font-weight: 600;
}
.ai-model-current-id {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.ai-model-current-id span {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ai-model-current-id code,
.ai-model-catalogue-row code {
  color: var(--text-main);
  font-size: 0.94rem;
  font-weight: 700;
}
.ai-model-catalogue {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}
.ai-model-catalogue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-main);
}
.ai-model-catalogue-row > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.ai-model-catalogue-row span {
  color: var(--text-muted);
  font-size: 0.76rem;
}
.ai-model-activity-filter {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.ai-model-date-control {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 210px;
  min-height: 42px;
  padding: 9px 11px;
  background: white;
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  color: var(--text-main);
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.ai-model-date-control:focus-within {
  outline: 3px solid rgba(186, 32, 37, 0.18);
  outline-offset: 2px;
}
.ai-model-date-action {
  color: var(--brand-red);
  font-size: 0.74rem;
  font-weight: 700;
}
.journal-date-control {
  min-width: 190px;
  min-height: 36px;
  padding: 6px 9px;
  font-size: 0.75rem;
}
.ai-model-table td,
.ai-model-table th {
  padding: 11px 12px;
  text-align: left;
}
.ai-model-table td {
  font-size: 0.8rem;
}
.ai-model-pagination {
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}

.prompt-library {
  display: grid;
  gap: 20px;
}
.prompt-library-header,
.prompt-library-toolbar,
.prompt-library-detail-head,
.prompt-library-section-head,
.prompt-library-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.prompt-library-header h3,
.prompt-library-toolbar h4,
.prompt-library-detail h4,
.prompt-library-detail h5 {
  margin: 0;
  color: var(--text-main);
}
.prompt-library-header p,
.prompt-library-help {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}
.prompt-library-catalogue,
.prompt-library-detail {
  padding: 20px;
}
.prompt-library-filters {
  display: flex;
  gap: 10px;
}
.prompt-library-filters select,
.prompt-library-filters input {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  background: white;
  color: var(--text-main);
  font: inherit;
}
.prompt-library-filters input {
  min-width: 250px;
}
.prompt-library-table-wrap {
  width: 100%;
  margin-top: 16px;
  overflow-x: auto;
  scrollbar-gutter: stable both-edges;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.prompt-library-table {
  width: 100%;
  min-width: 1000px;
  table-layout: fixed;
}
.prompt-library-table th:nth-child(1) { width: 18%; }
.prompt-library-table th:nth-child(2) { width: 10%; }
.prompt-library-table th:nth-child(3) { width: 17%; }
.prompt-library-table th:nth-child(4) { width: 14%; }
.prompt-library-table th:nth-child(5) { width: 12%; }
.prompt-library-table th:nth-child(6) { width: 10%; }
.prompt-library-table th:nth-child(7) { width: 9%; }
.prompt-library-table th:nth-child(8) { width: 10%; }
.prompt-library-table th,
.prompt-library-table td {
  padding-right: 12px;
  padding-left: 12px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.prompt-library-open-button {
  min-width: 70px;
  padding-right: 14px;
  padding-left: 14px;
  justify-content: center;
  white-space: nowrap;
}
.prompt-library-table tr.is-selected td {
  background: rgba(186, 32, 37, 0.055);
}
.prompt-library-name {
  display: grid;
  gap: 3px;
  min-width: 220px;
}
.prompt-library-name strong {
  color: var(--text-main);
}
.prompt-library-name span,
.prompt-library-id,
.prompt-library-table code,
.prompt-library-versions-table code {
  color: var(--text-muted);
  font-size: 0.73rem;
}
.prompt-library-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 9px;
  border: 1px solid var(--border-dark);
  border-radius: 999px;
  background: var(--bg-main);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}
.prompt-library-badge[data-kind="active"],
.prompt-library-badge[data-kind="passed"] {
  border-color: #abd7ba;
  background: #eef9f1;
  color: #16713b;
}
.prompt-library-badge[data-kind="blocked"],
.prompt-library-badge[data-kind="retired"] {
  border-color: #e5c7c8;
  background: #fff5f5;
  color: var(--brand-red);
}
.prompt-library-detail {
  display: grid;
  gap: 22px;
}
.prompt-library-detail[hidden],
#promptLibraryManagedEditor[hidden] {
  display: none !important;
}
.prompt-library-id {
  margin: 0 0 6px;
  font-family: monospace;
}
.prompt-library-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.prompt-library-facts > div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-main);
}
.prompt-library-facts span {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.prompt-library-facts strong {
  overflow-wrap: anywhere;
  color: var(--text-main);
  font-size: 0.82rem;
}
.prompt-library-editor {
  width: 100%;
  min-height: 260px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--border-dark);
  border-radius: 9px;
  background: white;
  color: var(--text-main);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.55;
  resize: vertical;
}
.prompt-library-editor[readonly] {
  background: var(--bg-main);
  color: var(--text-muted);
}
.prompt-library-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 12px;
}
.prompt-library-contract-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 16px;
}
.prompt-library-contract-grid section {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.prompt-library-contract-grid pre {
  max-height: 260px;
  margin: 12px 0 0;
  overflow: auto;
  color: var(--text-main);
  font-size: 0.74rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.prompt-library-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.prompt-library-actions button {
  max-width: 100%;
  overflow-wrap: anywhere;
}
.prompt-library-versions-table {
  min-width: 760px;
}
@media (max-width: 1100px) {
  .prompt-library-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .prompt-library-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .prompt-library-filters input,
  .prompt-library-filters select {
    min-width: 0;
    width: 100%;
  }
}
@media (max-width: 720px) {
  .platform-settings-tabs-wrap {
    margin-right: -4px;
    margin-left: -4px;
  }
  #platformGeneralFields,
  .platform-integration-grid {
    grid-template-columns: 1fr !important;
  }
  .profile-logo-layout {
    align-items: stretch;
    flex-direction: column;
  }
  .profile-logo-controls {
    width: 100%;
  }
  .profile-logo-input-row {
    grid-template-columns: 1fr;
    width: 100%;
  }
  .platform-settings-actions .btn-primary,
  #profileLogoUploadButton,
  #profileLogoSaveButton,
  #profileLogoRemoveButton {
    width: 100%;
  }
  .ai-model-header,
  .ai-model-section-head,
  .ai-model-form-row,
  .ai-model-add-row,
  .ai-model-activity-filter,
  .ai-model-pagination,
  .ai-model-catalogue-row {
    align-items: stretch;
    flex-direction: column;
  }
  .prompt-library-header,
  .prompt-library-toolbar,
  .prompt-library-detail-head,
  .prompt-library-section-head,
  .prompt-library-filters {
    align-items: stretch;
    flex-direction: column;
  }
  .prompt-library-filters input,
  .prompt-library-filters select {
    min-width: 0;
    width: 100%;
  }
  .prompt-library-filters {
    grid-template-columns: 1fr;
  }
  .prompt-library-catalogue,
  .prompt-library-detail {
    padding: 14px;
  }
  .prompt-library-header button,
  .prompt-library-section-head button {
    width: 100%;
  }
  .prompt-library-section-head .journal-toolbar-actions {
    flex-direction: column;
  }
  .prompt-library-section-head .journal-toolbar-actions .btn-secondary {
    justify-content: center;
    width: 100%;
  }
  .prompt-library-actions button {
    flex: 1 1 160px;
  }
  .prompt-library-facts,
  .prompt-library-contract-grid {
    grid-template-columns: 1fr;
  }
  .journal-toolbar {
    align-items: stretch !important;
    flex-direction: column;
    gap: 10px;
  }
  .journal-toolbar-actions {
    align-items: stretch;
    flex-wrap: wrap;
    width: 100%;
  }
  .journal-toolbar-actions .journal-date-control {
    min-width: 0;
    width: 100%;
  }
  .journal-toolbar-actions .btn-secondary {
    flex: 1 1 auto;
  }
  .operator-timezone-row {
    max-width: none;
    width: 100%;
  }
  .operator-timezone-field {
    min-width: 0;
    width: 100%;
  }
  .operator-timezone-row .btn-primary {
    width: 100%;
  }
  .ai-model-add-row {
    max-width: none;
    width: 100%;
  }
  .ai-model-add-row .btn-primary {
    width: 100%;
  }
  .ai-model-field {
    min-width: 0;
    width: 100%;
  }
  .ai-model-platform-badge,
  .ai-model-source-badge {
    align-self: flex-start;
  }
}
