:root {
  color-scheme: light;
  --canvas: #f4f5f0;
  --canvas-deep: #ecefe8;
  --surface: #ffffff;
  --surface-soft: #f8f9f6;
  --surface-tint: #eef5f1;
  --ink: #17231d;
  --ink-soft: #35443c;
  --muted: #68756e;
  --muted-2: #89938d;
  --line: #dce2dc;
  --line-strong: #c9d2ca;
  --accent: #23684e;
  --accent-dark: #184b39;
  --accent-soft: #dceee5;
  --accent-pale: #f0f8f4;
  --navy: #284a61;
  --blue-soft: #e6f0f6;
  --amber: #9a6215;
  --amber-soft: #f8ecd5;
  --coral: #a94734;
  --coral-soft: #f9e7e2;
  --violet: #6b558d;
  --violet-soft: #eee8f7;
  --shadow-sm: 0 1px 2px rgb(17 35 27 / 4%), 0 4px 12px rgb(17 35 27 / 3%);
  --shadow-md: 0 12px 34px rgb(17 35 27 / 10%);
  --shadow-lg: 0 24px 70px rgb(17 35 27 / 18%);
  --radius-sm: 8px;
  --radius: 13px;
  --radius-lg: 20px;
  --sidebar-width: 248px;
  --topbar-height: 72px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: ui-rounded, "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: inherit;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1,
h2,
h3,
h4 {
  color: var(--ink);
  font-family: var(--font-display);
  letter-spacing: -0.025em;
  line-height: 1.16;
}

h1 {
  font-size: clamp(28px, 3.4vw, 42px);
}

h2 {
  font-size: clamp(22px, 2.3vw, 30px);
}

h3 {
  font-size: 17px;
}

.sr-only {
  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;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 9999;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: white;
  background: var(--accent-dark);
  border-radius: 8px;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid rgb(35 104 78 / 30%);
  outline-offset: 2px;
}

.noscript {
  margin: 20px;
  padding: 16px;
  color: #6c2e22;
  background: var(--coral-soft);
  border: 1px solid #ecc5bb;
  border-radius: var(--radius);
}

/* Authentication */

.auth-shell {
  display: grid;
  grid-template-columns: minmax(430px, 1.05fr) minmax(440px, 0.95fr);
  min-height: 100vh;
  background: var(--surface);
}

.auth-story {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: clamp(32px, 5vw, 74px);
  overflow: hidden;
  color: #f3faf6;
  background:
    radial-gradient(circle at 72% 24%, rgb(147 190 159 / 22%) 0, transparent 23%),
    radial-gradient(circle at 14% 83%, rgb(217 178 110 / 14%) 0, transparent 28%),
    linear-gradient(145deg, #173d2f 0%, #122c23 57%, #0d231b 100%);
}

.auth-story::before,
.auth-story::after {
  position: absolute;
  content: "";
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 999px;
}

.auth-story::before {
  width: min(55vw, 680px);
  height: min(55vw, 680px);
  right: -34%;
  bottom: -22%;
}

.auth-story::after {
  width: min(30vw, 360px);
  height: min(30vw, 360px);
  right: -8%;
  bottom: -2%;
}

.auth-brand,
.brand-link,
.auth-mobile-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.auth-brand {
  position: relative;
  z-index: 1;
}

.brand-mark {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  width: 27px;
  height: 27px;
  padding: 5px;
  color: white;
  background: var(--accent);
  border-radius: 8px 8px 8px 3px;
}

.brand-mark i {
  display: block;
  flex: 1;
  background: currentColor;
  border-radius: 2px;
}

.brand-mark i:nth-child(1) { height: 38%; opacity: 0.7; }
.brand-mark i:nth-child(2) { height: 70%; opacity: 0.85; }
.brand-mark i:nth-child(3) { height: 100%; }

.auth-story .brand-mark {
  color: #183d2f;
  background: #d8eadf;
}

.auth-copy {
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin: auto 0;
}

.auth-copy h1 {
  margin-bottom: 24px;
  color: #f5faf7;
  font-size: clamp(42px, 5vw, 70px);
  font-weight: 720;
  letter-spacing: -0.05em;
}

.auth-copy > p:last-child {
  max-width: 540px;
  margin-bottom: 0;
  color: #bcd1c5;
  font-size: clamp(16px, 1.5vw, 19px);
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.auth-story .eyebrow {
  color: #9fceb4;
}

.auth-principles {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-principles span {
  padding: 7px 11px;
  color: #c7d9cf;
  font-size: 12px;
  border: 1px solid rgb(221 241 229 / 16%);
  border-radius: 999px;
  background: rgb(255 255 255 / 4%);
}

.auth-panel {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 40px;
}

.auth-form-wrap {
  width: min(100%, 420px);
}

.auth-form-wrap h2 {
  margin-bottom: 10px;
  font-size: 32px;
}

.auth-form-wrap > .muted {
  margin-bottom: 32px;
}

.auth-mobile-brand {
  display: none;
  margin-bottom: 40px;
}

.auth-form {
  display: grid;
  gap: 18px;
}

.auth-footnote {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* App shell and navigation */

.app-shell {
  min-height: 100vh;
  background: var(--canvas);
}

.sidebar {
  position: fixed;
  z-index: 50;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  min-height: 100vh;
  padding: 18px 14px 14px;
  color: #cbd7d0;
  background: #153a2d;
  border-right: 1px solid rgb(255 255 255 / 5%);
  transition: width 180ms ease;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 5px;
}

.brand-link {
  color: white;
  text-decoration: none;
}

.brand-link .brand-mark {
  color: #173d2f;
  background: #dcece3;
}

.sidebar .icon-button {
  color: #b9cbc1;
}

.sidebar .icon-button:hover {
  color: white;
  background: rgb(255 255 255 / 8%);
}

.workspace-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  margin: 22px 0 16px;
  padding: 10px;
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 12px;
  background: rgb(255 255 255 / 4%);
}

.workspace-avatar,
.user-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #173a2d;
  background: #d8eadd;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 780;
}

.workspace-copy,
.user-copy {
  min-width: 0;
  flex: 1;
}

.workspace-copy small,
.workspace-copy strong,
.user-copy small,
.user-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-copy small,
.user-copy small {
  color: #91a79b;
  font-size: 10px;
}

.workspace-copy strong,
.user-copy strong {
  color: #e5eee9;
  font-size: 12px;
  font-weight: 650;
}

.local-badge {
  padding: 3px 6px;
  color: #b8d8c6;
  background: rgb(120 188 150 / 11%);
  border-radius: 5px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.primary-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.nav-label {
  margin: 15px 10px 7px;
  color: #718b7e;
  font-size: 9px;
  font-weight: 760;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  margin: 2px 0;
  padding: 9px 10px;
  color: #b8cac0;
  border-radius: 9px;
  text-decoration: none;
  transition: color 140ms ease, background 140ms ease;
}

.nav-item:hover {
  color: white;
  background: rgb(255 255 255 / 5%);
}

.nav-item.active {
  color: #f5faf7;
  background: rgb(219 239 227 / 11%);
  box-shadow: inset 3px 0 0 #9acbb0;
}

.nav-item.active::after {
  position: absolute;
  right: 9px;
  width: 5px;
  height: 5px;
  content: "";
  background: #9acbb0;
  border-radius: 50%;
}

.nav-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 24px;
  height: 24px;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
}

.nav-count {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  color: #ffe3dc;
  background: rgb(196 84 59 / 35%);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 750;
  text-align: center;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 56px;
  margin-top: 14px;
  padding: 9px 5px 0;
  border-top: 1px solid rgb(255 255 255 / 8%);
}

.user-avatar {
  color: #4b3822;
  background: #f2dcb8;
  border-radius: 50%;
}

.sidebar.is-collapsed {
  width: 76px;
}

.sidebar.is-collapsed .brand-link > span:last-child,
.sidebar.is-collapsed .workspace-copy,
.sidebar.is-collapsed .local-badge,
.sidebar.is-collapsed .nav-label,
.sidebar.is-collapsed .nav-item > span:nth-child(2),
.sidebar.is-collapsed .nav-count,
.sidebar.is-collapsed .user-copy {
  display: none;
}

.sidebar.is-collapsed .workspace-card,
.sidebar.is-collapsed .nav-item,
.sidebar.is-collapsed .sidebar-foot {
  justify-content: center;
}

.sidebar.is-collapsed .nav-item {
  padding-inline: 8px;
}

.sidebar.is-collapsed .nav-item.active::after {
  display: none;
}

.sidebar.is-collapsed + .main-column {
  margin-left: 76px;
}

.main-column {
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  transition: margin-left 180ms ease;
}

.topbar {
  position: sticky;
  z-index: 40;
  top: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: var(--topbar-height);
  padding: 12px clamp(18px, 3vw, 42px);
  background: rgb(244 245 240 / 90%);
  border-bottom: 1px solid rgb(205 214 206 / 70%);
  backdrop-filter: blur(14px);
}

.mobile-menu-button {
  display: none;
}

.topbar-context {
  flex: 0 0 auto;
  min-width: 110px;
}

.topbar-context span,
.topbar-context strong {
  display: block;
}

.topbar-context span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-context strong {
  font-size: 16px;
}

.global-search {
  position: relative;
  display: flex;
  align-items: center;
  width: min(460px, 42vw);
  min-height: 42px;
  margin-right: auto;
  color: var(--muted);
  background: rgb(255 255 255 / 76%);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgb(17 35 27 / 2%);
}

.global-search:focus-within {
  background: white;
  border-color: #86ac99;
  box-shadow: 0 0 0 3px rgb(35 104 78 / 9%);
}

.global-search svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin-left: 12px;
}

.global-search input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 8px;
  background: transparent;
  border: 0;
  outline: 0;
}

.global-search kbd {
  margin-right: 9px;
  padding: 2px 6px;
  color: var(--muted-2);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: inherit;
  font-size: 9px;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.sync-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  font-size: 11px;
}

.sync-chip:hover {
  color: var(--ink);
  background: rgb(255 255 255 / 65%);
}

.sync-chip svg {
  width: 15px;
  height: 15px;
}

.status-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  background: var(--muted-2);
  border-radius: 50%;
}

