/* =========================================================
   WEBDOCS SUPPORT ADMIN DASHBOARD — CLEAN FINAL CSS
   Serious admin workspace · readable · responsive · stable
========================================================= */

/* =========================================================
   DESIGN TOKENS
========================================================= */

:root {
  --sa-bg: #f4f7fa;
  --sa-bg-soft: #eef3f7;
  --sa-surface: #ffffff;
  --sa-surface-soft: #f8fafc;
  --sa-surface-muted: #f1f5f9;

  --sa-text: #07111f;
  --sa-text-soft: #1f2f40;
  --sa-muted: #536579;
  --sa-faint: #78889a;

  --sa-line: #0f172a;
  --sa-line-soft: #b9c6d3;
  --sa-line-faint: #d8e0e8;

  --sa-blue: #0f3a5a;
  --sa-blue-2: #145c8b;
  --sa-blue-soft: #e7f2fb;

  --sa-green: #16724f;
  --sa-green-soft: #e9f8f0;

  --sa-yellow: #8b5d13;
  --sa-yellow-soft: #fff4d8;

  --sa-red: #a83246;
  --sa-red-soft: #fff0f3;

  --sa-shadow: 0 14px 32px rgba(15, 23, 42, 0.07);
  --sa-shadow-strong: 0 28px 80px rgba(15, 23, 42, 0.16);

  --sa-radius-lg: 20px;
  --sa-radius: 16px;
  --sa-radius-sm: 12px;
  --sa-radius-xs: 10px;

  --sa-header-h: 92px;
  --sa-gap: 12px;

  --sa-font:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

/* =========================================================
   RESET / BASE
========================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  color-scheme: light;
  overflow-x: hidden;
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  font-family: var(--sa-font);
  color: var(--sa-text);
  background:
    radial-gradient(circle at 10% 8%, rgba(20, 92, 139, 0.08), transparent 28%),
    linear-gradient(180deg, #ffffff 0%, var(--sa-bg) 30%, var(--sa-bg-soft) 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg,
video,
iframe {
  display: block;
  max-width: 100%;
}

[hidden],
.sa-hidden {
  display: none !important;
}

/* =========================================================
   APP MODES
========================================================= */

body.sa-login-mode {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(15, 58, 90, 0.12), transparent 30%),
    radial-gradient(circle at 86% 18%, rgba(139, 93, 19, 0.08), transparent 24%),
    #f3f7fb;
}

body.sa-login-mode .sa-header,
body.sa-login-mode .wau-global-footer,
body.sa-login-mode .sa-footer,
body.sa-login-mode .sa-auth-only {
  display: none !important;
}

body.sa-login-mode .sa-page {
  min-height: 100vh;
  padding: 24px;
  display: grid;
  place-items: center;
}

body.sa-app-mode .sa-auth-only {
  display: flex;
}

body.sa-app-mode #saAdminFooter.sa-auth-only,
body.sa-app-mode .wau-global-footer.sa-auth-only {
  display: block;
}

/* =========================================================
   TYPOGRAPHY / SMALL UTILS
========================================================= */

.sa-kicker {
  margin: 0 0 6px;
  color: var(--sa-blue-2);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 850;
}

.sa-copy,
.sa-note,
.sa-muted-text {
  color: var(--sa-muted);
}

.sa-empty-block,
.sa-empty-state {
  display: grid;
  gap: 8px;
  align-content: center;
  justify-items: start;
  padding: 22px 18px;
  color: var(--sa-muted);
}

.sa-empty-state h3 {
  margin: 0;
  color: var(--sa-text);
  font-size: 24px;
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.sa-empty-state p {
  margin: 0;
  max-width: 760px;
  line-height: 1.65;
}

/* =========================================================
   CHIPS / BADGES / STATUS
========================================================= */

.sa-chip,
.sa-inline-chip,
.sa-counter,
.sa-connection-chip,
.sa-connection-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  max-width: 100%;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1.5px solid var(--sa-line-soft);
  background: var(--sa-surface);
  color: var(--sa-text-soft);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 750;
  white-space: nowrap;
}

.sa-chip-outline {
  background: var(--sa-surface-soft);
  color: var(--sa-blue);
}

.sa-status-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--sa-yellow);
  box-shadow: 0 0 0 4px rgba(139, 93, 19, 0.14);
}

