*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:      #1e40af;
  --brand-dark: #1e3a8a;
  --text:       #0f172a;
  --muted:      #64748b;
  --border:     #e2e8f0;
  --bg:         #f8fafc;
  --white:      #ffffff;
  --red:        #dc2626;
  --radius:     6px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* ── Navigation ─────────────────────────────────── */
.nav {
  background: var(--brand);
  color: var(--white);
  height: 56px;
  display: flex;
  align-items: center;
}
.nav-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand { font-size: 1rem; font-weight: 600; letter-spacing: .02em; }
.nav-links  { display: flex; gap: .25rem; margin-left: 1.5rem; }
.nav-link   { color: rgba(255,255,255,.8); text-decoration: none; padding: .35rem .75rem; border-radius: var(--radius); font-size: .875rem; transition: background .15s; }
.nav-link:hover { background: rgba(255,255,255,.15); color: var(--white); }
.nav-right  { display: flex; align-items: center; gap: 1rem; }
.nav-user   { font-size: .875rem; opacity: .85; }

/* ── Nav dropdowns ───────────────────────────────── */
.nav-dd            { position: relative; }
.nav-dd-btn        { background: none; border: none; cursor: pointer; color: rgba(255,255,255,.8); font-size: .875rem; padding: .35rem .75rem; border-radius: var(--radius); display: flex; align-items: center; gap: .3rem; transition: background .15s; }
.nav-dd-btn:hover  { background: rgba(255,255,255,.15); color: var(--white); }
.nav-dd-menu       { display: none; position: absolute; top: calc(100% + .4rem); right: 0; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.12); min-width: 175px; z-index: 300; padding: .25rem 0; }
.nav-dd-menu.open  { display: block; }
.nav-dd-item       { display: block; padding: .45rem 1rem; color: var(--text); text-decoration: none; font-size: .875rem; white-space: nowrap; background: none; border: none; width: 100%; text-align: left; cursor: pointer; }
.nav-dd-item:hover { background: var(--bg); }
.nav-dd-divider    { height: 1px; background: var(--border); margin: .25rem 0; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .45rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .15s;
}
.btn-primary      { background: var(--brand); color: var(--white); }
.btn-primary:hover{ background: var(--brand-dark); }
.btn-ghost        { background: transparent; color: var(--white); border: 1px solid rgba(255,255,255,.4); }
.btn-ghost:hover  { background: rgba(255,255,255,.1); }
.btn-full         { width: 100%; }

/* ── Auth page ───────────────────────────────────── */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.auth-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
}
.auth-logo    { text-align: center; margin-bottom: 1.75rem; }
.auth-logo h1 { font-size: 2rem; color: var(--brand); font-weight: 700; }
.auth-logo p  { color: var(--muted); font-size: .875rem; margin-top: .25rem; }

/* ── Form fields ─────────────────────────────────── */
.field        { margin-bottom: 1rem; }
.field label  { display: block; font-weight: 500; margin-bottom: .35rem; font-size: .8125rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input  {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9375rem;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--brand); }
.btn-primary.btn-full { margin-top: .5rem; padding: .7rem; font-size: .9375rem; }

/* ── Alerts ──────────────────────────────────────── */
.alert         { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .875rem; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: var(--red); }

/* ── Main container ──────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem;
}
.page-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-header h2  { font-size: 1.25rem; font-weight: 600; }
.badge-count     { font-size: .8125rem; color: var(--muted); }
.empty-state     { color: var(--muted); padding: 2rem 0; text-align: center; }

/* ── Table ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table th {
  text-align: left;
  padding: .65rem 1rem;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  background: #f1f5f9;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover          { background: #f8fafc; }
.col-id   { width: 60px; color: var(--muted); }
.col-date { width: 120px; white-space: nowrap; }
.col-desc { max-width: 360px; }
.col-actions { width: 80px; text-align: right; }
.table-count { margin-top: .6rem; font-size: .8125rem; color: var(--muted); }

/* ── Secondary button ────────────────────────────── */
.btn-secondary      { background: var(--white); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover{ background: var(--bg); }
.btn-sm             { padding: .25rem .65rem; font-size: .8125rem; background: var(--white); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); }
.btn-sm:hover       { background: var(--bg); }

