/* =====================================================================
   Brandhaus Dashboard: design system
   Tokens first, then shell (sidebar, top bar, status strip), then
   components. Class names are shared with the server templates.
   ===================================================================== */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --subtle: #f8f9fb;
  --hover: #f5f7fb;
  --ink: #0f1729;
  --ink-2: #344054;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e4e7ec;
  --line-soft: #eef0f4;
  --accent: #3451e6;
  --accent-ink: #2537c4;
  --accent-soft: #eef1ff;
  --accent-line: #c9d2ff;
  --ok: #12b76a;
  --ok-ink: #067647;
  --ok-soft: #ecfdf3;
  --ok-line: #abefc6;
  --warn: #f79009;
  --warn-ink: #b54708;
  --warn-soft: #fffaeb;
  --warn-line: #fedf89;
  --danger: #f04438;
  --danger-ink: #b42318;
  --danger-soft: #fef3f2;
  --danger-line: #fecdca;
  --info-ink: #175cd3;
  --info-soft: #eff8ff;
  --info-line: #b2ddff;
  --side: #0c1324;
  --side-2: #131c33;
  --side-ink: #aab4c8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.07), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 10px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 18px 40px -12px rgba(16, 24, 40, 0.24), 0 4px 10px -4px rgba(16, 24, 40, 0.08);
  --ring: 0 0 0 4px rgba(52, 81, 230, 0.16);
  --sidebar-w: 248px;
  /* legacy names still used inline by a few templates */
  --ground: var(--bg);
  --accent-dark: var(--accent-ink);
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}
::selection {
  background: #dfe5ff;
}
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 6px;
}
h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.2;
}
h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--ink-2);
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
strong,
b {
  font-weight: 650;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- shell ---------- */
body.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(91, 124, 250, 0.18), transparent 60%),
    linear-gradient(180deg, var(--side-2), var(--side));
  color: var(--side-ink);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
  z-index: 30;
}
.brandmark {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 10px;
  color: #fff;
  text-decoration: none;
}
.brandmark:hover {
  color: #fff;
  text-decoration: none;
}
.brandmark svg {
  width: 34px;
  height: 34px;
  flex: none;
  filter: drop-shadow(0 4px 10px rgba(52, 81, 230, 0.45));
}
.brandmark b {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brandmark small {
  display: block;
  font-size: 11.5px;
  color: var(--side-ink);
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar a.nav {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--side-ink);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition:
    background 0.15s,
    color 0.15s;
}
.sidebar a.nav:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.sidebar a.nav.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.sidebar a.nav.active .ico {
  color: #8ea4ff;
}
.ico {
  width: 18px;
  height: 18px;
  flex: none;
}
.sidebar .badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.auto-state {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: #e4e8f1;
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
}
.auto-state:hover {
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.09);
}
.auto-state .pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(18, 183, 106, 0.6);
  animation: pulse 2.4s infinite;
}
.auto-state.off .pulse {
  background: var(--warn);
  animation: none;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(18, 183, 106, 0.55);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(18, 183, 106, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(18, 183, 106, 0);
  }
}
.me {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px 4px;
  min-width: 0;
}
.avatar {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #6d8bff, #2a3fd6);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
}
.me-mail {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--side-ink);
}
.signout {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--side-ink);
}
.signout:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.signout svg {
  width: 17px;
  height: 17px;
}

