:root {
  --ink: #172033;
  --muted: #69758a;
  --line: #dde3ee;
  --soft: #f3f6fb;
  --panel: #ffffff;
  --brand: #174ea6;
  --brand-dark: #0f2f7e;
  --blue: #1677bd;
  --green: #1f9f6b;
  --orange: #ef7d22;
  --red: #d94b4b;
  --shadow: 0 18px 45px rgba(26, 39, 68, .09);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-family: Inter, Arial, sans-serif;
  line-height: 1.4;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15,47,126,.96), rgba(23,78,166,.86)),
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.16), transparent 32%);
}
.login-screen.hidden { display: none; }
.login-panel {
  display: grid;
  grid-template-columns: .85fr 1.15fr;
  width: min(880px, 100%);
  min-height: 520px;
  overflow: hidden;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(5, 18, 45, .35);
}
.login-brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 34px;
  color: #fff;
  background: linear-gradient(180deg, #101a78, #1f5f9e);
}
.login-brand .brand-icon {
  color: var(--brand-dark);
  background: #fff;
}
.login-brand strong,
.login-brand small {
  display: block;
}
.login-brand strong { font-size: 24px; }
.login-brand small {
  margin-top: 6px;
  color: rgba(255,255,255,.74);
}
.login-form {
  display: grid;
  align-content: center;
  gap: 15px;
  padding: 46px;
}
.login-form h1 {
  margin: 0;
  font-size: 30px;
}
.login-form p {
  margin: -6px 0 10px;
  color: var(--muted);
}
.login-form label {
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
}
.login-form input { margin-top: 7px; }
.login-demo {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 8px;
  color: var(--muted);
  background: #f3f7ff;
  font-size: 12px;
}
.login-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 5px;
}
.login-shortcuts button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #c8d8f3;
  border-radius: 7px;
  color: var(--brand);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 280px;
  padding: 18px 14px;
  color: #fff;
  background: linear-gradient(180deg, #101a78, #1f5f9e);
}
.portal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 12px 16px;
  color: #fff;
  text-decoration: none;
}
.brand-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #0f2f7e;
  background: #fff;
  font-weight: 800;
}
.portal-brand strong,
.portal-brand small { display: block; }
.portal-brand small { color: rgba(255,255,255,.68); font-size: 12px; }
.portal-nav {
  display: grid;
  gap: 5px;
  margin-top: 12px;
}
.portal-nav button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: rgba(255,255,255,.78);
  background: transparent;
  text-align: left;
  font-weight: 700;
}
.portal-nav span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: #dbeafe;
  background: rgba(255,255,255,.12);
  font-size: 16px;
  font-weight: 900;
}
.portal-nav button:hover,
.portal-nav button.active {
  color: #fff;
  background: rgba(255,255,255,.13);
}
.portal-nav button.active .nav-icon,
.portal-nav button:hover .nav-icon {
  color: var(--brand-dark);
  background: #fff;
}
.sidebar-note {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 16px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  background: rgba(255,255,255,.1);
}
.sidebar-note span,
.sidebar-note strong,
.sidebar-note small { display: block; }
.sidebar-note span { color: rgba(255,255,255,.64); font-size: 12px; }
.sidebar-note strong { margin: 4px 0 7px; font-size: 14px; }
.sidebar-note small { color: rgba(255,255,255,.68); font-size: 11px; }

.shell {
  min-height: 100vh;
  margin-left: 280px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 76px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(12px);
}
.topbar p,
.drawer-head p {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.topbar h1,
.drawer-head h2 {
  margin: 0;
  font-size: 23px;
  letter-spacing: 0;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.user-chip {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--brand-dark);
  font-weight: 800;
}
.icon-button,
.ghost-button,
.primary-button {
  min-height: 40px;
  border-radius: 8px;
  font-weight: 800;
}
.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  font-size: 18px;
}
.menu-button { display: none; }
.ghost-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  color: var(--brand);
  background: #fff;
}
.primary-button {
  padding: 0 16px;
  border: 0;
  color: #fff;
  background: var(--brand);
}
.primary-button:hover { background: var(--brand-dark); }
.full { width: 100%; }

