:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-warm: var(--surface);
  --surface-subtle: #f6f7f8;
  --surface-hover: #f4f7fc;
  --fg: #111111;
  --fg-2: var(--fg);
  --muted: #6b6b6b;
  --meta: var(--muted);
  --border: #e5e5e5;
  --border-soft: var(--border);
  --accent: #2f6feb;
  --accent-on: #ffffff;
  --accent-soft: #edf4ff;
  --accent-hover: #285fc9;
  --accent-active: #2354b2;
  --success: #178541;
  --success-soft: #ecf8f0;
  --warn: #a86405;
  --warn-soft: #fff8e5;
  --danger: #c92929;
  --danger-soft: #fff0f0;
  --info: #087f8c;
  --info-soft: #edf9fa;
  --font-display: "HarmonyOS Sans SC", "MiSans", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-body: "HarmonyOS Sans SC", "MiSans", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --leading-body: 1.5;
  --leading-tight: 1.2;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --elev-flat: none;
  --elev-raised: 0 8px 24px rgb(17 17 17 / 10%);
  --focus-ring: 0 0 0 3px rgb(47 111 235 / 24%);
  --motion-fast: 150ms;
  --motion-base: 200ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --sidebar-width: 260px;
  --topbar-height: 56px;
}

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

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  color: var(--fg);
  background: var(--bg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

body.is-locked { overflow: hidden; }

button, input, select, textarea { color: inherit; font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
a { color: inherit; }
svg { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }

/* Authentication */
.auth-page { min-height: 100vh; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 416px); padding: 30px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border-radius: var(--radius-sm); color: var(--accent-on); background: var(--accent); font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.brand-mark-small { width: 34px; height: 34px; font-size: 16px; flex: 0 0 auto; }
.auth-heading { margin: 18px 0 24px; }
.auth-heading h1 { margin: 0; font-size: var(--text-2xl); line-height: var(--leading-tight); }
.auth-heading p { margin: 6px 0 0; color: var(--muted); font-size: var(--text-sm); }
.auth-form { display: grid; gap: 16px; }
.password-field { position: relative; }
.password-field input { padding-right: 48px; }
.password-toggle { position: absolute; top: 3px; right: 3px; }

/* Form controls */
.field { display: grid; min-width: 0; gap: 7px; }
.field label, .field-label { font-size: var(--text-sm); font-weight: 600; }
.required { color: var(--danger); }
.help-text { margin: 0; color: var(--muted); font-size: var(--text-xs); }
.form-message { min-height: 20px; margin: -2px 0 0; font-size: var(--text-sm); }
.form-message:empty { min-height: 0; }
.form-message.is-error { color: var(--danger); }
.form-message.is-success { color: var(--success); }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #d7d9dd;
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
textarea { min-height: 88px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #b8bdc5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; color: var(--muted); background: var(--surface-subtle); opacity: .8; }
input[type="checkbox"], input[type="radio"] { width: 16px; min-height: 16px; padding: 0; accent-color: var(--accent); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.checkbox-label { display: inline-flex; align-items: center; min-height: 40px; gap: 9px; font-size: var(--text-sm); font-weight: 500; }

/* Buttons */
.button, .icon-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--motion-fast), background var(--motion-fast), border-color var(--motion-fast), transform var(--motion-fast);
}
.button { padding: 8px 14px; }
.button svg { width: 17px; height: 17px; }
.button:hover, .icon-button:hover { text-decoration: none; }
.button:active, .icon-button:active { transform: translateY(1px); }
.button:disabled, .icon-button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button-primary { color: var(--accent-on); background: var(--accent); }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
.button-primary:active:not(:disabled) { background: var(--accent-active); }
.button-secondary { color: var(--fg); border-color: var(--border); background: var(--surface); }
.button-secondary:hover:not(:disabled) { border-color: #c8ccd2; background: var(--surface-subtle); }
.button-danger { color: #fff; background: var(--danger); }
.button-danger:hover:not(:disabled) { background: #ad2020; }
.button-quiet { color: var(--accent); background: transparent; }
.button-quiet:hover:not(:disabled) { background: var(--accent-soft); }
.button-block { width: 100%; }
.button-compact { min-height: 36px; padding: 6px 10px; font-size: var(--text-sm); }
.icon-button { position: relative; width: 40px; min-width: 40px; padding: 0; color: var(--muted); border-color: transparent; background: transparent; }
.icon-button:hover:not(:disabled) { color: var(--fg); background: var(--surface-subtle); }
.button.is-loading .button-label { opacity: .65; }
.button .spinner { display: none; }
.button.is-loading .spinner { display: block; }
[data-tooltip]::after {
  position: absolute;
  z-index: 80;
  top: calc(100% + 7px);
  left: 50%;
  max-width: 180px;
  padding: 5px 8px;
  transform: translate(-50%, -3px);
  border-radius: 5px;
  color: #fff;
  background: #24262a;
  content: attr(data-tooltip);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity var(--motion-fast), transform var(--motion-fast);
}
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.is-visible { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Application shell */
.auth-gate { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); background: var(--bg); font-size: var(--text-sm); }
.sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; display: flex; width: var(--sidebar-width); flex-direction: column; border-right: 1px solid var(--border); background: var(--surface); }
.sidebar-brand { display: flex; min-height: var(--topbar-height); align-items: center; gap: 11px; padding: 9px 18px; border-bottom: 1px solid var(--border); }
.sidebar-brand span:last-child { display: grid; line-height: 1.2; }
.sidebar-brand strong { font-size: 15px; }
.sidebar-brand small { margin-top: 2px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.sidebar-close { margin-left: auto; }
.main-nav { display: grid; align-content: start; flex: 1; gap: 3px; overflow-y: auto; padding: 14px 12px; }
.main-nav a { display: flex; min-height: 40px; align-items: center; gap: 11px; padding: 8px 11px; border-radius: 7px; color: #4d535b; font-size: var(--text-sm); font-weight: 550; text-decoration: none; }
.main-nav a svg { width: 18px; height: 18px; }
.main-nav a:hover { color: var(--accent); background: var(--accent-soft); }
.main-nav a.is-active { color: var(--accent-on); background: var(--accent); }
.sidebar-footer { display: flex; min-height: 52px; align-items: center; gap: 9px; padding: 10px 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: var(--text-xs); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.topbar { position: fixed; z-index: 30; top: 0; right: 0; left: var(--sidebar-width); display: flex; height: var(--topbar-height); align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--border); background: rgb(255 255 255 / 96%); }
.global-search { position: relative; display: block; width: min(320px, 40vw); }
.global-search svg { position: absolute; top: 10px; left: 11px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.global-search input { min-height: 36px; padding: 7px 10px 7px 35px; border-color: transparent; background: var(--surface-subtle); }
.global-search input:focus { border-color: var(--accent); background: var(--surface); }
.topbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.poll-status { color: var(--muted); font-size: var(--text-xs); }
.mobile-only { display: none; }
.main-content { min-height: 100vh; margin-left: var(--sidebar-width); padding: calc(var(--topbar-height) + 24px) 24px 36px; }
.sidebar-scrim, .drawer-scrim { position: fixed; z-index: 35; inset: 0; border: 0; background: rgb(17 17 17 / 40%); }
.sidebar-scrim { display: none; }

/* Page structure */
.page { width: min(100%, 1600px); margin: 0 auto; }
.page-header { display: flex; min-height: 44px; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-title h1 { margin: 0; font-size: var(--text-2xl); line-height: 1.25; }
.page-title p { margin: 5px 0 0; color: var(--muted); font-size: var(--text-sm); }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.eyebrow { margin: 0 0 3px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.section-stack { display: grid; gap: 18px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card { min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.metric-card .metric-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: var(--text-sm); }
.metric-value { display: block; margin-top: 10px; overflow: hidden; font-family: var(--font-mono); font-size: 26px; font-weight: 700; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
.metric-meta { display: block; min-height: 18px; margin-top: 8px; color: var(--muted); font-size: var(--text-xs); }
.metric-meta.is-good { color: var(--success); }
.metric-meta.is-bad { color: var(--danger); }
.two-column { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.two-column.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.panel-header { display: flex; min-height: 54px; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.panel-header h2 { margin: 0; font-size: var(--text-lg); line-height: 1.3; }
.panel-header p { margin: 2px 0 0; color: var(--muted); font-size: var(--text-xs); }
.panel-body { padding: 16px; }
.panel-body.flush { padding: 0; }
.panel-footer { display: flex; min-height: 56px; align-items: center; justify-content: flex-end; gap: 9px; padding: 10px 16px; border-top: 1px solid var(--border); }
.inline-feedback { min-height: 20px; margin-right: auto; font-size: var(--text-sm); }

/* Filters and tables */
.filter-bar { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.filter-bar .field { flex: 1 1 150px; gap: 4px; }
.filter-bar .field.grow { flex-basis: 240px; }
.filter-bar label { color: var(--muted); font-size: var(--text-xs); }
.filter-bar input, .filter-bar select { min-height: 36px; padding-top: 7px; padding-bottom: 7px; }
.filter-actions { display: flex; gap: 8px; }
.table-scroll { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.data-table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: var(--text-sm); }
.data-table.is-wide { min-width: 1120px; }
.data-table th, .data-table td { height: 46px; padding: 9px 13px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.data-table th { height: 40px; color: var(--muted); background: var(--surface-subtle); font-size: var(--text-xs); font-weight: 600; white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--surface-hover); }
.data-table td { max-width: 280px; }
.cell-ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-actions { display: flex; align-items: center; gap: 2px; white-space: nowrap; }
.cell-actions .icon-button { width: 34px; min-width: 34px; min-height: 34px; }
.table-state { display: grid; min-height: 210px; place-items: center; padding: 28px; text-align: center; }
.state-content { display: grid; max-width: 440px; justify-items: center; gap: 7px; color: var(--muted); }
.state-icon { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--border); border-radius: 50%; color: var(--muted); background: var(--surface-subtle); }
.state-content h3 { margin: 3px 0 0; color: var(--fg); font-size: var(--text-base); }
.state-content p { margin: 0; font-size: var(--text-sm); }
.state-content .button { margin-top: 5px; }
.state-content.is-error .state-icon { color: var(--danger); border-color: #f3c5c5; background: var(--danger-soft); }
.skeleton-lines { display: grid; width: min(320px, 75vw); gap: 9px; }
.skeleton-lines i { display: block; height: 9px; border-radius: 4px; background: #e9ebee; animation: pulse 1.4s ease-in-out infinite; }
.skeleton-lines i:nth-child(2) { width: 82%; }
.skeleton-lines i:nth-child(3) { width: 62%; }
@keyframes pulse { 50% { opacity: .45; } }

/* Status and data display */
.badge { display: inline-flex; min-height: 24px; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 999px; color: #4e555d; background: #f0f1f3; font-size: var(--text-xs); font-weight: 650; white-space: nowrap; }
.badge::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; opacity: .72; }
.badge-success { color: var(--success); background: var(--success-soft); }
.badge-warning { color: var(--warn); background: var(--warn-soft); }
.badge-danger { color: var(--danger); background: var(--danger-soft); }
.badge-info { color: var(--info); background: var(--info-soft); }
.badge-accent { color: var(--accent); background: var(--accent-soft); }
.progress { width: 110px; height: 7px; overflow: hidden; border: 0; border-radius: 5px; appearance: none; background: #e8eaed; }
.progress::-webkit-progress-bar { border-radius: 5px; background: #e8eaed; }
.progress::-webkit-progress-value { border-radius: 5px; background: var(--accent); }
.progress::-moz-progress-bar { border-radius: 5px; background: var(--accent); }
.definition-list { display: grid; grid-template-columns: 132px minmax(0, 1fr); margin: 0; border-top: 1px solid var(--border); }
.definition-list dt, .definition-list dd { min-height: 43px; margin: 0; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.definition-list dt { color: var(--muted); font-size: var(--text-sm); }
.definition-list dd { min-width: 0; overflow-wrap: anywhere; font-size: var(--text-sm); }
.definition-list > :nth-last-child(-n+2) { border-bottom: 0; }
.list-summary { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.list-summary li { display: flex; min-height: 45px; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); }
.list-summary li:last-child { border-bottom: 0; }
.list-summary strong { font-family: var(--font-mono); }
.segmented { display: inline-flex; min-height: 36px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-subtle); }
.segmented button { min-width: 60px; padding: 4px 10px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: var(--text-xs); font-weight: 600; }
.segmented button.is-active { color: var(--fg); background: var(--surface); box-shadow: 0 1px 2px rgb(17 17 17 / 8%); }
.credential-method { width: 100%; margin-bottom: 4px; }
.credential-method button { flex: 1; }
.credential-method-fields { display: grid; gap: 14px; }

/* Config and specialist forms */
.config-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 18px; align-items: start; }
.config-nav { position: sticky; top: calc(var(--topbar-height) + 24px); display: grid; gap: 3px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.config-nav button { min-height: 38px; padding: 8px 10px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: var(--text-sm); text-align: left; }
.config-nav button:hover, .config-nav button:focus-visible { color: var(--accent); background: var(--accent-soft); }
.config-sections { display: grid; min-width: 0; gap: 18px; }
.config-sections > .panel { scroll-margin-top: calc(var(--topbar-height) + 16px); }
.config-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.config-form-grid .span-2 { grid-column: span 2; }
.duration-matrix { min-width: 800px; border-collapse: collapse; font-size: var(--text-sm); }
.duration-matrix th, .duration-matrix td { min-width: 42px; height: 44px; padding: 7px; border-bottom: 1px solid var(--border); text-align: center; }
.duration-matrix th { color: var(--muted); background: var(--surface-subtle); font-size: var(--text-xs); }
.duration-matrix th:first-child, .duration-matrix td:first-child { position: sticky; left: 0; z-index: 1; min-width: 180px; text-align: left; background: var(--surface); }
.duration-matrix thead th:first-child { z-index: 2; background: var(--surface-subtle); }
.duration-matrix input { width: 16px; min-height: 16px; }
.model-name { display: flex; align-items: center; gap: 8px; }
.model-billing-grid { display: grid; gap: 20px; padding: 20px 16px; }
.model-billing-row { padding-top: 18px; border-top: 1px solid var(--border); }
.model-billing-row:first-child { padding-top: 0; border-top: 0; }
.model-billing-row h3 { margin: 0 0 12px; font-size: var(--text-sm); }
.switch { position: relative; display: inline-flex; width: 38px; height: 22px; flex: 0 0 auto; }
.switch input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch span { width: 100%; border-radius: 999px; background: #c9cdd3; transition: background var(--motion-fast); }
.switch span::after { display: block; width: 18px; height: 18px; margin: 2px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(17 17 17 / 22%); content: ""; transition: transform var(--motion-fast); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: var(--focus-ring); }
.import-form, .channel-form { display: grid; gap: 15px; }
.sensitive-note { display: flex; gap: 8px; padding: 10px 12px; border: 1px solid #cde2fc; border-radius: var(--radius-sm); color: #285784; background: #f2f8ff; font-size: var(--text-xs); }
.sensitive-note svg { width: 16px; height: 16px; flex: 0 0 auto; }

/* Drawers, modal and toast */
.detail-drawer { position: fixed; z-index: 70; top: 0; right: 0; bottom: 0; width: min(520px, calc(100vw - 24px)); overflow-y: auto; border-left: 1px solid var(--border); background: var(--surface); box-shadow: var(--elev-raised); animation: drawer-in var(--motion-base) var(--ease-standard); }
.drawer-scrim { z-index: 65; }
.drawer-header, .modal-header { display: flex; min-height: 70px; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 18px; border-bottom: 1px solid var(--border); }
.drawer-header h2, .modal-header h2 { margin: 0; font-size: var(--text-xl); }
.drawer-content, .modal-content { padding: 18px; }
@keyframes drawer-in { from { transform: translateX(20px); opacity: .4; } }
.app-modal { width: min(560px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 32px)); padding: 0; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--fg); background: var(--surface); box-shadow: var(--elev-raised); }
.app-modal::backdrop { background: rgb(17 17 17 / 44%); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; width: min(360px, calc(100vw - 32px)); gap: 9px; pointer-events: none; }
.toast { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 10px; padding: 12px 13px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--elev-raised); pointer-events: auto; animation: toast-in var(--motion-base) var(--ease-standard); }
.toast.is-success { border-left-color: var(--success); }
.toast.is-error { border-left-color: var(--danger); }
.toast strong { display: block; font-size: var(--text-sm); }
.toast p { margin: 2px 0 0; color: var(--muted); font-size: var(--text-xs); overflow-wrap: anywhere; }
.toast .icon-button { width: 28px; min-width: 28px; min-height: 28px; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column, .two-column.equal { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .mobile-only { display: inline-flex; }
  .sidebar { transform: translateX(-100%); transition: transform var(--motion-base) var(--ease-standard); box-shadow: var(--elev-raised); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .sidebar-scrim { display: block; }
  .topbar { left: 0; padding: 0 12px; }
  .main-content { margin-left: 0; padding-right: 16px; padding-left: 16px; }
  .config-layout { grid-template-columns: 1fr; }
  .config-nav { position: static; grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
}

@media (max-width: 640px) {
  :root { --topbar-height: 56px; }
  .sidebar { width: 100%; }
  .auth-shell { padding: 0; background: var(--surface); }
  .auth-card { width: 100%; min-height: 100vh; padding: 28px 20px; border: 0; border-radius: 0; }
  .auth-heading { margin-top: 16px; }
  .global-search { width: auto; flex: 1; }
  .global-search input { min-width: 0; }
  .topbar-actions .poll-status, #logout-button span { display: none; }
  #logout-button { width: 40px; min-width: 40px; padding: 0; }
  .main-content { padding: calc(var(--topbar-height) + 16px) 12px 28px; }
  .page-header { align-items: stretch; flex-direction: column; margin-bottom: 16px; }
  .page-title h1 { font-size: 21px; }
  .page-actions { justify-content: flex-start; }
  .page-actions .button { flex: 1; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { padding: 13px; }
  .metric-value { font-size: 21px; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-bar .field { width: 100%; flex-basis: auto; }
  .filter-actions { display: grid; grid-template-columns: repeat(2, 1fr); }
  .field-row, .field-row.three, .config-form-grid { grid-template-columns: 1fr; }
  .config-form-grid .span-2 { grid-column: auto; }
  .panel-header { align-items: flex-start; }
  .detail-drawer { inset: 0; width: 100%; border: 0; }
  .app-modal { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; border: 0; border-radius: 0; }
  .drawer-header, .modal-header { position: sticky; z-index: 2; top: 0; background: var(--surface); }
  .definition-list { grid-template-columns: 112px minmax(0, 1fr); }
  .toast-region { right: 10px; bottom: 10px; width: calc(100vw - 20px); }
  [data-tooltip]::after { display: none; }
}

@media (max-width: 400px) {
  .metric-grid { grid-template-columns: 1fr; }
  .topbar { gap: 4px; padding: 0 8px; }
  .topbar-actions { gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