.shell {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
/* Search, brand and data view live in the sidebar */
.sidebar .search {
  position: relative;
}
.sidebar .search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  color: #7f8aa3;
  pointer-events: none;
}
.sidebar .search input[type="search"] {
  width: 100%;
  height: 36px;
  padding-left: 33px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  box-shadow: none;
  font-size: 13px;
}
.sidebar .search input::placeholder {
  color: #7f8aa3;
}
.sidebar .search input[type="search"]:focus {
  background: rgba(255, 255, 255, 0.1);
  border-color: #6d8bff;
  box-shadow: 0 0 0 3px rgba(109, 139, 255, 0.25);
}
.side-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.side-view form {
  margin: 0;
}
.side-view label,
.side-view .seg {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.side-view label > span,
.seg-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--side-ink);
}
.side-view select {
  flex: 1;
  max-width: 140px;
  min-height: 30px;
  padding: 4px 28px 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background-color: rgba(255, 255, 255, 0.06);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aab4c8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  color: #fff;
  box-shadow: none;
  font-size: 12.5px;
}
.side-view select option {
  color: var(--ink);
}
.seg-group {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
}
.seg-group button {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--side-ink);
  cursor: pointer;
}
.seg-group button:hover {
  color: #fff;
}
.seg-group button.on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
/* Feeds list in the sidebar, above the automatic actions state */
.side-feeds {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.side-label {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7f8aa3;
  list-style: none;
  cursor: pointer;
  user-select: none;
  transition:
    background 0.15s,
    color 0.15s;
}
.side-label::-webkit-details-marker {
  display: none;
}
.side-label:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #c9d1e3;
}
.side-sum {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: #7f8aa3;
}
.side-feeds[open] .side-sum {
  display: none;
}
/* the Feeds header takes the colour of the worst feed status */
.side-label.health-ok,
.side-label.health-ok .side-sum {
  color: #47cd89;
}
.side-label.health-stalled,
.side-label.health-stalled .side-sum {
  color: #fdb022;
}
.side-label.health-down,
.side-label.health-down .side-sum {
  color: #f97066;
}
.side-label.health-ok:hover,
.side-label.health-stalled:hover,
.side-label.health-down:hover {
  filter: brightness(1.15);
}
.side-chev {
  width: 6px;
  height: 6px;
  margin-left: 10px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
}
.side-feeds[open] .side-chev {
  margin-left: auto;
  transform: rotate(45deg);
}
.feedlist {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.feedlist .none {
  padding: 4px 10px;
  font-size: 12px;
  color: #7f8aa3;
}
.sidebar .feed {
  display: flex;
  padding: 5px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--side-ink);
  font-size: 12.5px;
  font-weight: 500;
}
.sidebar .feed:hover,
.sidebar .feed:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  box-shadow: none;
}
.sidebar .feed-stalled {
  color: #fdb022;
}
.sidebar .feed-down {
  color: #fda29b;
  font-weight: 600;
}
.sidebar .feed .tip {
  position: fixed;
  top: 50%;
  left: calc(var(--sidebar-w) + 4px);
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar .feed .tip::before {
  top: 50%;
  left: -6px;
  margin-top: -5px;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.modebar {
  padding: 7px 32px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--warn-ink);
  background: linear-gradient(90deg, var(--warn-soft), #fff6e5);
  border-bottom: 1px solid var(--warn-line);
}
.modebar::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--warn);
  vertical-align: 1px;
}
.modebar.real {
  color: var(--info-ink);
  background: linear-gradient(90deg, var(--info-soft), #f5faff);
  border-bottom-color: var(--info-line);
}
.modebar.real::before {
  background: var(--info-ink);
}
.wrap {
  width: 100%;
  max-width: 1720px;
  margin: 0 auto;
}
main.wrap {
  padding: 26px 32px 56px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- feed chips with status dots ---------- */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  flex: none;
}
.dot-ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.16);
}
.dot-stalled {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(247, 144, 9, 0.18);
}
.dot-down {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(240, 68, 56, 0.2);
}
.feed {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 3px 10px 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-2);
  font-weight: 500;
  cursor: default;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.feed:hover {
  border-color: #cfd4dc;
  box-shadow: var(--shadow-xs);
}
.feed-stalled {
  color: var(--warn-ink);
  border-color: var(--warn-line);
  background: var(--warn-soft);
}
.feed-down {
  color: var(--danger-ink);
  border-color: var(--danger-line);
  background: var(--danger-soft);
  font-weight: 600;
}
.feed .tip {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  min-width: 240px;
  max-width: 380px;
  padding: 10px 12px;
  background: #101828;
  color: #f2f4f7;
  font-weight: 400;
  font-size: 12px;
  line-height: 1.5;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  white-space: normal;
}
.feed .tip::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 16px;
  width: 10px;
  height: 10px;
  background: #101828;
  transform: rotate(45deg);
}
.feed:hover .tip,
.feed:focus .tip,
.feed:focus-within .tip {
  display: block;
}
.stale {
  color: var(--warn-ink);
  font-weight: 600;
}

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
}
.card.flush {
  padding: 0;
  overflow-x: auto;
}
.card .cardhead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  padding: 14px 18px;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
  border-bottom: 1px solid var(--line-soft);
}
.card .cardhead .muted,
.card .cardhead .small {
  font-weight: 400;
}
.card .cardfoot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  padding: 12px 18px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--subtle);
  border-top: 1px solid var(--line-soft);
  border-radius: 0 0 var(--radius) var(--radius);
}
.card > h2:first-child {
  margin-bottom: 14px;
}

