:root {
  color-scheme: light;
  --navy-950: #06253a;
  --navy-900: #063451;
  --navy-800: #124b6c;
  --navy-700: #1b5b7d;
  --brand-500: #00a5d9;
  --brand-700: #00749c;
  /* Legacy semantic names retained for compatibility with existing views. */
  --teal-700: var(--brand-700);
  --teal-600: #006b91;
  --teal-500: var(--brand-500);
  --teal-300: #7dd4f0;
  --teal-100: #d9f3fc;
  --teal-50: #f0faff;
  --slate-900: #172033;
  --slate-700: #344256;
  --slate-600: #526174;
  --slate-500: #6b788a;
  --slate-300: #cbd5df;
  --slate-200: #e1e7ed;
  --slate-100: #edf2f6;
  --slate-50: #f7f9fb;
  --white: #ffffff;
  --danger-700: #b42318;
  --danger-100: #fee4e2;
  --danger-50: #fff5f4;
  --warning-700: #a15c07;
  --warning-100: #fef0c7;
  --warning-50: #fffaeb;
  --success-700: #067647;
  --success-100: #d1fadf;
  --success-50: #ecfdf3;
  --info-700: #175cd3;
  --info-100: #dbeafe;
  --info-50: #eff6ff;
  --surface: var(--white);
  --surface-muted: var(--slate-50);
  --page: #f3f6f8;
  --border: var(--slate-200);
  --text: var(--slate-900);
  --text-muted: var(--slate-600);
  --focus: #00749c;
  --sidebar-width: 268px;
  --topbar-height: 68px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgb(7 24 39 / 0.05), 0 1px 4px rgb(7 24 39 / 0.04);
  --shadow: 0 12px 30px rgb(7 24 39 / 0.08);
  --transition: 160ms ease;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

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

html {
  min-width: 320px;
  background: var(--page);
  scroll-behavior: smooth;
}

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

body.menu-open {
  overflow: hidden;
}

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

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

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--teal-700);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--teal-600);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--navy-950);
  line-height: 1.2;
}

.hidden,
[hidden] {
  display: none !important;
}

.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;
}

.skip-link {
  position: fixed;
  z-index: 2000;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--navy-950);
  box-shadow: var(--shadow);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

.sidebar {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid rgb(255 255 255 / 0.09);
  background:
    radial-gradient(circle at 20% 0%, rgb(0 165 217 / 0.2), transparent 32%),
    linear-gradient(180deg, var(--navy-950), var(--navy-900));
  color: rgb(255 255 255 / 0.82);
}

.sidebar-header {
  padding: max(22px, env(safe-area-inset-top)) 20px 18px;
  border-bottom: 1px solid rgb(255 255 255 / 0.09);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--white);
  text-decoration: none;
}

.brand-corporate {
  align-items: stretch;
  flex-direction: column;
  gap: 12px;
}

.brand-logo-wrap {
  display: block;
  padding: 12px;
  border-radius: 12px;
  background: var(--white);
}

.brand-logo {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.brand-corporate .brand-title {
  font-size: 14px;
  letter-spacing: 0.04em;
}

.sidebar-close {
  display: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  color: var(--white);
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 8px 22px rgb(0 165 217 / 0.28);
}

.brand-copy {
  min-width: 0;
}

.brand-title {
  display: block;
  overflow: hidden;
  color: var(--white);
  font-size: 15px;
  font-weight: 750;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-subtitle {
  display: block;
  margin-top: 1px;
  color: rgb(255 255 255 / 0.78);
  font-size: 12px;
}

.sidebar-nav {
  display: grid;
  gap: 5px;
  padding: 18px 12px;
}

.nav-label {
  margin: 14px 10px 5px;
  color: rgb(255 255 255 / 0.68);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: rgb(255 255 255 / 0.72);
  font-weight: 650;
  text-decoration: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}

.nav-link svg,
.nav-link .nav-icon {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  opacity: 0.9;
}

.nav-link:hover {
  border-color: rgb(255 255 255 / 0.08);
  background: rgb(255 255 255 / 0.07);
  color: var(--white);
}

.nav-link.active,
.nav-link[aria-current="page"] {
  border-color: rgb(0 165 217 / 0.35);
  background: rgb(0 165 217 / 0.2);
  color: var(--white);
  box-shadow: inset 3px 0 var(--teal-500);
}

.nav-count {
  min-width: 24px;
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 99px;
  background: rgb(255 255 255 / 0.11);
  color: inherit;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px max(20px, env(safe-area-inset-bottom));
  border-top: 1px solid rgb(255 255 255 / 0.09);
  color: rgb(255 255 255 / 0.76);
  font-size: 12px;
}

.app-main {
  display: flex;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
}

.topbar {
  position: sticky;
  z-index: 40;
  top: 0;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 11px clamp(18px, 3vw, 36px);
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 0.92);
  box-shadow: 0 1px 0 rgb(7 24 39 / 0.02);
  backdrop-filter: blur(14px);
}

.topbar-title {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
}

.topbar-actions,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.reminder-sound-toggle {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--white);
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition), transform var(--transition);
}