.sa-status-dot.is-online {
  background: var(--sa-green);
  box-shadow: 0 0 0 4px rgba(22, 114, 79, 0.14);
}

.sa-status-dot.is-offline {
  background: var(--sa-red);
  box-shadow: 0 0 0 4px rgba(168, 50, 70, 0.14);
}

.sa-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1.5px solid var(--sa-line-soft);
  background: var(--sa-surface-soft);
  color: var(--sa-muted);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 850;
}

.sa-badge.is-green {
  background: var(--sa-green-soft);
  border-color: #abdcc7;
  color: var(--sa-green);
}

.sa-badge.is-yellow {
  background: var(--sa-yellow-soft);
  border-color: #e0bf78;
  color: var(--sa-yellow);
}

.sa-badge.is-red {
  background: var(--sa-red-soft);
  border-color: #e3aab4;
  color: var(--sa-red);
}

.sa-badge.is-blue {
  background: var(--sa-blue-soft);
  border-color: #acc7dc;
  color: var(--sa-blue);
}

/* =========================================================
   BUTTONS / FORMS
========================================================= */

.sa-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border-radius: var(--sa-radius-xs);
  border: 1.5px solid var(--sa-line);
  background: #ffffff;
  color: var(--sa-line);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.2;
  text-align: center;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.sa-btn:hover,
.sa-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
  outline: none;
}

.sa-btn-primary {
  background: var(--sa-line);
  color: #ffffff;
}

.sa-btn-primary:hover,
.sa-btn-primary:focus-visible {
  background: var(--sa-blue);
}

.sa-btn-soft {
  background: var(--sa-surface-soft);
  color: var(--sa-text);
  border-color: var(--sa-line-soft);
}

.sa-btn-soft:hover,
.sa-btn-soft:focus-visible {
  background: #ffffff;
  border-color: var(--sa-line);
}

.sa-btn-danger-soft {
  background: var(--sa-red-soft);
  color: var(--sa-red);
  border-color: #e3aab4;
}

.sa-field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.sa-field-fill {
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
}

.sa-field label {
  color: var(--sa-muted);
  font-size: 12px;
  font-weight: 850;
}