/* ---------- rows (alerts, approvals, history) ---------- */
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 12px 4px;
  border-top: 1px solid var(--line-soft);
  font-size: 13.5px;
  color: var(--ink-2);
}
.row:first-of-type {
  border-top: 0;
}
.row strong {
  color: var(--ink);
}
.who {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--subtle);
  border: 1px solid var(--line-soft);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}
.pill.late::before,
.pill.warn::before,
.pill.ok::before,
.pill.info::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.late {
  background: var(--danger-soft);
  color: var(--danger-ink);
  border-color: var(--danger-line);
}
.warn {
  background: var(--warn-soft);
  color: var(--warn-ink);
  border-color: var(--warn-line);
}
.ok {
  background: var(--ok-soft);
  color: var(--ok-ink);
  border-color: var(--ok-line);
}
.info {
  background: var(--info-soft);
  color: var(--info-ink);
  border-color: var(--info-line);
}
.brand {
  background: #f2f4f7;
  color: var(--ink-2);
  border-color: var(--line);
}
.pill.muted {
  background: #f2f4f7;
  color: var(--muted);
  border-color: var(--line);
}
.tag-demo {
  display: inline-block;
  margin-left: 5px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 16px;
  background: #fff4e0;
  color: #b25e09;
  vertical-align: 1px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: var(--shadow-xs);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background 0.15s,
    border-color 0.15s,
    box-shadow 0.15s,
    transform 0.05s;
}
.btn:hover {
  background: var(--hover);
  border-color: #c2c8d2;
  color: var(--ink);
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: linear-gradient(180deg, #4560f0, var(--accent));
  border-color: var(--accent-ink);
  color: #fff;
  box-shadow:
    0 1px 2px rgba(37, 55, 196, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.btn-primary:hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
  color: #fff;
}
.btn.on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.btn.small {
  min-height: 26px;
  padding: 3px 9px;
  font-size: 12px;
  border-radius: 7px;
}
.btn-lg {
  min-height: 42px;
  font-size: 14px;
}
form.inline {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin: 0;
}

/* ---------- inputs ---------- */
select,
input[type="search"],
input[type="number"],
input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
textarea {
  font: inherit;
  font-size: 13.5px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-xs);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
select {
  padding-right: 30px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 15px;
  cursor: pointer;
}
select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: #8ea0f5;
  box-shadow: var(--ring);
}
input[type="number"] {
  width: 84px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}
label {
  font-size: 13px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
textarea {
  width: 100%;
  min-height: 64px;
  line-height: 1.5;
}

/* ---------- tables ---------- */
table.t {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.t th {
  position: relative;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 10px 14px;
  background: var(--subtle);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.t td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  color: var(--ink-2);
}
.t tbody tr:last-child > td {
  border-bottom: 0;
}
.t tbody tr:hover > td {
  background: var(--hover);
}
.t td:first-child,
.t th:first-child {
  padding-left: 18px;
}
.t td:last-child,
.t th:last-child {
  padding-right: 18px;
}
.t tr.grp td {
  font-weight: 700;
  color: var(--ink);
  background: var(--subtle);
}
.t tr.sub td:first-child {
  padding-left: 32px;
  white-space: nowrap;
}
.t tr.sel td {
  background: var(--accent-soft);
}
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.t th.num {
  text-align: right;
}
/* Search and filter bar: under the page heading and tiles, above the list */
.filterbar {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.filterbar .searchbox {
  position: relative;
  flex: 1 1 280px;
  max-width: 420px;
}
.filterbar .searchbox::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 50%;
  width: 15px;
  height: 15px;
  margin-top: -7.5px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E")
    center / contain no-repeat;
  pointer-events: none;
}
.filterbar .searchbox input[type="search"] {
  width: 100%;
  padding-left: 34px;
}

/* Sortable headers: a faint up-down mark, a solid arrow on the sorted column */
.t th.sortable {
  cursor: pointer;
  user-select: none;
  padding-right: 24px;
  transition:
    color 0.15s,
    background 0.15s;
}
.t th.sortable:hover {
  color: var(--ink);
  background: #eef1f6;
}
.t th.sortable::after {
  content: "";
  position: absolute;
  right: 9px;
  top: 50%;
  width: 7px;
  height: 10px;
  margin-top: -5px;
  opacity: 0.35;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 10'%3E%3Cpath d='M3.5 0 7 4H0zM3.5 10 0 6h7z' fill='%23667085'/%3E%3C/svg%3E")
    center / contain no-repeat;
}
.t th.sortable:hover::after {
  opacity: 0.7;
}
.t th.sortable[aria-sort="ascending"],
.t th.sortable[aria-sort="descending"] {
  color: var(--accent-ink);
}
.t th.sortable[aria-sort="ascending"]::after {
  opacity: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 10'%3E%3Cpath d='M3.5 2 7 7H0z' fill='%232537c4'/%3E%3C/svg%3E");
}
.t th.sortable[aria-sort="descending"]::after {
  opacity: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 10'%3E%3Cpath d='M3.5 8 0 3h7z' fill='%232537c4'/%3E%3C/svg%3E");
}
.t th.sortable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  box-shadow: none;
}

/* ---------- toolbars, page headers ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}
.toolbar h1 {
  margin-right: 6px;
}
.toolbar .right {
  margin-left: auto;
}
main.wrap > .toolbar:first-child,
main.wrap > .flash + .toolbar,
main.wrap > style + .toolbar {
  padding-bottom: 4px;
}

/* ---------- stats and tiles ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}
.stat {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
}
.stat::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, #dfe4ff, transparent);
}
.stat .l,
.tile .l,
.baseline .l {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat .v {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.stat .s,
.stat > .muted.small {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.stat.accent {
  border-color: var(--accent-line);
  background: linear-gradient(180deg, #f6f7ff, #fff 60%);
}
.stat.accent::after {
  background: linear-gradient(90deg, var(--accent), #8ea4ff);
}
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.tile {
  position: relative;
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, var(--subtle));
  color: inherit;
  text-decoration: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    transform 0.15s;
}
.tile.link::after {
  content: "";
  position: absolute;
  top: 16px;
  right: 16px;
  width: 7px;
  height: 7px;
  border-top: 2px solid var(--faint);
  border-right: 2px solid var(--faint);
  transform: rotate(45deg);
  transition: transform 0.15s;
}
.tile.link:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
}
.tile.link:hover::after {
  border-color: var(--accent);
  transform: translateX(2px) rotate(45deg);
}
.tile .v {
  margin: 6px 0 2px;
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.tile .s {
  font-size: 12.5px;
  color: var(--muted);
}
.baseline {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.baseline .l {
  margin-bottom: 6px;
}
table.t.compact {
  max-width: 460px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  overflow: hidden;
}
table.t.compact td,
table.t.compact th {
  padding: 6px 12px;
}

/* ---------- collapsible sections on Today ---------- */
details.section {
  padding: 0;
  overflow: visible;
}
details.section > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius);
  transition: background 0.15s;
}
details.section[open] > summary {
  border-radius: var(--radius) var(--radius) 0 0;
}
details.section > summary::-webkit-details-marker {
  display: none;
}
details.section > summary h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
}
details.section > summary:hover {
  background: var(--subtle);
}
details.section .chev {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  transform: none;
}
details.section .chev::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateX(-1px) rotate(-45deg);
  transition: transform 0.18s ease;
}
details.section[open] .chev::before {
  transform: translateY(-1px) rotate(45deg);
}
details.section .count {
  display: inline-block;
  min-width: 22px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #f2f4f7;
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 650;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
details.section[data-key^="alerts:"] .count {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger-ink);
}
details.section[data-key="approvals"] .count {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-ink);
}
details.section .summary-extra {
  margin-left: auto;
}
details.section .section-body {
  padding: 4px 20px 16px;
  border-top: 1px solid var(--line-soft);
}
details.section[data-key="week"] .section-body {
  padding-top: 16px;
}
.section-controls {
  display: inline-flex;
  gap: 6px;
}
details.more > summary {
  margin-top: 6px;
  padding: 8px 4px;
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

/* ---------- mark handled with a note ---------- */
details.handle {
  display: inline-block;
  position: relative;
}
details.handle > summary {
  list-style: none;
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12.5px;
}
details.handle > summary::-webkit-details-marker {
  display: none;
}
details.handle[open] > summary {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-ink);
}
.handle-form {
  position: absolute;
  z-index: 35;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
}
.handle-form label {
  display: block;
  font-weight: 650;
  color: var(--ink);
}
.handle-form textarea {
  display: block;
  margin-top: 8px;
  font-weight: 400;
  resize: vertical;
}
.handle-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.row.handled {
  color: var(--muted);
}
.row.handled .handled-note {
  flex: 1 1 280px;
  color: var(--ink-2);
  padding-left: 10px;
  border-left: 2px solid var(--ok-line);
}

