:root {
  color-scheme: dark;
  --bg: #08111f;
  --panel: #111b2b;
  --panel-2: #162335;
  --ink: #eef5ff;
  --muted: #98a9bd;
  --line: #26364b;
  --accent: #29d3a2;
  --accent-2: #f6c453;
  --danger: #ff6b6b;
  --warning: #ffb454;
  --info: #71b7ff;
  --ok: #38d996;
  --shadow: 0 24px 70px rgba(0, 0, 0, .35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 10% -10%, rgba(41, 211, 162, .16), transparent 34rem),
    radial-gradient(circle at 96% 8%, rgba(246, 196, 83, .10), transparent 30rem),
    linear-gradient(160deg, #08111f 0%, #0d1726 46%, #101827 100%);
  color: var(--ink);
  overflow-x: hidden;
}

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

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
}

.login-screen {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  min-height: 100vh;
}

.brand-panel {
  align-content: center;
  display: grid;
  min-height: 100vh;
  padding: 56px;
}

.brand-mark {
  align-items: center;
  display: flex;
  gap: 14px;
  margin-bottom: 48px;
}

.brand-icon {
  align-items: center;
  background: #102542;
  border-radius: 18px;
  display: grid;
  height: 54px;
  justify-content: center;
  overflow: hidden;
  padding: 0;
  width: 54px;
}

.brand-icon img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.2;
}

.brand-subtitle {
  color: var(--muted);
  font-size: .9rem;
}

.brand-panel h1 {
  font-size: clamp(2.4rem, 6vw, 5.6rem);
  letter-spacing: 0;
  line-height: .95;
  margin: 0;
  max-width: 760px;
}

.brand-copy {
  color: #c9d7e7;
  font-size: clamp(1rem, 1.7vw, 1.25rem);
  line-height: 1.65;
  margin: 28px 0 0;
  max-width: 650px;
  overflow-wrap: break-word;
}

.feature-strip {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 44px;
  max-width: 760px;
}

.feature-chip {
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 8px;
  color: #dce8f6;
  min-width: 0;
  overflow-wrap: break-word;
  padding: 14px;
}

.login-card {
  align-self: center;
  background: rgba(17, 27, 43, .84);
  border-left: 1px solid rgba(255, 255, 255, .08);
  box-shadow: var(--shadow);
  display: grid;
  gap: 20px;
  margin: 28px;
  padding: 30px;
  position: relative;
}

.login-card h2,
.view-title h2,
.modal-card h2 {
  font-size: 1.55rem;
  letter-spacing: 0;
  margin: 0;
}

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

.role-grid {
  display: grid;
  gap: 10px;
}

.role-button,
.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  gap: 9px;
  justify-content: center;
  min-height: 42px;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.role-button {
  background: #132035;
  border: 1px solid var(--line);
  color: var(--ink);
  justify-content: flex-start;
  padding: 14px;
  width: 100%;
}

.role-button:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.role-button.active {
  background: rgba(41, 211, 162, .14);
  border-color: rgba(41, 211, 162, .55);
}

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

label {
  color: #dbe7f5;
  display: grid;
  font-size: .88rem;
  gap: 7px;
}

input,
select,
textarea {
  background: #0b1525;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 42px;
  outline: none;
  padding: 10px 12px;
  width: 100%;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(41, 211, 162, .16);
}

.primary-button {
  background: var(--accent);
  color: #06101b;
  font-weight: 800;
  padding: 10px 16px;
}

.secondary-button {
  background: #20324b;
  color: var(--ink);
  padding: 10px 14px;
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 14px;
}

.danger-button {
  background: rgba(255, 107, 107, .14);
  color: #ffd1d1;
  padding: 10px 14px;
}

.icon-button {
  aspect-ratio: 1;
  background: #17253a;
  border: 1px solid var(--line);
  color: var(--ink);
  height: 42px;
  padding: 0;
}

