:root {
  --primary: #016bfc;
  --deep: #0156e8;
  --cyan: #0188fd;
  --green: #6ec30d;
  --green-dark: #3aab2d;
  --navy: #07152f;
  --navy-2: #0b2348;
  --ink: #0a1628;
  --muted: #5b6f89;
  --line: #d7e4f4;
  --bg: #eef3f9;
  --card: #ffffff;
  --accent: #016bfc;
  --accent-2: #0188fd;
  --success: #6ec30d;
  --success-ink: #3aab2d;
  --success-bg: #eef8d6;
  --info-bg: #e6f3ff;
  --soft: #e8f1fc;
  --danger: #b42318;
  --warn: #b54708;
  --sidebar-w: 236px;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(10, 22, 40, 0.04), 0 4px 14px rgba(10, 22, 40, 0.04);
  --shadow-md: 0 4px 20px rgba(10, 22, 40, 0.07);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(1, 107, 252, 0.1), transparent 28%),
    radial-gradient(circle at bottom right, rgba(110, 195, 13, 0.08), transparent 22%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Hide login instantly when a stored session token exists (before app.js boots). */
html.boot-session #auth-screen {
  display: none !important;
}
html.boot-session #portal-screen {
  display: block !important;
}
html.boot-session body {
  overflow: hidden;
  height: 100%;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  position: relative;
}

.auth-hero {
  background:
    radial-gradient(circle at 18% 18%, rgba(182, 200, 161, 0.32), transparent 30%),
    radial-gradient(circle at 88% 82%, rgba(1, 136, 253, 0.35), transparent 34%),
    linear-gradient(160deg, #041226, #082a57 58%, #0156e8 132%);
  color: #edf4fa;
  padding: 2rem 4rem 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
}

.hero-top-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.hero-top-link,
.hero-top-cta {
  width: auto;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.hero-top-link {
  background: transparent;
  color: #eef5ff;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.hero-top-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

.hero-top-cta {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.hero-top-cta:hover {
  background: rgba(255, 255, 255, 0.22);
}

.hero-brand {
  display: flex;
  gap: 0.9rem;
  align-items: center;
}

.hero-brand strong {
  display: block;
  font-size: 0.95rem;
}

.hero-badge {
  padding: 0.4rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.1);
  color: #eef5ff;
  font-size: 0.72rem;
  font-weight: 700;
}

.auth-view {
  display: none;
}

.auth-view.active {
  display: block;
}

.auth-switch {
  margin: 0.35rem 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}

.auth-switch-btn {
  width: auto;
  padding: 0;
  margin-left: 0.25rem;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  border: 0;
  text-decoration: underline;
}

.auth-switch-btn:hover {
  background: transparent;
  color: var(--deep);
}

.password-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
  align-items: center;
}

.password-field input {
  width: 100%;
}

.password-toggle {
  width: auto;
  min-width: 4.2rem;
  padding: 0.55rem 0.7rem;
  margin: 0;
  background: #eef3fb;
  color: var(--deep);
  border: 1px solid #d5e0ef;
  font-size: 0.75rem;
  font-weight: 700;
}

.password-toggle:hover {
  background: #e2ebf8;
}

.staff-org-tabs {
  flex-wrap: wrap;
  gap: 0.4rem;
}

.staff-org-tabs .active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.field {
  display: grid;
  gap: 0.28rem;
}

.field label,
.auth-view > .form-grid > label:not(.check-row) {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

.hero-main {
  max-width: 640px;
}

.auth-hero h1 {
  font-size: 3rem;
  line-height: 1.05;
  margin: 0.2rem 0 0.9rem;
}

.auth-hero p, .auth-hero li {
  color: #c8dbf8;
  font-size: 0.92rem;
}

.hero-copy {
  max-width: 620px;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  gap: 0.7rem;
  margin: 1.35rem 0 1.5rem;
  flex-wrap: wrap;
}

.hero-cta,
.hero-link {
  width: auto;
  min-width: 170px;
  padding: 0.82rem 1rem;
  border-radius: 12px;
}

.hero-link {
  background: rgba(255, 255, 255, 0.08);
  color: #eef5ff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  transition: background 0.14s ease, transform 0.1s ease, box-shadow 0.14s ease;
}

.hero-cta {
  background: linear-gradient(180deg, #6ec30d, #3aab2d);
  color: #fff;
  transition: background 0.14s ease, transform 0.1s ease, box-shadow 0.14s ease;
}

.hero-cta:hover {
  background: linear-gradient(180deg, #7bd619, #329f25);
}

.hero-cta:active:not(:disabled) {
  transform: scale(0.98);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.22);
  background: linear-gradient(180deg, #58a80a, #2d8f1f);
}

.hero-link:hover {
  background: rgba(255, 255, 255, 0.16);
}

.hero-link:active:not(:disabled) {
  transform: scale(0.98);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.25);
  background: rgba(255, 255, 255, 0.22);
}

.hero-panels {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 1rem;
  margin-top: 0.4rem;
}

.hero-panel {
  padding: 1.15rem;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}

.hero-panel-primary {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.04));
}

.panel-label {
  margin: 0 0 0.9rem;
  color: #f4f9ff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-feature-list {
  display: grid;
  gap: 0.95rem;
}

.hero-feature strong {
  display: block;
  margin-bottom: 0.22rem;
  font-size: 0.95rem;
}

.hero-feature span {
  color: #c8dbf8;
  font-size: 0.83rem;
  line-height: 1.55;
}

.hero-stats {
  display: grid;
  gap: 0.75rem;
  margin: 0;
}

.hero-stat {
  padding: 0.9rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
}

.hero-stat strong {
  display: block;
  margin-bottom: 0.22rem;
  font-size: 0.95rem;
}

.hero-stat span {
  color: #c8dbf8;
  font-size: 0.82rem;
}

.hero-note {
  margin-top: 1rem;
  padding: 0.95rem 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  width: fit-content;
  max-width: 520px;
}

.hero-note p {
  margin: 0.12rem 0;
}

.auth-logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
}

.auth-card-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  margin: 0 auto 1rem;
  display: block;
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(15, 39, 68, 0.16);
}