/* ---------- layouts ---------- */
.two {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-start;
}
.two > .main {
  flex: 999 1 640px;
  min-width: 0;
}
.two > .side {
  flex: 1 1 300px;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px 28px;
  font-size: 13px;
}
.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  font-size: 13px;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  color: var(--ink);
}

/* ---------- provenance popovers and drawers ---------- */
details.prov {
  display: inline-block;
}
details.prov summary {
  cursor: pointer;
  list-style: none;
  border-bottom: 1px dotted #98a2b3;
  font-variant-numeric: tabular-nums;
}
details.prov summary::-webkit-details-marker {
  display: none;
}
details.prov[open] summary {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
details.prov .pop {
  position: absolute;
  z-index: 20;
  margin-top: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 12px;
  box-shadow: var(--shadow-lg);
  max-width: 380px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  white-space: normal;
}
details.drawer summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
}
details.drawer .pop {
  margin-top: 8px;
  background: var(--subtle);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- status text ---------- */
.up,
.ok-t {
  color: var(--ok-ink);
  font-weight: 600;
}
.down,
.miss-t {
  color: var(--danger-ink);
  font-weight: 600;
}
.warn-t {
  color: var(--warn-ink);
  font-weight: 600;
}
a.ok-t,
a.miss-t,
a.warn-t {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

/* ---------- Today: the "Needs you" count beside the page title ---------- */
.needs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 5px 4px 12px;
  border-radius: 999px;
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  color: var(--danger-ink);
  font-size: 12.5px;
  font-weight: 600;
}
.needs b {
  min-width: 24px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.needs.none {
  background: var(--ok-soft);
  border-color: var(--ok-line);
  color: var(--ok-ink);
}
.needs.none b {
  background: var(--ok);
}

/* ---------- order stage stepper ---------- */
.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.steps li {
  flex: 1 1 110px;
  min-width: 100px;
  padding: 10px 10px 4px 0;
  border-top: 4px solid var(--line);
  border-radius: 2px;
  font-size: 12px;
}
.steps li.done {
  border-top-color: var(--ok);
}
.steps li.now {
  border-top-color: var(--accent);
}
.steps li.now .n {
  color: var(--accent-ink);
}
.steps li.due {
  border-top-color: var(--warn);
}
.steps li.todo {
  color: var(--faint);
}
.steps .n {
  font-weight: 650;
  display: block;
  color: var(--ink);
}
.steps li.todo .n {
  color: var(--faint);
}
.steps .d {
  color: var(--muted);
  display: block;
}

/* ---------- approvals ---------- */
.ap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-xs);
  border-left: 4px solid var(--accent);
}
.ap.sent {
  border-left-color: var(--ok);
  background: linear-gradient(90deg, #f6fdf9, #fff 40%);
}
.ap.rej {
  border-left-color: var(--danger);
  background: linear-gradient(90deg, #fff8f7, #fff 40%);
}
.draft {
  background: var(--subtle);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--ink);
}

/* ---------- messages ---------- */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border: 1px solid var(--accent-line);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-xs);
  animation: drop 0.25s ease-out;
}
.flash::before {
  content: "";
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  background:
    var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4 8-9'/%3E%3C/svg%3E")
    center / 12px no-repeat;
}
.flash.err {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger-ink);
}
.flash.err::before {
  background:
    var(--danger)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M12 7v6M12 17h.01'/%3E%3C/svg%3E")
    center / 12px no-repeat;
}
@keyframes drop {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}
.banner,
.warnbox {
  padding: 12px 16px;
  border: 1px solid var(--warn-line);
  border-radius: 12px;
  background: var(--warn-soft);
  color: var(--warn-ink);
  font-size: 13.5px;
}
.note {
  padding: 9px 14px;
  border: 1px solid var(--warn-line);
  border-radius: 10px;
  background: var(--warn-soft);
  color: var(--warn-ink);
  font-size: 12.5px;
}

