:root {
  --bg: #F6F4FB;
  --surface: #FFFFFF;
  --purple-50: #F3EEF9;
  --purple-100: #E8DFF4;
  --purple-200: #D4C4EA;
  --purple-300: #B9A4E3;
  --purple-400: #9B82D1;
  --purple-500: #8A6BC4;
  --purple-600: #7357A8;
  --text: #2B2740;
  --muted: #7A7590;
  --border: #E6E0F0;
  --danger: #C45C6A;
  --danger-soft: #F8E8EB;
  --warn: #C4923A;
  --warn-soft: #F8F0E0;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(43, 39, 64, 0.06);
  --sidebar: 260px;
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--purple-600); text-decoration: none; }
button, input, select { font-family: inherit; }
img { max-width: 100%; display: block; }

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

.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  padding: 4px 0 8px;
}
.sidebar-brand img {
  width: 100%;
  max-width: 220px;
  height: auto;
  max-height: 80px;
  object-fit: contain;
  display: block;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--purple-500);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.brand-mark-lg { width: 48px; height: 48px; font-size: 22px; }

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  margin-bottom: 18px;
}
.sidebar-search input {
  border: 0;
  background: transparent;
  width: 100%;
  outline: none;
  color: var(--text);
}

.nav-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 16px 8px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
  font-weight: 500;
}
.nav-item:hover { background: var(--purple-50); }
.nav-item.is-active {
  background: var(--purple-50);
  color: var(--purple-600);
}
.nav-ico { width: 20px; height: 20px; display: grid; place-items: center; }
.nav-ico svg { width: 18px; height: 18px; }

.sidebar-foot { margin-top: auto; padding-top: 16px; }
.sidebar-user, .cell-user, .profile-dropdown-head, .auth-brand, .profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user strong, .cell-user strong { display: block; font-size: 13px; }
.sidebar-user span, .profile-dropdown-head span { color: var(--muted); font-size: 12px; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--purple-500);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar-lg { width: 40px; height: 40px; }
.avatar-xl { width: 64px; height: 64px; font-size: 24px; }

.app-main { flex: 1; min-width: 0; }

.topbar {
  height: 68px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.crumbs { color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.crumb-sep { color: var(--purple-200); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.profile-menu { position: relative; }
.profile-btn {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 8px;
}
.profile-dropdown-head { padding: 8px; margin-bottom: 6px; }
.profile-dropdown a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
}
.profile-dropdown a:hover { background: var(--purple-50); }

.app-content { padding: 28px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head h1 { margin: 0 0 4px; font-size: 26px; }
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.import-steps { margin: 0; padding-left: 18px; color: var(--text); }
.import-steps li { margin: 8px 0; line-height: 1.45; }
.import-steps code, .form-card code { font-size: 12px; }
.danger-card { border-color: #f0cfd4; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.card-head h3, .card h3 { margin: 0; font-size: 16px; }

.stat-grid, .dash-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}
.stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dash-grid { grid-template-columns: 1.05fr 1.4fr; }
.stat-card h2 { margin: 6px 0; font-size: 28px; }
.stat-label { margin: 0; color: var(--muted); font-size: 13px; font-weight: 600; }

.star-body { display: flex; gap: 16px; align-items: center; }
.star-body img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 14px;
  background: var(--purple-50);
}
.star-metrics { display: flex; gap: 24px; margin-top: 12px; }
.star-metrics span { display: block; color: var(--muted); font-size: 12px; }

.chart-wrap { height: 220px; }

.badge, .chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--purple-50);
  color: var(--purple-600);
  font-size: 12px;
  font-weight: 600;
}
.badge-warn { background: var(--warn-soft); color: var(--warn); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 28px !important; }
.empty-card { text-align: center; color: var(--muted); }

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.toolbar input[type="search"] { flex: 1; }

input, select {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  color: var(--text);
}
input:focus, select:focus { border-color: var(--purple-300); box-shadow: 0 0 0 3px var(--purple-50); }

textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
}
textarea:focus { border-color: var(--purple-300); box-shadow: 0 0 0 3px var(--purple-50); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; font-weight: 600; }
.field-inline { min-width: 220px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.field-span-2 { grid-column: span 2; }
.form-card-compact {
  max-width: 680px;
}
.form-card-compact .form-grid { gap: 12px; }
.phone-split {
  display: grid;
  grid-template-columns: 158px 1fr;
  gap: 8px;
}
.form-actions { margin-top: 20px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.error { color: var(--danger); }
.error-list { color: var(--danger); font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.preview { width: 88px; height: 88px; object-fit: cover; border-radius: 12px; margin-top: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
}
.btn-primary { background: var(--purple-500); color: #fff; }
.btn-primary:hover { background: var(--purple-600); }
.btn-ghost { background: var(--purple-50); color: var(--purple-600); }
.btn-danger-ghost { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 10px; font-size: 12px; }
.btn-lg { padding: 14px 16px; font-size: 15px; }

.inventory-card { padding: 0; overflow: hidden; }
.inventory-table { margin: 0; }
.inventory-table th,
.inventory-table td { padding: 8px 16px; vertical-align: middle; }
.inventory-table thead th {
  background: var(--bg);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.inventory-table tbody tr:hover { background: var(--purple-50); }
.inventory-table .num { text-align: right; white-space: nowrap; }
.inv-product {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}
.inv-thumb {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--purple-50);
}
.inv-thumb img {
  width: 36px;
  height: 36px;
  max-width: 36px;
  max-height: 36px;
  object-fit: cover;
  display: block;
}
.inv-product strong { display: block; font-size: 14px; }
.inv-product .muted { font-size: 12px; }
.inv-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}
.is-inactive { opacity: 0.65; }

.sale-layout {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  align-items: start;
}
.sale-products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  max-height: 640px;
  overflow: auto;
}
.sale-product {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
  background: #fff;
  text-align: left;
}
.sale-product:hover { border-color: var(--purple-300); background: var(--purple-50); }
.sale-product img { height: 90px; width: 100%; object-fit: cover; border-radius: 10px; background: var(--purple-50); }
.sale-product h4 { margin: 8px 0 4px; font-size: 13px; }
.sale-ticket { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 88px; }
.ticket-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  font-size: 18px;
}
.qty-input, .price-input { width: 88px; padding: 6px 8px; }
.qty-input.qty-sm { width: 64px; }
.consign-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--purple-600);
  white-space: nowrap;
}
.consign-check input { width: auto; margin: 0; }
.consign-move {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.client-results { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.client-option {
  text-align: left;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
}
.client-option:hover, .client-option.is-selected { border-color: var(--purple-400); background: var(--purple-50); }
.selected-client {
  padding: 12px;
  border-radius: 12px;
  background: var(--purple-50);
  margin-bottom: 12px;
}
.selected-client.is-empty { background: var(--bg); color: var(--muted); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(43, 39, 64, 0.35);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(720px, 100%);
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.toast {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: var(--purple-50);
  color: var(--purple-600);
}
.toast-error { background: var(--danger-soft); color: var(--danger); }
.toast-success { background: var(--purple-50); color: var(--purple-600); }

.auth-body { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.auth-wrap { width: min(440px, calc(100% - 32px)); }
.auth-card { background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 20px 0 6px; }
.auth-kicker {
  margin: 0 0 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
code { background: var(--purple-50); padding: 2px 6px; border-radius: 6px; }

.filter-row { display: flex; gap: 10px; }

.menu-toggle { display: none; }

@media (max-width: 1100px) {
  .stat-grid, .dash-grid, .sale-layout, .form-grid { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .sidebar {
    display: none;
    position: fixed;
    z-index: 40;
    height: 100vh;
  }
  .sidebar.is-open { display: flex; }
  .menu-toggle { display: inline-flex; }
  .sale-ticket { position: static; }
}

@media (max-width: 900px) {
  .hide-sm { display: none; }
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.choice-grid-3 { grid-template-columns: repeat(3, 1fr); }
.field-label {
  margin: 14px 0 4px;
  font-size: 13px;
  font-weight: 600;
}
#creditPanel { margin-top: 14px; }
.track-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.track-inline .btn.is-active,
.btn.btn-ghost.is-active {
  border-color: var(--purple-400);
  background: var(--purple-50);
  color: var(--purple-600);
}
.choice, .track-choice {
  text-align: left;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--text);
}
.choice strong, .track-choice strong { display: block; margin-bottom: 4px; }
.choice span, .track-choice span { color: var(--muted); font-size: 12px; }
.choice.is-active, .track-choice.is-active {
  border-color: var(--purple-400);
  background: var(--purple-50);
}
.track-admin {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.filter-pills { align-items: center; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}
.pill.is-active {
  background: var(--purple-50);
  border-color: var(--purple-200);
  color: var(--purple-600);
}
.share-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.share-row input { flex: 1; min-width: 180px; }
.order-message {
  margin: 0;
  padding: 14px 16px;
  background: var(--purple-50);
  border-radius: 14px;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}
.order-files {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.order-files img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.cell-wrap { max-width: 320px; white-space: normal; }
.row-actions { display: flex; gap: 6px; }
.nav-count {
  margin-left: auto;
  min-width: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--purple-500);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.public-shell {
  width: min(560px, calc(100% - 32px));
  padding: 32px 0;
}
.public-shell.is-wide { width: min(880px, calc(100% - 32px)); }
.public-panel .page-head { margin-bottom: 18px; }
.public-panel .card { margin-bottom: 0; }
.public-head {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}
.public-head img {
  max-height: 64px;
  width: auto;
  max-width: 220px;
  object-fit: contain;
}
.public-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.public-card h1 { margin: 0 0 8px; font-size: 26px; }
.track-lookup { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.track-timeline {
  list-style: none;
  margin: 24px 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.track-step {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  position: relative;
  padding-bottom: 22px;
}
.track-step:last-child { padding-bottom: 0; }
.track-step:last-child .track-dot::after { display: none; }
.track-dot {
  width: 14px;
  height: 14px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--border);
  position: relative;
  justify-self: center;
}
.track-dot::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 16px;
  width: 2px;
  height: calc(100% + 10px);
  background: var(--border);
}
.track-step.is-done .track-dot,
.track-step.is-current .track-dot { background: var(--purple-500); }
.track-step.is-done .track-dot::after,
.track-step.is-current .track-dot::after { background: var(--purple-200); }
.track-step.is-pending { opacity: 0.55; }
.track-step p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.track-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
  padding: 14px;
  background: var(--bg);
  border-radius: 14px;
}
.track-meta span { display: block; color: var(--muted); font-size: 12px; }
.track-items { list-style: none; padding: 0; margin: 0 0 18px; }
.track-items li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

@media (max-width: 700px) {
  .choice-grid, .choice-grid-3, .track-meta, .phone-split { grid-template-columns: 1fr; }
}