.eyebrow {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--green);
}

.auth-card {
  display: grid;
  align-content: center;
  padding: 2.2rem;
  background: linear-gradient(180deg, #f7fbff, #eef5fc);
}

.auth-card-shell {
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
  border: 1px solid rgba(1, 107, 252, 0.1);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 28px 80px rgba(7, 21, 47, 0.12);
}

.auth-card-head {
  margin-bottom: 1rem;
}

.auth-card-kicker {
  margin: 0 0 0.25rem;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
}

.auth-card-title {
  margin: 0 0 0.5rem;
  font-size: 1.65rem;
  line-height: 1.15;
}

.auth-card-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.auth-panel { display: none; }
.auth-panel.active { display: grid; }

.auth-tabs {
  display: none;
}

.auth-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.section-intro {
  display: grid;
  gap: 0.18rem;
  margin-bottom: 0.25rem;
}

.section-intro span {
  color: var(--muted);
  font-size: 0.78rem;
}

.check-row {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.check-row input {
  width: 16px;
  min-width: 16px;
  margin-top: 0.1rem;
}

.auth-checklist {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.15rem;
  padding: 0.9rem;
  border-radius: 14px;
  background: linear-gradient(180deg, #edf5ff, #e7f1fd);
  color: var(--muted);
  font-size: 0.76rem;
}

.auth-tabs {
  margin-bottom: 1rem;
  padding: 0.28rem;
  border-radius: 14px;
  background: #eef4fb;
}

.auth-inline-note {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.15rem;
}

.auth-inline-note a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.auth-inline-note a:hover {
  text-decoration: underline;
}

/*
 * App shell (admin + distributor):
 * - Sidebar is position:fixed full viewport height (no bottom white gap on scroll)
 * - Topbar stays fixed in the workspace; .workspace-body scrolls
 * - nav-backdrop must NOT be a grid item (distributor markup has it as a sibling)
 */
body.portal-open {
  overflow: hidden;
  height: 100%;
}

.layout {
  display: block;
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

.layout:not(.hidden) {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.distributor-layout .workspace {
  background:
    radial-gradient(circle at 0% 0%, rgba(110, 195, 13, 0.05), transparent 28%),
    radial-gradient(circle at 100% 0%, rgba(1, 107, 252, 0.06), transparent 30%),
    var(--bg);
}

.distributor-layout .nav-btn.active {
  background: linear-gradient(90deg, rgba(110, 195, 13, 0.28), rgba(1, 107, 252, 0.22));
  box-shadow: inset 3px 0 0 var(--green);
}

.layout > .nav-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 65;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  max-height: none;
  background: linear-gradient(185deg, #0a1a33 0%, var(--navy) 42%, #040d1c 100%);
  color: #d7e6f2;
  padding: 1rem 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 30;
}

.side-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.15rem;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.side-nav::-webkit-scrollbar {
  width: 5px;
}

.side-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 99px;
}

.brand {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.35rem 0.4rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.brand strong {
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.brand p {
  margin: 0.12rem 0 0;
  font-size: 0.68rem;
  color: #8eabc8;
  letter-spacing: 0.02em;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-label {
  margin: 0.95rem 0.45rem 0.28rem;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #7a92b0;
  font-weight: 700;
}

.nav-label:first-child {
  margin-top: 0.15rem;
}

.profile-panel { display: none; }
.profile-panel.active { display: block; }

.nav-btn, .ghost, .tab-btn, .seg-btn, button {
  font-family: inherit;
  cursor: pointer;
}

.nav-btn {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #b8c9db;
  padding: 0.5rem 0.7rem;
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-btn.active {
  background: linear-gradient(90deg, rgba(1, 107, 252, 0.42), rgba(1, 107, 252, 0.18));
  color: #fff;
  box-shadow: inset 3px 0 0 #3d8dff;
}

.nav-btn.is-locked,
.tab-item.is-locked {
  opacity: 0.45;
}

.nav-count {
  display: inline-block;
  min-width: 1.2rem;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: #d92d20;
  color: #fff;
  font-size: 0.68rem;
  line-height: 1.3;
  text-align: center;
}
.nav-count[hidden] { display: none; }

.sidebar-foot {
  flex-shrink: 0;
  margin-top: 0.65rem;
  padding: 0.85rem 0.35rem 0.15rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.12));
}

.sidebar-foot p {
  font-size: 0.7rem;
  color: #93a8ba;
  margin: 0 0 0.55rem;
  padding: 0 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar .ghost {
  width: 100%;
  background: rgba(1, 107, 252, 0.2);
  color: #fff;
  border: 1px solid rgba(1, 107, 252, 0.28);
  border-radius: 9px;
  padding: 0.55rem 0.75rem;
  font-weight: 650;
}

.sidebar .ghost:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.workspace {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  min-width: 0;
  min-height: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  box-sizing: border-box;
}

.workspace-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.1rem 1.35rem 2rem;
  overscroll-behavior: contain;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  flex: 0 0 auto;
  margin: 0;
  padding: 0.85rem 1.35rem;
  background: rgba(255, 255, 255, 0.94);
  border: 0;
  border-bottom: 1px solid rgba(215, 228, 244, 0.95);
  border-radius: 0;
  box-shadow: 0 1px 0 rgba(15, 39, 68, 0.04);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  z-index: 50;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.topbar-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(15, 39, 68, 0.14);
}

.topbar h2 { margin: 0; font-size: 1.18rem; letter-spacing: -0.02em; font-weight: 700; }
.topbar p { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.78rem; }

.alert-strip { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.welcome-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  margin-bottom: 0.9rem;
  background: linear-gradient(135deg, rgba(1, 107, 252, 0.12), rgba(110, 195, 13, 0.12));
  border: 1px solid #cfe1fb;
  border-radius: 14px;
}

.welcome-banner h3 {
  margin: 0.15rem 0 0.25rem;
  font-size: 1rem;
}

.welcome-banner p {
  margin: 0;
  color: var(--muted);
}

.welcome-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.chip {
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 600;
}

.chip.warn { background: #feeccc; color: var(--warn); }
.chip.expired { background: #fce7e5; color: var(--danger); }
.chip.ok { background: var(--success-bg); color: var(--success-ink); }

.view { display: none; }
.view.active { display: grid; gap: 0.8rem; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.kpi, .card {
  background: var(--card);
  border: 1px solid rgba(215, 228, 244, 0.95);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-sm);
}

.kpi span, .metric-row span {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi strong { display: block; margin-top: 0.35rem; font-size: 1.15rem; }

.two-col, .three-col {
  display: grid;
  gap: 0.7rem;
}

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

.card h3 { margin: 0 0 0.7rem; font-size: 0.86rem; }

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.card-head h3 { margin: 0; }

.card-title-wrap {
  flex: 1;
  min-width: 0;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  padding: 0.38rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.8rem;
}

.progress {
  height: 8px;
  background: var(--soft);
  border-radius: 99px;
  margin-top: 0.7rem;
  overflow: hidden;
}

.progress div {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--green-dark));
}

.form-grid { display: grid; gap: 0.42rem; }

input, select, button, textarea {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #c5d8ef;
  padding: 0.5rem 0.58rem;
  font-size: 0.78rem;
  font-family: inherit;
}

textarea {
  resize: vertical;
  min-height: 72px;
}

button {
  border: 0;
  background: var(--primary);
  color: white;
  font-weight: 700;
  transition: background 0.14s ease, color 0.14s ease, transform 0.1s ease, box-shadow 0.14s ease, border-color 0.14s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button:hover {
  background: var(--deep);
}

button:active:not(:disabled) {
  transform: scale(0.97);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.18);
  background: #014bb8;
}

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

button:focus-visible,
.nav-btn:focus-visible,
.ghost:focus-visible,
.tab-btn:focus-visible,
.seg-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.ghost, .tab-btn, .seg-btn {
  width: auto;
  background: var(--soft);
  color: var(--navy);
}

.ghost:hover, .tab-btn:hover, .seg-btn:hover {
  background: #d7e8ff;
}

.ghost:active:not(:disabled),
.tab-btn:active:not(:disabled),
.seg-btn:active:not(:disabled) {
  transform: scale(0.97);
  box-shadow: inset 0 2px 4px rgba(7, 21, 47, 0.12);
  background: #c5daf5;
  color: var(--navy);
}

.nav-btn {
  transition: background 0.14s ease, color 0.14s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn:active:not(:disabled) {
  transform: scale(0.98);
  background: rgba(1, 107, 252, 0.42);
  color: #fff;
}

.sidebar .ghost:active:not(:disabled) {
  transform: scale(0.98);
  background: #014bb8;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tab-bar, .seg { display: flex; gap: 0.3rem; }
.tab-btn.active, .seg-btn.active,
.tab-btn.active:hover, .seg-btn.active:hover {
  background: var(--primary);
  color: #fff;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.table th,
.table td {
  text-align: left;
  vertical-align: middle;
  font-size: 0.74rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  line-height: 1.35;
}

.table th {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  background: #f5f9fd;
}

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

.table td button,
.table td .ghost,
.table td select,
.table td input:not([type="checkbox"]):not([type="radio"]) {
  width: auto;
  min-width: 0;
  vertical-align: middle;
}

.table td button,
.table td .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.32rem 0.55rem;
  margin: 0.12rem 0.2rem 0.12rem 0;
}

.table td .row-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.35rem;
  width: auto;
}

.table td.row-actions,
.table td:has(.row-actions) {
  text-align: right;
  white-space: nowrap;
}

.table td.num,
.table th.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.orders-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 0.8rem;
  align-items: start;
}

.orders-inbox {
  min-width: 980px;
}

.orders-inbox .col-check {
  width: 2.4rem;
  padding-right: 0.2rem;
}

.orders-inbox td button,
.orders-inbox td .ghost {
  white-space: nowrap;
  margin: 0;
}

#ord-inbox .toolbar {
  flex-wrap: wrap;
  align-items: center;
}

#ord-inbox .toolbar input,
#ord-inbox .toolbar select,
#ord-inbox .toolbar button {
  flex: 0 1 auto;
  width: auto;
  min-width: 0;
}

#ord-inbox .toolbar input {
  flex: 1 1 200px;
  min-width: 180px;
}

#ord-inbox .toolbar select {
  min-width: 140px;
}

#ord-inbox .toolbar button {
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .orders-split {
    grid-template-columns: 1fr;
  }
}

.hint { color: var(--muted); font-size: 0.72rem; }
.toast {
  margin-top: 0.7rem;
  margin-bottom: 0.7rem;
  background: var(--success-bg);
  color: var(--success-ink);
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.portal-toast {
  position: sticky;
  top: 0.5rem;
  z-index: 10;
  margin: 0 0 0.75rem;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}

.portal-toast.error {
  background: #fce7e5;
  color: #b42318;
}

.cat {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  margin-bottom: 0.28rem;
}

.bar {
  height: 6px;
  background: var(--soft);
  border-radius: 99px;
  margin-bottom: 0.5rem;
}

.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--primary));
  border-radius: 99px;
}