.reminder-sound-toggle:hover,
.reminder-sound-toggle.is-active {
  border-color: var(--teal-300);
  background: var(--teal-50);
  color: var(--teal-700);
}

.reminder-sound-toggle.needs-attention {
  border-color: #f2b84b;
  background: var(--warning-50);
  color: var(--warning-700);
  animation: reminder-pulse 1.6s ease-in-out infinite;
}

.reminder-permission-banner:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px clamp(18px, 3vw, 36px);
  border-bottom: 1px solid #f2b84b;
  background: var(--warning-50);
  color: var(--warning-700);
  font-size: 13px;
}

.reminder-permission-banner strong {
  color: var(--navy-900);
}

.reminder-permission-banner .button {
  flex: 0 0 auto;
}

.reminder-permission-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--teal-100);
  color: var(--teal-700);
  font-size: 13px;
  font-weight: 800;
}

.user-name {
  display: block;
  font-size: 13px;
  font-weight: 750;
}

.user-role {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
}

.mobile-menu {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  color: var(--navy-900);
  cursor: pointer;
}

.mobile-menu:hover {
  background: var(--slate-50);
}

.sidebar-overlay {
  position: fixed;
  z-index: 45;
  inset: 0;
  display: none;
  border: 0;
  background: rgb(7 24 39 / 0.54);
  backdrop-filter: blur(2px);
}

.content {
  width: 100%;
  max-width: 1580px;
  flex: 1;
  margin: 0 auto;
  padding: clamp(22px, 3vw, 38px);
}

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

.page-header > div:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.page-header h1 {
  margin-bottom: 7px;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: -0.035em;
}

.page-header p,
.page-description {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--text-muted);
}

.page-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

/* Surfaces, grids and metrics */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card-header,
.card-body,
.card-footer {
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.card-header h2,
.card-header h3 {
  margin: 0;
  font-size: 16px;
}

.card-header p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.card-footer {
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
}

.section-stack {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
}

.grid-2,
.grid-3,
.kpi-grid {
  display: grid;
  gap: 18px;
}

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

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

.kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 22px;
}

.kpi {
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: 19px 20px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.kpi::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--kpi-accent, var(--teal-600));
  content: "";
}

.kpi--navy,
.kpi.navy {
  --kpi-accent: var(--navy-700);
}

.kpi--teal,
.kpi.teal {
  --kpi-accent: var(--teal-600);
}

.kpi--warning,
.kpi.warning {
  --kpi-accent: #e5a21a;
}

.kpi--danger,
.kpi.danger {
  --kpi-accent: #d92d20;
}

.kpi-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.kpi-value {
  display: block;
  overflow: hidden;
  margin-top: 9px;
  color: var(--navy-950);
  font-size: clamp(25px, 3vw, 34px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.045em;
  line-height: 1.08;
  text-overflow: ellipsis;
}

.kpi-detail {
  display: block;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 13px 15px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  position: sticky;
  z-index: 1;
  top: 0;
  background: var(--slate-50);
  color: var(--slate-600);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

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

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: var(--teal-50);
}

.data-table .cell-primary {
  color: var(--navy-950);
  font-weight: 700;
}

.data-table .cell-muted {
  color: var(--text-muted);
}

.data-table .numeric {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  white-space: nowrap;
}

/* Badges */
.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--slate-100);
  color: var(--slate-700);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
}

.badge::before {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  opacity: 0.72;
}

.badge--pending,
.badge--pendiente,
.badge.stage-pendiente,
.badge[data-stage="pendiente"] {
  border-color: #f7d89b;
  background: var(--warning-50);
  color: var(--warning-700);
}

.badge--followup,
.badge--seguimiento,
.badge.stage-seguimiento,
.badge[data-stage="seguimiento"] {
  border-color: #a6e8df;
  background: var(--teal-50);
  color: var(--teal-700);
}

.badge--won,
.badge--ganada,
.badge--done,
.badge.stage-ganada,
.badge.status-done,
.badge[data-stage="ganada"],
.badge[data-status="done"] {
  border-color: #a9eac3;
  background: var(--success-50);
  color: var(--success-700);
}