.status-dot.ok { background: #3b956d; box-shadow: 0 0 0 3px rgb(59 149 109 / 12%); }
.status-dot.warn { background: #d18a2b; box-shadow: 0 0 0 3px rgb(209 138 43 / 12%); }
.status-dot.bad { background: #be5641; box-shadow: 0 0 0 3px rgb(190 86 65 / 12%); }

.view-root {
  width: min(100%, 1500px);
  margin: 0 auto;
  padding: clamp(22px, 3vw, 42px);
  padding-bottom: 70px;
}

.mobile-bottom-nav,
.mobile-drawer,
.mobile-drawer-backdrop {
  display: none;
}

/* Buttons and fields */

.button,
.icon-button,
.chip-button,
.table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 0;
  border-radius: 9px;
  font-weight: 660;
  line-height: 1.1;
  text-decoration: none;
  transition: transform 100ms ease, color 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button {
  gap: 8px;
  padding: 11px 16px;
}

.button svg {
  width: 17px;
  height: 17px;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button.primary {
  color: white;
  background: var(--accent);
  box-shadow: 0 4px 12px rgb(35 104 78 / 16%);
}

.button.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.button.secondary {
  color: var(--ink-soft);
  background: white;
  border: 1px solid var(--line-strong);
}

.button.secondary:hover:not(:disabled) {
  border-color: #93a69b;
}

.button.ghost {
  color: var(--accent);
  background: transparent;
}

.button.ghost:hover:not(:disabled) {
  background: var(--accent-pale);
}

.button.danger-ghost {
  color: var(--coral);
  background: transparent;
}

.button.compact {
  min-height: 40px;
  padding: 9px 13px;
  font-size: 12px;
}

.button.wide {
  width: 100%;
}

.icon-button {
  flex: 0 0 auto;
  width: 44px;
  padding: 0;
  color: var(--muted);
  background: transparent;
}

.icon-button:hover {
  color: var(--ink);
  background: var(--canvas-deep);
}

.chip-button {
  min-height: 38px;
  padding: 7px 11px;
  color: var(--muted);
  background: white;
  border: 1px solid var(--line);
  font-size: 11px;
}

.chip-button[aria-pressed="true"],
.chip-button.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: #b8dac7;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field.span-2 {
  grid-column: 1 / -1;
}

.field label,
.field legend {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 660;
}

.field label .optional {
  color: var(--muted-2);
  font-weight: 450;
}

.field input,
.field select,
.field textarea,
.filter-control {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: none;
  transition: border 120ms ease, box-shadow 120ms ease;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.filter-control:focus {
  border-color: #6d9d85;
  box-shadow: 0 0 0 3px rgb(35 104 78 / 10%);
}

.field input[aria-invalid="true"],
.field select[aria-invalid="true"],
.field textarea[aria-invalid="true"] {
  border-color: #c75b46;
}

.field small,
.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.field-error {
  min-height: 0;
  margin: 0;
  color: var(--coral);
  font-size: 11px;
}

.field-error:empty {
  display: none;
}

.checkbox-field {
  align-content: center;
}

.checkbox-field > label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 9px 11px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}

.checkbox-field input {
  width: 19px;
  min-height: 19px;
  margin: 0;
  accent-color: var(--accent);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 48px;
}

.password-wrap .icon-button {
  position: absolute;
  top: 0;
  right: 0;
}

.inline-alert {
  padding: 11px 13px;
  border: 1px solid;
  border-radius: 9px;
  font-size: 12px;
}

.inline-alert.error {
  color: #7d2f23;
  background: var(--coral-soft);
  border-color: #edc3b8;
}

.inline-alert.success {
  color: var(--accent-dark);
  background: var(--accent-pale);
  border-color: #bfdfcd;
}

.muted {
  color: var(--muted);
}

/* Page building blocks */

.view-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 24px;
  animation: view-in 180ms ease both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.view-heading h1 {
  margin-bottom: 7px;
}

.view-heading p:last-child {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
}

.heading-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 15px;
}

.section-head h2,
.section-head h3,
.section-head p {
  margin-bottom: 0;
}

.section-title-group p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.section-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}

.section-link svg {
  width: 14px;
  height: 14px;
}

.panel,
.metric-card,
.exception-card,
.action-card,
.entity-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.panel {
  min-width: 0;
  padding: 20px;
}

.panel.flush {
  padding: 0;
  overflow: hidden;
}

.panel.tint {
  background: var(--surface-tint);
  border-color: #d6e5dd;
}

.panel.warn-tint {
  background: #fdf8ed;
  border-color: #eadabd;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
  gap: 20px;
}

.balanced-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.three-column {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.metric-card {
  position: relative;
  min-width: 0;
  padding: 17px;
  overflow: hidden;
}

.metric-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  content: "";
  background: var(--accent);
  opacity: 0;
}

.metric-card.is-risk::before {
  background: var(--coral);
  opacity: 1;
}

.metric-card.is-positive::before {
  opacity: 1;
}

.metric-label-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
}