/* ── Search bar ──────────────────────────────────── */
.search-bar         { display: flex; gap: .5rem; margin-bottom: 1.25rem; }
.search-bar input   { flex: 1; max-width: 360px; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9375rem; outline: none; }
.search-bar input:focus { border-color: var(--brand); }

/* ── Form card (create / edit) ───────────────────── */
.form-card          { background: var(--white); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.form-card fieldset { border: none; border-bottom: 1px solid var(--border); padding: 1.25rem 1.5rem; }
.form-card fieldset:last-of-type { border-bottom: none; }
.form-card legend   { font-weight: 600; font-size: .8125rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 1rem; }
.form-grid          { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem 1.25rem; }
.form-card select   { width: 100%; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9375rem; background: var(--white); outline: none; }
.form-card select:focus { border-color: var(--brand); }
.form-actions       { padding: 1.25rem 1.5rem; display: flex; gap: .75rem; background: #f8fafc; }
.req                { color: var(--red); }

/* ── Detail page ─────────────────────────────────── */
.detail-grid        { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.detail-card        { background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem 1.5rem; }
.detail-card h3     { font-size: .8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 1rem; }
dl                  { display: grid; grid-template-columns: max-content 1fr; gap: .35rem .75rem; font-size: .9rem; }
dt                  { color: var(--muted); font-weight: 500; white-space: nowrap; }
dd                  { color: var(--text); }
.detail-section     { margin-top: .5rem; }
.detail-section h3  { font-size: 1rem; font-weight: 600; margin-bottom: .75rem; }

/* ── Status badges ───────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-open        { background: #dcfce7; color: #166534; }
.status-in-progress { background: #fef9c3; color: #854d0e; }
.status-closed      { background: #f1f5f9; color: var(--muted); }

/* ── Textarea ────────────────────────────────────── */
textarea {
  width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9375rem;
  font-family: inherit;
  outline: none;
  resize: vertical;
  transition: border-color .15s;
}
textarea:focus { border-color: var(--brand); }
.field-wide     { grid-column: 1 / -1; }

/* ── Inline add/edit forms ───────────────────────── */
.inline-add-form  { display: flex; gap: .5rem; align-items: center; }
.inline-add-form input { flex: 1; max-width: 300px; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; outline: none; }
.inline-add-form input:focus { border-color: var(--brand); }
.inline-edit-form { display: flex; gap: .4rem; align-items: center; }
.inline-edit-form input { padding: .35rem .6rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .875rem; outline: none; width: 200px; }
.inline-edit-form input:focus { border-color: var(--brand); }

.person-link-form { align-items: flex-end; gap: .75rem; padding: .65rem; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; }
.person-link-fields { display: flex; flex-direction: column; gap: .4rem; flex: 1; min-width: 220px; }
.person-search-input,
.person-link-fields select {
  width: 100%;
  padding: .5rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  background: var(--white);
  outline: none;
}
.person-search-input:focus,
.person-link-fields select:focus { border-color: var(--brand); }
.person-link-fields select { min-height: 36px; }
.person-add-btn { min-width: 72px; }

/* ── Danger button ───────────────────────────────── */
.btn-danger       { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-muted        { color: var(--muted); border-color: var(--border); }

/* ── Detail card variants ────────────────────────── */
.desc-text          { color: var(--text); line-height: 1.7; white-space: pre-wrap; }
.detail-card-wide   { grid-column: span 2; }

/* ── Admin grid ──────────────────────────────────── */
.admin-grid      { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-top: .5rem; }
.admin-card      { display: flex; justify-content: space-between; align-items: center; background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem 1.5rem; text-decoration: none; color: var(--text); font-weight: 500; transition: border-color .15s, box-shadow .15s; }
.admin-card:hover{ border-color: var(--brand); box-shadow: 0 2px 8px rgba(30,64,175,.08); }
.admin-card-arrow{ color: var(--muted); }

/* ── Admin collapsible ─────────────────── */
.collapse-btn       { background:none;border:1px solid var(--border);cursor:pointer;padding:.2rem .5rem;color:var(--muted);font-size:.8rem;border-radius:var(--radius);transition:background .15s; }
.collapse-btn:hover { background:var(--bg); }
.jump-bar           { display:flex;flex-wrap:wrap;gap:.4rem;margin-bottom:1.25rem; }

/* ── Dashboard stat cards ────────────────────────── */
.stat-grid       { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card       { background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem 1.5rem; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--brand); line-height: 1; margin-bottom: .25rem; }
.stat-card .stat-label { font-size: .8125rem; color: var(--muted); }

/* ── Breadcrumbs ─────────────────────────────────── */
.breadcrumb-nav  { padding: .5rem 0 0; }
.breadcrumb-list { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem; font-size: .8125rem; color: var(--muted); padding: 0 0 .25rem; }
.breadcrumb-link { color: var(--brand); text-decoration: none; }
.breadcrumb-link:hover { text-decoration: underline; }
.breadcrumb-sep  { color: var(--border); }
.breadcrumb-current { color: var(--muted); }

/* ── Alert success ───────────────────────────────── */
.alert-success   { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; }

/* ── Enhanced empty state ────────────────────────── */
.empty-state-box { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty-state-box p { margin-bottom: 1rem; }

/* ── Version footer ──────────────────────────────── */
.app-footer {
  text-align: center;
  padding: .6rem 1.5rem;
  font-size: .72rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  background: var(--bg);
}

/* ── Report charts ───────────────────────────────── */
.reports-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
.reports-grid .detail-card { min-height: 320px; }
.reports-grid canvas { width: 100% !important; height: 240px !important; }

/* ── Notification center ─────────────────────────── */
.notif-wrap { position: relative; }
.notif-btn {
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.15);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.notif-count {
  position: absolute;
  right: -4px;
  top: -5px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: .65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.notif-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 360px;
  max-width: 90vw;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .18);
  z-index: 1200;
  overflow: hidden;
}
.notif-dropdown.open { display: block; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: .65rem .75rem; border-bottom: 1px solid var(--border); }
.notif-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: .55rem;
  text-decoration: none;
  color: var(--text);
  padding: .7rem .75rem;
  border-bottom: 1px solid #f1f5f9;
}
.notif-item:last-child { border-bottom: none; }
.notif-item.notif-unread { background: #eff6ff; }
.notif-item small { color: var(--muted); font-size: .75rem; }
.notif-msg { display: block; font-size: .85rem; }

/* ── Case tabs ──────────────────────────────────── */
.case-tabs { display: flex; flex-wrap: wrap; gap: .45rem; margin: 1rem 0 1.1rem; }
.case-tab {
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text);
  border-radius: var(--radius);
  padding: .42rem .72rem;
  font-size: .83rem;
  cursor: pointer;
}
.case-tab.active { background: var(--brand); border-color: var(--brand); color: var(--white); }

.progress-shell { height: 12px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.progress-fill { height: 100%; background: var(--brand); }

.history-timeline { border-left: 3px solid #dbeafe; padding-left: .85rem; }
.history-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: .65rem;
  align-items: start;
  padding: .65rem .2rem;
  border-bottom: 1px solid #eef2f7;
}
.history-item:last-child { border-bottom: none; }
.history-item p { margin-top: .15rem; color: var(--muted); font-size: .85rem; }
.history-item small { color: var(--muted); white-space: nowrap; font-size: .75rem; }

/* ── Modal ──────────────────────────────────────── */
.app-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.app-modal-card {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--white);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 1.1rem 1.2rem;
}
.app-modal-card h3 { margin-bottom: .7rem; }
.app-modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .8rem; }

/* ── Icon color helpers ──────────────────────────── */
.text-primary { color: #2563eb; }
.text-success { color: #16a34a; }
.text-warning { color: #d97706; }
.text-danger { color: #dc2626; }
.text-secondary { color: #64748b; }

/* ── Responsive adjustments ──────────────────────── */
@media (max-width: 900px) {
  .reports-grid { grid-template-columns: 1fr; }
  .nav-inner { padding: 0 .75rem; }
  .nav-links { display: none; }
  .nav-user { display: none; }
  .person-link-form { flex-direction: column; align-items: stretch; }
  .person-add-btn { width: 100%; }
}

/* ── Report wizard ──────────────────────────────── */
.wizard-page-header {
  align-items: flex-start;
  justify-content: space-between;
}

.wizard-page-subtitle {
  color: var(--muted);
  margin-top: .35rem;
}

.report-wizard-form {
  overflow: visible;
}

.report-wizard-shell {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1rem;
  padding: 1rem;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

.report-wizard-sidebar {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  padding: 1rem;
  align-self: start;
  position: sticky;
  top: .75rem;
}

.wizard-nav-title {
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: .75rem;
}

.wizard-step-list {
  list-style: none;
  display: grid;
  gap: .35rem;
  margin-bottom: 1rem;
}

.wizard-step-button {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: .65rem;
  align-items: center;
  text-align: left;
  padding: .5rem .6rem;
  font-size: .84rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.wizard-step-button:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

.wizard-step-button.is-active {
  border-color: var(--brand);
  background: #dbeafe;
}

.wizard-step-button.is-complete {
  border-color: #bfdbfe;
  background: #f0f9ff;
}

.wizard-step-index {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 600;
  color: #334155;
  background: #fff;
}

.wizard-step-button.is-active .wizard-step-index,
.wizard-step-button.is-complete .wizard-step-index {
  border-color: var(--brand);
  color: var(--brand);
}

.wizard-step-label {
  font-weight: 500;
  line-height: 1.35;
}

.wizard-summary-card {
  border-top: 1px solid var(--border);
  padding-top: .85rem;
}

.wizard-summary-card h4 {
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: .65rem;
}

.wizard-summary-list {
  grid-template-columns: max-content 1fr;
  gap: .3rem .55rem;
  font-size: .84rem;
}

.wizard-summary-list dt {
  color: #64748b;
}

.wizard-summary-list dd {
  color: #0f172a;
}

.report-wizard-main {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  padding: 1rem 1.15rem;
}

.wizard-step-error {
  margin-bottom: 1rem;
}

.wizard-step-panel {
  display: none;
}

.wizard-step-panel.is-active {
  display: block;
}

.wizard-step-panel h3 {
  font-size: 1.05rem;
  margin-bottom: .35rem;
}

.wizard-step-help {
  color: var(--muted);
  margin-bottom: 1rem;
  max-width: 70ch;
}

.wizard-dual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: .85rem;
}

.wizard-compact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: .75rem;
}

.wizard-multi-select {
  width: 100%;
  min-height: 220px;
}

.wizard-field-help {
  color: var(--muted);
  font-size: .76rem;
  margin-top: .3rem;
  display: block;
}

.wizard-subsection {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .85rem .9rem;
  background: #fbfdff;
  margin-bottom: .9rem;
}

.wizard-subsection h4 {
  font-size: .9rem;
  margin-bottom: .2rem;
}

.wizard-sub-help {
  color: var(--muted);
  font-size: .82rem;
  margin-bottom: .6rem;
}

.builder-row-list {
  display: grid;
  gap: .5rem;
  margin-bottom: .7rem;
}

.builder-row {
  display: grid;
  gap: .5rem;
  align-items: end;
}

.builder-row-filter {
  grid-template-columns: 1.5fr 1.2fr 1.6fr .9fr .9fr auto;
}

.builder-row-filter-header {
  display: grid;
  grid-template-columns: 1.5fr 1.2fr 1.6fr auto;
  gap: .5rem;
  padding: 0 0 .2rem;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

.builder-row-metric {
  grid-template-columns: 1fr 1fr 1.15fr auto;
}

.builder-row-formula {
  grid-template-columns: .95fr 2fr auto;
}

.wizard-count-badge {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  font-size: .72rem;
  font-weight: 600;
  border-radius: 10px;
  padding: .05rem .45rem;
  margin-left: .3rem;
  vertical-align: middle;
}

.wizard-field-help-top {
  display: block;
  margin-bottom: .35rem;
}

.wizard-disclosure-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.formula-token-tray {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .65rem;
}

.formula-token-btn {
  padding: .2rem .5rem;
  font-size: .78rem;
}

.token-empty-hint {
  color: var(--muted);
  font-size: .78rem;
}

.wizard-roles-title {
  display: block;
  font-size: .8125rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: .45rem;
}

.wizard-role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .45rem;
}

.wizard-role-option,
.wizard-check-option {
  display: flex;
  align-items: center;
  gap: .45rem;
}

.wizard-publish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .65rem;
}

.wizard-mode-toggle {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
  margin-bottom: .7rem;
}

.json-editor-panel {
  margin-top: .6rem;
}

.wizard-code-area {
  width: 100%;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: .84rem;
}

.is-hidden {
  display: none !important;
}

.is-hidden-textarea {
  display: none;
}

.wizard-action-bar {
  border-top: 1px solid var(--border);
  background: #f8fafc;
  padding: .9rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.wizard-action-right {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
}

/* ── Report run page ────────────────────────────── */
.report-run-header {
  justify-content: space-between;
  align-items: flex-start;
}

.report-run-subtitle {
  margin-top: .35rem;
  color: var(--muted);
}

.report-run-actions {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.report-run-overview,
.report-run-pagination,
.report-run-chart-card,
.report-run-table-card {
  margin-bottom: 1rem;
}

.report-run-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .75rem;
}

.report-run-stat {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
  padding: .7rem .8rem;
  display: grid;
  gap: .3rem;
}

.report-run-stat span {
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.report-run-stat strong {
  font-size: .92rem;
  color: var(--text);
  line-height: 1.35;
  word-break: break-word;
}

.report-run-pagination-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
}

.report-run-page-size-form label {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin: 0;
}

.report-run-page-size-form span {
  font-weight: 600;
}

.report-run-page-size-form select {
  max-width: 130px;
}

.report-run-page-nav {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.report-run-page-text {
  color: var(--muted);
}

.report-run-section-head {
  margin-bottom: .75rem;
}

.report-run-section-head p {
  margin-top: .2rem;
  color: var(--muted);
}

.report-run-chart-wrap {
  height: 280px;
}

.report-run-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

@media (max-width: 1120px) {
  .report-wizard-shell {
    grid-template-columns: 1fr;
  }

  .report-wizard-sidebar {
    position: static;
  }

  .wizard-dual-grid {
    grid-template-columns: 1fr;
  }

  .report-run-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 860px) {
  .builder-row-filter,
  .builder-row-metric,
  .builder-row-formula {
    grid-template-columns: 1fr;
  }

  .wizard-action-bar {
    align-items: stretch;
  }

  .wizard-action-right,
  .wizard-action-left {
    width: 100%;
  }

  .wizard-action-right .btn,
  .wizard-action-left .btn {
    width: 100%;
  }

  .report-run-page-size-form,
  .report-run-page-size-form label,
  .report-run-page-nav {
    width: 100%;
  }

  .report-run-page-nav .btn {
    flex: 1;
    min-width: 120px;
    justify-content: center;
  }
}