.badge--lost,
.badge--perdida,
.badge--overdue,
.badge.stage-perdida,
.badge.status-overdue,
.badge[data-stage="perdida"],
.badge[data-status="overdue"] {
  border-color: #f7b4af;
  background: var(--danger-50);
  color: var(--danger-700);
}

.badge--open,
.badge.status-open,
.badge[data-status="open"] {
  border-color: #b9d3fc;
  background: var(--info-50);
  color: var(--info-700);
}

.badge--cancelled,
.badge.status-cancelled,
.badge[data-status="cancelled"] {
  border-color: var(--slate-300);
  background: var(--slate-50);
  color: var(--slate-600);
}

.badge--high,
.badge.priority-alta,
.badge[data-priority="alta"] {
  border-color: #f7b4af;
  background: var(--danger-50);
  color: var(--danger-700);
}

.badge--medium,
.badge.priority-media,
.badge[data-priority="media"] {
  border-color: #f7d89b;
  background: var(--warning-50);
  color: var(--warning-700);
}

.badge--low,
.badge.priority-baja,
.badge[data-priority="baja"] {
  border-color: #b9d3fc;
  background: var(--info-50);
  color: var(--info-700);
}

.badge[data-email="accepted"] {
  border-color: #a9eac3;
  background: var(--success-50);
  color: var(--success-700);
}

.badge[data-email="failed"] {
  border-color: #f7b4af;
  background: var(--danger-50);
  color: var(--danger-700);
}

.badge[data-email="pending"],
.badge[data-email="sending"],
.badge[data-email="uncertain"] {
  border-color: #b9d3fc;
  background: var(--info-50);
  color: var(--info-700);
}

.badge[data-email="skipped"] {
  border-color: var(--slate-300);
  background: var(--slate-50);
  color: var(--slate-600);
}

/* Forms and buttons */
.form,
.form-stack {
  display: grid;
  gap: 17px;
}

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

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field label,
.field-label {
  color: var(--navy-900);
  font-size: 13px;
  font-weight: 700;
}

.field-help {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dictation-button {
  flex: 0 0 auto;
}

.dictation-button.is-listening {
  border-color: var(--danger-700);
  background: var(--danger-50);
  color: var(--danger-700);
}

.commercial-reasons .field {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.commercial-reasons .field.is-active {
  border-color: #5eead4;
  background: var(--teal-50);
}

.source-closure-note {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #a9eac3;
  border-radius: var(--radius-sm);
  background: var(--success-50);
  color: var(--success-700);
  font-size: 13px;
  line-height: 1.55;
}

.field-error {
  margin: 0;
  color: var(--danger-700);
  font-size: 12px;
  font-weight: 650;
}

.input,
.select,
.textarea,
input:not([type]),
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 43px;
  padding: 9px 12px;
  border: 1px solid var(--slate-300);
  border-radius: 9px;
  background: var(--white);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(7 24 39 / 0.03);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.textarea,
textarea {
  min-height: 108px;
  resize: vertical;
}

.input:hover,
.select:hover,
.textarea:hover,
input:hover,
select:hover,
textarea:hover {
  border-color: #9aabba;
}

.input:focus,
.select:focus,
.textarea:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal-600);
  outline: 0;
  box-shadow: 0 0 0 3px rgb(0 165 217 / 0.16);
}

input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  background: var(--slate-100);
  color: var(--slate-500);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger-700);
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.checkbox-row input {
  width: 17px;
  height: 17px;
  min-height: 0;
  margin-top: 2px;
  accent-color: var(--teal-700);
}

.button,
button.button,
a.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid var(--teal-700);
  border-radius: 9px;
  background: var(--teal-700);
  color: var(--white);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition), background var(--transition);
}

.button:hover {
  border-color: #005c7c;
  background: #005c7c;
  color: var(--white);
  box-shadow: 0 7px 18px rgb(15 118 110 / 0.18);
  transform: translateY(-1px);
}

.button:active {
  box-shadow: none;
  transform: translateY(0);
}

.button:disabled,
.button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.button--secondary,
.button.secondary {
  border-color: var(--navy-800);
  background: var(--navy-800);
}

.button--secondary:hover,
.button.secondary:hover {
  border-color: var(--navy-950);
  background: var(--navy-950);
}

.button--outline,
.button.outline {
  border-color: var(--slate-300);
  background: var(--white);
  color: var(--navy-900);
  box-shadow: none;
}