.map { width: 100%; border-radius: 10px; margin-bottom: 0.6rem; }

.status {
  border-radius: 99px;
  padding: 0.1rem 0.4rem;
  font-size: 0.66rem;
  font-weight: 700;
}

.status.Low, .status.Watch { background: #feeccc; color: var(--warn); }
.status.Critical, .status.expired { background: #fce7e5; color: var(--danger); }
.status.Active, .status.ok { background: var(--success-bg); color: var(--success-ink); }
.status.OnLeave { background: #feeccc; color: var(--warn); }
.status.Terminated { background: #eceff3; color: #5b6575; }
.status.Pending { background: var(--soft); color: var(--primary); }

.stack { display: grid; gap: 0.7rem; }

.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0.85rem 0;
}

.plan-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem;
  background: #f9fbff;
}

.plan-card.current {
  border-color: var(--primary);
  box-shadow: 0 10px 24px rgba(1, 107, 252, 0.08);
}

.plan-card h4 {
  margin: 0 0 0.3rem;
  font-size: 0.86rem;
}

.plan-card p {
  margin: 0.18rem 0;
}

.plan-card ul {
  margin: 0.55rem 0 0;
  padding-left: 1rem;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.toolbar input, .toolbar select, .toolbar button {
  width: auto;
  min-width: 140px;
  flex: 1;
}

.row-actions {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.row-actions button {
  width: auto;
  padding: 0.28rem 0.42rem;
  font-size: 0.66rem;
}

.row-actions button:active:not(:disabled) {
  transform: scale(0.95);
}

.priority-High { color: #b42318; font-weight: 700; }
.priority-Normal { color: var(--muted); }

.status.Approved, .status.Confirmed, .status.Packed { background: var(--info-bg); color: var(--deep); }
.status.Dispatched { background: #feeccc; color: var(--warn); }
.status.Delivered { background: var(--success-bg); color: var(--success-ink); }
.status.Rejected, .status.Cancelled, .status.Deactivated { background: #fce7e5; color: var(--danger); }
.status.Incoming { background: var(--info-bg); color: var(--cyan); }

.inv-panel { display: none; }
.inv-panel.active { display: grid; gap: 0.8rem; }
.ord-panel { display: none; }
.ord-panel.active { display: grid; gap: 0.8rem; }

.hr-panel { display: none; }
.hr-panel.active { display: grid; gap: 0.8rem; }

#view-staff .tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.85rem;
  padding: 0.35rem;
  background: #f4f7fb;
  border: 1px solid var(--line, #d8dee8);
  border-radius: 10px;
}
#view-staff .tab-btn {
  flex: 1 1 auto;
  min-width: 7.5rem;
  text-align: center;
}
.rpt-panel { display: none; }
.rpt-panel.active { display: grid; gap: 0.8rem; }
.report-toolbar { flex-wrap: wrap; gap: 0.5rem; }
.trend { display: inline-block; margin-top: 0.25rem; font-size: 0.75rem; font-weight: 600; }
.trend.up { color: var(--success-ink, #1f7a3f); }
.trend.down { color: #b42318; }
.status.High { background: #fde8e8; color: #b42318; }
.status.Medium { background: #feeccc; color: var(--warn); }
.status.Low { background: var(--success-bg); color: var(--success-ink); }
.prod-thumb { font-size: 1.1rem; }
.prod-thumb img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; vertical-align: middle; }

.report-out {
  white-space: pre-wrap;
  font-size: 0.72rem;
  margin: 0;
  font-family: "IBM Plex Sans", sans-serif;
}

/* Billing POS tabs (shared pattern with admin) */
#view-billing .admin-tab-bar {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
#view-billing .admin-tab {
  border: 1px solid var(--line, #d8dee8);
  background: #fff;
  color: var(--muted, #5b6575);
  padding: 0.42rem 0.75rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
#view-billing .admin-tab.active {
  background: var(--deep, #0b3d91);
  border-color: var(--deep, #0b3d91);
  color: #fff;
}
#view-billing .admin-tab-panel {
  display: none;
}
#view-billing .admin-tab-panel.active {
  display: block;
}
.stock-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
}
.stock-badge.in_stock { background: var(--success-bg, #e8f7ee); color: var(--success-ink, #1f7a3f); }
.stock-badge.low_stock { background: #feeccc; color: var(--warn, #9a6700); }
.stock-badge.out_of_stock { background: #fce7e5; color: var(--danger, #b42318); }
.status.Grace, .status.Scheduled, .status.Sent, .status.Draft { background: #feeccc; color: var(--warn); }
.status.Inactive, .status.Discontinued { background: #eceff3; color: #5b6575; }
.status.Suspended, .status.Exception { background: #fce7e5; color: var(--danger); }
.status.Paid, .status.Received, .status.Delivered { background: var(--success-bg); color: var(--success-ink); }
.status.Requested, .status.Assigned { background: var(--info-bg); color: var(--deep); }

/* —— Professional module chrome (Payments / Notifications) —— */
.card-desc {
  margin: 0.2rem 0 0;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.4;
  max-width: 38rem;
}

.kpi .kpi-help {
  display: block;
  margin-top: 0.28rem;
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  line-height: 1.35;
}

.mod-hero {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 1rem;
  align-items: center;
  padding: 1.1rem 1.25rem;
  border-radius: 14px;
  border: 1px solid rgba(1, 86, 232, 0.14);
  background:
    radial-gradient(circle at 92% 18%, rgba(110, 195, 13, 0.18), transparent 34%),
    linear-gradient(135deg, #041a36 0%, #0a3a7a 55%, #016bfc 130%);
  color: #edf4fa;
  box-shadow: 0 14px 28px rgba(4, 26, 54, 0.18);
  margin-bottom: 0.15rem;
}

.form-hint,
.func-hint {
  margin: 0 0 0.55rem;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.4;
}

.mod-hero h2 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.mod-hero p {
  margin: 0;
  color: rgba(237, 244, 250, 0.78);
  font-size: 0.8rem;
  max-width: 42rem;
  line-height: 1.45;
}

.mod-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.mod-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.mod-hero-aside {
  display: grid;
  gap: 0.45rem;
  justify-items: end;
  text-align: right;
}

.mod-hero-aside .mod-stat {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(237, 244, 250, 0.65);
}

.mod-hero-aside strong {
  font-size: 1.35rem;
  font-weight: 700;
}

.seg-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.3rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(1, 86, 232, 0.04);
}

.seg-tabs button {
  width: auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.55rem 0.9rem;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.76rem;
  cursor: pointer;
}

.seg-tabs button.active,
.seg-tabs button:hover {
  background: var(--soft);
  color: var(--deep);
}

.seg-tabs button.active {
  background: linear-gradient(180deg, #e8f1fc, #dcebff);
  box-shadow: inset 0 0 0 1px rgba(1, 107, 252, 0.2);
}

.seg-tabs .seg-tabs-actions {
  margin-left: auto;
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.field-label {
  display: grid;
  gap: 0.28rem;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.field-label > span {
  text-transform: uppercase;
  font-size: 0.66rem;
  letter-spacing: 0.05em;
}

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

.form-grid .span-2,
.form-grid.dense-2 .span-2 { grid-column: 1 / -1; }

.field-label input,
.field-label select,
.field-label textarea {
  width: 100%;
  font-weight: 500;
  color: var(--ink);
}

.method-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.method-card {
  position: relative;
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f8fbff;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.method-card:hover {
  border-color: rgba(1, 107, 252, 0.35);
  transform: translateY(-1px);
}

.method-card.active {
  border-color: var(--primary);
  background: linear-gradient(180deg, #ffffff, #eef5ff);
  box-shadow: 0 8px 18px rgba(1, 107, 252, 0.1);
}

.method-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.method-card strong {
  font-size: 0.86rem;
  color: var(--navy);
}

.method-card small {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
}

.method-card .method-ico {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-bottom: 0.25rem;
  background: var(--soft);
  color: var(--deep);
}

.method-card.cod .method-ico {
  background: var(--success-bg);
  color: var(--success-ink);
}

.secure-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: #f4faf0;
  border: 1px solid #d7ebbf;
  color: var(--success-ink);
  font-size: 0.72rem;
  font-weight: 600;
}

.list-stack {
  display: grid;
  gap: 0.55rem;
}

.txn-card,
.inbox-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f9fcff);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.txn-card:hover,
.inbox-card:hover {
  border-color: rgba(1, 107, 252, 0.28);
  box-shadow: 0 10px 22px rgba(1, 86, 232, 0.07);
}

.inbox-card.unread {
  border-color: rgba(1, 107, 252, 0.35);
  background: linear-gradient(180deg, #f3f8ff, #ffffff);
  box-shadow: inset 3px 0 0 var(--primary);
}

.txn-mark,
.inbox-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 800;
  background: var(--soft);
  color: var(--deep);
}

.txn-mark.cod { background: var(--success-bg); color: var(--success-ink); }
.txn-mark.held { background: #fce7e5; color: var(--danger); }
.txn-mark.failed { background: #fce7e5; color: var(--danger); }

.txn-body h4,
.inbox-body h4 {
  margin: 0 0 0.2rem;
  font-size: 0.84rem;
}

.txn-meta,
.inbox-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.txn-aside,
.inbox-aside {
  display: grid;
  gap: 0.35rem;
  justify-items: end;
  text-align: right;
}

.txn-aside .amt {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--navy);
}

.txn-actions,
.inbox-aside .txn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: flex-end;
}

.txn-actions button {
  width: auto;
  padding: 0.35rem 0.65rem;
  font-size: 0.7rem;
}

.progress-thin {
  height: 6px;
  background: var(--soft);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.45rem;
  min-width: 110px;
}

.progress-thin > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--primary));
}

.risk-meter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  color: var(--muted);
}

.risk-bar {
  width: 52px;
  height: 6px;
  border-radius: 99px;
  background: #eceff3;
  overflow: hidden;
}

.risk-bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), #f5a524, var(--danger));
}

.kpi.accent {
  background: linear-gradient(180deg, #ffffff, #f3f8ff);
  border-color: rgba(1, 107, 252, 0.2);
}

.kpi.warn-kpi {
  background: linear-gradient(180deg, #ffffff, #fff8ef);
  border-color: rgba(181, 71, 8, 0.2);
}

.kpi.danger-kpi {
  background: linear-gradient(180deg, #ffffff, #fff5f4);
  border-color: rgba(180, 35, 24, 0.18);
}

.empty-state {
  text-align: center;
  padding: 1.6rem 1rem;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fafcff;
}

.empty-state strong {
  display: block;
  color: var(--navy);
  margin-bottom: 0.25rem;
  font-size: 0.88rem;
}

.pref-block {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.pref-block:last-of-type { border-bottom: 0; }

.pref-block h4 {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  color: var(--navy);
}

.channel-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.channel-pills label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.channel-pills input { width: auto; margin: 0; }

.channel-pills label:has(input:checked) {
  background: var(--soft);
  border-color: rgba(1, 107, 252, 0.35);
  color: var(--deep);
}

.stat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.stat-chip {
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 0.72rem;
}

.stat-chip b { color: var(--navy); }

.status.Held, .status.Failed, .status.Discrepancy, .status.Rejected { background: #fce7e5; color: var(--danger); }
.status.Partial, .status.PartiallyRefunded, .status.Processing, .status.Pending3DS, .status.Initiated { background: #feeccc; color: var(--warn); }
.status.Reconciled, .status.Completed, .status.Authenticated, .status.Released { background: var(--success-bg); color: var(--success-ink); }
.status.Generated, .status.Queued { background: var(--info-bg); color: var(--deep); }

@media (max-width: 980px) {
  .mod-hero,
  .form-grid.dense-2,
  .method-grid,
  .txn-card,
  .inbox-card {
    grid-template-columns: 1fr;
  }
  .mod-hero-aside,
  .txn-aside,
  .inbox-aside {
    justify-items: start;
    text-align: left;
  }
  .seg-tabs .seg-tabs-actions {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 980px) {
  .auth-screen, .two-col, .three-col, .kpi-grid {
    grid-template-columns: 1fr;
  }
  .auth-hero {
    padding: 1.5rem 1.2rem 2rem;
  }
  .auth-card {
    padding: 1rem;
  }
  .auth-grid-2,
  .welcome-banner {
    grid-template-columns: 1fr;
  }
  .welcome-banner {
    display: grid;
  }
  .hero-topbar,
  .hero-actions,
  .hero-panels,
  .auth-inline-note,
  .hero-top-actions {
    display: grid;
  }
  .auth-hero h1 {
    font-size: 2.1rem;
  }
  .auth-card-shell {
    padding: 1.25rem;
    border-radius: 20px;
  }
}

.leaflet-host {
  height: 380px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #dfe9f5;
  z-index: 1;
}

.maps-suggest {
  display: grid;
  gap: 0.25rem;
  max-height: 160px;
  overflow: auto;
}

.maps-suggest button {
  width: 100%;
  text-align: left;
  background: #f7fbff;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 500;
  padding: 0.45rem 0.6rem;
}

.maps-suggest button:hover {
  background: var(--soft);
  color: var(--deep);
}

.maps-suggest small {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
}

/* ── Mobile / web-view layout ─────────────────────────────── */
html { -webkit-text-size-adjust: 100%; }

.nav-toggle,
.nav-backdrop,
.mobile-tabbar { display: none; }

.table-scroll { width: 100%; max-width: 100%; }

@media (max-width: 980px) {
  html, body { overflow-x: hidden; height: 100%; }
  body.portal-open { overflow: hidden; height: 100%; }
  body.nav-open { overflow: hidden; }

  .layout:not(.hidden) {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .workspace {
    margin-left: 0;
    width: 100%;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    padding: 0;
  }

  .workspace-body {
    padding: 0.85rem 0.75rem calc(4.6rem + env(safe-area-inset-bottom));
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70;
    width: min(84vw, 300px);
    height: 100dvh;
    max-height: none;
    padding: calc(1rem + env(safe-area-inset-top)) 0.85rem calc(1rem + env(safe-area-inset-bottom));
    transform: translateX(-102%);
    transition: transform 0.24s ease;
    box-shadow: 12px 0 32px rgba(4, 16, 36, 0.35);
    overscroll-behavior: contain;
  }
  body.nav-open .sidebar { transform: translateX(0); }

  .nav-backdrop,
  .layout > .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(4, 16, 36, 0.48);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }

  .nav-btn { padding: 0.72rem 0.75rem; font-size: 0.86rem; }

  .topbar {
    position: relative;
    z-index: 50;
    margin: 0;
    padding: calc(0.55rem + env(safe-area-inset-top)) 0.75rem 0.55rem;
    background: rgba(238, 245, 252, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    gap: 0.4rem;
  }
  .topbar-title { width: 100%; gap: 0.55rem; }
  .topbar-title > div { min-width: 0; }
  .topbar-logo { width: 30px; height: 30px; border-radius: 8px; }
  .topbar h2 { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar p {
    font-size: 0.72rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .topbar .alert-strip:empty { display: none; }
  .alert-strip { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .alert-strip::-webkit-scrollbar { display: none; }
  .alert-strip > * { flex-shrink: 0; }

  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border-radius: 10px;
    background: var(--card);
    border: 1px solid var(--line);
  }
  .nav-toggle:hover { background: var(--soft); }
  .nav-toggle span {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: var(--navy);
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  body.nav-open .nav-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  body.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
  body.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  .portal-toast { top: calc(4.4rem + env(safe-area-inset-top)); }

  .mobile-tabbar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    padding: 0.3rem 0.3rem calc(0.3rem + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 18px rgba(1, 86, 232, 0.08);
  }
  .tab-item {
    display: grid;
    justify-items: center;
    gap: 0.15rem;
    padding: 0.35rem 0.1rem;
    background: transparent;
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 600;
    border-radius: 10px;
  }
  .tab-item:hover { background: var(--soft); color: var(--deep); }
  .tab-item svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .tab-item.active { color: var(--primary); background: var(--info-bg); }

  /* Grid items default to min-width:auto, which lets a wide table stretch the whole column */
  .view.active { grid-template-columns: minmax(0, 1fr); }
  .view > *, .two-col > *, .three-col > *, .kpi-grid > *, .card, .stack > *, .form-grid > * { min-width: 0; }
  .form-grid, .stack { grid-template-columns: minmax(0, 1fr); }
  input[type="file"] { max-width: 100%; }

  /* Grids collapse */
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; }
  .two-col, .three-col, .plan-grid, .mod-hero, .method-grid,
  .form-grid.dense-2, .auth-grid-2, .welcome-banner { grid-template-columns: 1fr; }
  .form-grid.dense-2 .span-2 { grid-column: auto; }

  .kpi, .card { padding: 0.75rem; border-radius: 12px; }
  .kpi strong { font-size: 1.05rem; word-break: break-word; }

  .card-head { flex-wrap: wrap; }
  .welcome-actions > * { flex: 1 1 100%; }

  /* Touch-friendly controls; 16px stops iOS zooming into inputs */
  input, select, textarea { font-size: 16px; min-height: 42px; }
  input[type="checkbox"], input[type="radio"] { min-height: 0; width: auto; }
  button { min-height: 40px; }
  .row-actions button { min-height: 34px; padding: 0.35rem 0.6rem; font-size: 0.72rem; }

  .toolbar input, .toolbar select, .toolbar button { min-width: 0; flex: 1 1 calc(50% - 0.4rem); }

  /* Segmented tabs scroll horizontally instead of wrapping into many rows */
  .seg-tabs, .seg, .tab-bar, .admin-tab-bar {
    display: flex;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .seg-tabs::-webkit-scrollbar, .seg::-webkit-scrollbar, .tab-bar::-webkit-scrollbar, .admin-tab-bar::-webkit-scrollbar { display: none; }
  .seg-tabs button, .seg button, .tab-bar button, .admin-tab-bar button { flex-shrink: 0; white-space: nowrap; width: auto; }
  .seg-tabs .seg-tabs-actions { flex-shrink: 0; width: auto; }

  /* Tables */
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.75rem;
    padding: 0 0.75rem;
  }
  .table-scroll table { min-width: 560px; }
  .table th, .table td { white-space: nowrap; }

  .leaflet-host { height: 300px; }
  canvas { max-width: 100%; }
}

@media (max-width: 600px) {
  .toolbar input, .toolbar select, .toolbar button { flex-basis: 100%; }
  .auth-hero h1 { font-size: 1.55rem; line-height: 1.2; }
  .auth-hero { padding: calc(1.1rem + env(safe-area-inset-top)) 1rem 1.4rem; }
  .auth-card { padding: 0.75rem 0.75rem calc(1rem + env(safe-area-inset-bottom)); }
  .auth-card-shell { padding: 1rem; }
  .hero-panels { display: none; }
  /* Sign-in form first on phones; the marketing hero follows below */
  .auth-screen { display: flex; flex-direction: column; }
  .auth-card { order: -1; padding-top: calc(0.9rem + env(safe-area-inset-top)); }
  .auth-hero .hero-top-actions,
  .auth-hero .hero-actions { display: none; }
  .auth-hero h1 { font-size: 1.3rem; }
  .hero-note { font-size: 0.75rem; }
  .card h3 { font-size: 0.9rem; }
}

@media (max-width: 360px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .tab-item span { font-size: 0.6rem; }
}
