/* Rescue operations: warm, document-like workspace on an 8 px grid. */
:root {
  --canvas: #ffffff;
  --surface: #fbfbfa;
  --sidebar: #f7f6f3;
  --ink: #292926;
  --muted: #787774;
  --subtle: #999892;
  --line: #eaeaea;
  --primary: #242423;
  --primary-hover: #3b3b38;
  --green: #346538;
  --green-bg: #edf3ec;
  --amber: #85611c;
  --amber-bg: #fbf3db;
  --red: #9f2f2d;
  --red-bg: #fdebec;
  --focus: #595953;
  font-family: 'PingFang SC', 'Microsoft YaHei', 'SF Pro Display', 'Helvetica Neue', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

/* Base and text */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--canvas);
}
button,
input,
select,
textarea {
  font: inherit;
  line-height: 1.5;
}
button,
input,
select,
textarea,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  border: 0;
  cursor: pointer;
}
button:disabled,
[aria-disabled='true'] {
  cursor: not-allowed;
}
button:disabled {
  opacity: 0.48;
}
button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
button,
a {
  transition:
    background-color 120ms ease,
    color 120ms ease;
}
a {
  color: inherit;
  text-decoration-color: var(--subtle);
  text-underline-offset: 0.2em;
}
h1,
h2,
h3,
p {
  margin: 0;
  line-height: 1.5;
}
h1 {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.025em;
}
h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
h3 {
  font-size: 16px;
  font-weight: 600;
}
small,
.muted {
  color: var(--muted);
}
small {
  font-size: 12px;
}
svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
[hidden] {
  display: none !important;
}
.text-right {
  text-align: right;
}
.number,
.money,
.stat-value,
.source-value {
  font-variant-numeric: tabular-nums;
}
.money {
  font-weight: 500;
}
.note {
  color: var(--muted);
  font-size: 13px;
}
.subheading {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

/* Application frame */
.boot-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
  color: var(--muted);
}
.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100dvh;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: 240px;
  padding: 32px 24px 24px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 1px solid #dcdcd5;
  border-radius: 8px;
  background: var(--canvas);
  color: var(--ink);
  font-size: 22px;
  font-weight: 600;
}
.brand-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: -0.025em;
}
.brand-caption {
  margin-top: 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}