.button--outline:hover,
.button.outline:hover {
  border-color: var(--teal-600);
  background: var(--teal-50);
  color: var(--teal-700);
}

.button--ghost,
.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--slate-700);
  box-shadow: none;
}

.button--ghost:hover,
.button.ghost:hover {
  border-color: transparent;
  background: var(--slate-100);
  color: var(--navy-900);
}

.button--danger,
.button.danger {
  border-color: var(--danger-700);
  background: var(--danger-700);
}

.button--danger:hover,
.button.danger:hover {
  border-color: #912018;
  background: #912018;
}

.button--small,
.button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.button--wide,
.button.wide {
  width: 100%;
}

.button svg {
  width: 17px;
  height: 17px;
}

/* Notices and alerts */
.notice,
.alert {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border: 1px solid var(--slate-300);
  border-radius: 10px;
  background: var(--slate-50);
  color: var(--slate-700);
  font-size: 13px;
}

.notice strong,
.alert strong {
  color: inherit;
}

.notice--success,
.notice.success,
.alert--success,
.alert.success {
  border-color: #a9eac3;
  background: var(--success-50);
  color: var(--success-700);
}

.notice--warning,
.notice.warning,
.alert--warning,
.alert.warning {
  border-color: #f7d89b;
  background: var(--warning-50);
  color: var(--warning-700);
}

.notice--danger,
.notice.error,
.alert--danger,
.alert.error {
  border-color: #f7b4af;
  background: var(--danger-50);
  color: var(--danger-700);
}

.notice--info,
.notice.info,
.alert--info,
.alert.info {
  border-color: #b9d3fc;
  background: var(--info-50);
  color: var(--info-700);
}

.notice.compact {
  padding: 10px 12px;
  font-size: 12px;
}

/* Activity timeline */
.timeline {
  position: relative;
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 10px;
  width: 2px;
  background: var(--slate-200);
  content: "";
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 20px;
}

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

.timeline-marker {
  position: relative;
  z-index: 1;
  width: 12px;
  height: 12px;
  margin: 5px 0 0 5px;
  border: 3px solid var(--white);
  border-radius: 50%;
  background: var(--teal-600);
  box-shadow: 0 0 0 1px var(--teal-600);
}

.timeline-content {
  min-width: 0;
  padding: 0 0 2px;
}

.timeline-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 5px 12px;
  margin: 0 0 3px;
  color: var(--navy-900);
  font-size: 13px;
  font-weight: 750;
}

.timeline-meta {
  display: block;
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 11px;
}

.timeline-content p:last-child {
  margin-bottom: 0;
}

/* Reminders */
.reminder-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.reminder-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
}

.reminder-item.is-overdue {
  border-color: #f7b4af;
  background: var(--danger-50);
}

.reminder-check {
  position: relative;
  display: block;
  width: 19px;
  height: 19px;
  border: 2px solid var(--teal-600);
  border-radius: 50%;
  background: var(--teal-50);
  accent-color: var(--teal-700);
}

.reminder-check::after {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--teal-600);
  content: "";
}

a.reminder-item {
  color: inherit;
  text-decoration: none;
}

.reminder-alert-region {
  position: fixed;
  z-index: 80;
  top: calc(var(--topbar-height) + var(--reminder-banner-offset, 0px) + 14px);
  right: 18px;
  display: grid;
  width: min(430px, calc(100vw - 36px));
  max-height: calc(100vh - var(--topbar-height) - var(--reminder-banner-offset, 0px) - 28px);
  gap: 10px;
  overflow: auto;
  pointer-events: none;
}

.reminder-alert {
  padding: 16px;
  border: 1px solid #f2b84b;
  border-left: 5px solid var(--warning-700);
  border-radius: 13px;
  background: var(--white);
  box-shadow: 0 18px 45px rgb(7 24 39 / 0.24);
  color: var(--navy-900);
  pointer-events: auto;
  animation: reminder-enter 220ms ease-out both;
}

.reminder-alert.is-overdue {
  border-color: #f7b4af;
  border-left-color: var(--danger-700);
}

.reminder-alert.reminder-alert-system {
  border-color: #f7b4af;
  border-left-color: var(--danger-700);
}

.reminder-alert-system .reminder-alert-header {
  color: var(--danger-700);
}

.reminder-alert-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--warning-700);
}

.reminder-alert.is-overdue .reminder-alert-header {
  color: var(--danger-700);
}

.reminder-alert-close {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--slate-100);
  color: var(--slate-700);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}

.reminder-alert-close:hover {
  background: var(--slate-200);
}

