:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #18191b;
  --muted: #667085;
  --line: #dde3ea;
  --charcoal: #171717;
  --wine: #9a302f;
  --wine-dark: #651412;
  --wine-soft: #fae8e6;
  --teal: #147d74;
  --teal-soft: #e7f5f2;
  --amber: #b7791f;
  --amber-soft: #fff4d7;
  --green: #2f7a55;
  --green-soft: #e6f4ec;
  --red: #b42318;
  --red-soft: #fde8e5;
  --shadow: 0 18px 44px rgba(24, 25, 27, 0.09);
  --app-header-height: 72px;
  --command-band-height: 130px;
  --sticky-gap: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

body {
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: #eef1f4;
}

.login-panel {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-top: 8px solid var(--wine);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand,
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand img {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 8px 24px rgba(101, 20, 18, 0.12);
}

.login-brand span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.login-brand strong {
  display: block;
  margin-top: 3px;
  color: var(--wine-dark);
  font-size: 18px;
}

.login-panel h1 {
  margin: 28px 0 22px;
  font-size: 30px;
  line-height: 1.12;
}

.startup-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(154, 48, 47, 0.1), transparent 34%),
    linear-gradient(315deg, rgba(20, 125, 116, 0.12), transparent 38%),
    #eef1f4;
}

.startup-panel {
  display: grid;
  justify-items: center;
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: 44px 34px;
  text-align: center;
}