.icon-button svg,
.nav-item svg,
.button-icon {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

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

.sidebar {
  background: rgba(8, 17, 31, .86);
  border-right: 1px solid rgba(255, 255, 255, .08);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand-mark {
  margin: 0;
}

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

.nav-item {
  align-items: center;
  background: transparent;
  border-radius: 8px;
  color: #b9c8db;
  cursor: pointer;
  display: flex;
  gap: 11px;
  min-height: 44px;
  padding: 11px 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(41, 211, 162, .12);
  color: var(--ink);
}

.user-card {
  background: #101c2d;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.user-card strong {
  display: block;
  margin-bottom: 4px;
}

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

.topbar {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.install-button {
  white-space: nowrap;
}

.mobile-menu {
  display: none;
}

.view-title p {
  color: var(--muted);
  margin: 6px 0 0;
}

.status-pill {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #c7d6e8;
  display: inline-flex;
  font-size: .83rem;
  gap: 8px;
  padding: 8px 12px;
  white-space: nowrap;
}

.status-dot {
  background: var(--ok);
  border-radius: 50%;
  height: 8px;
  width: 8px;
}

.status-dot.offline {
  background: var(--warning);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

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

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

.kpi-card,
.panel,
.table-card,
.mini-card {
  background: rgba(17, 27, 43, .88);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .18);
}

.kpi-card {
  padding: 16px;
}

.kpi-card span {
  color: var(--muted);
  display: block;
  font-size: .82rem;
  margin-bottom: 9px;
}

.kpi-card strong {
  display: block;
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  letter-spacing: 0;
}

.kpi-card small {
  color: var(--accent);
  display: block;
  margin-top: 8px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(310px, .75fr);
}

.crm-board {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  overflow-x: auto;
  padding-bottom: 6px;
}

.crm-column {
  min-width: 220px;
}

.panel {
  padding: 16px;
}

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

.panel-head h3 {
  font-size: 1rem;
  margin: 0;
}

.chart {
  height: 300px;
  width: 100%;
}

.ranking-list,
.activity-list,
.card-list {
  display: grid;
  gap: 10px;
}

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

.seller-row,
.activity-row,
.client-row {
  align-items: center;
  background: #0c1728;
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 12px;
}

.avatar {
  align-items: center;
  background: linear-gradient(135deg, #253b57, #152235);
  border-radius: 50%;
  color: #eaf4ff;
  display: grid;
  font-size: .82rem;
  font-weight: 800;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.progress {
  background: #0a1322;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress > span {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  display: block;
  height: 100%;
  width: var(--value, 0%);
}

.table-card {
  overflow: hidden;
}

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

.data-table th,
.data-table td {
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: #101c2d;
  color: #c7d6e8;
  font-size: .8rem;
  font-weight: 700;
}

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

.tag {
  border-radius: 999px;
  display: inline-flex;
  font-size: .77rem;
  font-weight: 700;
  padding: 5px 9px;
}

.tag.ok {
  background: rgba(56, 217, 150, .13);
  color: #8ff0c7;
}

.tag.warning {
  background: rgba(255, 180, 84, .14);
  color: #ffd294;
}

.tag.danger {
  background: rgba(255, 107, 107, .14);
  color: #ffb3b3;
}

.tag.info {
  background: rgba(113, 183, 255, .14);
  color: #b7dbff;
}

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

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

.permission-check {
  align-items: center;
  background: #0c1728;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
}

.permission-check input {
  min-height: auto;
  width: auto;
}

.modal {
  align-items: center;
  background: rgba(4, 8, 14, .68);
  display: none;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 30;
}

.modal.open {
  display: flex;
}

.modal-card {
  background: #111b2b;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 92vh;
  max-width: 900px;
  overflow: auto;
  padding: 22px;
  width: min(900px, 100%);
}

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

.split {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .6fr);
}

.mini-card {
  padding: 14px;
}

.mini-card h4 {
  margin: 0 0 8px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

.qr {
  background: #fff;
  border-radius: 8px;
  display: grid;
  gap: 2px;
  grid-template-columns: repeat(17, 1fr);
  margin: 12px auto 0;
  padding: 10px;
  width: min(260px, 100%);
}

.qr span {
  aspect-ratio: 1;
  background: #fff;
}

.qr span.on {
  background: #07111f;
}

.toast {
  background: #0d1828;
  border: 1px solid rgba(41, 211, 162, .45);
  border-radius: 8px;
  bottom: 18px;
  box-shadow: var(--shadow);
  color: var(--ink);
  left: 50%;
  max-width: min(560px, calc(100vw - 32px));
  padding: 13px 15px;
  position: fixed;
  transform: translate(-50%, 22px);
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.drawer-open .sidebar {
  transform: translateX(0);
}

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

  .dashboard-grid,
  .crm-board,
  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .login-screen {
    display: block;
    grid-template-columns: 1fr;
    overflow-x: hidden;
  }

  .brand-panel {
    min-height: auto;
    overflow: hidden;
    padding: 28px 18px 8px;
    width: 100%;
  }

  .brand-panel h1,
  .brand-copy {
    max-width: calc(100vw - 36px);
    white-space: normal;
  }

  .feature-strip {
    grid-template-columns: 1fr;
    margin-top: 24px;
    max-width: calc(100vw - 36px);
    width: calc(100vw - 36px);
  }

  .login-card {
    margin: 18px auto;
    max-width: calc(100vw - 36px);
    min-width: 0;
    width: calc(100% - 36px);
  }

  .login-card p,
  .role-button,
  .login-fields {
    max-width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: 100vh;
    position: fixed;
    transform: translateX(-105%);
    transition: transform .2s ease;
    width: 286px;
    z-index: 40;
  }

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

  .main {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
  }

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

  .toolbar {
    justify-content: flex-start;
  }

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

  .data-table {
    min-width: 760px;
  }

  .table-card {
    overflow-x: auto;
  }
}

@media (max-width: 560px) {
  .brand-panel h1 {
    font-size: 2.4rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .seller-row,
  .activity-row,
  .client-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .seller-row > strong,
  .client-row > .row-actions {
    grid-column: 1 / -1;
  }

  .row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
}