.nav-caption {
  margin: 40px 0 16px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 12px;
}
.nav {
  display: grid;
  gap: 8px;
}
.nav button {
  width: 100%;
  min-height: 48px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #66665f;
  background: transparent;
}
.nav button svg {
  width: 16px;
  height: 16px;
}
.nav button:hover {
  color: var(--ink);
  background: #eeede8;
}
.nav button.active {
  color: var(--ink);
  background: var(--canvas);
  border-color: var(--line);
  font-weight: 600;
}
.sidebar-bottom {
  margin-top: auto;
  padding-top: 40px;
}
.workspace-tag {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 16px 0;
  border-top: 1px solid #e3e2dc;
}
.workspace-tag svg {
  width: 16px;
  height: 16px;
  margin-top: 0;
  color: var(--muted);
}
.workspace-tag strong {
  display: block;
  font-size: 12px;
  font-weight: 500;
}
.workspace-tag small {
  display: block;
  margin-top: 8px;
  font-size: 11px;
}
.sidebar-note {
  padding-top: 8px;
  color: var(--muted);
  font-size: 11px;
}
.workspace {
  grid-column: 2;
  min-width: 0;
}
.topbar {
  min-height: 80px;
  padding: 16px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: var(--canvas);
}
.breadcrumb,
.topbar-right,
.user-control {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.breadcrumb,
.topbar-right {
  font-size: 12px;
  color: var(--muted);
}
.breadcrumb strong {
  font-weight: 500;
  color: var(--ink);
}
.topbar-right {
  flex-shrink: 0;
}
.user-control {
  padding-left: 24px;
  border-left: 1px solid var(--line);
  gap: 8px;
}
.avatar {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: var(--sidebar);
  color: var(--muted);
  font-size: 12px;
}
.logout {
  min-height: 40px;
  padding: 8px;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.logout:hover {
  background: var(--sidebar);
  color: var(--ink);
}
.content {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 40px;
  min-width: 0;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
}
.page-head > div:first-child {
  min-width: 0;
}
.page-head p {
  max-width: 720px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}
.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
}
.eyebrow {
  margin-bottom: 8px;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
}
.icon-btn.mobile-menu,
.mobile-overlay {
  display: none;
}

/* Controls and feedback */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--canvas);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.btn svg {
  width: 16px;
  height: 16px;
}
.btn:hover:not(:disabled) {
  background: var(--sidebar);
  border-color: #d5d4ce;
}
.btn:active:not(:disabled) {
  background: #eeede8;
}
.btn-primary {
  color: var(--canvas);
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled),
.btn-primary:active:not(:disabled) {
  color: var(--canvas);
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn-soft {
  background: var(--sidebar);
}
.btn-text {
  padding: 8px;
  background: transparent;
  border-color: transparent;
}
.btn-text:hover:not(:disabled) {
  border-color: transparent;
}
.btn-sm {
  padding: 8px;
  font-size: 12px;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
}
.icon-btn:hover {
  background: var(--sidebar);
  color: var(--ink);
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 9999px;
  background: #f1f0ec;
  color: #6d6c65;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.tag-green {
  color: var(--green);
  background: var(--green-bg);
}
.tag-amber {
  color: var(--amber);
  background: var(--amber-bg);
}
.tag-red {
  color: var(--red);
  background: var(--red-bg);
}
.dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: currentColor;
}
.notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: #66665f;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.notice svg {
  width: 16px;
  height: 16px;
  margin-top: 0;
}
.notice > div {
  min-width: 0;
}
.notice strong {
  font-weight: 600;
}
.notice-warning {
  color: var(--amber);
  background: var(--amber-bg);
  border-color: #eee3c4;
}
.form-error {
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid #f0d9d9;
  border-radius: 4px;
  background: var(--red-bg);
  color: var(--red);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.inline-error {
  display: block;
  max-width: 256px;
  margin-top: 8px;
  color: var(--red);
  font-size: 12px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 24px;
  max-width: min(640px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 16px 24px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: var(--canvas);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.toast.error {
  color: var(--red);
  background: var(--red-bg);
  border-color: #f0d9d9;
}

/* Cards, metrics and overview */
.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--canvas);
}
.content > .card + .card,
#query-result > .card + .card {
  margin-top: 24px;
}
.card-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}
.card-head > div {
  min-width: 0;
}
.card-head p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
.card-body {
  padding: 24px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  position: relative;
  padding: 24px;
}
.stat-label {
  padding-right: 24px;
  color: var(--muted);
  font-size: 12px;
}
.stat-icon {
  position: absolute;
  top: 24px;
  right: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: #aaa9a1;
}
.stat-icon svg {
  width: 16px;
  height: 16px;
}
.stat-value {
  margin: 24px 0 8px;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.035em;
  overflow-wrap: anywhere;
}
.stat-unit {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
}
.stat-meta {
  color: var(--muted);
  font-size: 12px;
}
.stat-feature {
  background: var(--surface);
}
.stat-feature .stat-value {
  font-weight: 600;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
  align-items: start;
  gap: 24px;
}
.wide {
  grid-column: 1 / -1;
}
.integration-list {
  padding: 0 24px;
}
.integration-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}
.integration-row:last-child {
  border-bottom: 0;
}
.integration-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #797971;
}
.integration-icon svg {
  width: 24px;
  height: 24px;
}
.integration-name {
  min-width: 0;
  flex: 1;
}
.integration-name strong {
  display: block;
  font-size: 13px;
  font-weight: 500;
}
.integration-name small {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.empty {
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  min-height: 280px;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-compact {
  min-height: 192px;
  padding: 32px 24px;
}
.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: #97968f;
}
.empty-icon svg {
  width: 24px;
  height: 24px;
}
.empty strong {
  color: #53534e;
  font-size: 14px;
  font-weight: 500;
}
.empty p {
  max-width: 384px;
  font-size: 13px;
}
.empty .btn {
  margin-top: 8px;
}
.rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px;
  padding: 24px;
}
.rule {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  min-width: 0;
}
.rule svg {
  width: 16px;
  height: 16px;
  color: #96958e;
}
.rule strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
}
.rule p {
  color: var(--muted);
  font-size: 12px;
}
.bar-list {
  display: grid;
  gap: 24px;
  padding: 24px;
}
.bar-row-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  font-size: 13px;
}
.bar-row-head strong {
  font-weight: 500;
}
.bar-track {
  height: 8px;
  border-radius: 4px;
  background: #f0efeb;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  background: #777a6d;
}
.footnote {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 32px;
  color: var(--muted);
  font-size: 11px;
}
.footnote svg {
  width: 16px;
  height: 16px;
}

