:root {
  --paper: var(--bg);
  --surface: var(--panel);
  --card: var(--panel);
  --teal: #0b6f69;
  --teal-dark: #084d4a;
  --teal-soft: #dcecea;
  --lime: #b9d968;
  --amber: #d78a28;
  --red: #b94638;
  --blue: #3d6c91;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-width: 320px; }
.app-header:has(.enterprise-global-search) .crumb { flex: 1 0 auto; }
.app-header .enterprise-global-search {
  position: relative;
  flex: 1 1 320px;
  max-width: 440px;
  min-width: 220px;
}
.app-header .enterprise-search-row { display: flex; min-width: 0; }
.app-header .enterprise-search-row input {
  width: 100%;
  height: 36px;
  margin: 0;
  padding: 0 28px 0 11px;
  border: 1px solid var(--line, #dbe3ea);
  border-radius: 9px;
  background: var(--panel, #fff);
  color: var(--ink, #0f172a);
  box-shadow: none;
}
.app-header .enterprise-search-kbd {
  position: absolute;
  right: 9px;
  top: 8px;
  color: var(--muted, #64748b);
  font: 11px/20px ui-monospace, SFMono-Regular, Menlo, monospace;
  pointer-events: none;
}
.app-header .enterprise-search-results {
  position: absolute;
  z-index: 80;
  left: 0;
  right: 0;
  top: calc(100% + 7px);
  max-height: min(64vh, 520px);
  overflow: auto;
  border: 1px solid var(--line, #dbe3ea);
  border-radius: 12px;
  background: var(--panel, #fff);
  box-shadow: 0 18px 45px rgba(15, 23, 42, .18);
  padding: 6px;
}
.app-header .enterprise-search-status { padding: 9px 10px; color: var(--muted, #64748b); font-size: 12px; }
.app-header .enterprise-search-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
}
.app-header .enterprise-search-item:hover,
.app-header .enterprise-search-item[aria-selected="true"] { background: rgba(15, 118, 110, .09); }
.app-header .enterprise-search-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.app-header .enterprise-search-meta { color: var(--muted, #64748b); font-size: 12px; }
.app-header .enterprise-search-type { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.app-header .enterprise-sr-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.page-toolbar:not(.filters) { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; min-height: 56px; }
.page-note { color: var(--muted); font-size: 13px; }
.page-toolbar label.page-note { display: flex; align-items: center; gap: 8px; }
.page-toolbar select { width: auto; min-width: 140px; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.boot { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; gap: 16px; color: var(--muted); background: var(--paper); text-align: center; }
.boot span { width: 34px; height: 34px; justify-self: center; border: 3px solid var(--teal-soft); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-button { position: relative; }
.icon-button em { position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; padding: 0 5px; border: 2px solid #102a2a; border-radius: 99px; color: white; background: var(--red); font: 700 12px/16px sans-serif; }
.eyebrow, .panel-title small, .dialog-head small, .drawer-head small { margin: 0; color: var(--muted); font-size: var(--fs-xs); font-weight: var(--fw-sb); letter-spacing: 0; }

.primary, .secondary, .ghost { border-radius: 8px; padding: 8px 14px; font-size: var(--fs-sm); font-weight: var(--fw-sb); line-height: 1.4; cursor: pointer; }
.primary { border: 0; color: #fff; background: var(--brand); }
.primary:hover { filter: brightness(0.97); }
.secondary { border: 1px solid var(--line); color: var(--ink); background: var(--btn); }
.ghost { border: 1px solid var(--line); color: var(--ink); background: transparent; }
.ghost:hover, .secondary:hover { filter: brightness(0.97); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(11,111,105,.2); outline-offset: 2px; }

.panel { background: var(--panel); }
.stat-grid { display: grid; gap: 12px; margin-bottom: 18px; }
.stat-grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat-grid button { position: relative; min-height: 122px; padding: 19px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; text-align: left; background: var(--card); box-shadow: 0 8px 26px rgba(35,50,48,.05); }
.stat-grid button::after { position: absolute; right: -25px; bottom: -42px; width: 90px; height: 90px; border-radius: 50%; background: var(--teal-soft); content: ""; opacity: .8; }
.stat-grid button:hover { border-color: #b8c9c3; transform: translateY(-1px); }
.stat-grid small, .stat-grid span, .stat-grid b { display: block; position: relative; z-index: 1; }
.stat-grid small { color: var(--muted); font-size: 14px; font-weight: 700; }
.stat-grid b { margin: 9px 0 6px; font: 700 36px/1 Georgia, serif; }
.stat-grid span { color: #8a9693; font-size: 13px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 16px; padding: 13px 15px; box-shadow: none; }
.segmented { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: #ecebe5; }
.segmented button { padding: 8px 14px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 15px; font-weight: 700; }
.segmented button.active { color: var(--teal-dark); background: #fff; box-shadow: 0 2px 9px rgba(30,48,43,.09); }
.filters { display: flex; gap: 8px; }
input, select, textarea { border: 1px solid #d4d8d1; border-radius: 9px; color: var(--ink); background: #fff; }
input, select { height: 38px; padding: 0 11px; }
textarea { padding: 10px 11px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #a4aca8; }
.filters input { width: min(260px, 24vw); }

.table-panel { min-height: 520px; overflow: hidden; }
.stack-body { padding: 16px; }
.stack-body > .domain-grid,
.stack-body > .split-grid { margin-bottom: 16px; }
.dash-board { display: grid; gap: 16px; }
.dash-board > .domain-grid,
.dash-board > .split-grid { margin-bottom: 0; }
#view-quality > .dash-board { margin-top: 18px; }
.page-toolbar label.page-note { display: flex; align-items: center; gap: 8px; }
.page-toolbar select { width: auto; min-width: 140px; }
.table-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid #ebe8e1; }
.table-head b, .table-head small { display: block; }
.table-head small { margin-top: 3px; color: var(--muted); font-size: 14px; }
.task-list { display: grid; }
.task-row { display: grid; grid-template-columns: minmax(220px, 1.6fr) minmax(120px, .7fr) 105px 130px 90px; gap: 14px; align-items: center; min-height: 76px; padding: 12px 20px; border-bottom: 1px solid #efede7; cursor: pointer; }
.task-row:hover { background: #fbfaf6; }
.task-title { min-width: 0; }
.task-title b { display: block; overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.task-title small { display: block; margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.source-tag, .status-tag, .priority-tag { display: inline-flex; width: fit-content; align-items: center; height: 26px; padding: 0 10px; border-radius: 99px; font-size: 13px; font-weight: 750; }
.source-tag { color: #42605a; background: #e9eeeb; }
.status-tag { color: var(--teal); background: var(--teal-soft); }
.status-tag.overdue, .priority-tag.urgent { color: var(--red); background: #f7e4e0; }
.priority-tag.high { color: #a66318; background: #f7ead5; }
.task-cell { color: #53635f; font-size: 15px; }
.task-cell b { display: block; color: var(--ink); font-size: 15px; }
.empty { display: grid; place-items: center; padding: 70px 20px; color: var(--muted); text-align: center; }
.empty span { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 14px; border: 1px solid #ccd9d4; border-radius: 16px; color: var(--teal); background: var(--teal-soft); font-size: 22px; }
.empty p { margin: 5px 0 0; font-size: 15px; }

.analytics-filter { justify-content: flex-start; align-items: flex-end; }
.analytics-filter label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; font-weight: 650; }
.analytics-filter button { margin-top: 0; }
.domain-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 0; }
.domain-card { position: relative; display: block; min-height: 124px; padding: 16px 16px 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 23, 42, .04)); }
.domain-card::before { position: absolute; top: 0; right: 0; left: 0; height: 3px; background: var(--brand, var(--teal)); content: ""; }
.domain-card.unavailable::before { background: var(--line); }
a.domain-card:hover { border-color: var(--brand-line, #99f6e4); }
.domain-card small { color: var(--muted); font-size: 13px; font-weight: 650; }
.domain-card b { display: block; margin: 12px 0 8px; color: var(--ink); font-size: 28px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.domain-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.domain-card.unavailable { background: var(--bg); }
.domain-card.unavailable b { color: var(--soft); font-size: 18px; }
.insight-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 16px; align-items: start; }
.insight { min-height: 0; padding: 18px 20px 16px; }
.insight.wide { grid-row: span 2; }
#familyRevenuePanel { min-height: 0; }
.panel-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-title h2, .dialog-head h2, .drawer-head h2 { margin: 2px 0 0; color: var(--ink); font-size: 18px; font-weight: 700; line-height: 1.3; }
.panel-title .definition { max-width: 360px; color: var(--muted); font-size: 12px; line-height: 1.45; text-align: right; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 22px; }
.chart-block h3 { margin: 0 0 10px; color: var(--muted); font-size: 12px; font-weight: 650; }
.bar-row { display: grid; grid-template-columns: minmax(72px, 96px) minmax(0, 1fr) auto; gap: 8px; align-items: center; margin: 7px 0; font-size: 13px; }
.bar-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 8px; overflow: hidden; border-radius: 99px; background: var(--line-soft, #f1f5f9); }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--brand, var(--teal)); }
.bar-row b { color: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums; }
.revenue-row { display: grid; grid-template-columns: 72px minmax(80px, 1fr) auto; gap: 6px 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.revenue-row b { font-size: 13px; font-weight: 650; }
.revenue-figs { display: flex; gap: 14px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.revenue-row small { grid-column: 2 / -1; color: var(--muted); font-size: 12px; }
.metric-stack { display: grid; }
.metric-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.metric-item span { color: var(--muted); font-size: 13px; }
.metric-item b { color: var(--ink); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.team-list { display: grid; }
.team-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.team-row b { font-size: 14px; }
.team-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.team-row strong { color: var(--brand, var(--teal)); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

.split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.split-grid > .panel, .flow-panel, .quality-panel { padding: 22px; }
.card-list { display: grid; gap: 10px; }
.mini-card { padding: 14px; border: 1px solid #e2dfd8; border-radius: 12px; background: #fff; }
.mini-card-head { display: flex; justify-content: space-between; gap: 12px; }
.mini-card b { font-size: 13px; }
.mini-card p { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.mini-card .actions { display: flex; gap: 6px; margin-top: 11px; }
.mini-card .actions button { min-height: 28px; padding: 0 9px; border: 1px solid #d8ddd7; border-radius: 8px; color: var(--teal); background: #fff; font-size: 10px; font-weight: 700; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.flow-panel { margin-top: 16px; }
.flow-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.flow-columns h3 { margin: 0 0 13px; color: var(--muted); font-size: 11px; }
.coverage-card ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.coverage-card li { display: flex; justify-content: space-between; padding: 12px 13px; border-radius: 10px; font-size: 11px; background: #f5f4ee; }
.coverage-card li.ready span { color: var(--teal); }
.coverage-card li.hold span { color: var(--amber); }
.quality-list { display: grid; }
.quality-row { display: grid; grid-template-columns: 90px minmax(220px, 1fr) 120px 110px auto; gap: 12px; align-items: center; padding: 13px 4px; border-bottom: 1px solid #ece9e2; }
.quality-row > b { font-size: 12px; }
.quality-row small { color: var(--muted); font-size: 10px; }
.severity { width: fit-content; padding: 4px 8px; border-radius: 99px; color: #8a651e; background: #f6ebd4; font-size: 9px; font-weight: 800; }
.severity.critical { color: var(--red); background: #f7e4e0; }

.drawer { position: fixed; top: 0; right: 0; z-index: 60; width: min(430px, 100vw); height: 100vh; overflow: auto; border-left: 1px solid var(--line); background: #fffdfa; box-shadow: -20px 0 60px rgba(15,35,32,.15); }
.detail-drawer { width: min(620px, 100vw); }
.drawer-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: 22px 24px; border-bottom: 1px solid var(--line); background: rgba(255,253,250,.96); backdrop-filter: blur(10px); }
.drawer-head button, .dialog-head button { width: 34px; height: 34px; border: 1px solid #ddd; border-radius: 9px; background: white; font-size: 20px; }
.notice-list { display: grid; }
.notice { padding: 17px 24px; border-bottom: 1px solid #ece9e2; }
.notice.unread { background: #f4faf8; }
.notice b { display: block; font-size: 13px; }
.notice p { margin: 5px 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.notice small { color: #95a09d; font-size: 9px; }
.task-detail { padding: 24px; }
.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.detail-meta div { padding: 12px; border-radius: 10px; background: #f3f2ec; }
.detail-meta small, .detail-meta b { display: block; }
.detail-meta small { color: var(--muted); font-size: 9px; }
.detail-meta b { margin-top: 5px; font-size: 12px; }
.detail-section { padding: 19px 0; border-top: 1px solid #eae7df; }
.detail-section h3 { margin: 0 0 12px; font-size: 12px; }
.check-row { display: flex; gap: 9px; align-items: center; margin: 8px 0; font-size: 12px; }
.comment { margin: 8px 0; padding: 10px 12px; border-radius: 10px; background: #f4f3ed; font-size: 11px; }
.comment small { display: block; margin-top: 4px; color: var(--muted); }
.inline-form { display: flex; gap: 8px; }
.inline-form input { min-width: 0; flex: 1; }

dialog { width: min(680px, calc(100vw - 28px)); max-height: calc(100vh - 40px); padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: var(--panel); box-shadow: 0 24px 70px rgba(15, 23, 42, .22); }
dialog::backdrop { background: rgba(15, 23, 42, .46); }
.wide-dialog { width: min(1120px, calc(100vw - 28px)); }
#metricDialog[open] { display: flex; flex-direction: column; width: min(1180px, calc(100vw - 32px)); max-height: min(860px, calc(100vh - 40px)); overflow: hidden; background: var(--panel); }
#metricDialog form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
.metric-lead { margin: 0; padding: 12px 20px; border-bottom: 1px solid var(--line); color: var(--muted); background: var(--panel); font-size: 13px; line-height: 1.45; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 22px 24px; }
.form-grid label { display: grid; gap: 6px; color: #52615e; font-size: 11px; font-weight: 700; }
.form-grid .span-2 { grid-column: span 2; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 16px 24px 22px; border-top: 1px solid #edeae3; }
.metric-table { flex: 1 1 auto; min-height: 0; overflow: auto; background: var(--panel); }
.metric-row { display: grid; grid-template-columns: 104px 132px minmax(160px, 1.15fr) minmax(180px, 1.25fr) minmax(128px, .9fr) 80px; gap: 12px; align-items: start; min-width: 860px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 13px; line-height: 1.45; }
.metric-row > * { min-width: 0; overflow-wrap: anywhere; }
.metric-row.head { position: sticky; top: 0; z-index: 1; align-items: center; color: var(--muted); background: var(--bg); font-size: 12px; font-weight: 650; white-space: nowrap; }
.metric-row:hover:not(.head) { background: var(--hover); }
.metric-name { font-size: 14px; font-weight: 700; }
.metric-state { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.metric-domain, .metric-flag { font-style: normal; }
.metric-domain { color: var(--muted); font-size: 12px; }
.metric-flag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 650; white-space: nowrap; }
.metric-flag.is-wait { background: var(--warn-soft); color: var(--warn-ink); }
.metric-formula { font-family: var(--font-mono); font-size: 12px; line-height: 1.45; color: var(--ink-2); }

.toast-region { position: fixed; right: 22px; top: calc(56px + 12px); bottom: auto; z-index: 12000; display: grid; gap: 8px; justify-items: end; }
.toast-region .toast { position: static; top: auto; right: auto; bottom: auto; z-index: auto; }
.toast { max-width: 360px; padding: 12px 15px; border-radius: 11px; color: white; background: #173b38; box-shadow: 0 12px 35px rgba(0,0,0,.22); font-size: 12px; animation: toast-in .2s ease-out; }
.toast.error { background: #873a31; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1100px) {
  .domain-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-grid.five { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 780px) {
  .stat-grid.five, .domain-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { align-items: stretch; flex-direction: column; }
  .segmented { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: visible; }
  .segmented button { min-width: 0; padding-right: 4px; padding-left: 4px; white-space: nowrap; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: span 2; width: 100%; }
  .task-row { grid-template-columns: minmax(0, 1fr) auto; }
  .task-row > :nth-child(2), .task-row > :nth-child(4), .task-row > :nth-child(5) { display: none; }
  .insight-grid, .split-grid, .flow-columns { grid-template-columns: 1fr; }
  .insight.wide { grid-row: auto; }
  .panel-title .definition { max-width: none; text-align: left; }
  .chart-grid { grid-template-columns: 1fr; }
  .quality-row { grid-template-columns: 75px minmax(0, 1fr) auto; }
  .quality-row > :nth-child(3), .quality-row > :nth-child(4) { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .metric-row { min-width: 760px; }
}

@media (max-width: 860px) {
  .toast-region { top: auto; bottom: 16px; }
}