.metric-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 620;
}

.metric-value {
  display: block;
  margin: 7px 0 8px;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: clamp(22px, 2.25vw, 30px);
  font-weight: 720;
  letter-spacing: -0.04em;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: var(--muted);
  font-size: 9px;
}

.metric-meta > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provenance,
.status-badge,
.confidence-badge,
.severity-badge,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 690;
  line-height: 1.3;
  white-space: nowrap;
}

.provenance.observed,
.status-badge.active,
.status-badge.healthy,
.status-badge.validated,
.status-badge.ready,
.status-badge.winner,
.status-badge.resolved,
.status-badge.completed {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: #c1decd;
}

.provenance.calculated,
.status-badge.testing,
.status-badge.measuring,
.status-badge.published,
.status-badge.building,
.status-badge.researching,
.status-badge.preparing {
  color: var(--navy);
  background: var(--blue-soft);
  border-color: #cadde9;
}

.provenance.estimated,
.status-badge.watch,
.status-badge.warning,
.status-badge.open,
.status-badge.draft_ready,
.status-badge.paused,
.status-badge.inconclusive,
.status-badge.sample_ordered {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: #ecd7ae;
}

.status-badge.restricted,
.status-badge.suspended,
.status-badge.rejected,
.status-badge.loser,
.status-badge.closed {
  color: var(--coral);
  background: var(--coral-soft);
  border-color: #edc8bf;
}