.startup-gear {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin-bottom: 22px;
  border: 1px solid rgba(154, 48, 47, 0.18);
  border-radius: 50%;
  background: linear-gradient(180deg, #fff, #f7ebe9);
  color: var(--wine);
  box-shadow: inset 0 0 0 10px rgba(154, 48, 47, 0.05), 0 18px 40px rgba(101, 20, 18, 0.14);
}

.startup-gear svg {
  width: 54px;
  height: 54px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
  animation: spin 1.4s linear infinite;
}

.startup-panel h1 {
  margin: 10px 0 10px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

.startup-panel p {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 15px;
}

.login-form label,
.field-control,
.filter-field {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.login-form input,
.field-control input,
.user-form input,
.user-form select,
.filter-trigger,
.filter-search {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

.login-form input::placeholder,
.field-control input::placeholder,
.user-form input::placeholder,
.filter-search::placeholder {
  color: #aab4c1;
  opacity: 1;
}

.login-form input:focus,
.field-control input:focus,
.user-form input:focus,
.user-form select:focus,
.filter-trigger:focus,
.filter-search:focus {
  border-color: var(--wine);
  box-shadow: 0 0 0 3px rgba(154, 48, 47, 0.14);
}

.login-form button,
.export-button,
.ghost-button,
.filter-head button,
.pager button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 850;
}

.login-form button {
  border-color: var(--wine);
  background: var(--wine);
  color: #fff;
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 850;
}

.app-shell {
  display: block;
  min-height: 100vh;
  overflow: visible;
  background: var(--bg);
}

.admin-shell {
  min-height: 100vh;
  background: #eef1f4;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 90;
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 72px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(221, 227, 234, 0.86);
  background: #fff;
  backdrop-filter: none;
}

.brand-lockup img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: contain;
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
}

.brand-lockup span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.dashboard-menu {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.admin-tabs {
  display: flex;
  justify-content: center;
}

.menu-item {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 0 15px;
  font-size: 13px;
  font-weight: 850;
}

.menu-item.active {
  border-color: var(--wine);
  background: var(--wine-soft);
  color: var(--wine-dark);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.data-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.data-pill {
  color: var(--teal);
  background: var(--teal-soft);
}

.export-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-color: rgba(20, 125, 116, 0.22);
  color: var(--teal);
  background: var(--teal-soft);
}

.export-button img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.workspace {
  --workspace-padding: 16px;
  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  gap: var(--sticky-gap);
  width: min(1680px, 100%);
  min-height: auto;
  margin: 0 auto;
  padding: var(--workspace-padding);
  overflow: visible;
  background: var(--bg);
}

.admin-workspace {
  display: grid;
  gap: 16px;
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.admin-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

.admin-hero h1 {
  margin: 6px 0 8px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
}

.admin-hero p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.dashboard-sticky-head {
  position: sticky;
  top: calc(var(--app-header-height) + var(--workspace-padding));
  z-index: 80;
  display: grid;
  gap: var(--sticky-gap);
  background: var(--bg);
  isolation: isolate;
}

.dashboard-sticky-head::before {
  content: "";
  position: absolute;
  top: calc(var(--workspace-padding) * -1);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  background: var(--bg);
  pointer-events: none;
}

.command-band {
  position: relative;
  display: block;
  align-items: center;
  min-height: var(--command-band-height);
  height: var(--command-band-height);
  padding: 22px;
  border-radius: 10px;
  background: var(--charcoal);
  color: #fff;
  box-shadow: none;
}

.command-copy h1 {
  margin: 7px 0 0;
  font-size: clamp(26px, 2.7vw, 38px);
  line-height: 1;
}

.command-copy {
  min-width: 0;
}

.command-copy p {
  max-width: 780px;
  margin: 0;
  color: #d4dae2;
  font-size: 13px;
  line-height: 1.55;
}

.command-band .eyebrow,
.command-band .last-update {
  color: #aeb7c4;
}

.command-band .last-update {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 16px;
  line-height: 1.2;
  text-align: left;
}

.command-band .last-update span {
  color: #8f9aaa;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.command-band .last-update strong {
  color: #fff;
  font-size: 12px;
}

.command-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.command-metrics article {
  display: grid;
  align-content: end;
  min-height: 150px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  padding: 16px;
}

.command-metrics span {
  color: #b9c2cf;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.command-metrics strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.command-metrics .risk strong {
  color: #ffb3aa;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
  gap: var(--sticky-gap);
  min-width: 0;
  min-height: auto;
  overflow: visible;
  background: var(--bg);
}

.dashboard-layout.filters-collapsed {
  grid-template-columns: 1fr;
}

.dashboard-content {
  min-width: 0;
  min-height: auto;
  overflow: visible;
  padding-top: 0;
  padding-right: 0;
  padding-bottom: 24px;
  background: var(--bg);
}

.filter-deck,
.panel,
.signal-card,
.insight-card,
.table-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
}

.filter-deck {
  position: relative;
  align-self: start;
  overflow: visible;
  box-shadow: none;
}

.filter-head {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.filter-head strong {
  display: block;
  margin-top: 2px;
  font-size: 17px;
}

.filters-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 9px;
  padding: 12px;
}

#clearFilters {
  grid-column: auto;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-color: rgba(20, 125, 116, 0.22) !important;
  background: var(--teal-soft) !important;
  color: var(--teal) !important;
}

.filter-toggle::before {
  content: "";
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right: 0;
  border-bottom: 0;
  transform: translateY(3px) rotate(45deg);
}

.filters-collapsed .filter-toggle::before {
  transform: translateY(-2px) rotate(225deg);
}

.filters-collapsed .filter-deck {
  overflow: hidden;
}

.filters-collapsed .filter-head {
  display: grid;
  grid-template-columns: 1fr auto;
  min-height: auto;
  padding: 12px;
  border-bottom: 0;
}

.filters-collapsed .filter-head > div,
.filters-collapsed #clearFilters,
.filters-collapsed .filters-form {
  display: none;
}

.filters-collapsed #filtersToggle {
  min-height: 38px;
  padding: 0 12px;
  writing-mode: horizontal-tb;
}

.field-control,
.filter-field {
  position: relative;
}

.filter-field,
.field-control {
  gap: 5px;
  font-size: 11px;
}

.field-control input,
.filter-trigger {
  height: 34px;
}

.filter-trigger {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.filter-trigger span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-clear {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #7a8492;
  font-size: 18px;
  font-weight: 850;
  line-height: 1;
}

.filter-clear:hover {
  background: #edf1f5;
  color: var(--wine);
}

.filter-popover {
  position: fixed;
  top: var(--filter-popover-top, 0);
  left: var(--filter-popover-left, 0);
  z-index: 140;
  width: var(--filter-popover-width, min(360px, 92vw));
  overflow: hidden;
  border: 1px solid #cfd6df;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.2);
}

.filter-search {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.filter-options {
  max-height: 260px;
  overflow: auto;
  color: var(--ink);
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 650;
}

.filter-option:hover {
  background: var(--surface-2);
}

.filter-option.is-muted {
  color: var(--muted);
  cursor: default;
}

.loading-state {
  display: none !important;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 180px;
  color: var(--muted);
  font-weight: 850;
}

.loader {
  width: 20px;
  height: 20px;
  border: 3px solid #dfe6ee;
  border-top-color: var(--wine);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.dashboard-grid,
.summary-view,
.base-view,
.users-view {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.dashboard-widget {
  cursor: grab;
  transition: box-shadow 0.16s ease, opacity 0.16s ease, transform 0.16s ease;
}

.dashboard-widget:active {
  cursor: grabbing;
}

.dashboard-widget.is-dragging {
  opacity: 0.58;
  transform: scale(0.995);
}

.dashboard-widget.is-drop-target {
  box-shadow: 0 0 0 3px rgba(20, 125, 116, 0.22), 0 14px 32px rgba(24, 25, 27, 0.12);
}

.dashboard-widget.is-drop-before {
  box-shadow: inset 5px 0 0 var(--teal), 0 0 0 3px rgba(20, 125, 116, 0.18), 0 14px 32px rgba(24, 25, 27, 0.12);
}

.dashboard-widget.is-drop-after {
  box-shadow: inset -5px 0 0 var(--teal), 0 0 0 3px rgba(20, 125, 116, 0.18), 0 14px 32px rgba(24, 25, 27, 0.12);
}

.widget-drop-zone {
  display: none;
  grid-column: span 3;
  min-height: 112px;
  border: 2px dashed rgba(20, 125, 116, 0.45);
  border-radius: 8px;
  background: rgba(231, 245, 242, 0.72);
  color: var(--teal);
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  pointer-events: none;
}

.dashboard-grid.is-reordering .widget-drop-zone {
  display: grid;
}

.dashboard-grid.is-drop-end .widget-drop-zone {
  border-color: var(--teal);
  background: var(--teal-soft);
  box-shadow: inset 0 0 0 2px rgba(20, 125, 116, 0.12);
}

.panel-span {
  grid-column: 1 / -1;
  min-width: 0;
  width: 100%;
}

.signal-grid {
  display: contents;
}

.insight-rail {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 2fr);
  gap: 0;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 6px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: none;
}

.insight-rail.danger {
  border-left-color: var(--red);
}

.insight-rail.good {
  border-left-color: var(--green);
}

.insight-main {
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 18px 20px;
  background: linear-gradient(90deg, rgba(244, 246, 248, 0.92), rgba(255, 255, 255, 0));
}

.insight-main strong {
  display: block;
  margin-top: 7px;
  font-size: clamp(20px, 2vw, 30px);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.insight-main p {
  max-width: 560px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.insight-rail.danger .insight-main strong {
  color: var(--red);
}

.insight-rail.good .insight-main strong {
  color: var(--green);
}

.insight-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 0;
}

.insight-fact {
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 18px 20px;
  border-left: 1px solid var(--line);
}

.insight-fact span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.insight-fact strong {
  display: block;
  min-width: 0;
  margin-top: 8px;
  font-size: 16px;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insight-fact em {
  display: block;
  min-width: 0;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.signal-card {
  display: grid;
  grid-column: span 3;
  align-content: start;
  min-height: 116px;
  padding: 13px;
}

.signal-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.signal-card strong {
  display: block;
  min-width: 0;
  margin-top: 13px;
  font-size: clamp(18px, 1.5vw, 24px);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.signal-card em {
  display: block;
  min-width: 0;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 750;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.signal-card.good strong {
  color: var(--green);
}

.signal-card.warn strong,
.signal-card.focus strong {
  color: var(--amber);
}

.signal-card.danger {
  border-color: rgba(180, 35, 24, 0.24);
  background: var(--red);
  color: #fff;
}

.signal-card.danger span,
.signal-card.danger em {
  color: rgba(255, 255, 255, 0.78);
}

.panel {
  grid-column: span 4;
  overflow: hidden;
}

.dashboard-grid > .panel:not(.panel-xl) {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 430px;
}

.dashboard-grid > .panel:not(.panel-xl) > :not(header) {
  min-height: 0;
  overflow: auto;
}

.panel-xl {
  grid-column: span 8;
}

.panel-xl[data-widget-key="timeline"] {
  grid-column: 1 / -1;
}

.panel-focus {
  grid-column: span 4;
}

.panel header,
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.panel h2,
.table-toolbar h2 {
  margin: 2px 0 0;
  font-size: 19px;
}

.timeline-chart {
  display: block;
  height: 260px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 6px;
  background: linear-gradient(180deg, #fff, #fbfcfd);
}

.timeline-stage {
  min-width: 100%;
  height: 100%;
}

.timeline-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.timeline-gridline line {
  stroke: #e7ecf2;
  stroke-width: 1;
}

.timeline-gridline text,
.timeline-x-label,
.timeline-value-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.timeline-gridline text {
  text-anchor: end;
}

.timeline-x-label {
  text-anchor: middle;
}

.timeline-value-label {
  fill: #4f5d6d;
  font-size: 12px;
  font-weight: 900;
  paint-order: stroke;
  stroke: #fff;
  stroke-linejoin: round;
  stroke-width: 4px;
  text-anchor: middle;
}

.timeline-area {
  fill: url(#timelineArea);
}

.timeline-line {
  fill: none;
  stroke: var(--red);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.timeline-point {
  fill: #fff;
  stroke: var(--red);
  stroke-width: 3;
}

.empty-chart {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.focus-list,
.branch-grid,
.bucket-list,
.matrix-list,
.aging-chart,
.summary-chart {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.bucket-list {
  gap: 6px;
}

.focus-summary {
  display: grid;
  gap: 3px;
  min-height: 74px;
  border: 1px solid rgba(183, 121, 31, 0.24);
  border-radius: 8px;
  background: var(--amber-soft);
  padding: 14px;
}

.focus-summary span,
.focus-summary em {
  color: #8a5a13;
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
  text-transform: uppercase;
}

.focus-summary strong {
  font-size: 28px;
  line-height: 1;
}

.focus-row,
.bucket-row,
.matrix-row,
.summary-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 40px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.focus-row div,
.bucket-row div,
.matrix-row div,
.summary-row div {
  min-width: 0;
}

.focus-row strong,
.summary-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-row span,
.summary-row span,
.matrix-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.focus-row b,
.bucket-row b,
.matrix-row b,
.summary-row b {
  font-size: 12px;
  white-space: nowrap;
}

.focus-row > i,
.bucket-row > i,
.summary-row > i {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  background: var(--teal);
}

.branch-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.branch-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px;
}

.branch-card span,
.branch-card em,
.bucket-row em,
.matrix-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.branch-card strong {
  display: block;
  margin-top: 5px;
  font-size: 17px;
}

.branch-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.branch-card p b {
  color: var(--ink);
}

.risk-line,
.aging-row div {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf2;
}

.risk-line i,
.aging-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--red);
}

.bucket-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 8px 10px;
}

.bucket-row div {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bucket-row em {
  margin-top: 0;
}

.matrix-row {
  min-height: 58px;
}

.aging-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 52px;
  gap: 10px;
  align-items: center;
}

.aging-row span,
.aging-row strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.aging-row strong {
  color: var(--ink);
  text-align: right;
}

.table-panel {
  grid-column: 1 / -1;
  overflow: hidden;
}

.table-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pager button:disabled,
.export-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.table-scroll {
  max-height: 520px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

th,
td {
  overflow: hidden;
  padding: 11px 10px;
  border-bottom: 1px solid #edf0f3;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 900;
}

th:first-child,
td:first-child {
  text-align: left;
}

.supplier-group-row td {
  background: #ffffff;
  font-weight: 850;
}

.supplier-group-row:hover td {
  background: #f7fbfa;
}

.supplier-group-row.is-expanded td {
  border-top: 1px solid rgba(20, 125, 116, 0.28);
  border-bottom-color: rgba(20, 125, 116, 0.2);
  background: #eaf7f4;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.supplier-group-row.is-expanded td:first-child {
  box-shadow:
    inset 4px 0 0 var(--teal),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.supplier-group-row td:first-child {
  white-space: normal;
}

.drilldown-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-right: 10px;
  border: 1px solid rgba(20, 125, 116, 0.26);
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  vertical-align: middle;
}

.drilldown-toggle span {
  line-height: 1;
  font-size: 16px;
  font-weight: 950;
}

.supplier-group-row.is-expanded .drilldown-toggle {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.supplier-cell {
  display: inline-grid;
  gap: 4px;
  max-width: calc(100% - 42px);
  vertical-align: middle;
}

.supplier-cell strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supplier-cell span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invoice-row td {
  background: #fbfcfd;
  color: #3d4652;
}

.invoice-row:hover td {
  background: #f1f8f7;
}

.invoice-row td:first-child {
  padding-left: 46px;
}

.invoice-cell {
  display: grid;
  gap: 4px;
}

.invoice-cell strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.invoice-cell span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.invoice-note td {
  background: #f7fbfa;
  color: var(--muted);
  padding: 14px 18px 14px 46px;
  text-align: left;
  font-weight: 850;
}

.invoice-note.danger td {
  color: var(--red);
  background: var(--red-soft);
}

.sort-header {
  max-width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-weight: 900;
}

.sort-header.sorted::after {
  content: " v";
  color: var(--wine);
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f4faf9;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 900;
}

.status-badge.ok {
  color: #0f766e;
  background: var(--teal-soft);
}

.status-badge.danger {
  color: var(--red);
  background: var(--red-soft);
}

.summary-view,
.base-view {
  grid-template-columns: 1fr;
}

.summary-chart {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.base-info {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  padding: 16px;
}

.base-tile {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 14px;
}

.base-tile span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.base-tile strong {
  display: block;
  margin-top: 10px;
  font-size: 16px;
  line-height: 1.35;
}

.base-tile.wide {
  grid-column: span 4;
}

.admin-workspace .users-view {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
}

.admin-workspace .users-view > .panel-span {
  grid-column: 1 / -1;
  width: 100%;
}

.admin-shell.user-form-open,
.admin-shell.delete-confirm-open {
  overflow: hidden;
}

.admin-shell.user-form-open::before,
.admin-shell.delete-confirm-open::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(15, 23, 42, 0.46);
  backdrop-filter: blur(2px);
}

.users-admin {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 16px;
}

.users-admin.form-open {
  grid-template-columns: minmax(0, 1fr);
}

.user-form {
  display: grid;
  align-content: start;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 16px;
}

.user-form:not([hidden]) {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 100;
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  transform: translate(-50%, -50%);
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.34);
}

.confirm-dialog:not([hidden]) {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 100;
  display: grid;
  gap: 12px;
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.34);
  padding: 18px;
  transform: translate(-50%, -50%);
}

.confirm-dialog h3,
.confirm-dialog p {
  margin: 0;
}

.confirm-dialog h3 {
  font-size: 22px;
}

.confirm-dialog p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.user-form h3 {
  margin: 0;
  font-size: 20px;
}

.form-grid,
.scope-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.user-form label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 9px !important;
  min-height: 38px;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.scope-grid {
  grid-template-columns: 1fr;
}

.scope-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.scope-title button,
.param-row button {
  min-height: 34px;
  border: 1px solid rgba(20, 125, 116, 0.22);
  border-radius: 7px;
  background: var(--teal-soft);
  color: var(--teal);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.params-list {
  display: grid;
  gap: 10px;
}

.param-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.param-row button {
  border-color: rgba(180, 35, 24, 0.18);
  background: var(--red-soft);
  color: var(--red);
}

.user-message {
  min-height: 18px;
  margin: 0;
  color: var(--teal);
  font-size: 12px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.form-actions button,
.table-action {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 850;
}

.action-cell {
  display: flex;
  align-items: center;
  gap: 7px;
}

.icon-action {
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  padding: 0;
}

.icon-action svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-action.danger {
  border-color: rgba(180, 35, 24, 0.22);
  background: var(--red-soft);
  color: var(--red);
}

.action-tooltip {
  position: fixed;
  z-index: 130;
  max-width: 220px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  background: #18191b;
  color: #fff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.24);
  padding: 7px 9px;
  pointer-events: none;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.25;
  white-space: nowrap;
}

.form-actions button:first-child {
  border-color: var(--wine);
  background: var(--wine);
  color: #fff;
}

.users-table {
  width: 100%;
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.users-table table {
  width: 100%;
  min-width: 100%;
  table-layout: auto;
}

.users-table th,
.users-table td {
  text-align: left;
}

.users-table tbody tr {
  cursor: default;
}

.users-table td:first-child strong,
.users-table td:first-child span {
  display: block;
}

.users-table td:first-child span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.empty-row {
  height: 96px;
  color: var(--muted);
  font-weight: 850;
  text-align: center;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(14, 17, 23, 0.48);
  backdrop-filter: blur(2px);
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 90;
  width: min(480px, 96vw);
  height: 100vh;
  overflow: auto;
  background: var(--bg);
  color: var(--ink);
  box-shadow: -22px 0 60px rgba(0, 0, 0, 0.32);
}

.detail-drawer header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 12px;
  padding: 26px 24px 28px;
  background: linear-gradient(135deg, var(--wine-dark), var(--wine));
  color: #fff;
}

.detail-drawer h2 {
  margin: 4px 0 0;
  font-size: 22px;
}

.detail-drawer p {
  margin: 8px 0 0;
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
}

.detail-drawer button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
}

.drawer-total {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 22px 24px;
  background: var(--charcoal);
  color: #fff;
}

.drawer-total span {
  display: block;
  color: #aab5c4;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.drawer-metrics span,
.drawer-fields span,
.drawer-timeline span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.drawer-total strong {
  grid-column: 1;
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.drawer-total em {
  align-self: center;
  border-radius: 999px;
  background: rgba(20, 125, 116, 0.25);
  color: #bff8f1;
  padding: 9px 12px;
  font-style: normal;
  font-size: 11px;
  font-weight: 900;
}

.drawer-total em.danger {
  background: rgba(180, 35, 24, 0.25);
  color: #ffd2cc;
}

.drawer-timeline,
.drawer-metrics,
.drawer-fields {
  display: grid;
  gap: 10px;
  padding: 18px 24px 0;
}

.drawer-metrics {
  grid-template-columns: repeat(3, 1fr);
}

.drawer-timeline {
  position: relative;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 26px 24px 8px;
}

.drawer-timeline::before {
  content: "";
  position: absolute;
  top: 44px;
  left: 58px;
  right: 58px;
  height: 3px;
  border-radius: 999px;
  background: #dce4ed;
}

.drawer-fields {
  grid-template-columns: repeat(2, 1fr);
  padding-bottom: 24px;
}

.drawer-metrics article,
.drawer-fields article {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  box-shadow: 0 10px 22px rgba(24, 25, 27, 0.06);
}

.drawer-timeline article {
  position: relative;
  min-width: 0;
  padding: 42px 8px 8px;
  text-align: center;
}

.drawer-timeline article::before {
  content: "";
  position: absolute;
  top: 11px;
  left: 50%;
  z-index: 1;
  width: 16px;
  height: 16px;
  border: 3px solid var(--teal);
  border-radius: 999px;
  background: var(--surface);
  transform: translateX(-50%);
}

.drawer-timeline article:first-child::before {
  border-color: var(--wine);
}

.drawer-timeline article:nth-child(2)::before {
  border-color: var(--amber);
}

.drawer-timeline article:last-child::before {
  border-color: var(--teal);
}

.drawer-timeline strong,
.drawer-metrics strong,
.drawer-fields strong {
  display: block;
  overflow: hidden;
  margin-top: 8px;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-timeline strong {
  white-space: normal;
}

@media (max-width: 1280px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .filters-form {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .signal-card,
  .widget-drop-zone {
    grid-column: span 4;
  }

  .panel,
  .panel-xl,
  .panel-focus {
    grid-column: span 6;
  }
}

@media (max-width: 900px) {
  .app-header {
    grid-template-columns: 1fr;
  }

  .dashboard-menu,
  .header-actions,
  .admin-tabs {
    justify-content: flex-start;
  }

  .command-band,
  .command-metrics,
  .summary-chart,
  .base-info {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dashboard-layout,
  .dashboard-layout.filters-collapsed {
    grid-template-columns: 1fr;
  }

  .filter-deck {
    max-height: none;
  }

  .filters-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
  }

  .filter-popover {
    top: var(--filter-popover-top, 0);
    left: var(--filter-popover-left, 0);
  }

  .filters-collapsed .filter-head {
    min-height: auto;
  }

  .filters-collapsed #filtersToggle {
    width: auto;
    min-height: 38px;
    padding: 0 12px;
    writing-mode: horizontal-tb;
  }

  .panel,
  .panel-xl,
  .panel-focus,
  .signal-card,
  .widget-drop-zone {
    grid-column: 1 / -1;
  }

  .insight-rail,
  .insight-facts {
    grid-template-columns: 1fr;
  }

  .insight-fact {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .timeline-chart {
    grid-template-columns: repeat(12, minmax(72px, 1fr));
  }

  .branch-grid {
    grid-template-columns: 1fr;
  }

  .base-tile.wide {
    grid-column: span 1;
  }

  .admin-hero {
    display: grid;
  }

  .users-admin,
  .users-admin.form-open,
  .form-grid,
  .param-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .workspace {
    --workspace-padding: 10px;
  }

  .app-header,
  .command-band,
  .admin-hero {
    padding: 14px;
  }

  .filters-form,
  .filter-head,
  .table-toolbar,
  .header-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dashboard-menu {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .menu-item {
    width: 100%;
  }

  .drawer-timeline,
  .drawer-metrics,
  .drawer-fields {
    grid-template-columns: 1fr;
  }
}

.panel-xl[data-widget-key="timeline"] {
  grid-column: 1 / -1;
}