/* Query filters and progress */
.filter-panel {
  padding: 24px;
  margin-bottom: 24px;
}
.filter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.range-shortcuts {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  border-radius: 4px;
  background: var(--sidebar);
}
.range-shortcuts button {
  min-width: 64px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.range-shortcuts button:hover:not(:disabled) {
  background: #eeede8;
}
.range-shortcuts button.active {
  border-color: #dcdcd5;
  background: var(--canvas);
  color: var(--ink);
  font-weight: 500;
}
.dates {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.dates input {
  width: 152px;
}
.filter-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}
.filter-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 24px;
}
.filter-toggles {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
}
.query-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-box {
  padding: 16px 24px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}
.progress-track {
  height: 8px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 4px;
  background: #eae9e4;
}
.progress-fill {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  background: #73776b;
  transform: scaleX(0);
  transform-origin: left;
}
.progress-fill.indeterminate {
  transform: scaleX(1);
  animation: subtle-pulse 1600ms ease-in-out infinite;
}
.data-context {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(224px, 100%), 1fr));
  gap: 16px;
  padding: 24px;
}
.source-card {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.source-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.source-value {
  margin: 24px 0 8px;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.025em;
}
.source-card p {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.source-card .inline-error {
  max-width: none;
}

/* Forms and connection settings */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}
.field {
  display: grid;
  align-content: start;
  min-width: 0;
  gap: 8px;
}
.field-full {
  grid-column: 1 / -1;
}
.field > label,
.field-label {
  color: #55554f;
  font-size: 13px;
  font-weight: 500;
}
.field > label .tag {
  margin-left: 8px;
}
.field > small {
  font-size: 12px;
  overflow-wrap: anywhere;
}
:where(input:not([type='checkbox']):not([type='radio']), select, textarea) {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid #ddddd6;
  border-radius: 4px;
  background: var(--canvas);
  color: var(--ink);
  font-size: 13px;
}
input::placeholder,
textarea::placeholder {
  color: #96958e;
  opacity: 1;
}
input:focus,
select:focus,
textarea:focus {
  border-color: #77776d;
}
input:disabled,
select:disabled,
textarea:disabled {
  background: #f4f3ef;
  color: var(--muted);
  cursor: not-allowed;
}
textarea {
  min-height: 104px;
  resize: vertical;
}
input[type='checkbox'],
input[type='radio'] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin: 0;
  accent-color: var(--primary);
}
.checks {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
}
.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  max-width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--canvas);
  color: #66665f;
  font-size: 12px;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.check-chip:has(input:checked) {
  color: var(--ink);
  border-color: #aeaea4;
  background: var(--sidebar);
}
.check-chip:has(input:disabled) {
  color: var(--muted);
  background: #f4f3ef;
  cursor: not-allowed;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  color: #66665f;
  font-size: 13px;
}
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}
.form-meta {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 24px;
}
.section-icon {
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-icon svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}
.status-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  font-size: 13px;
}
.connection-result {
  margin-top: 16px;
}
.connection-result:empty {
  display: none;
}
.connection-result .notice {
  margin-bottom: 0;
}
.account-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 12px;
}
.account-summary strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}
.metric-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}
.binding-list {
  display: grid;
  gap: 16px;
}
.binding-item {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.binding-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.binding-item h3 {
  font-size: 14px;
}
.binding-item .checks {
  margin-bottom: 16px;
}
.binding-dates {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.binding-dates label {
  display: grid;
  gap: 8px;
}

/* Data tables and the four explicit table states */
.table-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #cccac2 transparent;
}
.table-scroll:focus-visible {
  outline-offset: -2px;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}
.table-with-state {
  table-layout: fixed;
}
.table-with-state th {
  white-space: normal;
  overflow-wrap: anywhere;
}
thead {
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}
th {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  font-weight: 500;
}
td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: #fbfbf9;
}
.table-title {
  color: var(--ink);
  font-weight: 500;
}
.table-sub {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}
.wrap-cell {
  min-width: 192px;
  max-width: 320px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.table-search {
  max-width: 256px;
}
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tabs button {
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.tabs button:hover {
  background: var(--sidebar);
}
.tabs button.active {
  border-color: var(--line);
  color: var(--ink);
  background: var(--sidebar);
  font-weight: 500;
}
.table-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  min-height: 224px;
  padding: 40px 24px;
  color: var(--muted);
  text-align: center;
  white-space: normal;
}
td:has(> .table-state) {
  padding: 0;
}
.table-state > svg {
  width: 24px;
  height: 24px;
  color: #96958e;
}
.table-state h3,
.table-state strong {
  color: #55554f;
  font-size: 14px;
  font-weight: 500;
}
.table-state p {
  max-width: 448px;
  font-size: 13px;
}
.table-state .empty {
  padding: 0;
  min-height: 0;
}
.table-state-loading {
  background: var(--canvas);
}
.skeleton-lines {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: 448px;
}
.skeleton-line {
  display: block;
  width: 100%;
  height: 16px;
  border-radius: 4px;
  background: #eae9e3;
  animation: subtle-pulse 1600ms ease-in-out infinite;
}
.skeleton-line:nth-child(even) {
  width: 72%;
}
.table-state-error {
  background: #fffafa;
}
.table-state-error > svg,
.table-state-error h3,
.table-state-error strong {
  color: var(--red);
}
.table-state-disabled {
  background: var(--surface);
  color: var(--muted);
}
.table-state-disabled > svg {
  color: #aaa99f;
}
.row-disabled,
.row-disabled:hover {
  color: var(--muted);
  background: var(--surface);
}
.row-disabled .table-title {
  color: var(--muted);
}
.row-disabled input {
  accent-color: #9a998e;
}
.table-scroll-hint {
  display: none;
}
@keyframes subtle-pulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* Dialogs */
dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100dvh - 64px);
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--canvas);
  color: var(--ink);
}
dialog::backdrop {
  background: rgb(41 41 38 / 28%);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  min-width: 0;
  overflow-wrap: anywhere;
}
.modal-body {
  padding: 24px;
}
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