/* ---------- switch ---------- */
.sw {
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  border: 0;
  background: transparent;
}
.sw .k {
  width: 40px;
  height: 23px;
  border-radius: 12px;
  background: #d0d5dd;
  position: relative;
  display: inline-block;
  transition: background 0.2s;
}
.sw .k::after {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 2.5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.2);
  transition: left 0.2s;
}
.sw.on .k {
  background: var(--ok);
}
.sw.on .k::after {
  left: 19.5px;
}

/* ---------- misc components ---------- */
.rank {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2a3555, var(--ink));
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.tl {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}
.tl li {
  position: relative;
  padding: 6px 0 10px 20px;
  margin-left: 6px;
  border-left: 2px solid var(--line);
}
.tl li:last-child {
  border-left-color: transparent;
}
.tl li::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
}
.dg {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 6px 12px;
  font-size: 13px;
  align-items: center;
}
.msg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 13px;
}

/* ---------- exchange rate ---------- */
.fx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px 32px;
}
.fx-rate {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin: 4px 0 6px;
  font-size: 30px;
  font-weight: 750;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.fx-rate .small,
.fx-rate .muted {
  letter-spacing: 0;
  font-weight: 500;
}
.fx-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.fx-actions label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.fx-chip {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 5px 6px 5px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow-xs);
  font-size: 13px;
}
.fx-chip strong {
  font-variant-numeric: tabular-nums;
}