.status-badge.neutral,
.tag {
  color: var(--ink-soft);
  background: var(--surface-soft);
  border-color: var(--line);
}

.confidence-badge.high { color: var(--accent); background: var(--accent-pale); }
.confidence-badge.medium { color: var(--amber); background: #fff8e9; }
.confidence-badge.low { color: var(--coral); background: #fff4f1; }

.severity-badge.critical,
.severity-badge.high { color: var(--coral); background: var(--coral-soft); }
.severity-badge.medium { color: var(--amber); background: var(--amber-soft); }
.severity-badge.low { color: var(--navy); background: var(--blue-soft); }

.list-stack {
  display: grid;
  gap: 10px;
}

.exception-card,
.action-card {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  padding: 14px;
  box-shadow: none;
}

.exception-card {
  border-left: 3px solid var(--amber);
}

.exception-card.severity-high,
.exception-card.severity-critical {
  border-left-color: var(--coral);
}

.exception-icon,
.action-order {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--amber);
  background: var(--amber-soft);
  border-radius: 9px;
  font-size: 12px;
  font-weight: 760;
}

.severity-high .exception-icon,
.severity-critical .exception-icon {
  color: var(--coral);
  background: var(--coral-soft);
}

.exception-copy,
.action-copy {
  min-width: 0;
}

.exception-copy h3,
.action-copy h3 {
  margin: 1px 0 4px;
  font-size: 13px;
}

.exception-copy p,
.action-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.action-card {
  grid-template-columns: auto minmax(0, 1fr);
  padding: 15px;
}

.action-order {
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 50%;
}

.action-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.action-traits span {
  padding: 2px 6px;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: 5px;
  font-size: 9px;
}

.action-traits span.strong {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.freshness-list {
  display: grid;
  gap: 12px;
}

.freshness-item {
  display: grid;
  grid-template-columns: minmax(95px, 1fr) 1.6fr auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 10px;
}

.freshness-item strong {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 620;
}

.freshness-bar {
  height: 6px;
  overflow: hidden;
  background: var(--canvas-deep);
  border-radius: 999px;
}

.freshness-bar i {
  display: block;
  width: var(--freshness, 80%);
  height: 100%;
  background: #62a180;
  border-radius: inherit;
}

.freshness-item.is-stale .freshness-bar i { background: #d18a2b; }
.freshness-item.is-missing .freshness-bar i { width: 15%; background: #c45b45; }

.pipeline-summary {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 6px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.pipeline-stage {
  position: relative;
  display: grid;
  flex: 1 0 96px;
  min-height: 72px;
  place-content: center;
  padding: 10px;
  text-align: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 9px;
}

.pipeline-stage:not(:last-child)::after {
  position: absolute;
  z-index: 2;
  top: calc(50% - 4px);
  right: -7px;
  width: 7px;
  height: 7px;
  content: "";
  background: white;
  border-top: 1px solid var(--line-strong);
  border-right: 1px solid var(--line-strong);
  transform: rotate(45deg);
}

.pipeline-stage strong {
  font-family: var(--font-display);
  font-size: 20px;
}

.pipeline-stage span {
  color: var(--muted);
  font-size: 9px;
}

/* Toolbar, tabs, tables, entity cards */

.section-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 4px;
  overflow-x: auto;
  background: var(--canvas-deep);
  border-radius: 10px;
  scrollbar-width: none;
}

.section-tabs::-webkit-scrollbar { display: none; }

.section-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 640;
  white-space: nowrap;
}

.section-tab[aria-selected="true"] {
  color: var(--ink);
  background: white;
  box-shadow: 0 1px 4px rgb(17 35 27 / 8%);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 18px;
  padding: 0 5px;
  color: var(--muted);
  background: var(--canvas-deep);
  border-radius: 999px;
  font-size: 9px;
}

.content-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.filter-group,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group {
  min-width: 0;
}

.filter-search {
  position: relative;
  min-width: 190px;
}

.filter-search svg {
  position: absolute;
  top: 13px;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.filter-search input {
  padding-left: 34px;
}

.filter-control {
  width: auto;
  min-width: 130px;
  font-size: 11px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.data-table th,
.data-table td {
  padding: 12px 13px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

.data-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 9px;
  font-weight: 740;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background 100ms ease;
}

.data-table tbody tr:hover {
  background: #fbfcfa;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table .cell-primary {
  min-width: 160px;
}

.cell-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.cell-title > span:last-child {
  min-width: 0;
}

.cell-title strong,
.cell-title small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-title strong {
  font-size: 11px;
  font-weight: 680;
}

.cell-title small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.entity-thumb {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 760;
}

.entity-thumb.coral { color: var(--coral); background: var(--coral-soft); }
.entity-thumb.amber { color: var(--amber); background: var(--amber-soft); }
.entity-thumb.blue { color: var(--navy); background: var(--blue-soft); }
.entity-thumb.violet { color: var(--violet); background: var(--violet-soft); }

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 3px;
}

.table-action {
  min-width: 36px;
  min-height: 36px;
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
}

.table-action:hover {
  color: var(--accent);
  background: var(--accent-pale);
}

.table-action svg {
  width: 16px;
  height: 16px;
}

.table-number {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.entity-card {
  min-width: 0;
  padding: 16px;
  box-shadow: none;
}

.entity-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.entity-card h3 {
  margin: 0;
  font-size: 14px;
}

.entity-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.entity-card-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.entity-card-stat {
  padding: 9px;
  background: var(--surface-soft);
  border-radius: 8px;
}

.entity-card-stat small,
.entity-card-stat strong {
  display: block;
}

.entity-card-stat small {
  color: var(--muted);
  font-size: 9px;
}

.entity-card-stat strong {
  margin-top: 2px;
  font-size: 13px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.score-ring {
  --score: 72;
  position: relative;
  display: grid;
  place-items: center;
  width: 45px;
  height: 45px;
  background: conic-gradient(var(--accent) calc(var(--score) * 1%), var(--canvas-deep) 0);
  border-radius: 50%;
}

.score-ring::before {
  position: absolute;
  width: 34px;
  height: 34px;
  content: "";
  background: white;
  border-radius: 50%;
}

.score-ring span {
  position: relative;
  z-index: 1;
  font-size: 10px;
  font-weight: 760;
}

/* Kanban */

.kanban-wrap {
  margin-inline: -2px;
  padding: 2px 2px 12px;
  overflow-x: auto;
}

.kanban {
  display: grid;
  grid-auto-columns: minmax(235px, 1fr);
  grid-auto-flow: column;
  gap: 12px;
  min-width: max-content;
}

.kanban-column {
  width: min(280px, 70vw);
  padding: 10px;
  background: var(--canvas-deep);
  border-radius: 12px;
}

.kanban-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding: 0 3px 9px;
}

.kanban-head strong {
  font-size: 11px;
}

.kanban-head span {
  display: grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  color: var(--muted);
  background: rgb(255 255 255 / 75%);
  border-radius: 999px;
  font-size: 9px;
}

.kanban-cards {
  display: grid;
  gap: 8px;
}

.kanban-card {
  min-height: 104px;
  padding: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: 0 2px 5px rgb(17 35 27 / 3%);
}

.kanban-card h3 {
  margin: 8px 0 5px;
  font-size: 12px;
}

.kanban-card p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.kanban-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 11px;
  padding-top: 9px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 9px;
}

.kanban-add {
  width: 100%;
  min-height: 38px;
  margin-top: 8px;
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  font-size: 10px;
}

.kanban-add:hover {
  color: var(--accent);
  background: rgb(255 255 255 / 45%);
  border-color: #91b3a2;
}

/* Empty, loading and errors */

.state-panel {
  display: grid;
  min-height: 260px;
  place-items: center;
  padding: 30px;
  text-align: center;
  background: white;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.state-content {
  max-width: 380px;
}

.state-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 16px;
}

.state-icon svg {
  width: 24px;
  height: 24px;
}

.state-panel.error .state-icon {
  color: var(--coral);
  background: var(--coral-soft);
}

.state-panel h2,
.state-panel h3 {
  margin-bottom: 7px;
}

.state-panel p {
  margin-bottom: 17px;
  color: var(--muted);
  font-size: 12px;
}

.skeleton-grid {
  display: grid;
  gap: 18px;
}

.skeleton-heading,
.skeleton-card,
.skeleton-line {
  position: relative;
  overflow: hidden;
  background: #e6eae5;
  border-radius: 8px;
}

.skeleton-heading::after,
.skeleton-card::after,
.skeleton-line::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 55%) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: shimmer 1.3s infinite;
}

@keyframes shimmer {
  to { transform: translateX(100%); }
}

.skeleton-heading { width: min(310px, 65vw); height: 35px; }
.skeleton-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.skeleton-card { height: 135px; }
.skeleton-panel { display: grid; gap: 12px; padding: 20px; background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.skeleton-line { height: 18px; }
.skeleton-line.short { width: 55%; }

/* Special modules */

.qa-list,
.check-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink-soft);
  background: var(--surface-soft);
  border-radius: 8px;
  font-size: 10px;
}

.check-item .check {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 19px;
  height: 19px;
  color: white;
  background: var(--accent);
  border-radius: 50%;
}

.check-item .check.pending {
  color: var(--muted);
  background: white;
  border: 1px solid var(--line-strong);
}

.check-item svg { width: 12px; height: 12px; }

.media-preview {
  position: relative;
  display: grid;
  aspect-ratio: 16 / 10;
  place-items: center;
  color: #d7e7df;
  background:
    linear-gradient(145deg, rgb(255 255 255 / 9%), transparent),
    #294e3d;
  border-radius: 10px;
  overflow: hidden;
}

.media-preview.vertical { aspect-ratio: 9 / 12; }

.media-preview::after {
  position: absolute;
  inset: 10px;
  content: "";
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 7px;
}

.media-preview span {
  display: grid;
  z-index: 1;
  width: 42px;
  height: 42px;
  place-items: center;
  background: rgb(255 255 255 / 13%);
  border-radius: 50%;
}

.media-preview span svg { width: 18px; height: 18px; }

.approval-banner {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  color: #6e4a18;
  background: #fff8e9;
  border: 1px solid #ead8b5;
  border-radius: 10px;
}

.approval-banner svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.approval-banner strong,
.approval-banner span {
  display: block;
}

.approval-banner strong { font-size: 11px; }
.approval-banner span { margin-top: 2px; font-size: 10px; opacity: 0.85; }

.finance-hero {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(130px, 0.62fr));
  overflow: hidden;
  background: #153a2d;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.finance-total,
.finance-mini {
  padding: 22px;
  color: #d7e5dd;
}

.finance-total {
  background: rgb(255 255 255 / 4%);
}

.finance-mini {
  border-left: 1px solid rgb(255 255 255 / 8%);
}

.finance-total small,
.finance-mini small {
  display: block;
  color: #9db6aa;
  font-size: 10px;
}

.finance-total strong,
.finance-mini strong {
  display: block;
  margin-top: 6px;
  color: white;
  font-family: var(--font-display);
  font-size: 20px;
}

.finance-total strong { font-size: 32px; }
.finance-total span,
.finance-mini span { display: block; margin-top: 5px; color: #aac1b5; font-size: 9px; }

.coverage-meter {
  display: grid;
  gap: 7px;
}

.coverage-track {
  height: 8px;
  overflow: hidden;
  background: var(--canvas-deep);
  border-radius: 999px;
}

.coverage-track span {
  display: block;
  width: var(--coverage, 0%);
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

.coverage-copy {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
}

.source-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.source-logo {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 10px;
  font-weight: 760;
}

.source-copy {
  flex: 1;
  min-width: 0;
}

.source-copy strong,
.source-copy small {
  display: block;
}

.source-copy strong { font-size: 11px; }
.source-copy small { margin-top: 2px; color: var(--muted); font-size: 9px; }

.disabled-action {
  cursor: not-allowed;
  opacity: 0.58;
}

.metric-definition {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(240px, 1.5fr) repeat(3, minmax(110px, 0.65fr));
  gap: 12px;
  align-items: center;
  padding: 13px 15px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.metric-definition strong,
.metric-definition small {
  display: block;
}

.metric-definition strong { font-size: 11px; }
.metric-definition small { color: var(--muted); font-size: 9px; }
.metric-definition p { margin: 0; color: var(--ink-soft); font-size: 10px; }

.audit-timeline {
  position: relative;
  display: grid;
  gap: 0;
}

.audit-item {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 62px;
  padding: 7px 0;
}

.audit-item:not(:last-child)::before {
  position: absolute;
  top: 29px;
  bottom: -3px;
  left: 10px;
  width: 1px;
  content: "";
  background: var(--line);
}

.audit-dot {
  z-index: 1;
  width: 21px;
  height: 21px;
  margin-top: 1px;
  background: var(--accent-soft);
  border: 5px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #a8cbb9;
}

.audit-copy strong,
.audit-copy small { display: block; }
.audit-copy strong { font-size: 10px; }
.audit-copy small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.audit-time { color: var(--muted); font-size: 9px; white-space: nowrap; }

/* Dialogs and search */

.app-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(88vh, 880px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.app-dialog::backdrop {
  background: rgb(12 29 22 / 55%);
  backdrop-filter: blur(3px);
}

.dialog-frame {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: min(88vh, 880px);
  margin: 0;
  background: white;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin-bottom: 5px;
  font-size: 22px;
}

.dialog-head p:last-child {
  margin-bottom: 0;
  font-size: 11px;
}

.dialog-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 22px 24px;
  overflow-y: auto;
}

.dialog-frame > .inline-alert {
  margin: 0 24px 14px;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 24px;
  background: var(--surface-soft);
  border-top: 1px solid var(--line);
}

.approval-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 auto 0 0;
  color: var(--amber);
  font-size: 10px;
}

.approval-note svg { width: 16px; height: 16px; }

.search-dialog {
  width: min(720px, calc(100vw - 32px));
  align-self: start;
  margin-top: min(12vh, 110px);
}

.search-dialog-head {
  align-items: center;
  padding: 12px 14px 12px 20px;
}

.search-dialog-head form {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
}

.search-dialog-head input {
  width: 100%;
  height: 44px;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 15px;
}

.search-results {
  min-height: 160px;
  max-height: min(62vh, 520px);
  padding: 12px;
  overflow-y: auto;
}

.search-hint {
  display: grid;
  min-height: 140px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.search-result-group h3 {
  margin: 12px 9px 6px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-result {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 9px;
}

.search-result:hover,
.search-result:focus-visible {
  background: var(--surface-tint);
}

.search-result strong,
.search-result small { display: block; }
.search-result strong { font-size: 11px; }
.search-result small { margin-top: 2px; color: var(--muted); font-size: 9px; }

.toast-region {
  position: fixed;
  z-index: 500;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 13px;
  color: #e9f3ee;
  background: #173c2e;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 11px;
  box-shadow: var(--shadow-md);
  animation: toast-in 180ms ease both;
  pointer-events: auto;
}

.toast.error { background: #692f26; }
.toast svg { width: 18px; height: 18px; }
.toast strong,
.toast small { display: block; }
.toast strong { font-size: 11px; }
.toast small { margin-top: 2px; color: rgb(255 255 255 / 70%); font-size: 9px; }
.toast button { min-width: 36px; min-height: 36px; color: inherit; background: transparent; border: 0; border-radius: 8px; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-definition { grid-template-columns: minmax(140px, 0.8fr) minmax(220px, 1.4fr) repeat(2, minmax(100px, 0.6fr)); }
  .metric-definition > :nth-child(5) { display: none; }
  .sync-label { display: none; }
}

@media (max-width: 1024px) {
  :root { --sidebar-width: 220px; }
  .view-root { padding-inline: 24px; }
  .two-column { grid-template-columns: minmax(0, 1.25fr) minmax(270px, 0.75fr); }
  .three-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finance-hero { grid-template-columns: repeat(3, 1fr); }
  .finance-total { grid-column: 1 / -1; }
  .finance-mini:first-of-type { border-left: 0; }
  .global-search { width: min(350px, 35vw); }
}

@media (max-width: 850px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-story { display: none; }
  .auth-mobile-brand { display: inline-flex; }
  .auth-panel { padding: 28px; background: radial-gradient(circle at 100% 0, var(--accent-soft), transparent 38%), white; }
  .auth-form-wrap { width: min(100%, 460px); }
}

@media (max-width: 768px) {
  :root { --topbar-height: 64px; }

  .sidebar { display: none; }
  .main-column,
  .sidebar.is-collapsed + .main-column { margin-left: 0; }
  .topbar { gap: 8px; padding: 9px 14px; }
  .mobile-menu-button { display: inline-flex; }
  .topbar-context { min-width: 0; margin-right: auto; }
  .topbar-context span { display: none; }
  .topbar-context strong { font-size: 15px; }
  .global-search { width: 44px; min-width: 44px; border: 0; background: transparent; }
  .global-search svg { margin: auto; }
  .global-search input,
  .global-search kbd { display: none; }
  .sync-chip { width: 44px; padding: 0; justify-content: center; }
  .sync-chip .status-dot,
  .sync-chip .sync-label { display: none; }
  .top-create { display: none; }
  .view-root { padding: 22px 16px calc(96px + env(safe-area-inset-bottom)); }
  .view-heading { align-items: flex-start; }
  .view-heading h1 { margin-bottom: 4px; font-size: 27px; }
  .view-heading .heading-actions .button span { display: none; }
  .view-heading .heading-actions .button { width: 44px; padding: 0; }
  .button,
  .button.compact,
  .icon-button,
  .section-tab,
  .section-link,
  .table-action,
  .kanban-add,
  .sync-chip { min-height: 44px; }
  .table-action { min-width: 44px; }
  .two-column,
  .balanced-columns { grid-template-columns: 1fr; }
  .three-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-body { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }

  .mobile-bottom-nav {
    position: fixed;
    z-index: 70;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    min-height: calc(68px + env(safe-area-inset-bottom));
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgb(255 255 255 / 95%);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgb(17 35 27 / 6%);
    backdrop-filter: blur(14px);
  }

  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    min-height: 52px;
    padding: 3px;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 630;
    text-decoration: none;
  }

  .mobile-bottom-nav a.active { color: var(--accent); }
  .mobile-bottom-nav svg { width: 20px; height: 20px; }
  .mobile-bottom-nav button:nth-child(3) { overflow: visible; }
  .mobile-create-icon {
    display: grid;
    width: 40px;
    height: 40px;
    margin-top: -24px;
    place-items: center;
    color: white;
    background: var(--accent);
    border: 4px solid white;
    border-radius: 50%;
    box-shadow: 0 5px 13px rgb(35 104 78 / 25%);
  }
  .mobile-create-icon svg { width: 18px; height: 18px; }

  .mobile-drawer-backdrop {
    position: fixed;
    z-index: 98;
    inset: 0;
    display: block;
    background: rgb(12 29 22 / 48%);
    opacity: 0;
    transition: opacity 180ms ease;
  }

  .mobile-drawer-backdrop.is-open { opacity: 1; }

  .mobile-drawer {
    position: fixed;
    z-index: 99;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    width: min(86vw, 330px);
    padding: 17px;
    color: #d5e2db;
    background: #153a2d;
    box-shadow: var(--shadow-lg);
    transform: translateX(-104%);
    transition: transform 200ms ease;
  }

  .mobile-drawer.is-open { transform: translateX(0); }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
  .drawer-head .icon-button { color: white; }
  .drawer-nav { display: grid; gap: 3px; }
  .drawer-nav .nav-item { min-height: 48px; }
  .drawer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 16px; border-top: 1px solid rgb(255 255 255 / 10%); }
  .drawer-footer span strong,
  .drawer-footer span small { display: block; }
  .drawer-footer span strong { color: white; font-size: 11px; }
  .drawer-footer span small { color: #8fa79b; font-size: 9px; }
  .drawer-footer .button { color: #d9e6df; }

  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-definition { grid-template-columns: minmax(120px, 0.8fr) minmax(190px, 1.4fr) minmax(90px, 0.6fr); }
  .metric-definition > :nth-child(4) { display: none; }
  .toast-region { right: 16px; bottom: calc(82px + env(safe-area-inset-bottom)); }
}

@media (max-width: 600px) {
  .view-stack { gap: 18px; }
  .view-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .view-heading > div:first-child { min-width: 0; }
  .view-heading p:last-child { font-size: 12px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .metric-card { padding: 14px; }
  .metric-value { font-size: 22px; }
  .panel { padding: 16px; }
  .three-column,
  .card-grid { grid-template-columns: 1fr; }
  .content-toolbar { align-items: stretch; flex-direction: column; }
  .filter-group { overflow-x: auto; padding-bottom: 2px; }
  .filter-search { min-width: 180px; }
  .filter-control { flex: 0 0 auto; }
  .finance-hero { grid-template-columns: 1fr 1fr; }
  .finance-total { grid-column: 1 / -1; }
  .finance-mini { border-top: 1px solid rgb(255 255 255 / 8%); }
  .finance-mini:nth-child(3) { border-left: 0; }
  .metric-definition { grid-template-columns: 1fr; }
  .metric-definition > :nth-child(4),
  .metric-definition > :nth-child(5) { display: block; }
  .qa-list,
  .check-list { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .auth-panel { place-items: start center; min-height: 100dvh; padding: 30px 20px; }
  .auth-mobile-brand { margin-bottom: 58px; }
  .auth-form-wrap h2 { font-size: 27px; }
  .topbar { padding-inline: 8px; }
  .topbar .icon-button,
  .topbar .global-search,
  .topbar .sync-chip { width: 44px; min-width: 44px; }
  .view-root { padding: 18px 12px calc(92px + env(safe-area-inset-bottom)); }
  .view-heading h1 { font-size: 24px; }
  .view-heading .eyebrow { margin-bottom: 4px; }
  .metric-card { min-height: 117px; padding: 13px; }
  .metric-label-row { min-height: 35px; }
  .metric-label { font-size: 10px; }
  .metric-value { margin-top: 4px; font-size: 20px; }
  .metric-meta { display: grid; justify-content: start; }
  .panel { padding: 14px; }
  .panel.flush { padding: 0; }
  .section-head { align-items: flex-start; }
  .section-head h2 { font-size: 19px; }
  .section-head .button span { display: none; }
  .exception-card { grid-template-columns: auto minmax(0, 1fr); }
  .exception-card > .severity-badge { grid-column: 2; justify-self: start; }
  .freshness-item { grid-template-columns: minmax(85px, 1fr) 1fr; }
  .freshness-item > span:last-child { display: none; }
  .pipeline-stage { flex-basis: 87px; min-height: 66px; }
  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td { display: block; width: 100%; }
  .data-table thead { display: none; }
  .data-table tbody { display: grid; gap: 10px; padding: 10px; }
  .data-table tbody tr {
    padding: 11px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
  }
  .data-table tbody tr:hover { background: white; }
  .data-table td {
    display: grid;
    grid-template-columns: minmax(92px, 0.7fr) minmax(0, 1.3fr);
    align-items: center;
    gap: 9px;
    min-height: 37px;
    padding: 7px 3px;
    border-bottom: 1px solid #edf0ec;
    text-align: right;
  }
  .data-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-align: left;
    text-transform: uppercase;
  }
  .data-table td:first-child {
    display: block;
    padding-bottom: 11px;
    text-align: left;
  }
  .data-table td:first-child::before { display: none; }
  .data-table td:last-child { border-bottom: 0; }
  .table-actions { justify-content: flex-end; }
  .cell-title strong,
  .cell-title small { white-space: normal; }
  .dialog-frame { max-height: 94dvh; }
  .app-dialog { width: calc(100vw - 16px); max-height: 94dvh; border-radius: 15px; }
  .dialog-head { padding: 18px 16px 13px; }
  .dialog-head h2 { font-size: 20px; }
  .dialog-body { padding: 17px 16px; }
  .dialog-frame > .inline-alert { margin-inline: 16px; }
  .dialog-actions { position: sticky; bottom: 0; padding: 11px 16px calc(11px + env(safe-area-inset-bottom)); }
  .dialog-actions .approval-note { display: none; }
  .dialog-actions .button { flex: 1; }
  .search-dialog { margin-top: 8px; }
  .search-dialog-head { padding: 8px 8px 8px 15px; }
  .finance-hero { grid-template-columns: 1fr; }
  .finance-total,
  .finance-mini { padding: 17px; border-left: 0; border-top: 1px solid rgb(255 255 255 / 8%); }
  .finance-total { border-top: 0; }
  .finance-mini strong { font-size: 18px; }
  .audit-item { grid-template-columns: 24px minmax(0, 1fr); }
  .audit-time { grid-column: 2; margin-top: -14px; }
}

@media (max-width: 360px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 110px; padding: 11px; }
  .metric-value { font-size: 19px; }
  .mobile-bottom-nav { padding-inline: 3px; }
  .mobile-bottom-nav a,
  .mobile-bottom-nav button { font-size: 8px; }
  .topbar-context strong { max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: #aeb9b0;
    --line-strong: #8f9e93;
    --muted: #4f5e56;
  }
}

@media print {
  .sidebar,
  .topbar,
  .mobile-bottom-nav,
  .heading-actions,
  .content-toolbar,
  .table-actions { display: none !important; }
  .main-column { margin: 0; }
  .view-root { max-width: none; padding: 0; }
  .panel,
  .metric-card { break-inside: avoid; box-shadow: none; }
}