.sa-field input,
.sa-field select,
.sa-field textarea {
  width: 100%;
  min-width: 0;
  border: 1.5px solid var(--sa-line-soft);
  border-radius: var(--sa-radius-xs);
  background: #ffffff;
  color: var(--sa-text);
  padding: 11px 12px;
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.sa-field textarea {
  resize: vertical;
}

.sa-field input:focus,
.sa-field select:focus,
.sa-field textarea:focus {
  border-color: var(--sa-blue-2);
  box-shadow: 0 0 0 4px rgba(20, 92, 139, 0.11);
}

.sa-form {
  display: grid;
  gap: 12px;
}

.sa-form-fill {
  height: 100%;
  min-height: 0;
  grid-template-rows: auto minmax(220px, 1fr) auto;
}

.sa-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* =========================================================
   LOGIN
========================================================= */

.sa-login-wrap {
  width: 100%;
  display: grid;
  place-items: center;
}

body.sa-login-mode .sa-login-card {
  width: min(560px, 100%);
  overflow: hidden;
  border: 2px solid var(--sa-line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--sa-shadow-strong);
}

body.sa-login-mode .sa-login-grid {
  display: block;
}

body.sa-login-mode .sa-login-copy {
  padding: 26px 26px 14px;
  border-bottom: 1px solid var(--sa-line-faint);
  background:
    radial-gradient(circle at 95% 12%, rgba(20, 92, 139, 0.10), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

body.sa-login-mode .sa-login-copy h1 {
  margin: 0 0 10px;
  color: var(--sa-text);
  font-size: clamp(28px, 5vw, 38px);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

body.sa-login-mode .sa-login-copy p {
  margin: 0;
  font-size: 13px;
  line-height: 1.62;
}

body.sa-login-mode .sa-login-points {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  margin-top: 16px;
}

body.sa-login-mode .sa-point-card {
  display: grid;
  gap: 4px;
  padding: 12px 13px;
  border: 1.5px solid var(--sa-line-soft);
  border-radius: 14px;
  background: #ffffff;
}

body.sa-login-mode .sa-point-card strong {
  font-size: 13px;
}

body.sa-login-mode .sa-point-card span {
  color: var(--sa-muted);
  font-size: 12px;
  line-height: 1.5;
}

body.sa-login-mode .sa-login-panel {
  display: grid;
  gap: 14px;
  padding: 24px 26px 26px;
  background: var(--sa-surface);
}

/* =========================================================
   HEADER
========================================================= */

.sa-header {
  min-height: var(--sa-header-h);
  padding: 10px 12px;
  border-bottom: 2px solid var(--sa-line);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

.sa-header-shell {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.sa-header-left {
  min-width: 0;
}

.sa-brand-admin {
  padding: 6px 8px 6px 0;
}

.sa-header-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sa-header .sa-chip {
  min-height: 34px;
  border-color: #9fb0c0;
  background: #f8fafc;
  color: var(--sa-blue);
  font-weight: 850;
}

.sa-top-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px 16px;
  flex-wrap: wrap;
}

.sa-top-links a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--sa-muted);
  font-size: 15px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.sa-top-links a:hover,
.sa-top-links a:focus-visible {
  color: var(--sa-line);
  background: #ffffff;
  border-color: var(--sa-line-soft);
  outline: none;
}

/* =========================================================
   PAGE / APP SHELL
========================================================= */

.sa-page {
  min-height: calc(100vh - var(--sa-header-h));
  padding: 12px;
}

.sa-app {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: var(--sa-gap);
  min-height: calc(100vh - var(--sa-header-h) - 24px);
}

.sa-screen {
  min-height: 0;
}

.sa-screen-active {
  display: block;
}

/* =========================================================
   SHARED PANELS
========================================================= */

.sa-card,
.sa-subcard,
.sa-toolbar,
.sa-system-strip,
.sa-ops-metrics,
.sa-nav {
  border: 2px solid var(--sa-line);
  border-radius: var(--sa-radius-lg);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--sa-shadow);
}

.sa-card {
  overflow: hidden;
}

.sa-card-fill,
.sa-subcard,
.sa-main-detail,
.sa-sidebar,
.sa-detail-main,
.sa-detail-side,
.sa-investigation-main,
.sa-investigation-side {
  min-height: 0;
}

.sa-card-head,
.sa-subcard-head,
.sa-panel-head,
.sa-panel-head-tight {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.sa-card-head,
.sa-subcard-head {
  padding: 14px 16px;
  border-bottom: 1.5px solid var(--sa-line-faint);
  background: linear-gradient(180deg, #ffffff 0%, var(--sa-surface-soft) 100%);
}

.sa-panel-head-tight h2 {
  margin: 0;
  font-size: 22px;
}

.sa-card-head h3,
.sa-subcard-head h4 {
  margin: 0;
  color: var(--sa-text);
  font-size: 16px;
}

.sa-subcard-head h4 {
  font-size: 14px;
}

.sa-card-head span,
.sa-subcard-head span {
  color: var(--sa-faint);
  font-size: 12px;
}

.sa-screen-body,
.sa-subcard-body {
  min-height: 0;
  overflow: auto;
  padding: 14px 16px;
}

/* =========================================================
   TOP TOOLBAR / SYSTEM STRIP / NAV
========================================================= */

.sa-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}

.sa-toolbar-left,
.sa-toolbar-right,
.sa-toolbar-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.sa-toolbar-brand h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
}

#saSessionStarted,
#saSessionCounter,
#saSessionExpiry {
  font-variant-numeric: tabular-nums;
}

#saSessionCounter.is-warning {
  background: var(--sa-yellow-soft);
  border-color: #e6c37c;
  color: var(--sa-yellow);
}

#saSessionCounter.is-danger {
  background: var(--sa-red-soft);
  border-color: #df9cab;
  color: var(--sa-red);
}

.sa-system-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
}

.sa-strip-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-right: 1.5px solid var(--sa-line-faint);
  background: linear-gradient(180deg, #ffffff 0%, #f9fbfd 100%);
}

.sa-strip-card:last-child {
  border-right: 0;
}