/* ---------- feed indicator settings ---------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding: 12px 18px;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--subtle);
  border-bottom: 1px solid var(--line-soft);
}
.legend > span {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.nowcount {
  display: inline-flex;
  align-items: center;
  margin-right: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---------- in-page segmented switch (range currency basis) ---------- */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  align-self: flex-start;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: #e9ecf2;
  font-size: 13px;
}
.segmented .btn {
  min-height: 30px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  border-radius: 9px;
}
.segmented .btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.6);
}
.segmented .btn.on {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* ---------- page tabs as sub-links under the active sidebar entry ---------- */
.sidebar a.nav.has-sub {
  background: rgba(255, 255, 255, 0.07);
  box-shadow: none;
}
.subnav {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 2px 0 6px 19px;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}
.subnav a.sub {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  color: #98a3bb;
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  transition:
    background 0.15s,
    color 0.15s;
}
.subnav a.sub:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}
.subnav a.sub.active {
  background: rgba(109, 139, 255, 0.16);
  color: #fff;
}
.subnav a.sub.active::before {
  content: "";
  position: absolute;
  left: -13px;
  top: 7px;
  bottom: 7px;
  width: 2px;
  border-radius: 2px;
  background: #8ea4ff;
}
.sub-count {
  margin-left: auto;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #dfe4f0;
  font-size: 11px;
  font-weight: 650;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- collapsible supplier cards (distributor orders, by supplier) ---------- */
details.supplier > summary.supplier-head {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 14px 18px;
  cursor: pointer;
  border-radius: var(--radius);
}
details.supplier > summary::-webkit-details-marker {
  display: none;
}
details.supplier > summary:hover {
  background: var(--subtle);
}
details.supplier[open] > summary {
  border-bottom: 1px solid var(--line-soft);
  border-radius: var(--radius) var(--radius) 0 0;
}
details.supplier .chev {
  color: var(--muted);
}
details.supplier[open] .chev {
  transform: rotate(45deg);
}
details.supplier .right {
  margin-left: auto;
}

/* ---------- alert history on an entry ---------- */
.alert-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.ah-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  font-size: 13px;
}
.ah-head a {
  margin-left: auto;
}
.ah-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0 2px;
  border-top: 1px solid var(--line-soft);
  font-size: 13px;
}
.ah-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.ah-item.open .ah-top details.handle {
  margin-left: auto;
}
.ah-item.closed .ah-top > span:nth-child(2) {
  color: var(--ink-2);
}
.ah-sub {
  font-size: 12.5px;
}
.ah-note {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-left: 3px solid var(--ok);
  border-radius: 0 8px 8px 0;
  background: var(--ok-soft);
  color: var(--ink);
}
.ah-note.auto {
  border-left-color: var(--line);
  background: var(--subtle);
  color: var(--muted);
}
.ah-who {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--ok-ink);
}
.ah-note.auto .ah-who {
  color: var(--muted);
}
.handled-inline {
  margin-top: 2px;
  padding-left: 8px;
  border-left: 2px solid var(--ok-line);
  color: var(--ink-2);
}
.t td.note-cell {
  max-width: 420px;
  color: var(--ink);
}
.t td.note-cell:not(.auto) {
  border-left: 3px solid var(--ok-line);
}
code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 6px;
  background: #f2f4f7;
  color: var(--ink-2);
}