/* Login: type-led, warm and quiet */
.login-page {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  background: var(--canvas);
}
.login-story {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  padding: 48px 64px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}
.login-statement {
  padding: 64px 0;
}
.login-statement .eyebrow {
  margin-bottom: 24px;
}
.login-statement h1 {
  margin-bottom: 24px;
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.035em;
}
.login-statement p {
  max-width: 384px;
  color: var(--muted);
  font-size: 14px;
}
.login-flow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 40px;
  color: #aaa89d;
  font-size: 12px;
}
.login-flow span {
  padding: 8px 0;
  color: #6e6c63;
}
.login-flow svg {
  width: 16px;
  height: 16px;
}
.login-bottom {
  color: var(--muted);
  font-size: 12px;
}
.login-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px;
}
.login-form {
  width: 100%;
  max-width: 384px;
}
.login-form h2 {
  margin-bottom: 16px;
  font-size: 28px;
  font-weight: 500;
}
.login-form > p {
  margin-bottom: 40px;
  color: var(--muted);
  font-size: 14px;
}
.login-form .field {
  margin-bottom: 24px;
}
.login-form input {
  min-height: 48px;
  font-size: 14px;
}
.login-form .btn {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  font-size: 14px;
}
.login-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  color: var(--muted);
  font-size: 12px;
}
.login-note svg {
  width: 16px;
  height: 16px;
}