.sa-strip-label {
  color: var(--sa-muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 850;
}

.sa-strip-card strong {
  color: var(--sa-line);
  font-size: 16px;
}

.sa-nav {
  display: flex;
  gap: 8px;
  padding: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.sa-nav::-webkit-scrollbar {
  display: none;
}

.sa-nav-item {
  flex: 0 0 auto;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sa-muted);
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.sa-nav-item:hover,
.sa-nav-item:focus-visible {
  background: var(--sa-surface-soft);
  color: var(--sa-text);
  outline: none;
}

.sa-nav-item.is-active {
  background: var(--sa-line);
  border-color: var(--sa-line);
  color: #ffffff;
}

/* =========================================================
   OPERATIONS COUNTERS
========================================================= */

.sa-ops-metrics {
  overflow: hidden;
}

.sa-ops-metrics-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1.5px solid var(--sa-line-faint);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.sa-ops-metrics-head h3 {
  margin: 0;
  font-size: 16px;
}

.sa-range-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border: 1.5px solid var(--sa-line-soft);
  border-radius: 999px;
  background: var(--sa-surface-soft);
}

.sa-range-btn {
  padding: 8px 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--sa-muted);
  font-size: 12px;
  font-weight: 850;
}

.sa-range-btn:hover,
.sa-range-btn:focus-visible {
  background: #ffffff;
  color: var(--sa-text);
  outline: none;
}

.sa-range-btn.is-active {
  background: var(--sa-line);
  color: #ffffff;
}

.sa-ops-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
}

.sa-ops-card {
  display: grid;
  align-content: center;
  gap: 7px;
  min-height: 106px;
  padding: 14px 16px;
  border-right: 1.5px solid var(--sa-line-faint);
  background: #ffffff;
}

.sa-ops-card:last-child {
  border-right: 0;
}

.sa-ops-card span {
  color: var(--sa-muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 850;
}

.sa-ops-card strong {
  color: var(--sa-line);
  font-size: 30px;
  line-height: 1;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.sa-ops-card small {
  color: var(--sa-faint);
  font-size: 11px;
  line-height: 1.35;
}

.sa-ops-card-ai {
  background: linear-gradient(180deg, #fff8e8 0%, #ffffff 100%);
}

/* =========================================================
   MAIN TICKET WORKSPACE
========================================================= */

.sa-grid-main {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: var(--sa-gap);
  min-height: 540px;
  height: calc(100vh - var(--sa-header-h) - 365px);
}

.sa-sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--sa-gap);
}

.sa-main-detail {
  min-height: 0;
}

.sa-ticket-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 100%;
  height: 100%;
  overflow: auto;
  padding: 8px;
  background: var(--sa-bg-soft);
}

.sa-ticket-item {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 1.5px solid var(--sa-line-soft);
  border-radius: 12px;
  background: #ffffff;
  text-align: left;
}

.sa-ticket-item:hover,
.sa-ticket-item:focus-visible {
  border-color: var(--sa-line);
  background: #fcfdff;
  outline: none;
}

.sa-ticket-item.is-active {
  border-color: var(--sa-line);
  background: var(--sa-blue-soft);
  box-shadow: inset 4px 0 0 var(--sa-line);
}

.sa-ticket-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sa-ticket-id,
.sa-ticket-subject {
  color: var(--sa-text);
  font-size: 13px;
  word-break: break-word;
}

.sa-ticket-status {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1.5px solid var(--sa-line-soft);
  background: var(--sa-surface-soft);
  color: var(--sa-muted);
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.sa-ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--sa-faint);
  font-size: 11px;
}

/* =========================================================
   TICKET DETAIL
========================================================= */

.sa-ticket-detail {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  height: 100%;
  min-height: 0;
  padding: 14px;
}

.sa-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1.5px solid var(--sa-line-soft);
  border-radius: 16px;
  background: #ffffff;
}

.sa-detail-title {
  min-width: 0;
}

.sa-detail-title h3 {
  margin: 0 0 8px;
  font-size: 22px;
  line-height: 1.12;
  letter-spacing: -0.025em;
}

.sa-ticket-id-line {
  color: var(--sa-faint);
  font-size: 12px;
  word-break: break-word;
}

.sa-detail-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.sa-meta-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.sa-meta-card {
  min-width: 0;
  padding: 10px;
  border: 1.5px solid var(--sa-line-soft);
  border-radius: 12px;
  background: #ffffff;
}

.sa-meta-label {
  display: block;
  margin-bottom: 6px;
  color: var(--sa-faint);
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-weight: 850;
}

.sa-meta-value {
  color: var(--sa-text);
  font-size: 12px;
  word-break: break-word;
}

.sa-detail-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 12px;
  min-height: 0;
}

.sa-detail-main {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 0;
}