.reminder-alert-title {
  margin: 0 0 7px;
  font-size: 15px;
  font-weight: 800;
}

.reminder-alert-meta,
.reminder-alert-due {
  margin: 3px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.reminder-alert-due {
  margin-bottom: 11px;
  color: var(--navy-900);
  font-weight: 700;
}

@keyframes reminder-enter {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes reminder-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

.reminder-title {
  display: block;
  color: var(--navy-900);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.reminder-meta {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

/* Pagination */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.pagination-summary {
  color: var(--text-muted);
  font-size: 12px;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 5px;
}

.page-link {
  display: inline-grid;
  min-width: 36px;
  height: 36px;
  place-items: center;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--slate-700);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.page-link:hover {
  border-color: var(--teal-600);
  background: var(--teal-50);
  color: var(--teal-700);
}

.page-link.active,
.page-link[aria-current="page"] {
  border-color: var(--teal-700);
  background: var(--teal-700);
  color: var(--white);
}

.page-link[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.45;
  pointer-events: none;
}

/* Authentication and installer */
.auth-shell {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 15% 15%, rgb(0 165 217 / 0.23), transparent 28%),
    radial-gradient(circle at 88% 85%, rgb(30 70 101 / 0.34), transparent 32%),
    linear-gradient(145deg, var(--navy-950), var(--navy-800));
}

.auth-card {
  width: min(100%, 460px);
  padding: clamp(24px, 5vw, 38px);
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: var(--radius-lg);
  background: rgb(255 255 255 / 0.98);
  box-shadow: 0 28px 70px rgb(0 0 0 / 0.28);
}

.diagnostics-card {
  width: min(100%, 920px);
}

.diagnostics-card .brand {
  width: min(100%, 290px);
}

.diagnostics-card .card {
  margin-bottom: 20px;
}

.auth-card .brand {
  margin-bottom: 26px;
  color: var(--navy-950);
}

.auth-card .brand-corporate {
  gap: 15px;
}

.auth-card .brand-logo-wrap {
  padding: 0;
  background: transparent;
}

.auth-card .brand-copy {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.diagnostic-code,
.health-summary dd,
.installer-shell code {
  overflow-wrap: anywhere;
}

.health-summary {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(0, 2fr);
  gap: 12px 18px;
}

.health-summary dt {
  color: var(--text-muted);
}

.health-summary dd {
  margin: 0;
  font-weight: 650;
}

.auth-card .brand-title {
  color: var(--navy-950);
}

.auth-card .brand-subtitle {
  color: var(--text-muted);
}

.auth-card h1 {
  margin-bottom: 8px;
  font-size: clamp(24px, 5vw, 30px);
  letter-spacing: -0.035em;
}

.auth-intro {
  margin-bottom: 23px;
  color: var(--text-muted);
}

.auth-footer {
  margin: 21px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
}

.installer-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: clamp(22px, 4vw, 48px) 18px;
}

.installer-checklist,
.checklist {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--slate-50);
  color: var(--slate-700);
  font-size: 13px;
}

.checklist-icon {
  display: grid;
  width: 21px;
  height: 21px;
  flex: 0 0 21px;
  place-items: center;
  border-radius: 50%;
  background: var(--slate-200);
  color: var(--slate-600);
  font-size: 11px;
  font-weight: 800;
}

.checklist-item.is-complete .checklist-icon,
.checklist-item.complete .checklist-icon {
  background: var(--success-100);
  color: var(--success-700);
}

/* Imports and progress */
.import-drop {
  position: relative;
  display: grid;
  min-height: 170px;
  place-items: center;
  padding: 28px;
  border: 2px dashed #a8b7c5;
  border-radius: var(--radius);
  background: var(--slate-50);
  color: var(--text-muted);
  text-align: center;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.import-drop:hover,
.import-drop:focus-within,
.import-drop.is-dragover {
  border-color: var(--teal-600);
  background: var(--teal-50);
  color: var(--teal-700);
}

.import-drop input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.import-drop-title {
  display: block;
  margin-bottom: 5px;
  color: var(--navy-900);
  font-weight: 750;
}

.file-name {
  display: block;
  max-width: 100%;
  margin-top: 9px;
  overflow: hidden;
  color: var(--teal-700);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--slate-200);
}

.progress-bar {
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal-700), var(--teal-500));
  transition: width 260ms ease;
}

progress {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--slate-200);
}

progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--slate-200);
}

progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal-700), var(--teal-500));
}

progress::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal-700), var(--teal-500));
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 11px;
}