/* Compact desktops and tablets */
@media (max-width: 1279px) {
  .content {
    padding: 32px;
  }
  .topbar {
    padding-right: 32px;
    padding-left: 32px;
  }
  .stat {
    padding: 24px 16px;
  }
  .stat-icon {
    right: 16px;
  }
  .stat-value {
    font-size: 28px;
  }
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .login-story,
  .login-main {
    padding: 48px;
  }
  .login-statement h1 {
    font-size: 32px;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .page-head {
    flex-wrap: wrap;
  }
  .filter-fields {
    grid-template-columns: minmax(0, 1fr);
  }
  .rule-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
  .topbar-right > time {
    display: none;
  }
  .dates {
    width: 100%;
  }
  .dates input {
    width: 0;
    flex: 1;
  }
  .metric-toolbar {
    width: 100%;
  }
}

/* Mobile: fixed drawer, fluid content, scrolling contained inside tables */
@media (max-width: 767px) {
  h1 {
    font-size: 24px;
  }
  h2 {
    font-size: 16px;
  }
  .shell {
    display: block;
  }
  .sidebar {
    z-index: 60;
    width: 240px;
    max-width: calc(100vw - 48px);
    padding-top: 24px;
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform 160ms ease,
      visibility 160ms;
  }
  .shell.menu-open .sidebar {
    transform: translateX(0);
    visibility: visible;
  }
  .shell.menu-open .mobile-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: block;
    width: 100%;
    background: rgb(41 41 38 / 24%);
  }
  .workspace {
    width: 100%;
    min-width: 0;
  }
  .topbar {
    min-height: 64px;
    padding: 8px 16px;
    gap: 8px;
  }
  .breadcrumb {
    gap: 8px;
  }
  .breadcrumb > span {
    display: none;
  }
  .topbar-right {
    gap: 8px;
  }
  .topbar-right > time,
  .user-control .username {
    display: none;
  }
  .user-control {
    padding-left: 0;
    border-left: 0;
  }
  .icon-btn.mobile-menu {
    display: inline-flex;
  }
  .content {
    padding: 24px 16px 32px;
  }
  .page-head {
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
  }
  .page-head p {
    font-size: 13px;
  }
  .page-actions {
    width: 100%;
    padding-top: 0;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .stat {
    padding: 16px;
  }
  .stat-icon {
    display: none;
  }
  .stat-label {
    padding-right: 0;
    font-size: 12px;
  }
  .stat-value {
    margin-top: 24px;
    font-size: 24px;
  }
  .stat-meta {
    font-size: 11px;
  }
  .card-head,
  .card-body,
  .filter-panel {
    padding: 16px;
  }
  .card-head {
    gap: 16px;
  }
  .card-head p {
    font-size: 12px;
  }
  .dashboard-grid {
    gap: 16px;
  }
  .integration-list {
    padding: 0 16px;
  }
  .integration-row {
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 0;
  }
  .integration-name {
    flex-basis: calc(100% - 40px);
  }
  .integration-row > .tag {
    margin-left: 40px;
  }
  .empty {
    min-height: 256px;
    padding: 40px 16px;
  }
  .empty-compact {
    min-height: 192px;
    padding: 32px 16px;
  }
  .empty p {
    font-size: 12px;
  }
  .rule-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    padding: 24px 16px;
  }
  .bar-list {
    padding: 24px 16px;
  }
  .filter-top {
    gap: 16px;
  }
  .range-shortcuts {
    width: 100%;
    flex-wrap: nowrap;
  }
  .range-shortcuts button {
    flex: 1;
    min-width: 0;
    padding: 8px;
    font-size: 12px;
  }
  .dates {
    width: 100%;
    gap: 8px;
  }
  .dates input {
    width: 0;
    flex: 1;
    padding-right: 8px;
    padding-left: 8px;
    font-size: 12px;
  }
  .filter-fields {
    grid-template-columns: minmax(0, 1fr);
  }
  .filter-toggles {
    gap: 16px;
  }
  .query-actions {
    width: 100%;
  }
  .query-actions .btn-primary {
    flex: 1;
  }
  .progress-box {
    padding: 16px;
  }
  .progress-top {
    gap: 8px;
  }
  .source-grid {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
  }
  .source-card {
    padding: 16px;
  }
  .form-grid,
  .binding-dates {
    grid-template-columns: minmax(0, 1fr);
  }
  .field-full {
    grid-column: auto;
  }
  .settings-grid {
    gap: 16px;
  }
  .status-line {
    padding: 16px;
  }
  .metric-toolbar {
    width: 100%;
  }
  .metric-toolbar > .btn {
    width: 100%;
  }
  .account-summary {
    gap: 8px;
  }
  .table-search {
    max-width: none;
  }
  .table-scroll {
    border-radius: 0;
  }
  .table-with-state thead {
    display: none;
  }
  th,
  td {
    padding: 16px;
  }
  .table-footer {
    gap: 16px;
    padding: 16px;
  }
  .table-actions {
    gap: 0;
  }
  .tabs {
    gap: 0;
  }
  .tabs button {
    padding: 8px;
    font-size: 12px;
  }
  .table-state {
    padding: 32px 16px;
  }
  .table-scroll-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-top: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    font-size: 11px;
  }
  .table-scroll-hint svg {
    width: 16px;
    height: 16px;
  }
  .modal-head {
    padding: 16px;
  }
  .modal-body {
    padding: 24px 16px;
  }
  .modal-footer {
    gap: 8px;
  }
  .login-page {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
  }
  .login-story {
    padding: 24px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .login-statement,
  .login-bottom {
    display: none;
  }
  .login-main {
    padding: 48px 24px;
    align-items: flex-start;
  }
  .login-form h2 {
    font-size: 24px;
  }
  .login-form > p {
    margin-bottom: 32px;
  }
  .toast {
    bottom: 16px;
    padding: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .skeleton-line,
  .progress-fill.indeterminate {
    opacity: 0.75;
  }
}