.view {
  display: none;
  padding: 24px 28px 36px;
}
.view.active { display: block; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}
.metric-card,
.panel,
.dealer-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.metric-card {
  min-height: 128px;
  padding: 20px;
  border-top: 4px solid var(--brand);
}
.metric-card.accent { border-top-color: var(--orange); }
.metric-card.warning { border-top-color: var(--red); }
.metric-card.success { border-top-color: var(--green); }
.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.metric-card strong {
  display: block;
  margin: 10px 0 5px;
  font-size: 38px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(330px, .8fr);
  gap: 16px;
  margin-top: 16px;
}
.report-grid,
.package-layout,
.settings-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.report-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.full-row { grid-column: 1 / -1; }
.panel { padding: 18px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}
.panel-head.compact { align-items: flex-start; }
.panel h2,
.dealer-card h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}
.panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 190px 190px auto;
  gap: 10px;
}
input,
select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
input:focus,
select:focus {
  border-color: #88aee8;
  box-shadow: 0 0 0 3px rgba(23, 78, 166, .12);
}
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}
th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}
.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--brand);
  background: #eaf2ff;
  font-size: 11px;
  font-weight: 800;
}
.status.pending { color: #a85a00; background: #fff1df; }
.status.assigned { color: #087150; background: #e5f7ef; }
.status.done { color: #276642; background: #dff4e9; }
.status.cancelled { color: #a73535; background: #ffe8e8; }
.active-badge,
.link-code {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 7px;
  color: #087150;
  background: #e5f7ef;
  font-size: 11px;
  font-weight: 800;
}
.active-badge.passive { color: #a73535; background: #ffe8e8; }
.link-code { color: var(--brand); background: #eaf2ff; }
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.row-action {
  border: 1px solid #bbd1ef;
  border-radius: 7px;
  color: var(--brand);
  background: #fff;
  font-weight: 800;
  min-height: 32px;
  padding: 0 10px;
}
.row-action.danger {
  color: #b42318;
  border-color: #f3b8b0;
  background: #fff7f6;
}

.flow-list {
  display: grid;
  gap: 12px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}
.flow-list li {
  display: grid;
  grid-template-columns: 34px 1fr;
  column-gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.flow-list span {
  display: grid;
  grid-row: span 2;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  background: var(--brand);
  font-weight: 800;
}
.flow-list strong { font-size: 13px; }
.flow-list small { color: var(--muted); font-size: 12px; }

.dealer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.dealer-card { padding: 18px; }
.full-row { grid-column: 1 / -1; }
.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.card-title-row .row-actions { justify-content: flex-end; }
.icon-action {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--brand);
  background: #fff;
  font-size: 17px;
  cursor: pointer;
}
.icon-action:hover { background: #eef4ff; }
.icon-action.success { color: #087150; }
.icon-action.danger { color: #c83838; }
.icon-action.danger:hover { background: #fff1f1; }
.dealer-card .meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}
.dealer-card .meta div {
  display: grid;
  gap: 4px;
}
.dealer-card small { color: var(--muted); font-size: 12px; }
.dealer-card strong { font-size: 22px; }
.card-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.link-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.link-card h3 {
  margin: 9px 0 4px;
  font-size: 18px;
}
.link-card small {
  color: var(--muted);
}
.link-url {
  overflow-wrap: anywhere;
  padding: 10px;
  border-radius: 7px;
  color: var(--brand);
  background: #f3f7ff;
  font-size: 12px;
  font-weight: 800;
}
.muted-url {
  color: #64748b;
  background: #f8fafc;
  font-weight: 700;
}
.link-card .meta {
  display: flex;
  gap: 28px;
}
.link-card .meta div {
  display: grid;
  gap: 4px;
}

.package-list {
  display: grid;
  gap: 16px;
}
.package-category {
  display: grid;
  gap: 9px;
}
.package-category h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0;
}
.package-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.package-item strong,
.package-item small {
  display: block;
}
.package-item small {
  margin-top: 4px;
  color: var(--muted);
}
.package-item > span {
  font-weight: 800;
}
.package-item em {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--brand);
  background: #eaf2ff;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

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

.user-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.user-card {
  display: grid;
  gap: 13px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.user-card h3 {
  margin: 0 0 3px;
  font-size: 17px;
}
.user-card small,
.user-card p {
  color: var(--muted);
  font-size: 12px;
}
.user-card p { margin: 0; }
.role-badge {
  width: max-content;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--brand);
  background: #eaf2ff;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.role-badge.dealer {
  color: #087150;
  background: #e5f7ef;
}
.role-badge.passive {
  color: #8a3a00;
  background: #fff3e6;
}
.settings-help {
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: 12px;
}
.tenant-list {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}
.tenant-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.tenant-item strong,
.tenant-item small { display: block; }
.tenant-item small {
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
}
.transfer-card,
.empty-state {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.transfer-card {
  display: grid;
  gap: 11px;
}
.transfer-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
}
.transfer-card small,
.transfer-card p {
  color: var(--muted);
  font-size: 12px;
}
.transfer-card p { margin: 0; }
.empty-state {
  grid-column: 1 / -1;
  color: var(--muted);
}

.task-list { display: grid; gap: 10px; }
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.task-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}
.task-item span { margin-left: auto; color: var(--muted); font-size: 12px; }

.bars {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}
.bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 34px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
}
.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf5;
}
.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.mini-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.mini-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.mini-form input,
.mini-form select { margin-top: 7px; }
.check-line {
  display: flex !important;
  align-items: center;
  gap: 9px;
  color: var(--ink) !important;
}
.check-line input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--brand);
}
.settings-grid div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.settings-grid strong,
.settings-grid small { display: block; }
.settings-grid small { margin-top: 5px; color: var(--muted); }

.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  justify-content: flex-end;
  background: rgba(13, 24, 45, .42);
}
.drawer.open { display: flex; }
.drawer-panel {
  width: min(440px, 100%);
  min-height: 100%;
  padding: 22px;
  background: #fff;
  box-shadow: -20px 0 50px rgba(15, 30, 55, .18);
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.lead-form {
  display: grid;
  gap: 14px;
}
.lead-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.lead-form input,
.lead-form select { margin-top: 7px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: -90px;
  z-index: 60;
  min-width: min(460px, calc(100% - 28px));
  padding: 14px 18px;
  border-radius: 8px;
  color: #fff;
  background: var(--brand-dark);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  transition: bottom .25s;
  font-size: 13px;
  font-weight: 700;
}
.toast.show { bottom: 22px; }

@media (max-width: 1120px) {
  .metric-grid,
  .dealer-grid,
  .link-grid,
  .transfer-grid,
  .user-grid,
  .report-grid,
  .package-layout,
  .settings-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid,
  .report-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .24s;
  }
  .sidebar.open { transform: translateX(0); }
  .shell { margin-left: 0; }
  .menu-button { display: grid; }
  .topbar { padding: 12px 14px; }
  .topbar-actions .ghost-button { display: none; }
  .view { padding: 16px 14px 28px; }
  .metric-grid,
  .dealer-grid,
  .settings-grid,
  .link-grid,
  .transfer-grid,
  .user-grid,
  .package-layout,
  .settings-layout { grid-template-columns: 1fr; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .filters { grid-template-columns: 1fr; width: 100%; }
  .full-row { grid-column: auto; }
  .login-panel { grid-template-columns: 1fr; }
  .login-brand { min-height: 170px; }
}
