:root {
  --bg: #f0f4f9;
  --bg-accent: #e4ecf5;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-raised: #ffffff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #0f2744;
  --primary-hover: #163a66;
  --primary-2: #0a1c30;
  --accent: #0d9488;
  --accent-soft: #ccfbf1;
  --accent-glow: rgba(13, 148, 136, 0.15);
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --ok: #059669;
  --shadow-sm: 0 1px 3px rgba(15, 39, 68, 0.06);
  --shadow: 0 8px 30px rgba(15, 39, 68, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 39, 68, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.18s ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(13, 148, 136, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(15, 39, 68, 0.05), transparent);
  color: var(--text);
  font-family: "Plus Jakarta Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button {
  border: 0;
}

a {
  color: inherit;
}

/* ── Login ── */

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(380px, 46%) minmax(420px, 1fr);
}

.login-brand {
  background: linear-gradient(165deg, #0f2744 0%, #0a1c30 42%, #064e3b 100%);
  color: #fff;
  padding: 52px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.login-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 85%, rgba(13, 148, 136, 0.32), transparent 45%),
    radial-gradient(circle at 85% 15%, rgba(255, 255, 255, 0.07), transparent 38%);
  pointer-events: none;
}

.login-brand::after {
  content: "";
  position: absolute;
  right: -120px;
  bottom: -120px;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.login-brand > * {
  position: relative;
  z-index: 1;
}

.login-brand-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.login-brand-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.88);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #fff 0%, #e2e8f0 100%);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 26px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  flex-shrink: 0;
}

.login-brand h1 {
  font-size: 38px;
  line-height: 1.1;
  margin: 0 0 14px;
  font-weight: 800;
  letter-spacing: -0.03em;
  max-width: 420px;
}

.login-brand-top p {
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.7;
  max-width: 460px;
  font-size: 15px;
  margin: 0;
}

.login-features {
  list-style: none;
  margin: 32px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.login-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  font-weight: 600;
}

.login-feature-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.22);
  flex-shrink: 0;
}

.login-brand-foot {
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  margin: 0;
}

.login-brand-compact .login-brand-top p,
.login-brand-compact .login-features,
.login-brand-compact .login-brand-foot,
.login-api-hint,
.login-panel-note {
  display: none;
}

.login-panel {
  padding: 40px 48px;
  display: grid;
  place-items: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.login-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(13, 148, 136, 0.06), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(15, 39, 68, 0.04), transparent 35%);
  pointer-events: none;
}

.login-panel::after {
  content: "";
  position: absolute;
  inset: 24px;
  border: 1px dashed rgba(15, 39, 68, 0.07);
  border-radius: 20px;
  pointer-events: none;
}

.login-panel-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  display: grid;
  gap: 16px;
}

.login-card,
.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

.login-card {
  width: 100%;
  padding: 36px;
  display: grid;
  gap: 20px;
}

.login-card-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.login-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-soft) 0%, #e0f2fe 100%);
  color: var(--primary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.login-card-icon svg {
  width: 24px;
  height: 24px;
}

.login-card h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}

