:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-blue: #f2f7ff;
  --text: #172033;
  --text-strong: #0f172a;
  --muted: #667085;
  --subtle: #98a2b3;
  --line: #e4e9f0;
  --line-strong: #d5dce7;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eaf2ff;
  --green: #15803d;
  --green-soft: #eaf8ef;
  --amber: #b45309;
  --amber-soft: #fff6df;
  --red: #c4323e;
  --red-soft: #fff0f1;
  --gray-soft: #eef2f6;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.05);
  --shadow-md: 0 14px 36px rgb(15 23 42 / 0.14);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --sidebar: 220px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Microsoft YaHei", "Noto Sans CJK SC", "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
a,
input,
select,
textarea,
summary,
[tabindex]:not([tabindex="-1"]) {
  outline: none;
}

:focus-visible {
  outline: 3px solid rgb(37 99 235 / 0.28);
  outline-offset: 2px;
}

::selection {
  color: var(--text-strong);
  background: #cfe0ff;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 22px 14px 16px;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 10px 18px;
  color: var(--text-strong);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: inline-grid;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #fff;
  background: var(--blue);
  border-radius: 9px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.nav-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px 12px;
  color: #475467;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.nav-link:hover {
  color: var(--text-strong);
  background: var(--surface-soft);
}

.nav-link.active {
  color: var(--blue-dark);
  background: var(--blue-soft);
  border-color: #d9e7ff;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  margin-top: auto;
  padding: 10px;
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px clamp(18px, 3vw, 38px);
  background: rgb(255 255 255 / 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.global-search {
  position: relative;
  flex: 1 1 360px;
  max-width: 520px;
}

.global-search input,
.global-search select {
  width: 100%;
}

.page {
  width: min(100%, 1460px);
  margin: 0 auto;
  padding: 26px clamp(18px, 3vw, 38px) 48px;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.page-heading h1,
.page-heading h2,
.panel-header h2,
.panel-header h3,
.drawer-header h2,
.drawer-header h3 {
  margin: 0;
  color: var(--text-strong);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.page-heading h1 {
  font-size: clamp(22px, 2.2vw, 30px);
  font-weight: 760;
}

.page-heading p {
  max-width: 720px;
  margin: 6px 0 0;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.subtle {
  color: var(--subtle);
}

.toolbar,
.filters,
.inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 16px;
}

.filters {
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.tabs,
.drawer-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar,
.drawer-tabs::-webkit-scrollbar {
  display: none;
}

.tabs {
  margin: 0 0 16px;
  padding: 4px;
  background: var(--gray-soft);
  border-radius: 11px;
}

.tab {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 7px 13px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-weight: 650;
  cursor: pointer;
}

.tab:hover {
  color: var(--text-strong);
}

.tab.active {
  color: var(--text-strong);
  background: var(--surface);
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.1);
}

.btn,
.icon-btn,
.close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease,
    box-shadow 140ms ease, transform 100ms ease;
}

.btn {
  gap: 7px;
  min-height: 40px;
  padding: 8px 14px;
  color: #344054;
  background: var(--surface);
  border-color: var(--line-strong);
  border-radius: 9px;
  font-weight: 650;
  box-shadow: var(--shadow-sm);
}

.btn:hover,
.icon-btn:hover,
.close-btn:hover {
  border-color: #b9c3d1;
  background: var(--surface-soft);
}

.btn:active,
.icon-btn:active,
.close-btn:active {
  transform: translateY(1px);
}

.btn.primary {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.btn.primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.btn.secondary {
  color: var(--blue-dark);
  background: var(--blue-soft);
  border-color: #cfe0ff;
  box-shadow: none;
}

.btn.quiet {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.btn.danger {
  color: var(--red);
  background: var(--red-soft);
  border-color: #ffd4d8;
  box-shadow: none;
}

.btn.small {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 13px;
}

.btn:disabled,
.icon-btn:disabled,
.close-btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.icon-btn,
.close-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--muted);
  background: var(--surface);
  border-color: var(--line);
  border-radius: 9px;
}

.stack {
  display: grid;
  gap: 16px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

.panel {
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2,
.panel-header h3 {
  font-size: 16px;
  font-weight: 720;
}

.panel-body {
  padding: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.metric-value {
  margin-top: 6px;
  color: var(--text-strong);
  font-size: clamp(22px, 2.1vw, 30px);
  font-weight: 760;
  line-height: 1.15;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row:hover {
  background: #fafbfd;
}

.row-main {
  min-width: 0;
  flex: 1 1 auto;
}

button.row-main {
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

button.list-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

button.list-row:hover {
  background: #fafbfd;
}

.row-main > .row-title {
  display: block;
  font-size: 15px;
}

button.metric-card {
  cursor: pointer;
}

.row-title {
  overflow: hidden;
  color: var(--text-strong);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  display: flex;
  align-items: center;
  gap: 6px 12px;
  min-width: 0;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.avatar {
  display: inline-grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  overflow: hidden;
  color: var(--blue-dark);
  background: var(--blue-soft);
  border: 1px solid #d8e6ff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 750;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge,
.due {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 680;
  line-height: 1.2;
  white-space: nowrap;
}

.badge.blue {
  color: var(--blue-dark);
  background: var(--blue-soft);
}

.badge.green {
  color: var(--green);
  background: var(--green-soft);
}

.badge.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.badge.red,
.due.overdue {
  color: var(--red);
  background: var(--red-soft);
}

.badge.gray,
.due {
  color: #596579;
  background: var(--gray-soft);
}

.empty,
.loading {
  display: grid;
  min-height: 180px;
  padding: 28px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.notice {
  padding: 11px 13px;
  color: #344054;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.notice.warning {
  color: #7c3e05;
  background: var(--amber-soft);
  border-color: #f4d79c;
  border-left-color: #d97706;
}

.notice.error {
  color: #9f2430;
  background: var(--red-soft);
  border-color: #ffd3d7;
  border-left-color: var(--red);
}

.notice.success {
  color: #146c36;
  background: var(--green-soft);
  border-color: #c9ebd4;
  border-left-color: var(--green);
}

.skeleton {
  position: relative;
  min-height: 14px;
  overflow: hidden;
  color: transparent;
  background: #e8edf3;
  border-radius: 6px;
}

.skeleton::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.62), transparent);
  content: "";
  animation: skeleton-sweep 1.35s ease-in-out infinite;
}

@keyframes skeleton-sweep {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #596579;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 720;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fafbfd;
}

.funnel {
  display: grid;
  gap: 13px;
}

.funnel-stage {
  display: grid;
  grid-template-columns: minmax(88px, 0.8fr) minmax(120px, 2fr) auto;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.stage-bar {
  height: 9px;
  overflow: hidden;
  background: var(--gray-soft);
  border-radius: 999px;
}

.stage-bar > span,
.stage-bar::before {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  background: var(--blue);
  border-radius: inherit;
  content: "";
}

.suggestion {
  padding: 14px 16px;
  background: var(--surface-blue);
  border: 1px solid #dbe8ff;
  border-radius: var(--radius);
}

.suggestion strong {
  color: var(--text-strong);
}

.priority-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: priority;
}

.priority-list > li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  counter-increment: priority;
}

.priority-list > li::before {
  display: grid;
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  place-items: center;
  color: var(--blue-dark);
  background: var(--blue-soft);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 750;
  content: counter(priority);
}

.task-check {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 40px;
  cursor: pointer;
}

.task-check input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--blue);
}

dialog {
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 0;
}

dialog::backdrop {
  background: rgb(15 23 42 / 0.4);
  backdrop-filter: blur(2px);
}

.drawer {
  width: min(740px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  overflow: hidden;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.drawer[open] {
  display: flex;
  flex-direction: column;
  animation: drawer-in 180ms ease-out;
}

@keyframes drawer-in {
  from {
    opacity: 0.7;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex: 0 0 auto;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-header h2,
.drawer-header h3 {
  font-size: 20px;
}

.drawer-body {
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.drawer-tabs {
  flex: 0 0 auto;
  padding: 8px 16px 0;
  border-bottom: 1px solid var(--line);
}

.drawer-tabs .tab {
  border-radius: 8px 8px 0 0;
}

.drawer-tabs .tab.active {
  color: var(--blue-dark);
  box-shadow: inset 0 -2px var(--blue);
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-item {
  position: relative;
  padding: 0 0 20px 24px;
}

.timeline-item::before {
  position: absolute;
  top: 5px;
  left: 2px;
  width: 9px;
  height: 9px;
  background: var(--surface);
  border: 2px solid var(--blue);
  border-radius: 50%;
  content: "";
}

.timeline-item::after {
  position: absolute;
  top: 17px;
  bottom: -2px;
  left: 7px;
  width: 1px;
  background: var(--line-strong);
  content: "";
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item:last-child::after {
  display: none;
}

.form-dialog {
  width: min(600px, calc(100vw - 32px));
  max-height: min(86dvh, 760px);
  margin: auto;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.form-dialog[open] {
  animation: form-in 150ms ease-out;
}

@keyframes form-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: #344054;
  font-size: 13px;
  font-weight: 650;
}

.field:has(textarea),
.field.full {
  grid-column: 1 / -1;
}

.field input,
.field select,
.field textarea,
.global-search input,
.filters input,
.filters select {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  color: var(--text-strong);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.03);
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.global-search input:hover,
.filters input:hover,
.filters select:hover {
  border-color: #b7c1cf;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.global-search input:focus,
.filters input:focus,
.filters select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
}

.form-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 14px 20px;
  background: rgb(255 255 255 / 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.form-content { padding: 0 20px; }
.form-content .form-grid { padding: 0; }
.reference-contact { padding: 12px 0; border-bottom: 1px solid var(--line); }
.research-panel > summary { padding: 18px 20px; cursor: pointer; font-weight: 600; }
.page { display: grid; gap: 18px; }
.page-heading { margin-bottom: 0; }
.brand small, .user-box small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.brand > span:last-child { line-height: 1.45; }
.user-box > div { flex: 1; min-width: 0; }
.user-box .btn { white-space: nowrap; padding-inline: 3px; }
.global-search { display: flex; align-items: center; gap: 8px; }
.global-search > span, .global-search > kbd { display: none; }
.metric-card { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 5px; }
.metric-grid.compact { grid-template-columns: repeat(3,minmax(0,1fr)); }
.metric-value small { margin-left: 5px; font-size: 13px; font-weight: 500; }
.empty, .loading { align-content: center; gap: 8px; }
.empty p { margin: 0; }
.notice > strong, .notice > span, .notice > small { display: block; }
.help-panel .empty { min-height: 80px; padding: 18px; }
.panel > summary { padding: 16px; cursor: pointer; font-weight: 600; }
.panel > summary + .metric-grid { padding: 0 16px 16px; }

.form-error {
  grid-column: 1 / -1;
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
}

.login-page {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
  background: var(--bg);
}

.login-card {
  width: min(100%, 400px);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgb(15 23 42 / 0.09);
}

.money {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  max-width: min(380px, calc(100vw - 32px));
  padding: 11px 14px;
  color: #fff;
  background: #172033;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.mobile-nav {
  display: none;
}

@media (max-width: 980px) {
  :root {
    --sidebar: 184px;
  }

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

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

@media (max-width: 720px) {
  .app-shell {
    display: block;
    min-height: 100dvh;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    min-height: 56px;
    padding: 8px 14px;
  }

  .page {
    padding: 18px 14px 88px;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 16px;
  }

  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    gap: 10px;
  }

  .panel-header,
  .panel-body {
    padding-right: 14px;
    padding-left: 14px;
  }

  .mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    min-height: 66px;
    padding: 6px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
    background: rgb(255 255 255 / 0.97);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgb(15 23 42 / 0.06);
    backdrop-filter: blur(14px);
  }

  .mobile-nav .nav-link {
    justify-content: center;
    min-width: 0;
    min-height: 48px;
    padding: 5px 2px;
    font-size: 12px;
    text-align: center;
  }

  .drawer {
    width: 100vw;
    border-left: 0;
  }

  .drawer-body {
    padding: 16px 14px calc(18px + env(safe-area-inset-bottom));
  }

  .drawer-header {
    padding: 15px 14px;
  }

  .detail-summary {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  .topbar {
    gap: 8px;
  }

  .topbar .btn:not(.primary),
  .topbar .muted {
    display: none;
  }

  .page-heading h1 {
    font-size: 22px;
  }

  .metric-card {
    padding: 13px;
  }

  .metric-value {
    font-size: 23px;
  }

  .list-row {
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 12px 13px;
  }

  .row-actions {
    width: 100%;
    padding-left: 0;
    justify-content: flex-start;
  }

  .topbar .row-actions { width: auto; padding: 0; }
  .topbar .global-search { min-width: 0; }

  .form-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 14px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .form-actions {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }

  .form-actions .btn {
    flex: 1 1 0;
  }

  .detail-summary {
    grid-template-columns: 1fr;
  }

  .funnel-stage {
    grid-template-columns: 78px minmax(90px, 1fr) auto;
    gap: 8px;
  }

  .toast {
    right: 16px;
    bottom: 82px;
    left: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .sidebar,
  .topbar,
  .mobile-nav,
  .row-actions,
  .toolbar .btn {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .page {
    width: 100%;
    padding: 0;
  }

  .panel,
  .metric-card {
    break-inside: avoid;
    box-shadow: none;
  }
}

.long-text { white-space: pre-wrap; overflow-wrap: anywhere; }