/* ---------- expandable rows: detail opens underneath ---------- */
tr.expandable {
  cursor: pointer;
}
tr.expandable.open > td {
  background: var(--accent-soft);
  border-bottom-color: transparent;
}
tr.expandable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  box-shadow: none;
}
.t td.chevcell {
  width: 36px;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
}
a.detail-link {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  color: var(--faint);
  text-decoration: none;
}
tr.expandable:hover a.detail-link {
  background: #fff;
  color: var(--accent);
  box-shadow: var(--shadow-xs);
}
.chev {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  margin: 0 2px 2px 0;
}
tr.expandable.open .chev {
  transform: rotate(45deg);
}
tr.detail-row[hidden] {
  display: none;
}
tr.detail-row:target {
  display: table-row;
}
.t tr.detail-row > td,
.t tbody tr.detail-row:hover > td {
  background: linear-gradient(180deg, #f6f8ff, var(--subtle));
  border-left: 3px solid var(--accent);
  border-bottom: 1px solid var(--line);
  padding: 16px 20px;
  font-size: 13px;
  color: var(--ink);
}
.t tr.detail-row .t {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 8px 0 12px;
  width: auto;
  min-width: 420px;
  overflow: hidden;
}
.t tr.detail-row .t td,
.t tr.detail-row .t th {
  padding: 7px 12px;
}
.t tr.detail-row .t tbody tr:hover > td {
  background: var(--hover);
}
.detail-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- sign in ---------- */
body.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(60% 50% at 20% 10%, rgba(109, 139, 255, 0.35), transparent 70%),
    radial-gradient(50% 50% at 90% 90%, rgba(42, 63, 214, 0.28), transparent 70%),
    linear-gradient(160deg, #131c33, #0c1324);
}
.loginbox {
  width: min(400px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 32px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.55);
}
.login-mark svg {
  width: 44px;
  height: 44px;
}
.loginbox h1 {
  font-size: 22px;
}
.loginbox p {
  margin: -6px 0 4px;
}
.loginbox label {
  flex-direction: column;
  align-items: stretch;
  font-weight: 600;
  gap: 8px;
}
.loginbox input {
  height: 42px;
}

/* ---------- scrollbars ---------- */
.card.flush::-webkit-scrollbar {
  height: 10px;
}
.card.flush::-webkit-scrollbar-thumb {
  background: #d0d5dd;
  border-radius: 10px;
  border: 3px solid #fff;
}

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  :root {
    --sidebar-w: 220px;
  }
  .sidebar {
    padding: 16px 10px;
    gap: 14px;
  }
  main.wrap {
    padding: 22px 22px 48px;
  }
  .modebar {
    padding-left: 22px;
    padding-right: 22px;
  }
}
@media (max-width: 720px) {
  body.app {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    min-width: 0;
    position: static;
    height: auto;
    overflow: visible;
    gap: 12px;
    padding: 12px 14px;
  }
  .sidebar nav {
    flex-direction: row;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .sidebar nav::-webkit-scrollbar {
    display: none;
  }
  .sidebar a.nav {
    flex: none;
  }
  .side-foot {
    margin: 0;
  }
  .modebar {
    padding-left: 16px;
    padding-right: 16px;
  }
  main.wrap {
    padding: 18px 16px 40px;
  }
  .two > .side {
    max-width: none;
  }
  h1 {
    font-size: 22px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- review pass: alert rows, clickable tiles, paging, search, wide tables ---------- */
/* Alert row: label, then title over detail, then date, owner and the action in fixed columns */
.row.alert-row {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr) auto 64px auto;
  align-items: center;
  gap: 4px 14px;
  flex-wrap: nowrap;
}
.alert-row .ar-pill {
  display: flex;
}
.alert-row .ar-title {
  line-height: 1.35;
}
.alert-row .ar-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  margin-top: 2px;
  font-size: 12.5px;
}
.alert-row .ar-next {
  color: var(--ink-2);
  font-weight: 500;
}
.alert-row .ar-next::before {
  content: "Next: ";
  color: var(--faint);
  font-weight: 400;
}
.alert-row .ar-since {
  white-space: nowrap;
}
.alert-row .who {
  margin-left: 0;
  justify-self: start;
}
@media (max-width: 900px) {
  .row.alert-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .alert-row .ar-pill,
  .alert-row .ar-main {
    grid-column: 1 / -1;
  }
  .alert-row .ar-since {
    grid-column: 1;
  }
  .alert-row .who {
    display: none;
  }
}

/* Tiles that filter the list below when clicked */
a.stat.link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    transform 0.15s;
}
a.stat.link:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  color: inherit;
  text-decoration: none;
}

