:root {
  --bg: #f5f8fb;
  --surface: #ffffff;
  --ink: #071f3d;
  --muted: #647287;
  --line: #d8e2ec;
  --navy: #061d39;
  --navy-2: #0b2a4f;
  --blue: #0a4b78;
  --teal: #00a99d;
  --teal-dark: #007f7a;
  --green: #15803d;
  --amber: #b45309;
  --red: #dc2626;
  --shadow: 0 18px 42px rgba(7, 31, 61, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  min-width: 320px;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(0,169,157,.06), transparent 260px),
    var(--bg);
  font-family: "Segoe UI", Arial, sans-serif;
  overflow-x: hidden;
}
a { color: var(--teal-dark); text-decoration: none; }
img, svg { max-width: 100%; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 78px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, .94);
  color: var(--ink);
  border-bottom: 1px solid rgba(216, 226, 236, .9);
  box-shadow: 0 10px 30px rgba(7, 31, 61, .05);
}
.brand { display: flex; gap: 14px; align-items: center; color: var(--ink); min-width: 0; }
.brand-mark { width: 48px; height: 48px; border-radius: 13px; flex: 0 0 auto; }
.brand-text { min-width: 0; }
.brand strong { display: block; font-size: 23px; letter-spacing: 0; }
.brand strong span,
.auth-brand h1 span { color: var(--teal-dark); }
.brand small { display: block; color: var(--muted); white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.menu-toggle,
.sidebar-backdrop {
  display: none;
}
.menu-toggle {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  place-items: center;
}
.menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  margin: 3px 0;
  border-radius: 999px;
  background: currentColor;
}
.global-search input {
  width: 220px;
  min-height: 38px;
  padding: 7px 10px;
}
.language-form { margin: 0; }
.language-select {
  min-height: 38px;
  max-width: 170px;
  padding: 7px 34px 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  font-weight: 750;
}
.lang, .user-pill {
  padding: 7px 11px;
  border-radius: 999px;
  background: #eef7f6;
  color: var(--navy);
  font-size: 13px;
  font-weight: 700;
}
.lang.active { background: var(--teal); color: #fff; }

.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 78px); }
.public-content { grid-column: 1 / -1; max-width: 1180px; width: min(1180px, calc(100% - 32px)); margin: 34px auto; }
.public-portal {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(0,169,157,.08), transparent 300px),
    var(--bg);
}
.public-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 82px;
  padding: 16px clamp(18px, 4vw, 54px);
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(7, 31, 61, .04);
}
.public-portal-content {
  width: min(980px, calc(100% - 32px));
  margin: 34px auto 64px;
}
.public-portal .page-heading {
  text-align: left;
}
.public-portal .wizard-form,
.public-portal .stepper {
  max-width: 980px;
}
.agent-register-card {
  max-width: 920px;
  margin: 0 auto;
}
.public-form-shell {
  display: grid;
  gap: 22px;
}
.public-form-intro {
  max-width: 840px;
}
.public-form-intro h1 {
  margin: 12px 0 10px;
  font-size: 40px;
  line-height: 1.05;
}
.public-form-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}
.agent-register-card {
  display: grid;
  gap: 22px;
  padding: 32px;
}
.form-section-title {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.form-section-title:first-of-type {
  padding-top: 0;
  border-top: 0;
}
.form-section-title h2 {
  margin: 0 0 6px;
  font-size: 20px;
}
.form-section-title p {
  margin: 0;
  color: var(--muted);
}
.public-submit {
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.public-submit .button {
  min-width: 210px;
}
.sidebar {
  position: sticky;
  top: 78px;
  align-self: start;
  height: calc(100vh - 78px);
  padding: 22px 14px;
  background: linear-gradient(180deg, var(--navy), var(--navy-2));
  overflow-y: auto;
}
.sidebar a {
  display: block;
  padding: 11px 13px;
  margin-bottom: 6px;
  border-radius: 8px;
  color: #dce9f7;
  font-size: 14px;
  line-height: 1.25;
  font-weight: 700;
}
.sidebar a:hover { background: rgba(0,169,157,.18); color: #fff; }
.content { min-width: 0; padding: 30px; overflow-x: clip; }

.page-heading { margin-bottom: 22px; }
.compact-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.page-heading .button { margin-top: 12px; }
.page-heading h1, .auth-panel h1 { margin: 0 0 8px; font-size: 34px; line-height: 1.1; }
.page-heading p, .auth-panel p, .muted { color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card h2 { margin: 0 0 16px; font-size: 22px; }

.auth-panel { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 42px; align-items: center; max-width: 1040px; margin: 70px auto; }
.activation-panel { grid-template-columns: minmax(0, 1fr) minmax(420px, 560px); }
.auth-brand {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 44px 20px;
}
.auth-logo-lockup {
  width: 100%;
  max-width: 560px;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  margin-bottom: 26px;
  padding: 18px 20px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: visible;
}
.auth-logo-mark {
  width: 88px;
  height: 88px;
  border-radius: 16px;
  object-fit: contain;
  background: #02090f;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.auth-logo-lockup strong {
  display: block;
  color: var(--navy);
  font-size: 46px;
  line-height: 1.02;
  white-space: normal;
  overflow-wrap: normal;
}
.auth-logo-lockup strong span { color: var(--teal-dark); }
.auth-logo-lockup small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.3;
}
.auth-brand p { max-width: 560px; font-size: 18px; line-height: 1.55; }
.form-card { display: grid; gap: 16px; }
.password-activation-form { gap: 20px; }
.password-rules {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}
.password-rules div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  background: #fff;
}
.password-rules strong {
  min-width: 0;
  flex: 1;
  font-size: 14px;
}
.password-rules span {
  order: 2;
  min-width: 62px;
  text-align: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.password-rules .done span { background: #eaf7ef; color: var(--green); }
.password-rules .todo span { background: #fff5db; color: var(--amber); }
.form-card p { margin: 0; }
label span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
.form-control, .form-select, input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfdff;
  font: inherit;
}
.form-control:focus, .form-select:focus, input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(0, 169, 157, .18);
  border-color: var(--teal);
  background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; }
.span-2 { grid-column: 1 / -1; }
.form-grid h2 { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.filter-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.filters .button { min-width: 0; }
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.bulk-actions {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(160px, 240px) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}
.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 650;
}
.checkbox-grid input { width: auto; min-height: auto; }
.check-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
}
.check-inline span { margin: 0; }
.check-inline input { width: auto; min-height: auto; }
.inline-form { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: end; }
.inline-form p { margin: 0; }
.stacked-form p { margin: 0 0 12px; }

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
  text-align: center;
  line-height: 1.15;
  white-space: normal;
}
.button.primary { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.button.primary:hover { background: var(--navy); border-color: var(--navy); }
.button.ghost { background: #f8fafc; color: var(--navy); }
.button.danger { background: #fff1f1; border-color: #fecaca; color: var(--red); }
.button.mini { min-height: 32px; padding: 0 10px; font-size: 12px; }
.notice { padding: 14px 16px; border-radius: 10px; background: #fff7ed; color: var(--amber); font-weight: 700; }

.metrics { display: grid; grid-template-columns: repeat(6, minmax(140px, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric {
  padding: 18px;
  border: 1px solid rgba(37, 99, 235, .35);
  border-radius: 8px;
  background: #eaf1ff;
  min-width: 0;
}
.metric strong { display: block; font-size: 24px; color: var(--blue); line-height: 1.05; overflow-wrap: anywhere; }
.metric span { color: var(--ink); font-size: 13px; font-weight: 700; }
.metric.teal { background: #e8f6f3; border-color: rgba(15,118,110,.35); }
.metric.teal strong { color: var(--teal); }
.metric.green { background: #eaf7ef; border-color: rgba(21,128,61,.35); }
.metric.green strong { color: var(--green); }
.metric.amber { background: #fff5db; border-color: rgba(180,83,9,.35); }
.metric.amber strong { color: var(--amber); }
.metric.red { background: #fff1f1; border-color: rgba(220,38,38,.35); }
.metric.red strong { color: var(--red); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 22px; }
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
  align-items: start;
}
.dashboard-main,
.dashboard-side {
  display: grid;
  gap: 18px;
}
.dashboard-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, .7fr);
  gap: 18px;
}
.procedure-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.panel-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.resource-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.resource-grid.single-column { grid-template-columns: 1fr; }
.resource-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(7, 31, 61, .05);
}
.resource-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
  gap: 16px;
}
.resource-card h2 {
  margin: 8px 0 6px;
  font-size: 20px;
}
.resource-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}
.resource-note {
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
}
.resource-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.empty-state {
  grid-column: 1 / -1;
}
.section-gap {
  margin-top: 18px;
}
.case-create-form {
  display: grid;
  gap: 22px;
}
.comfortable-table th,
.comfortable-table td {
  padding-top: 14px;
  padding-bottom: 14px;
}
.audit-timeline {
  max-height: 620px;
  overflow: auto;
}
.procedure-form-card {
  position: sticky;
  top: 96px;
  padding: 20px;
}
.procedure-form {
  display: grid;
  gap: 14px;
}
.procedure-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.procedure-list {
  display: grid;
  gap: 12px;
}
.procedure-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(7, 31, 61, .05);
}
.procedure-card-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
  gap: 16px;
}
.procedure-card h2 {
  margin: 8px 0 6px;
  font-size: 20px;
}
.procedure-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}
.procedure-card dl {
  grid-template-columns: 70px minmax(0, 1fr);
  align-content: start;
}
.procedure-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.procedure-actions form { margin: 0; }
.muted-status {
  background: #eef2f7;
  color: var(--muted);
}
.compact-card { padding: 18px; }
.compact-card h2 { font-size: 17px; margin-bottom: 12px; }
.settings-layout {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
}
.settings-preview {
  display: grid;
  gap: 16px;
}
.brand-preview {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}
.brand-preview strong,
.brand-preview span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}
.brand-preview strong {
  font-size: 18px;
}
.brand-preview span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}
.swatches {
  display: flex;
  gap: 10px;
}
.swatches span {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.quick-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: 100%;
}
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 22px; }
.copy-link { padding: 14px; border-radius: 10px; background: #eaf1ff; color: var(--blue); font-family: Consolas, monospace; overflow-wrap: anywhere; }
.copy-link.slim { padding: 10px; max-height: 76px; overflow: auto; font-size: 12px; }
.copy-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 16px;
}
.copy-line .copy-link {
  margin: 0;
}
.compact-copy-line {
  grid-template-columns: 1fr;
}
.qr-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 16px;
}
.table-wrap,
.compact-list,
.bar-list,
.copy-link {
  min-width: 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f8fafc; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.status { display: inline-block; padding: 5px 9px; border-radius: 999px; background: #e8f7f5; color: var(--teal-dark); font-weight: 750; font-size: 12px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }

dl { display: grid; grid-template-columns: minmax(96px, 130px) minmax(0, 1fr); gap: 10px; margin: 0; }
dt { color: var(--muted); }
dd { min-width: 0; margin: 0; font-weight: 700; overflow-wrap: anywhere; word-break: break-word; }
.doc-list { display: grid; gap: 10px; margin-bottom: 18px; }
.stepper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  margin: 0 0 18px;
  list-style: none;
}
.stepper li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.stepper li.active {
  border-color: var(--teal-dark);
  box-shadow: 0 0 0 3px rgba(0,169,157,.12);
}
.stepper strong {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--teal-dark);
  color: #fff;
}
.qr-code {
  width: 172px;
  height: 172px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.swatches { display: flex; gap: 10px; margin-top: 18px; }
.swatches span {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.wizard-step h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}
.wizard-step h2::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--teal-dark);
}
.bar-list { display: grid; gap: 11px; }
.bar-list div {
  display: grid;
  grid-template-columns: minmax(96px, 150px) 1fr auto;
  align-items: center;
  gap: 10px;
}
.bar-list strong {
  display: block;
  min-width: 4px;
  height: 10px;
  border-radius: 999px;
  background: var(--teal-dark);
}
.bar-list em { color: var(--muted); font-style: normal; font-weight: 700; }
.progress {
  height: 12px;
  border-radius: 999px;
  background: #e8eef5;
  overflow: hidden;
}
.progress span { display: block; height: 100%; background: var(--teal-dark); }
.check-list { display: grid; gap: 8px; margin-top: 12px; }
.check-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}
.check-list .done { color: var(--green); font-weight: 800; }
.check-list .todo { color: var(--amber); font-weight: 800; }
.wizard-form { display: grid; gap: 18px; }
.wizard-step { display: none; }
.wizard-step.active { display: grid; }
.wizard-actions { justify-content: space-between; border-top: 1px solid var(--line); padding-top: 16px; }
.doc-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}
.doc-row[data-status="MISSING"] { border-color: #f59e0b; background: #fffaf0; }
.doc-row[data-status="RECEIVED"] { border-color: #86efac; background: #f0fdf4; }
.doc-row span { min-width: 0; overflow-wrap: anywhere; }
.doc-row small { display: block; margin-top: 4px; color: var(--muted); font-weight: 600; }
.compact-upload {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.stacked-form h3 {
  margin: 0 0 12px;
  color: var(--navy);
  font-size: 16px;
}
.timeline { display: grid; gap: 14px; }
.timeline div { padding-left: 14px; border-left: 3px solid var(--blue); }
.timeline strong, .timeline small { display: block; color: var(--muted); }
.compact-list { display: grid; gap: 12px; margin-bottom: 16px; }
.compact-list div { display: flex; justify-content: space-between; gap: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.compact-list-tight { gap: 8px; margin-bottom: 0; }
.compact-list-tight div { padding: 9px 10px; border-radius: 8px; }
.compact-list-tight strong,
.compact-list-tight span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.compact-list-scroll {
  max-height: 244px;
  overflow: auto;
  padding-right: 4px;
}
.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-heading h2 { margin: 0; }
.latest-actions div {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) auto;
  align-items: center;
}
.latest-actions strong,
.latest-actions span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.latest-actions small {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.action-card { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.success-panel { max-width: 860px; }

.messages { display: grid; gap: 10px; margin-bottom: 18px; }
.message { padding: 12px 14px; border-radius: 10px; background: #eef6ff; color: var(--blue); font-weight: 700; }
.message.success { background: #eaf7ef; color: var(--green); }
.message.warning { background: #fff5db; color: var(--amber); }
.success-page { max-width: 760px; margin: 60px auto; text-align: center; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 74px;
    z-index: 20;
    display: flex;
    height: auto;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    padding: 10px 12px;
    background: var(--navy);
    scrollbar-width: thin;
  }
  .sidebar a {
    flex: 0 0 auto;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    margin: 0;
  }
  .auth-panel, .split, .detail-grid, .form-grid, .metrics, .dashboard-grid, .dashboard-row, .procedure-layout, .procedure-card, .procedure-card-main, .panel-layout, .resource-grid, .resource-main, .filter-grid { grid-template-columns: 1fr; }
  .procedure-form-card { position: static; }
  .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .bulk-actions {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .span-2 { grid-column: auto; }
  .content { padding: 18px; }
  .topbar {
    flex-wrap: wrap;
    min-height: 74px;
    padding: 12px 18px;
  }
  .top-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .global-search { flex: 1 1 240px; }
  .global-search input { width: 100%; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .public-portal-content { width: min(100% - 24px, 980px); margin-top: 22px; }
  .agent-register-card,
  .wizard-form { padding: 22px; }
  .copy-line { grid-template-columns: 1fr; }
  .copy-line .button { width: 100%; }
  .filter-actions { justify-content: stretch; }
  .filter-actions .button { flex: 1; }
  .auth-panel {
    max-width: 720px;
    margin: 28px auto;
    gap: 18px;
  }
  .auth-brand {
    min-height: auto;
    padding: 18px 0 0;
  }
}

@media (max-width: 640px) {
  body.nav-open {
    overflow: hidden;
  }
  .menu-toggle {
    display: grid;
    order: 0;
  }
  .brand {
    flex: 1 1 calc(100% - 60px);
    order: 1;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    display: block;
    width: min(82vw, 320px);
    height: 100dvh;
    padding: 22px 14px;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--navy), var(--navy-2));
    box-shadow: 24px 0 60px rgba(7, 31, 61, .28);
    transform: translateX(-105%);
    transition: transform .22s ease;
  }
  .sidebar a {
    display: block;
    min-height: 44px;
    padding: 13px 12px;
    margin-bottom: 6px;
    text-align: left;
    white-space: normal;
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    width: 100%;
    min-height: 100dvh;
    border: 0;
    background: rgba(2, 16, 31, .52);
    cursor: pointer;
  }
  body.nav-open .sidebar {
    transform: translateX(0);
  }
  body.nav-open .sidebar-backdrop {
    display: block;
  }
  .topbar {
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
  }
  .public-topbar {
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
    padding: 12px;
  }
  .brand-mark { width: 42px; height: 42px; }
  .brand small { white-space: normal; }
  .brand strong { font-size: 20px; }
  .top-actions {
    order: 2;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: stretch;
    gap: 8px;
  }
  .top-actions .global-search,
  .top-actions .user-pill {
    grid-column: 1 / -1;
  }
  .language-select { max-width: none; width: 100%; min-height: 44px; }
  .language-form { min-width: 0; }
  .doc-row { grid-template-columns: 1fr; align-items: start; }
  dl { grid-template-columns: 1fr; gap: 4px; }
  .auth-panel {
    width: min(100%, calc(100vw - 24px));
    margin: 18px auto 28px;
  }
  .auth-brand h1 { font-size: 30px; }
  .auth-logo-lockup { grid-template-columns: 56px minmax(0, 1fr); gap: 12px; padding: 12px; }
  .auth-logo-mark { width: 56px; height: 56px; }
  .auth-logo-lockup strong { font-size: 28px; white-space: normal; }
  .filters { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: 1fr; }
  .stepper li {
    min-height: 52px;
    align-items: flex-start;
  }
  .bar-list div { grid-template-columns: 1fr; }
  .content { padding: 12px; }
  .public-content { width: min(100%, calc(100vw - 24px)); margin: 18px auto; }
  .card { padding: 16px; box-shadow: 0 10px 24px rgba(7, 31, 61, .06); }
  .metrics { grid-template-columns: 1fr; }
  .metric strong { font-size: 22px; }
  .page-heading h1, .auth-panel h1, .public-form-intro h1 { font-size: 30px; }
  .public-form-intro p { font-size: 16px; }
  .form-actions, .wizard-actions, .public-submit { flex-direction: column; align-items: stretch; }
  .form-actions .button, .wizard-actions .button, .public-submit .button { width: 100%; }
  .procedure-actions { flex-direction: column; }
  .procedure-actions .button, .procedure-actions form { width: 100%; }
  .qr-panel { align-items: stretch; }
  .qr-code { width: min(100%, 220px); height: auto; }
  .compact-heading,
  .card-heading {
    align-items: stretch;
    flex-direction: column;
  }
  .row-actions,
  .resource-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .row-actions .button,
  .resource-actions .button {
    width: 100%;
  }
  .compact-list div,
  .check-list div {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .latest-actions div {
    grid-template-columns: 1fr;
  }
  .latest-actions small,
  .latest-actions strong,
  .latest-actions span,
  .compact-list-tight strong,
  .compact-list-tight span {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .checkbox-grid,
  .procedure-form-grid {
    grid-template-columns: 1fr;
  }
  .inline-form {
    grid-template-columns: 1fr;
  }
  .copy-link {
    font-size: 13px;
  }
  .success-page {
    margin: 24px auto;
    text-align: left;
  }
  .success-page .button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  table.responsive-table,
  .table-wrap table {
    min-width: 0;
  }
  .table-wrap table thead {
    display: none;
  }
  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
  }
  .table-wrap tr {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(7,31,61,.04);
  }
  .table-wrap tr + tr {
    margin-top: 12px;
  }
  .table-wrap td {
    display: grid;
    grid-template-columns: minmax(92px, 38%) minmax(0, 1fr);
    gap: 10px;
    min-height: 36px;
    padding: 8px 0;
    border-bottom: 1px solid #edf2f7;
    text-align: right;
    overflow-wrap: anywhere;
  }
  .table-wrap td:last-child {
    border-bottom: 0;
  }
  .table-wrap td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-align: left;
    text-transform: uppercase;
  }
  .table-wrap td[colspan] {
    display: block;
    text-align: left;
  }
  .table-wrap td[colspan]::before {
    display: none;
  }
}

@media (max-width: 380px) {
  .sidebar {
    width: min(88vw, 300px);
  }
}