/* Empty states and footer */
.empty-state {
  display: grid;
  min-height: 210px;
  place-items: center;
  padding: 34px 20px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 13px;
  place-items: center;
  border-radius: 15px;
  background: var(--teal-50);
  color: var(--teal-700);
}

.empty-state h2,
.empty-state h3 {
  margin-bottom: 6px;
  font-size: 17px;
}

.empty-state p {
  max-width: 470px;
  margin: 0 auto 17px;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(18px, 3vw, 36px);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
}

.footer p {
  margin: 0;
}

/* Dialogs remain usable without external component libraries. */
.dialog-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgb(7 24 39 / 0.58);
  backdrop-filter: blur(3px);
}

.dialog {
  width: min(100%, 620px);
  max-height: min(88vh, 820px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: 0 30px 80px rgb(0 0 0 / 0.32);
}

.dialog-header,
.dialog-body,
.dialog-footer {
  padding: 20px;
}

.dialog-header,
.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-header {
  border-bottom: 1px solid var(--border);
}

.dialog-header h2 {
  margin: 0;
  font-size: 18px;
}

.dialog-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  background: var(--slate-50);
}

/* CRM-specific compositions */
.page-header .eyebrow,
.eyebrow {
  margin: 0 0 7px;
  color: var(--teal-700);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.data-table .cell-primary,
.data-table .cell-muted {
  display: block;
}

.data-table .cell-muted {
  margin-top: 3px;
  font-size: 11px;
}

.table-embedded {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.compact-table {
  min-width: 430px;
}

.compact-table th,
.compact-table td {
  padding-block: 10px;
}

.no-padding {
  padding: 0;
}

.dashboard-lower,
.recent-card,
.quote-layout {
  margin-top: 22px;
}

.filter-card,
.import-layout {
  margin-bottom: 22px;
}

.quote-metrics {
  margin-bottom: 0;
}

.content > .notice,
.notice + .form-stack,
.notice + .button-block {
  margin-bottom: 18px;
}

.stage-summary,
.quality-list,
.definition-list,
.alias-list {
  display: grid;
  gap: 0;
}

.stage-row,
.quality-row,
.definition-list > div,
.alias-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 45px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.stage-row:last-child,
.quality-row:last-child,
.definition-list > div:last-child,
.alias-list > div:last-child {
  border-bottom: 0;
}

.quality-row strong,
.stage-row strong {
  color: var(--navy-950);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.definition-list > div {
  align-items: flex-start;
}

.definition-list span,
.alias-list span {
  color: var(--text-muted);
  font-size: 12px;
}

.definition-list strong,
.alias-list strong {
  max-width: 62%;
  text-align: right;
  overflow-wrap: anywhere;
}

.metric-label {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.metric-value {
  display: block;
  margin-top: 8px;
  color: var(--navy-950);
  font-size: clamp(20px, 2.4vw, 28px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.metric-text {
  font-size: 18px;
  letter-spacing: normal;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(4, minmax(135px, 1fr)) auto;
  align-items: end;
  gap: 14px;
}

.dashboard-filter-grid,
.quotes-filter-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.filter-count {
  flex: 0 0 auto;
  padding: 5px 10px;
  border: 1px solid #99f6e4;
  border-radius: 999px;
  background: var(--teal-50);
  color: var(--teal-700);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.dashboard-charts,
.quote-dashboard-charts {
  align-items: start;
}

.chart-list {
  display: grid;
  gap: 17px;
}

.chart-row {
  min-width: 0;
}

.chart-row-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.chart-row-label span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.chart-row-label strong {
  color: var(--navy-950);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.chart-progress {
  display: block;
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--slate-100);
  accent-color: var(--teal-600);
  appearance: none;
}

.chart-progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--slate-100);
}

.chart-progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal-600), var(--teal-500));
}

.chart-progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--teal-600);
}

.chart-empty {
  max-width: none;
  padding: 22px 14px;
}

.quotes-dashboard {
  margin-bottom: 22px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 28px 0 16px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(20px, 2.3vw, 27px);
}