.sa-detail-side {
  display: grid;
  grid-template-rows: auto auto auto minmax(280px, 1fr);
  gap: 12px;
  min-height: 0;
}

/* =========================================================
   THREAD / MESSAGES / ATTACHMENTS
========================================================= */

.sa-thread,
.sa-attachments,
.sa-mini-list-wrap,
#saInvestigationTimeline,
#saInvestigationEvents,
#saInvestigationKnowledge,
#saInvestigationEmails,
#saInvestigationBillingSummary,
#saInvestigationBillingUsage,
#saInvestigationBillingAlerts,
#saInvestigationBillingPayments,
.sa-ai-result {
  min-height: 0;
  overflow: auto;
}

.sa-thread,
.sa-attachments {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  background: var(--sa-bg-soft);
}

.sa-message {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1.5px solid var(--sa-line-soft);
  border-radius: 12px;
  background: #ffffff;
}

.sa-message.is-visitor {
  background: #fbfdff;
  border-color: #9ebad1;
}

.sa-message.is-human {
  background: #f4fcf8;
  border-color: #addcc8;
}

.sa-message.is-assistant {
  background: #fff8e8;
  border-color: #e3c174;
}

.sa-message.is-system {
  background: #f7f9fb;
  border-color: #ccd8e2;
}

.sa-message-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
}

.sa-message-sender {
  color: var(--sa-text);
  font-weight: 850;
}

.sa-message-time {
  color: var(--sa-faint);
}

.sa-message-body {
  color: var(--sa-text-soft);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.sa-attachment-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1.5px solid var(--sa-line-soft);
  border-radius: 12px;
  background: #ffffff;
}

.sa-attachment-name {
  font-size: 13px;
  font-weight: 850;
  word-break: break-word;
}

.sa-attachment-meta {
  color: var(--sa-faint);
  font-size: 11px;
}

/* =========================================================
   D1 / DATA BOXES
========================================================= */

.sa-d1-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.sa-d1-box {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 12px;
  border: 1.5px solid var(--sa-line-soft);
  border-radius: 12px;
  background: #ffffff;
}

.sa-d1-label {
  color: var(--sa-faint);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 850;
}

.sa-d1-box strong {
  color: var(--sa-text);
  font-size: 13px;
  word-break: break-word;
}

/* =========================================================
   BILLING / LISTS / TABLES
========================================================= */

.sa-billing-stack {
  display: grid;
  gap: 10px;
}

.sa-billing-card,
.sa-list-card,
.sa-stat-box,
.sa-data-card,
.sa-metric-card,
.sa-investigation-box {
  border: 1.5px solid var(--sa-line-soft);
  border-radius: 14px;
  background: #ffffff;
}

.sa-billing-card {
  overflow: hidden;
}

.sa-billing-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--sa-line-faint);
  background: var(--sa-surface-soft);
}

.sa-billing-card-head h5 {
  margin: 0;
  font-size: 13px;
}

.sa-billing-card-head span {
  color: var(--sa-muted);
  font-size: 11px;
}

.sa-key-grid {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.sa-key-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.sa-key-row dt {
  color: var(--sa-faint);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 850;
}

.sa-key-row dd {
  margin: 0;
  color: var(--sa-text);
  font-size: 12px;
  word-break: break-word;
}

.sa-billing-usage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
}

.sa-stat-box {
  display: grid;
  gap: 5px;
  padding: 10px;
}

.sa-stat-box span,
.sa-metric-label {
  color: var(--sa-faint);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 850;
}

.sa-stat-box strong {
  color: var(--sa-line);
  font-size: 15px;
}

.sa-list-card {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  padding: 10px;
}

.sa-list-card:last-child {
  margin-bottom: 0;
}

.sa-list-title {
  font-size: 12px;
  font-weight: 850;
}

.sa-list-meta {
  color: var(--sa-faint);
  font-size: 11px;
  line-height: 1.5;
}

.sa-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.sa-metric-card {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.sa-metric-value {
  color: var(--sa-line);
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
}

.sa-overview-latest {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.sa-data-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.sa-data-card h3 {
  margin: 0;
  font-size: 14px;
}

.sa-mini-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--sa-muted);
  font-size: 12px;
  line-height: 1.55;
}

.sa-table-wrap {
  overflow: auto;
  border: 1.5px solid var(--sa-line-soft);
  border-radius: 16px;
  background: #ffffff;
}

