:root {
  --navy-900: #0B2B63;
  --navy-700: #17457E;
  --blue-600: #1E67C6;
  --teal-600: #11A998;
  --teal-700: #087A70;
  --mint-100: #DDF8F1;
  --blue-100: #E7F0FC;
  --violet-100: #EEF0FF;
  --warning-700: #8A6100;
  --warning-100: #FFF3CE;
  --danger-700: #B42318;
  --danger-100: #FFE4E3;
  --text: #10244A;
  --text-2: #5A6C88;
  --border: #DDE6F1;
  --background: #FBFDFF;
  --white: #FFFFFF;

  --bg: var(--background);
  --surface: var(--white);
  --surface-2: #F4F8FC;
  --ink: var(--text);
  --muted: var(--text-2);
  --line: var(--border);
  --line-strong: #C7D5E6;
  --accent: var(--teal-600);
  --accent-dark: var(--teal-700);
  --accent-soft: var(--mint-100);
  --good: var(--teal-700);
  --good-soft: var(--mint-100);
  --warn: var(--warning-700);
  --warn-soft: var(--warning-100);
  --danger: var(--danger-700);
  --danger-soft: var(--danger-100);
  --sidebar: var(--navy-900);
  --sidebar-2: #081F48;
  --sidebar-text: #F5F9FF;
  --shadow: 0 18px 48px rgba(11,43,99,.08);
  --radius: 18px;
  --radius-sm: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 12% 14%, rgba(30,103,198,.10), transparent 30%),
    radial-gradient(circle at 88% 84%, rgba(17,169,152,.10), transparent 32%),
    linear-gradient(145deg, #FBFDFF, #F1F6FC);
}
.auth-card {
  position: relative;
  width: min(100%, 520px);
  overflow: hidden;
  background: rgba(255,255,255,.98);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 28px 80px rgba(11,43,99,.12);
  padding: 40px;
}
.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--navy-900), var(--blue-600), var(--teal-600));
}
.brand { user-select: none; }
.brand-word {
  display: inline-flex;
  align-items: center;
  color: var(--navy-900);
  font-weight: 900;
  letter-spacing: .10em;
  font-size: 30px;
  line-height: 1;
}
.brand-large .brand-word { font-size: 42px; }
.brand-target {
  position: relative;
  width: .78em;
  height: .78em;
  margin: 0 .045em 0 -.015em;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--teal-600) 0 64deg, var(--navy-900) 64deg 360deg);
}
.brand-target::after {
  content: "";
  position: absolute;
  inset: 19%;
  border-radius: 50%;
  background: var(--white);
}
.brand-target::before {
  content: "";
  position: absolute;
  z-index: 1;
  width: 22%;
  height: 22%;
  left: 39%;
  top: 39%;
  border-radius: 50%;
  background: var(--teal-600);
}
.brand-tag {
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: .28em;
  color: var(--muted);
  font-weight: 800;
}
.auth-copy { margin: 38px 0 28px; }
.auth-copy h1 { margin: 8px 0 10px; color: var(--navy-900); font-size: 30px; line-height: 1.12; }
.auth-copy p { margin: 0; color: var(--text-2); font-size: 15px; line-height: 1.55; }
.eyebrow {
  display: inline-block;
  color: var(--teal-700);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .16em;
}
.auth-note, .security-note, .hint {
  color: var(--muted);
  font-size: 12px;
}
.auth-note {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.stack-form, .form-grid { display: grid; gap: 14px; }
.stack-form label, .form-grid label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
}
input, select {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  background: var(--white);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input:focus, select:focus {
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(30,103,198,.12);
}
.form-error { margin: 0; color: var(--danger); font-size: 12px; font-weight: 700; }

.btn {
  border: 0;
  min-height: 48px;
  border-radius: 15px;
  padding: 11px 16px;
  font-weight: 750;
  transition: transform .12s ease, opacity .12s ease, background .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .48; cursor: not-allowed; transform: none; }
.btn-primary { min-height: 56px; background: var(--navy-900); color: var(--white); box-shadow: 0 10px 24px rgba(11,43,99,.15); }
.btn-primary:hover { background: var(--navy-700); }
.btn-secondary { background: var(--surface-2); color: var(--navy-900); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: inherit; border: 1px solid var(--line); }
.btn-warning { background: var(--warning-100); color: var(--warning-700); border: 1px solid #E8CF8A; }
.btn-danger { background: var(--danger); color: white; }
.btn-small { min-height: 34px; padding: 7px 11px; font-size: 12px; }
.full { width: 100%; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0,1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, var(--navy-900), var(--sidebar-2));
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
}
.sidebar-brand { padding: 4px 8px 26px; }
.sidebar-brand .brand-word { color: var(--white); }
.sidebar-brand .brand-target {
  background: conic-gradient(var(--teal-600) 0 64deg, var(--white) 64deg 360deg);
}
.sidebar-brand .brand-target::after { background: var(--navy-900); }
.brand-compact { font-size: 23px; }
.sidebar-label { display: block; color: #B9CBE3; font-size: 11px; margin-top: 7px; letter-spacing: .06em; }
.nav-list { display: grid; gap: 7px; }
.nav-item {
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #C7D5E6;
  min-height: 46px;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  text-align: left;
  padding: 8px 10px;
  font-weight: 750;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: var(--white); }
.nav-item.active { background: var(--blue-100); color: var(--navy-900); }
.nav-glyph { font-size: 10px; opacity: .6; font-variant-numeric: tabular-nums; }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; padding: 16px 4px 4px; }
.sidebar-footer .btn-ghost { color: #EAF2FC; border-color: rgba(255,255,255,.22); }
.session-indicator { display: flex; gap: 8px; align-items: center; color: #C7D5E6; font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal-600); box-shadow: 0 0 0 4px rgba(17,169,152,.14); }

.main { min-width: 0; padding: 0 34px 44px; }
.topbar {
  min-height: 104px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.topbar h1 { margin: 4px 0 0; font-size: 27px; }
.topbar-actions { display: flex; gap: 10px; }
.panel { display: none; }
.active-panel { display: block; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 19px;
  box-shadow: var(--shadow);
}
.metric-card span { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-card strong { display: block; margin: 7px 0 3px; font-size: 31px; line-height: 1; }
.metric-card small { color: var(--text-2); }
.metric-accent { background: var(--navy-900); border-color: var(--navy-900); color: var(--white); }
.metric-accent span, .metric-accent small { color: #C7D5E6; }
.metric-accent strong { color: #7BE0D5; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}
.span-2 { grid-column: span 2; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.card-head h2, .section-intro h2, .subsection h3 { margin: 3px 0 0; }
.card-head h2, .section-intro h2 { font-size: 20px; }
.mini-kpis { display: flex; gap: 16px; color: var(--muted); font-size: 11px; }
.mini-kpis b { color: var(--ink); display: block; font-size: 16px; }

.growth-chart {
  min-height: 210px;
  display: grid;
  grid-template-columns: repeat(30,minmax(3px,1fr));
  gap: 4px;
  align-items: end;
  padding: 12px 0 8px;
}
.chart-bar {
  height: 100%;
  min-height: 150px;
  display: flex;
  gap: 2px;
  align-items: end;
}
.chart-bar i { flex: 1; display: block; border-radius: 4px 4px 1px 1px; min-height: 2px; }
.chart-bar .new { background: #d5cbc0; }
.chart-bar .active { background: var(--accent); }
.chart-legend { display: flex; gap: 16px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.legend-new { background: #d5cbc0; }
.legend-active { background: var(--accent); }

.product-list, .location-list, .membership-list { display: grid; gap: 9px; }
.product-row, .location-row, .membership-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
}
.product-row strong { font-size: 16px; }
.product-badge { font-size: 10px; font-weight: 900; color: var(--accent-dark); background: var(--accent-soft); border-radius: 999px; padding: 5px 8px; }
.empty-slot, .empty-state { color: var(--muted); padding: 20px 4px; }
.stat-lines { display: grid; gap: 12px; }
.stat-lines div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 9px; }
.stat-lines div:last-child { border-bottom: 0; }
.stat-lines span { color: var(--muted); }
.stat-lines strong { font-size: 18px; }

.growth-chart {
  height: 145px;
  display: flex;
  align-items: end;
  gap: 4px;
  padding: 14px 4px 0;
  border-bottom: 1px solid var(--border);
}
.growth-day {
  position: relative;
  flex: 1;
  min-width: 4px;
  height: 100%;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 1px;
}
.growth-bar { width: 42%; min-width: 2px; border-radius: 4px 4px 0 0; }
.growth-bar.new { background: var(--blue-600); opacity: .62; }
.growth-bar.active { background: var(--teal-600); }
.chart-legend { display: flex; gap: 16px; margin-top: 10px; color: var(--text-2); font-size: 11px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.legend-new { background: var(--blue-600); opacity: .62; }
.legend-active { background: var(--teal-600); }
.product-list { display: grid; gap: 10px; }
.product-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 13px; background: var(--surface);
}
.product-row span { color: var(--text-2); font-size: 12px; }
.product-row strong { color: var(--navy-900); }
.empty-slot { color: var(--text-2); font-size: 13px; padding: 8px 0; }
.stat-lines { display: grid; gap: 1px; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.stat-lines div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 14px; background: var(--white); }
.stat-lines div + div { border-top: 1px solid var(--border); }
.stat-lines span { color: var(--text-2); }
.stat-lines strong { color: var(--navy-900); }

.section-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px;
}
.search-wrap { width: min(420px, 100%); }
.search-input { min-height: 44px; }
.select-input { min-height: 44px; width: auto; min-width: 150px; }
.filter-row { flex: 1; display: flex; gap: 10px; flex-wrap: wrap; }
.filter-row .search-input { width: min(360px, 100%); }
.split-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, .8fr); gap: 18px; align-items: start; }
.user-split { grid-template-columns: minmax(0, 1.35fr) minmax(350px, .9fr); }
.list-card { overflow: hidden; }
.detail-card { position: sticky; top: 20px; padding: 20px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 620px; }
.data-table th {
  padding: 13px 15px;
  color: var(--text-2);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.data-table td { padding: 14px 15px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: #fbfdff; }
.data-table tbody tr.selected { background: #f3f8ff; box-shadow: inset 3px 0 0 var(--blue-600); }
.primary-cell { font-weight: 720; color: var(--navy-900); }
.secondary-cell { color: var(--text-2); font-size: 12px; margin-top: 3px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; }
.mini-chip, .status-chip {
  display: inline-flex; align-items: center; min-height: 27px; padding: 3px 9px;
  border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 11px; font-weight: 700;
}
.status-chip.active, .status-chip.online { color: var(--teal-700); background: var(--mint-100); }
.status-chip.locked { color: var(--warning-700); background: var(--warning-100); }
.status-chip.disabled { color: var(--danger-700); background: var(--danger-100); }
.online-badge { display: inline-flex; align-items: center; gap: 6px; color: var(--teal-700); font-size: 12px; font-weight: 700; }
.online-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--teal-600); }
.offline-badge { color: var(--text-2); font-size: 12px; }
.empty-state { padding: 32px; text-align: center; color: var(--text-2); }
.table-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.table-pager .hint { margin: 0; }

.section-toolbar, .section-intro {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 15px;
}
.section-intro p { max-width: 580px; margin: 0; color: var(--muted); }
.filter-row { display: flex; gap: 9px; flex-wrap: wrap; }
.search-wrap { min-width: min(420px,100%); }
.search-input { min-width: 240px; }
.select-input { min-width: 160px; }

.split-layout {
  display: grid;
  grid-template-columns: minmax(0,1.3fr) minmax(320px,.7fr);
  gap: 16px;
  align-items: start;
}
.user-split { grid-template-columns: minmax(0,1.25fr) minmax(360px,.75fr); }
.list-card { padding: 0; overflow: hidden; }
.table-wrap { overflow: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th, .data-table td {
  padding: 13px 15px;
  border-bottom: 1px solid #eee7df;
  vertical-align: middle;
  text-align: left;
}
.data-table th {
  color: var(--muted);
  background: #fbf8f3;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.data-table tbody tr { transition: background .12s ease; }
.data-table tbody tr:hover { background: #fbf6f0; }
.data-table tbody tr.selected { background: var(--accent-soft); }
.table-primary { font-weight: 800; }
.table-secondary { color: var(--muted); font-size: 11px; margin-top: 2px; }
.app-chip-row { display: flex; flex-wrap: wrap; gap: 5px; }
.app-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #eee8e0;
  color: #554f48;
  font-size: 10px;
  font-weight: 800;
}

.detail-card { position: sticky; top: 18px; }
.detail-meta {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 9px;
  margin-bottom: 18px;
}
.meta-item {
  background: var(--surface-2);
  border: 1px solid #ebe3da;
  border-radius: 11px;
  padding: 10px 11px;
}
.meta-item span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 3px; }
.meta-item strong { display: block; word-break: break-word; }
.subsection { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.subsection-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 11px; }
.subsection-head h3 { font-size: 15px; }
.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 10px;
  font-weight: 900;
  background: #eee8df;
  color: #5b554e;
}
.status-chip.active { background: var(--good-soft); color: var(--good); }
.status-chip.locked { background: var(--warn-soft); color: var(--warn); }
.status-chip.disabled, .status-chip.revoked { background: var(--danger-soft); color: var(--danger); }

.toggle-grid { display: grid; gap: 8px; }
.toggle-row {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.toggle-row label { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.switch {
  appearance: none;
  width: 38px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: #c8c0b6;
  position: relative;
  padding: 0;
}
.switch::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: white;
  transition: transform .16s ease;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }

.location-row { align-items: flex-start; }
.location-row .location-main { min-width: 0; }
.location-row .location-main strong { display: block; }
.location-row .location-main span { color: var(--muted); font-size: 11px; }

.credential-card {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 8px;
}
.credential-card .meta-item { background: #fff; }
.danger-zone { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); padding-top: 17px; margin-top: 18px; }

.membership-card {
  align-items: stretch;
  flex-direction: column;
}
.membership-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.membership-access-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.membership-access-grid fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 0;
  padding: 9px;
}
.membership-access-grid legend { color: var(--muted); font-size: 10px; font-weight: 800; }
.inline-checks { display: flex; flex-wrap: wrap; gap: 7px; }
.inline-checks label { display: inline-flex; gap: 5px; align-items: center; font-size: 11px; }
.inline-checks input { width: auto; min-height: auto; }

.module-grid {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 14px;
}
.module-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.module-card h3 { margin: 8px 0 4px; font-size: 18px; }
.module-card p { margin: 0; color: var(--muted); }
.module-code { color: var(--accent-dark); font-size: 10px; font-weight: 900; letter-spacing: .08em; }

.modal {
  width: min(620px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 32px 100px rgba(23,19,15,.28);
  padding: 0;
  color: var(--ink);
}
.modal::backdrop { background: rgba(24,20,17,.52); backdrop-filter: blur(3px); }
.modal-wide { width: min(820px, calc(100vw - 28px)); }
.modal form { padding: 24px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.modal-head h2 { margin: 4px 0 0; }
.icon-close {
  border: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #eee7df;
  color: #5b544d;
  font-size: 22px;
  line-height: 1;
}
.form-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.check-fieldset {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px;
  margin: 15px 0 0;
}
.check-fieldset legend { color: var(--muted); font-size: 11px; font-weight: 800; padding: 0 6px; }
.check-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.check-grid.vertical { grid-template-columns: 1fr; }
.check-grid label, .check-line {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 650 !important;
}
.check-grid input, .check-line input { width: auto; min-height: auto; }
.dialog-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.credential-fields { margin-top: 15px; }
.security-note {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f6f1ea;
  border: 1px solid var(--line);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

.toast {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  max-width: min(380px, calc(100vw - 30px));
  background: #211d19;
  color: white;
  border-radius: 12px;
  padding: 11px 14px;
  box-shadow: 0 16px 50px rgba(0,0,0,.24);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8e302c; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .module-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .split-layout, .user-split { grid-template-columns: 1fr; }
  .detail-card { position: static; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 14px; }
  .sidebar-brand { padding: 3px 4px 12px; }
  .nav-list { grid-template-columns: repeat(4,1fr); overflow-x: auto; }
  .nav-item { grid-template-columns: 1fr; text-align: center; min-width: 90px; }
  .nav-glyph { display: none; }
  .sidebar-footer { display: none; }
  .main { padding: 0 14px 30px; }
  .topbar { min-height: 84px; }
  .metric-grid, .dashboard-grid, .module-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .section-toolbar, .section-intro { align-items: stretch; flex-direction: column; }
  .filter-row { display: grid; grid-template-columns: 1fr; }
  .search-input, .select-input { min-width: 0; }
  .form-grid, .dialog-columns, .membership-access-grid, .detail-meta, .credential-card { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .check-grid { grid-template-columns: 1fr; }
  .growth-chart { gap: 2px; }
  .auth-shell { padding: 14px; }
  .auth-card { padding: 25px; border-radius: 22px; }
}

.detail-meta { display: grid; gap: 8px; margin-bottom: 18px; }
.meta-line { display: flex; justify-content: space-between; gap: 18px; color: var(--text-2); font-size: 12px; }
.meta-line strong { color: var(--text); font-weight: 650; text-align: right; word-break: break-word; }
.subsection { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--border); }
.subsection-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.hint { color: var(--text-2); font-size: 11px; }
.toggle-grid { display: grid; gap: 8px; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 13px; background: var(--background);
}
.toggle-copy strong { display: block; font-size: 13px; }
.toggle-copy span { color: var(--text-2); font-size: 11px; }
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #cad5e4; cursor: pointer; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; top: 3px; left: 3px; border-radius: 50%; background: white; box-shadow: 0 1px 5px rgba(0,0,0,.18); transition: .15s; }
.switch input:checked + span { background: var(--teal-600); }
.switch input:checked + span::after { transform: translateX(18px); }
.location-list, .membership-list { display: grid; gap: 8px; }
.location-item, .membership-item {
  padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--background);
}
.location-item-head, .membership-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.location-item strong, .membership-item strong { color: var(--navy-900); }
.location-item p, .membership-item p { color: var(--text-2); font-size: 12px; margin: 4px 0 0; }
.membership-actions { margin-top: 10px; display: flex; justify-content: flex-end; }

.credential-card { padding: 13px; border-radius: 14px; background: var(--surface); display: grid; gap: 7px; }
.credential-line { display: flex; justify-content: space-between; gap: 14px; font-size: 12px; }
.credential-line span { color: var(--text-2); }
.danger-zone { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--border); }
.section-intro { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.section-intro p { max-width: 580px; margin: 0; color: var(--text-2); }
.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.module-card { padding: 18px; border: 1px solid var(--border); border-radius: 18px; background: var(--white); }
.module-card-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.module-code { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: var(--blue-100); color: var(--navy-900); font-size: 12px; font-weight: 850; }
.module-card h3 { color: var(--navy-900); margin: 0 0 3px; }
.module-card p { color: var(--text-2); font-size: 12px; margin: 0; }
.module-card-meta { display: flex; gap: 7px; flex-wrap: wrap; }

.company-settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 18px 0 4px;
}
.company-setting-card {
  appearance: none;
  width: 100%;
  min-height: 112px;
  display: grid;
  grid-template-columns: 48px minmax(0,1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: linear-gradient(145deg, var(--white), var(--background));
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(11,43,99,.05);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.company-setting-card:hover {
  border-color: #AEC7E5;
  box-shadow: 0 12px 30px rgba(11,43,99,.10);
  transform: translateY(-1px);
}
.company-setting-card:focus-visible {
  outline: 3px solid rgba(30,103,198,.18);
  outline-offset: 2px;
}
.company-setting-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--blue-100);
  color: var(--navy-900);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
}
.company-setting-copy { min-width: 0; display: grid; gap: 5px; }
.company-setting-copy strong { color: var(--navy-900); font-size: 14px; }
.company-setting-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.company-setting-summary {
  display: block;
  max-width: 100%;
  color: var(--text-2);
  font-size: 11px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.company-setting-action { color: var(--blue-600); font-size: 12px; font-weight: 800; white-space: nowrap; }

.modal.company-editor-dialog { width: min(880px, calc(100vw - 32px)); }
.company-editor-dialog form {
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.company-editor-grid { align-items: start; }
.modal-lead {
  margin: -8px 0 18px;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.55;
}
.subscription-modal-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: -6px 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--background);
  color: var(--text-2);
  font-size: 12px;
}
.modal-divider { height: 1px; margin: 22px 0 18px; background: var(--border); }
.modal-section-head { margin-top: 18px; }
.modal-summary { margin-bottom: 18px; }
.modal-history { max-height: 240px; overflow-y: auto; padding-right: 4px; }
.company-editor-dialog .modal-actions {
  position: sticky;
  bottom: -24px;
  z-index: 3;
  margin-left: -2px;
  margin-right: -2px;
  padding: 14px 2px 6px;
  background: linear-gradient(180deg, rgba(255,255,255,0), var(--white) 26%);
}

.modal {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: var(--text);
  background: var(--white);
  box-shadow: 0 24px 70px rgba(11,43,99,.22);
}
.modal::backdrop { background: rgba(9,28,61,.38); backdrop-filter: blur(2px); }
.modal form { padding: 24px; }
.modal-wide { width: min(820px, calc(100vw - 32px)); }
.modal-small { width: min(480px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.icon-close {
  width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--white); cursor: pointer; color: var(--text-2); font-size: 22px; line-height: 1;
}
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.form-grid label { min-width: 0; }
.check-fieldset {
  margin: 18px 0 0; padding: 14px; border: 1px solid var(--border); border-radius: 15px;
}
.check-fieldset legend { padding: 0 5px; color: var(--text-2); font-size: 12px; font-weight: 700; }
.check-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.check-grid.vertical { grid-template-columns: 1fr; }
.check-item {
  min-height: 40px; display: flex; align-items: center; gap: 9px; padding: 7px 9px;
  border-radius: 11px; background: var(--surface); color: var(--text); font-size: 12px;
}
.check-item input, .check-line input { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--teal-600); }
.check-line { min-height: 48px; display: flex; align-items: center; gap: 9px; }
.check-line > span { margin: 0; color: var(--text); }
.dialog-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dialog-columns .check-fieldset { margin-top: 14px; }
.credential-fields { margin-top: 14px; }
.security-note { margin: 13px 0 0; color: var(--text-2); font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.toast {
  position: fixed; z-index: 1000; right: 24px; bottom: 24px;
  max-width: min(420px, calc(100vw - 48px)); padding: 12px 16px;
  border-radius: 14px; color: var(--white); background: var(--navy-900);
  box-shadow: var(--shadow); transform: translateY(20px); opacity: 0; pointer-events: none;
  transition: .2s;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--danger-700); }
.toast.success { background: var(--teal-700); }
.loading-row { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px; color: var(--text-2); }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--blue-600);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  :root { --sidebar: 220px; }
  .main { padding-left: 24px; padding-right: 24px; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .module-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .split-layout, .user-split { grid-template-columns: 1fr; }
  .detail-card { position: static; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: auto; padding: 15px; }
  .sidebar-brand { padding: 2px 4px 14px; }
  .nav-list { grid-template-columns: repeat(4,1fr); gap: 5px; }
  .nav-item { grid-template-columns: 1fr; min-height: 50px; text-align: center; padding: 6px; font-size: 11px; }
  .nav-glyph { display: none; }
  .sidebar-footer { margin-top: 12px; grid-template-columns: 1fr auto; align-items: center; }
  .sidebar-footer .full { width: auto; }
  .main { padding: 20px 15px 36px; }
  .topbar { min-height: 60px; margin-bottom: 16px; }
  .metric-grid, .dashboard-grid, .module-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .section-toolbar, .section-intro { align-items: stretch; flex-direction: column; }
  .filter-row { display: grid; grid-template-columns: 1fr; }
  .filter-row .search-input, .select-input { width: 100%; }
  .form-grid, .dialog-columns, .check-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .auth-shell { padding: 16px; }
  .auth-card { padding: 26px 20px; }
}

.growth-svg {
  width: 100%;
  height: 145px;
  display: block;
}
.growth-svg .new {
  fill: var(--blue-600);
  opacity: .62;
}
.growth-svg .active {
  fill: var(--teal-600);
}

.membership-authorities { margin-top: 8px; }


@media (max-width: 760px) {
  .company-settings-grid { grid-template-columns: 1fr; }
  .company-setting-card {
    min-height: 104px;
    grid-template-columns: 44px minmax(0,1fr);
  }
  .company-setting-icon { width: 44px; height: 44px; }
  .company-setting-action {
    grid-column: 2;
    justify-self: start;
  }
  .company-editor-dialog { width: calc(100vw - 20px); }
  .company-editor-dialog form {
    max-height: calc(100vh - 20px);
    padding: 20px 16px;
  }
}