.section-heading p:last-child {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.quote-dashboard-charts,
.currency-dashboard-card {
  margin-top: 18px;
}

.currency-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.currency-summary-item {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.currency-summary-item span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.currency-summary-item strong {
  overflow: hidden;
  color: var(--navy-950);
  font-size: clamp(19px, 2vw, 25px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
}

.quotes-results {
  margin-top: 22px;
}

.filter-actions,
.tabs-inline,
.reminder-actions,
.inline-form,
.inline-reset-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tabs-inline {
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.inline-form {
  margin-top: 7px;
}

.inline-reset-form {
  min-width: 310px;
}

.inline-reset-form input {
  min-height: 34px;
}

.reminder-page-list {
  gap: 12px;
}

.reminder-page-list .reminder-item {
  padding: 16px;
}

.reminder-actions {
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Status/actions get a separate row so long reminder text keeps its width. */
div.reminder-item,
article.reminder-item {
  grid-template-columns: auto minmax(0, 1fr);
}

.reminder-item > .reminder-actions {
  grid-column: 2;
  justify-content: flex-start;
}

.timeline-content p,
.file-name,
.reminder-alert-title,
.reminder-alert-meta {
  overflow-wrap: anywhere;
}

.import-progress {
  margin-top: 18px;
}

.steps-list {
  display: grid;
  gap: 16px;
  margin: 0;
  padding-left: 24px;
}

.steps-list li {
  padding-left: 4px;
}

.steps-list strong,
.steps-list span {
  display: block;
}

.steps-list span {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12px;
}

.alias-list,
.legacy-notes,
.match-suggestion {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.legacy-list {
  display: grid;
  gap: 16px;
}

.legacy-card .card-header h2 {
  font-size: 17px;
}

.legacy-notes {
  display: grid;
  gap: 10px;
}

.legacy-notes p {
  margin: 0;
  color: var(--slate-700);
}

.match-suggestion {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid #f7d89b;
  border-radius: 10px;
  background: var(--warning-50);
}

.match-suggestion > span {
  color: var(--warning-700);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.match-confirmed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1px solid #a9eac3;
  border-radius: 10px;
  background: var(--success-50);
  color: var(--success-700);
}

.match-confirmed form {
  flex: 0 0 auto;
}

.manual-match-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.account-card {
  max-width: 780px;
}

/* One-time installer */
.installer-card {
  width: min(100%, 780px);
}

.brand-auth strong,
.brand-auth small {
  display: block;
}

.brand-auth small {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.page-header.compact {
  margin-bottom: 18px;
}

.installer-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 20px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--slate-50);
  color: var(--slate-700);
  font-size: 12px;
}

.check-row > span:first-child {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  place-items: center;
  border-radius: 50%;
  font-weight: 800;
}

.check-row.is-ok > span:first-child {
  background: var(--success-100);
  color: var(--success-700);
}

.check-row.is-error > span:first-child {
  background: var(--danger-100);
  color: var(--danger-700);
}

.installer-card fieldset {
  min-width: 0;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 11px;
}

.installer-card legend {
  padding: 0 7px;
  color: var(--navy-900);
  font-size: 13px;
  font-weight: 800;
}

.installer-card .field small {
  color: var(--text-muted);
  font-size: 11px;
}

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

.field-full {
  grid-column: 1 / -1;
}

.button-primary {
  border-color: var(--teal-700);
  background: var(--teal-700);
}

.button-block {
  width: 100%;
}

.notice-success {
  margin-bottom: 18px;
  border-color: #a9eac3;
  background: var(--success-50);
  color: var(--success-700);
}

.notice-error {
  margin-bottom: 18px;
  border-color: #f7b4af;
  background: var(--danger-50);
  color: var(--danger-700);
}

@media (max-width: 1180px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .filter-search {
    grid-column: span 2;
  }
}

@media (max-width: 860px) {
  :root {
    --topbar-height: calc(68px + env(safe-area-inset-top));
  }

  input:not([type="hidden"]),
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  /* WebKit's native picker can ignore min-height; keep its native affordance. */
  select {
    height: 44px;
    /* Contain native selected-text painting; full options remain in the picker. */
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .button,
  button.button,
  a.button,
  .button.small,
  .button--small,
  .page-link,
  .dictation-button {
    min-width: 44px;
    min-height: 44px;
  }

  .mobile-menu {
    flex: 0 0 44px;
  }

  .user-chip {
    min-width: 44px;
    min-height: 44px;
  }

  a.cell-primary,
  a.reminder-title,
  .card-header > a {
    display: flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
  }

  .reminder-alert-close {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 60;
    top: 0;
    left: 0;
    width: min(var(--sidebar-width), 86vw);
    transform: translateX(-105%);
    transition: transform 210ms ease;
  }

  .sidebar-close {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    margin: 12px 12px 0;
    border: 1px solid rgb(255 255 255 / 0.3);
    border-radius: 8px;
    background: transparent;
    color: var(--white);
    font: inherit;
    cursor: pointer;
  }

  html:not(.js) .sidebar {
    position: static;
    width: 100%;
    height: auto;
    transform: none;
  }

  html:not(.js) .app-shell {
    display: block;
  }

  html:not(.js) .mobile-menu {
    display: none;
  }

  .sidebar.is-open,
  .app-shell.menu-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-overlay.is-open,
  .app-shell.menu-open .sidebar-overlay {
    display: block;
  }

  .mobile-menu {
    display: inline-flex;
  }

  .topbar {
    min-height: var(--topbar-height);
    padding-top: max(11px, env(safe-area-inset-top));
    padding-right: max(18px, env(safe-area-inset-right));
    padding-left: max(18px, env(safe-area-inset-left));
  }

  .content {
    padding: 24px 18px 30px;
    padding-right: max(18px, env(safe-area-inset-right));
    padding-left: max(18px, env(safe-area-inset-left));
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
    gap: 15px;
  }

  .page-actions {
    justify-content: flex-start;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

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

  .filter-actions {
    align-self: end;
  }
}

@media (max-width: 600px) {
  .topbar {
    gap: 8px;
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  .topbar .toolbar {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
  }

  .topbar-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-actions {
    flex: 0 0 auto;
    gap: 5px;
  }

  .user-chip .user-copy {
    display: none;
  }

  .reminder-sound-toggle [data-reminder-sound-label] {
    display: none;
  }

  .reminder-sound-toggle {
    width: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 0;
  }

  .reminder-permission-banner:not([hidden]) {
    align-items: stretch;
    flex-direction: column;
    padding: 12px 14px;
  }

  .reminder-permission-banner .button {
    flex: 1 1 auto;
  }

  .reminder-permission-actions {
    width: 100%;
  }

  .reminder-alert-region {
    top: calc(var(--topbar-height) + var(--reminder-banner-offset, 0px) + 8px);
    right: 10px;
    left: 10px;
    width: auto;
    max-height: calc(100vh - var(--topbar-height) - var(--reminder-banner-offset, 0px) - 18px);
  }

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

  .kpi {
    padding: 14px;
  }

  .kpi-value {
    font-size: clamp(23px, 6vw, 30px);
    overflow-wrap: anywhere;
  }

  .quote-metrics {
    grid-template-columns: 1fr;
  }

  .currency-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .currency-summary-item strong {
    overflow-wrap: anywhere;
  }

  .table-wrap:has(> .compact-table)::before {
    content: "Desliza lateralmente para ver todos los valores ↔";
    display: block;
    padding: 10px 12px;
    color: var(--text-muted);
    font-size: 11px;
    background: var(--teal-50);
  }

  .health-summary {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .health-summary dd {
    margin-bottom: 12px;
  }

  /* Progressive enhancement: JS supplies labels without changing table data. */
  .data-table[data-mobile-cards] {
    display: block;
    min-width: 0;
  }

  .data-table[data-mobile-cards] thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .data-table[data-mobile-cards] tbody,
  .data-table[data-mobile-cards] tr {
    display: block;
    width: 100%;
  }

  .data-table[data-mobile-cards] tbody tr {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }

  .data-table[data-mobile-cards] td {
    display: block;
    padding: 6px 0;
    border-bottom: 0;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .data-table[data-mobile-cards] td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .data-table[data-mobile-cards] td:first-child {
    margin-bottom: 5px;
    font-size: 15px;
  }

  .data-table[data-mobile-cards] td:last-child {
    font-weight: 650;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .installer-checks,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .filter-search,
  .field-full {
    grid-column: auto;
  }

  .filter-actions,
  .inline-reset-form {
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
  }

  .match-suggestion {
    grid-template-columns: 1fr;
  }

  .match-confirmed {
    align-items: flex-start;
    flex-direction: column;
  }

  .card-header,
  .card-body,
  .card-footer,
  .dialog-header,
  .dialog-body,
  .dialog-footer {
    padding: 16px;
  }

  .toolbar,
  .page-actions {
    width: 100%;
  }

  .page-actions .button {
    flex: 1 1 auto;
  }

  .reminder-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .reminder-item > :last-child {
    grid-column: 2;
  }

  .pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  .footer {
    align-items: flex-start;
    flex-direction: column;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .topbar .user-chip {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media print {
  .sidebar,
  .topbar,
  .mobile-menu,
  .sidebar-overlay,
  .page-actions,
  .footer,
  .button {
    display: none !important;
  }

  body,
  .app-shell,
  .app-main,
  .content {
    display: block;
    max-width: none;
    padding: 0;
    background: var(--white);
  }

  .card,
  .table-wrap,
  .kpi {
    break-inside: avoid;
    box-shadow: none;
  }
}