.sa-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.sa-table th,
.sa-table td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--sa-line-faint);
  text-align: left;
  vertical-align: top;
  font-size: 12px;
}

.sa-table th {
  background: var(--sa-surface-soft);
  color: var(--sa-text);
  font-weight: 850;
}

.sa-table td {
  color: var(--sa-text-soft);
}

/* =========================================================
   INVESTIGATION
========================================================= */

.sa-investigation-layout {
  display: grid;
  gap: var(--sa-gap);
}

.sa-investigation-top-copy {
  padding: 14px 16px;
  color: var(--sa-muted);
}

.sa-investigation-top-copy p {
  margin: 0;
  line-height: 1.6;
}

.sa-investigation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: var(--sa-gap);
}

.sa-investigation-main,
.sa-investigation-side {
  display: grid;
  align-content: start;
  gap: var(--sa-gap);
}

.sa-investigation-billing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.sa-investigation-box {
  min-height: 130px;
  padding: 14px;
}

.sa-investigation-box h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.sa-ai-workbench {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 16px;
}

.sa-ai-result {
  min-height: 220px;
  padding: 14px;
  border: 1.5px solid var(--sa-line-soft);
  border-radius: 14px;
  background: #ffffff;
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1400px) {
  .sa-grid-main {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .sa-detail-body,
  .sa-investigation-grid {
    grid-template-columns: minmax(0, 1fr) 360px;
  }
}

@media (max-width: 1200px) {
  .sa-header-shell {
    align-items: stretch;
    flex-direction: column;
  }

  .sa-top-links {
    justify-content: flex-start;
  }

  .sa-system-strip,
  .sa-ops-grid,
  .sa-meta-grid,
  .sa-overview-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sa-strip-card,
  .sa-ops-card {
    border-right: 0;
    border-bottom: 1px solid var(--sa-line-faint);
  }

  .sa-grid-main,
  .sa-detail-body,
  .sa-investigation-grid,
  .sa-ai-workbench {
    height: auto;
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .sa-sidebar,
  .sa-detail-side {
    grid-template-rows: auto;
  }

  .sa-ticket-list {
    max-height: 420px;
  }
}

@media (max-width: 780px) {
  :root {
    --sa-gap: 10px;
  }

  body.sa-login-mode .sa-page,
  .sa-page {
    padding: 8px;
  }

  .sa-header {
    padding: 8px;
  }

  .sa-toolbar,
  .sa-ops-metrics-head,
  .sa-detail-header,
  .sa-billing-card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .sa-toolbar-left,
  .sa-toolbar-right,
  .sa-toolbar-meta,
  .sa-detail-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .sa-system-strip,
  .sa-ops-grid,
  .sa-meta-grid,
  .sa-d1-grid,
  .sa-overview-grid,
  .sa-overview-latest,
  .sa-investigation-billing-grid,
  .sa-billing-usage-grid {
    grid-template-columns: 1fr;
  }

  .sa-range-tabs {
    width: 100%;
    justify-content: space-between;
  }

  .sa-range-btn {
    flex: 1;
  }

  .sa-form-actions,
  .sa-detail-actions {
    flex-direction: column;
  }

  .sa-btn {
    width: 100%;
  }

  .sa-key-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .sa-card,
  .sa-subcard,
  .sa-toolbar,
  .sa-system-strip,
  .sa-ops-metrics,
  .sa-nav {
    border-radius: 16px;
  }

  .sa-card-head,
  .sa-subcard-head,
  .sa-screen-body,
  .sa-subcard-body,
  .sa-ticket-detail,
  .sa-ai-workbench {
    padding: 12px;
  }

  .sa-ticket-list {
    max-height: 360px;
  }
}

@media (max-width: 520px) {
  .sa-top-links a {
    width: 100%;
    justify-content: center;
  }

  .sa-header-chips .sa-chip,
  .sa-toolbar-meta .sa-chip,
  .sa-counter,
  .sa-connection-chip,
  .sa-connection-box {
    width: 100%;
    justify-content: center;
    white-space: normal;
    text-align: center;
  }

  .sa-range-tabs {
    border-radius: 16px;
    flex-wrap: wrap;
  }

  .sa-range-btn {
    min-width: calc(50% - 3px);
  }

  body.sa-login-mode .sa-login-copy,
  body.sa-login-mode .sa-login-panel {
    padding-left: 18px;
    padding-right: 18px;
  }
}