.login-card-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-api-band {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.login-api-band > label {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.login-api-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.login-api-row input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  background: #fff;
  font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.login-api-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-api-hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.login-fields {
  display: grid;
  gap: 14px;
}

.login-submit {
  width: 100%;
  min-height: 46px;
  font-size: 14px;
  margin-top: 4px;
}

.login-panel-note {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.login-card .notice {
  margin-bottom: 0;
}

.login-card .grid {
  margin-top: 20px;
  gap: 14px;
}

/* ── App Shell ── */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
}

#mainMount {
  min-width: 0;
}

.loading-skeleton {
  display: grid;
  gap: 16px;
  padding: 4px 0 12px;
}

.skeleton-panel {
  display: grid;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.skeleton-line {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--surface-soft) 0%, #e8edf4 50%, var(--surface-soft) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.skeleton-line.wide {
  width: 42%;
  height: 18px;
}

.skeleton-line.short {
  width: 28%;
}

@keyframes skeleton-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: linear-gradient(180deg, var(--primary-2) 0%, #061220 100%);
  color: #fff;
  padding: 20px 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 4px;
}

.sidebar-title {
  font-weight: 800;
  line-height: 1.2;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.sidebar-sub {
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 16px;
  padding-top: 14px;
}

.nav-section {
  display: grid;
  gap: 2px;
}

.nav-section-title {
  padding: 10px 12px 6px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav button {
  width: 100%;
  min-height: 44px;
  text-align: left;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  display: grid;
  gap: 1px;
  transition: background var(--transition), color var(--transition);
}

.nav button.active {
  background: rgba(13, 148, 136, 0.22);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav button:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-title {
  font-weight: 700;
  font-size: 13px;
  color: inherit;
}

.nav-sub {
  color: rgba(255, 255, 255, 0.45);
  font-size: 11px;
  line-height: 1.25;
}

.nav button.active .nav-sub,
.nav button:hover .nav-sub {
  color: rgba(255, 255, 255, 0.65);
}

#logoutBtn {
  margin-top: 8px;
  min-height: 42px;
  border-radius: var(--radius-sm);
  background: rgba(220, 38, 38, 0.15);
  color: #fca5a5;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition);
}

#logoutBtn:hover {
  background: rgba(220, 38, 38, 0.28);
  color: #fff;
}

.main {
  min-width: 0;
  padding: 28px 32px;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.grid {
  display: grid;
  gap: 16px;
}

.metrics {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.metric {
  padding: 20px;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.metric:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  font-size: 32px;
  font-weight: 800;
  margin-top: 8px;
  letter-spacing: -0.03em;
}

/* ── Dashboard ── */

.dashboard-hero {
  min-height: 220px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary) 0%, #0a1c30 45%, #065f46 100%);
  color: #fff;
  padding: 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  align-items: end;
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.dashboard-hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(13, 148, 136, 0.3), transparent 70%);
  pointer-events: none;
}

.dashboard-hero > * {
  position: relative;
  z-index: 1;
}

.hero-kicker {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  backdrop-filter: blur(4px);
}

.dashboard-hero h2 {
  max-width: 760px;
  margin: 16px 0 10px;
  font-size: 32px;
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.dashboard-hero p {
  max-width: 640px;
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.65;
  font-size: 14px;
}

.hero-status {
  min-height: 128px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.hero-status strong {
  font-size: 14px;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.hero-status small {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 14px;
}

.kpi-card {
  position: relative;
  min-height: 130px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  cursor: default;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}

.kpi-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.kpi-card::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  width: 4px;
  height: 100%;
  background: #94a3b8;
  border-radius: 0 4px 4px 0;
}

.kpi-card.success::after { background: var(--accent); }
.kpi-card.warning::after { background: #f59e0b; }
.kpi-card.danger::after { background: var(--danger); }

.kpi-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
  background: #94a3b8;
}

.kpi-card.success .kpi-dot { background: var(--accent); }
.kpi-card.warning .kpi-dot { background: #f59e0b; }
.kpi-card.danger .kpi-dot { background: var(--danger); }

.kpi-value {
  margin-top: 16px;
  font-size: 32px;
  line-height: 1;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
}

.kpi-label {
  margin-top: 8px;
  font-weight: 700;
  font-size: 14px;
}

.kpi-hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.quick-card:hover {
  border-color: var(--accent);
  background: #fff;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.quick-card {
  min-height: 92px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  padding: 16px;
  cursor: pointer;
  display: grid;
  align-content: start;
  gap: 6px;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.quick-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.quick-card strong {
  font-size: 14px;
  font-weight: 700;
}

.quick-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* ── Panels ── */

.panel {
  padding: 22px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.panel-sub {
  color: var(--muted);
  margin: 4px 0 0;
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.inline-select {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.inline-select select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 800;
  padding: 0 12px;
}

.inline-search {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.inline-search-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-search input {
  width: 160px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 700;
  padding: 0 12px;
}

.pincode-search-result {
  max-width: 480px;
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary-hover);
  font-weight: 800;
  cursor: pointer;
  text-align: left;
}

.link-button:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ── Buttons ── */

.btn {
  min-height: 40px;
  border-radius: var(--radius-sm);
  padding: 0 16px;
  background: linear-gradient(180deg, var(--primary-hover) 0%, var(--primary) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(15, 39, 68, 0.2);
}

.btn:hover:not(:disabled):not(.loading) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(15, 39, 68, 0.28);
}

.btn:active:not(:disabled):not(.loading) {
  transform: translateY(0);
}

.btn:disabled,
.btn.loading {
  opacity: 0.72;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

.btn.secondary {
  background: var(--surface-soft);
  color: var(--primary);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.btn.secondary:hover:not(:disabled):not(.loading) {
  background: #fff;
  border-color: var(--primary);
}

.btn.danger {
  background: linear-gradient(180deg, #ef4444 0%, var(--danger) 100%);
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}

.btn.ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

.btn.secondary .btn-spinner,
.btn.ghost .btn-spinner {
  border-color: rgba(15, 39, 68, 0.2);
  border-top-color: var(--primary);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Forms ── */

.field-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

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

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

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

.field-grid-status {
  grid-template-columns: minmax(0, 280px);
}

.field-span-all {
  grid-column: 1 / -1;
}

.field-hint,
.field-hint-inline {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  line-height: 1.4;
}

.field-hint {
  margin: 4px 0 0;
}

.field-hint-inline {
  display: block;
  margin-top: 2px;
  font-weight: 500;
}

.dealer-edit-form {
  display: grid;
  gap: 16px;
}

.dealer-edit-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(15, 39, 68, 0.06), rgba(20, 184, 166, 0.08));
}

.dealer-edit-badge-wrap {
  display: grid;
  gap: 6px;
}

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

.dealer-edit-badge {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--primary);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-family: "Plus Jakarta Sans", ui-monospace, monospace;
}

.dealer-edit-hero-copy {
  margin: 0;
  max-width: 420px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.dealer-edit-band {
  margin: 0;
  background: #fff;
}

.dealer-edit-band-status {
  max-width: 320px;
}

.dealer-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 4px;
}

.phone-field-compact .phone-row {
  align-items: center;
}

.phone-field-compact .phone-country,
.phone-field-compact .phone-national,
.phone-field-compact .field input,
.phone-field-compact .field select {
  min-height: 42px;
}

.panel-edit-dealer .panel-head {
  margin-bottom: 4px;
}

.dealer-profile-panel {
  display: grid;
  gap: 18px;
  border-color: rgba(13, 148, 136, 0.28);
}

.dealer-profile-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(15, 39, 68, 0.06), rgba(13, 148, 136, 0.08));
}

.dealer-profile-hero h2,
.dealer-profile-block h3 {
  margin: 0;
}

.dealer-profile-hero h2 {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.2;
}

.dealer-profile-meta,
.dealer-profile-stats,
.dealer-profile-grid {
  display: grid;
  gap: 12px;
}

.dealer-profile-meta {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.dealer-profile-meta div,
.dealer-profile-stat,
.dealer-profile-block {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.dealer-profile-meta div {
  display: grid;
  gap: 6px;
  padding: 13px 14px;
}

.dealer-profile-meta span,
.dealer-profile-stat span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dealer-profile-meta strong {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.dealer-profile-stats {
  grid-template-columns: repeat(6, minmax(130px, 1fr));
}

.dealer-profile-stat {
  display: grid;
  gap: 8px;
  min-height: 92px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.dealer-profile-stat strong {
  color: var(--primary);
  font-size: 28px;
  line-height: 1;
}

.dealer-profile-stat-success strong {
  color: var(--ok);
}

.dealer-profile-stat-warn strong {
  color: var(--warn);
}

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

.dealer-profile-block {
  min-width: 0;
  padding: 16px;
  background: var(--surface-soft);
}

.panel-head.compact {
  margin-bottom: 10px;
}

.panel-head.compact h3 {
  font-size: 16px;
}

.role-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.role-strip button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  background: var(--surface-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.role-strip button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.dispatch-type-strip {
  margin-top: 4px;
}

.dispatch-type-strip button {
  min-width: 140px;
  justify-content: center;
}

.form-band {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.form-band h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.form-band p,
.help-line {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.scanner-box {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(220px, 1fr);
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.scanner-box[hidden] { display: none; }

.scanner-box video {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  background: #061827;
  object-fit: cover;
}

.scanner-copy {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.scanner-copy strong {
  color: var(--text);
}

.replace-case-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.replace-case-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.replace-case-head h2 {
  margin: 4px 0;
  font-size: 19px;
  font-weight: 800;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
}

.detail-row {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.detail-row span,
.note-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-row strong {
  font-size: 14px;
  font-weight: 600;
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
}

.note-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.note-grid p {
  margin: 5px 0 0;
  line-height: 1.5;
  font-size: 13px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field input[readonly] {
  background: var(--surface-soft);
  color: var(--muted);
  cursor: not-allowed;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.phone-row {
  display: grid;
  grid-template-columns: minmax(132px, 0.95fr) minmax(0, 1.4fr);
  gap: 10px;
  align-items: stretch;
}

.phone-country,
.phone-national {
  min-height: 46px;
}

.phone-field .help-line {
  margin-top: 6px;
}

/* ── Tables ── */

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
  background: #fff;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

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

tbody tr:hover {
  background: #f8fafc;
}

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

/* ── Pills & Notices ── */

.pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
}

.pill.ok {
  background: var(--accent-soft);
  color: var(--ok);
}

.pill.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.notice {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: #92400e;
  border: 1px solid #fcd34d;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
}

.notice.success {
  background: var(--accent-soft);
  color: var(--ok);
  border-color: #6ee7b7;
}

.toast-stack {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 3000;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: #fff7ed;
  color: #92400e;
  border: 1px solid #f59e0b;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  opacity: 0;
  transform: translateX(18px);
  transition: opacity var(--transition), transform var(--transition);
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast.success {
  background: #ecfdf5;
  color: var(--ok);
  border-color: #34d399;
}

.empty {
  padding: 36px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pager-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pager-actions strong {
  color: var(--text);
  font-size: 13px;
}

.split {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(420px, 1.2fr);
  gap: 16px;
}

.stack {
  display: grid;
  gap: 16px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.actions select,
.actions input {
  min-height: 38px;
  max-width: 190px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  background: #fff;
  color: var(--text);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(720px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
  padding: 18px;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head {
  margin-bottom: 14px;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

.print-qr-table-wrap {
  max-height: 420px;
}

.print-qr-table {
  min-width: 560px;
}

.print-product-qty {
  width: 110px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  text-align: center;
  font-weight: 800;
}

.completion-profile-modal {
  width: min(980px, 100%);
}

.completion-profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.completion-profile-grid h3 {
  margin: 8px 0 10px;
  font-size: 14px;
  color: var(--text);
}

.completion-notes {
  margin-top: 12px;
}

.completion-proof-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #f8fafc;
}

.completion-proof-image {
  display: block;
  width: 100%;
  max-height: 620px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.completion-proof-empty {
  display: grid;
  min-height: 220px;
  place-items: center;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-align: center;
  background: #fff;
}

.api-row {
  display: flex;
  gap: 8px;
  align-items: end;
}

.api-row .field {
  flex: 1;
}

.muted {
  color: var(--muted);
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-soft) 0%, #dbeafe 100%);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 800;
  flex-shrink: 0;
}

.profile-name {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.profile-role {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
}

/* ── Responsive ── */

@media (max-width: 1100px) {
  .app-shell,
  .login-shell,
  .split,
  .scanner-box,
  .completion-profile-grid,
  .detail-grid,
  .note-grid,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .metrics,
  .field-grid,
  .field-grid-2,
  .field-grid-3,
  .kpi-grid,
  .quick-grid,
  .dealer-profile-meta,
  .dealer-profile-stats,
  .dealer-profile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dealer-edit-hero,
  .dealer-profile-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .dashboard-hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .main,
  .login-panel,
  .login-brand {
    padding: 20px;
  }

  .login-brand h1 {
    font-size: 30px;
  }

  .login-card {
    padding: 24px;
  }

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

  .login-panel::after {
    display: none;
  }

  .metrics,
  .field-grid,
  .field-grid-2,
  .field-grid-3,
  .nav,
  .kpi-grid,
  .quick-grid,
  .scanner-box,
  .completion-profile-grid,
  .dealer-profile-meta,
  .dealer-profile-stats,
  .dealer-profile-grid {
    grid-template-columns: 1fr;
  }

  .dealer-edit-band-status {
    max-width: none;
  }

  .dashboard-hero {
    padding: 22px;
  }

  .dashboard-hero h2 {
    font-size: 24px;
  }

  .topbar,
  .panel-head,
  .replace-case-head {
    flex-direction: column;
    align-items: stretch;
  }
}