/* Paging */
.pager {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}
.btn.disabled {
  opacity: 0.45;
  pointer-events: none;
  box-shadow: none;
}

/* Search everywhere */
.searchbox.wide {
  position: relative;
  flex: 1 1 420px;
  max-width: 640px;
}
.searchbox.wide input {
  width: 100%;
  height: 40px;
  font-size: 14.5px;
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.tile.result .s {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--ink-2);
}
.tile.result.none {
  background: var(--subtle);
  opacity: 0.75;
}
.sidebar .search kbd {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  font:
    600 11px / 17px ui-monospace,
    Menlo,
    Consolas,
    monospace;
  color: #7f8aa3;
  pointer-events: none;
}
.sidebar .search input:focus + kbd,
.sidebar .search input:not(:placeholder-shown) + kbd {
  display: none;
}

/* Wide tables keep readable columns and scroll sideways instead of crushing text into tall cells */
.card.flush > table.t:has(> thead th:nth-child(9)) {
  min-width: 1080px;
}
.card.flush > table.t:has(> thead th:nth-child(12)) {
  min-width: 1320px;
}
.card.flush.more-right {
  box-shadow:
    var(--shadow-xs),
    inset -22px 0 18px -18px rgba(16, 24, 40, 0.22);
}
.card.flush.more-left {
  box-shadow:
    var(--shadow-xs),
    inset 22px 0 18px -18px rgba(16, 24, 40, 0.22);
}
.card.flush.more-left.more-right {
  box-shadow:
    var(--shadow-xs),
    inset 22px 0 18px -18px rgba(16, 24, 40, 0.22),
    inset -22px 0 18px -18px rgba(16, 24, 40, 0.22);
}

/* ---------- accounts, record fixes, alert hold-back, purchase orders ---------- */
.me-link {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
  color: inherit;
  text-decoration: none;
  border-radius: 8px;
}
.me-link:hover {
  color: #fff;
  text-decoration: none;
}
.me-link:hover .me-mail {
  color: #fff;
}
.login-help {
  margin: 4px 0 0 !important;
  text-align: center;
}
.t tr.inactive td {
  opacity: 0.55;
}
.user-edit form + form {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

details.fix > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
}
details.fix > summary::before {
  content: "";
  width: 13px;
  height: 13px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233451e6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}
details.fix[open] > .pop {
  position: relative;
  z-index: 10;
  min-width: min(560px, 90vw);
  background: #fff;
  box-shadow: var(--shadow-lg);
  color: var(--ink);
}
.fix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px 14px;
}
.fix-form label {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}
.fix-form label.wide {
  grid-column: 1 / -1;
  margin-top: 10px;
}
.fix-form input,
.fix-form select,
.fix-form textarea {
  width: 100%;
  font-weight: 400;
}

.handle-form label.snooze {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  margin-top: 8px;
  font-weight: 500;
  color: var(--muted);
}
.ar-prev {
  margin-top: 4px;
  padding: 4px 10px;
  border-left: 3px solid var(--warn-line);
  border-radius: 0 6px 6px 0;
  background: var(--warn-soft);
  font-size: 12.5px;
  color: var(--ink-2);
}
.ar-prev-label {
  font-weight: 650;
  color: var(--warn-ink);
}
.po-links {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
