@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f4f4f5;
  --bg-alt: #fafafa;
  --surface: #fff;
  --ink: #18181b;
  --ink-secondary: #3f3f46;
  --muted: #71717a;
  --muted-light: #a1a1aa;
  --line: #e4e4e7;
  --line-light: #f4f4f5;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-bg: #eff6ff;
  --blue-text: #1d4ed8;
  --red: #ef4444;
  --red-dark: #dc2626;
  --red-bg: #fef2f2;
  --red-text: #b91c1c;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --green-light: #dcfce7;
  --green-text: #15803d;
  --green-dark: #166534;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --amber-text: #92400e;
  --purple: #7c3aed;
  --orange: #f97316;
  --yellow: #facc15;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --fs-10: 10px;
  --fs-11: 11px;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-15: 15px;
  --fs-18: 18px;
  --fs-24: 24px;
  --fs-26: 26px;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.03);
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: var(--fs-14);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* =========== APP SHELL =========== */
.app {
  width: 1440px;
  margin: 0 auto;
  display: flex;
  min-height: 100vh;
  background: var(--bg-alt);
}

/* =========== SIDEBAR =========== */
.sb {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 20;
}

.logo {
  padding: 20px 20px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.logo-mark {
  width: 30px;
  height: 30px;
  background: var(--blue);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: var(--fs-14);
}

.logo-name { font-weight: 600; font-size: var(--fs-15); }
.logo-sub { font-size: var(--fs-11); color: var(--muted); margin-top: 1px; }

.nav { padding: 14px 12px; flex: 1; overflow: auto; }
.nav-section {
  font-size: var(--fs-11);
  font-weight: 600;
  color: var(--muted-light);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 10px 6px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--ink-secondary);
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 2px;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}

.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--blue-bg); color: var(--blue-dark); }

.nav a .ico {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.nav a .badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: var(--fs-10);
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.sb-foot {
  padding: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sb-foot-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.sb-foot-actions button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: color 0.15s, background 0.15s;
  display: grid;
  place-items: center;
}

.sb-foot-actions button:hover {
  color: var(--red-dark);
  background: var(--red-bg);
}

.av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: var(--fs-12);
  flex-shrink: 0;
}

.who { font-size: var(--fs-13); font-weight: 600; }
.who small { display: block; font-weight: 400; color: var(--muted); font-size: var(--fs-11); }

/* =========== TOPBAR =========== */
.main { flex: 1; display: flex; flex-direction: column; }

.top {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.crumbs {
  font-size: var(--fs-13);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.crumbs b { color: var(--ink); font-weight: 500; }

.search {
  margin-left: 24px;
  flex: 1;
  max-width: 380px;
  position: relative;
}

.search input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--bg-alt);
  border-radius: var(--radius);
  padding: 0 12px 0 36px;
  font-family: var(--font);
  font-size: var(--fs-13);
  outline: none;
  transition: border-color 0.15s;
}

.search input:focus { border-color: var(--blue); }

.search svg {
  position: absolute;
  left: 11px;
  top: 10px;
  width: 16px;
  height: 16px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
}

.kbd {
  position: absolute;
  right: 10px;
  top: 8px;
  font-size: var(--fs-10);
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  pointer-events: none;
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* =========== BUTTONS =========== */
.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--font);
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:hover { background: var(--bg-alt); }
.btn:active { transform: scale(0.98); }

.btn.primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.btn.primary:hover { background: var(--blue-dark); }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}

.icon-btn:hover { background: var(--bg-alt); }
.icon-btn:active { transform: scale(0.97); }

.icon-btn svg {
  width: 16px;
  height: 16px;
  stroke: var(--ink-secondary);
  fill: none;
  stroke-width: 2;
}

.dot {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 7px;
  height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 1.5px solid var(--surface);
}

/* =========== PAGE BODY =========== */
.body {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: fadeIn 0.3s ease;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.title h1 {
  font-size: var(--fs-24);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill {
  font-size: var(--fs-11);
  font-weight: 600;
  background: var(--green-light);
  color: var(--green-dark);
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pill .liv {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.title p { font-size: 13.5px; color: #52525b; }
.title p b { font-weight: 600; color: var(--ink); }

.head-tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* =========== KPI CARDS =========== */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
}

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

.kpi-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.kpi-h span {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}

.kpi-h .ic {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
}

.ic.b { background: var(--blue-bg); }
.ic.r { background: var(--red-bg); }
.ic.g { background: var(--green-bg); }
.ic.a { background: var(--amber-bg); }

.kpi-h .ic svg { width: 14px; height: 14px; stroke-width: 2; fill: none; }
.ic.b svg { stroke: var(--blue); }
.ic.r svg { stroke: var(--red-dark); }
.ic.g svg { stroke: var(--green); }
.ic.a svg { stroke: var(--amber); }

.kpi-v {
  font-size: var(--fs-26);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.kpi-f {
  font-size: var(--fs-12);
  color: var(--muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.delta { font-weight: 600; }
.delta.up { color: var(--red-dark); }
.delta.dn { color: var(--green); }

/* =========== GRID =========== */
.grid2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

/* =========== CARDS =========== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-h {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-h h3 { font-size: 14.5px; font-weight: 600; }
.card-h p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-h .right { display: flex; gap: 6px; align-items: center; }

/* =========== TABLE =========== */
table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }

th {
  text-align: left;
  padding: 10px 18px;
  font-weight: 500;
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  user-select: none;
}

th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--ink); }
th .sort-icon { display: inline-block; margin-left: 4px; opacity: 0.4; }
th.sorted .sort-icon { opacity: 1; color: var(--blue); }

td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-light);
  vertical-align: middle;
}

tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--bg-alt); transition: background 0.15s; }

.prod { display: flex; align-items: center; gap: 10px; }
.thumb {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--line-light);
  display: grid;
  place-items: center;
  font-size: 14px;
  flex-shrink: 0;
}

.prod b { font-weight: 600; display: block; font-size: var(--fs-13); }
.prod small { color: var(--muted); font-size: 11.5px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.tag.r { background: var(--red-bg); color: var(--red-text); }
.tag.a { background: var(--amber-bg); color: var(--amber-text); }
.tag.g { background: var(--green-bg); color: var(--green-text); }
.tag.b { background: var(--blue-bg); color: var(--blue-text); }

.price { font-variant-numeric: tabular-nums; font-weight: 500; }

.act {
  color: var(--blue);
  font-weight: 500;
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.act:hover { text-decoration: underline; }

/* =========== DISCOUNT LIST =========== */
.disc { padding: 6px 0; }
.disc-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-light);
  transition: background 0.15s;
}

.disc-item:last-child { border-bottom: 0; }
.disc-item:hover { background: var(--bg-alt); }

.comp {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: var(--fs-12);
  color: #fff;
  flex-shrink: 0;
}

.comp.z { background: var(--purple); }
.comp.b { background: var(--yellow); color: #422006; }
.comp.i { background: var(--orange); }

.disc-body { flex: 1; min-width: 0; }
.disc-body b { font-size: var(--fs-13); font-weight: 600; display: block; margin-bottom: 2px; }
.disc-body small { color: var(--muted); font-size: 11.5px; }
.disc-meta {
  font-size: var(--fs-11);
  color: var(--muted-light);
  margin-top: 4px;
  display: flex;
  gap: 8px;
}

/* =========== ADJUSTMENTS =========== */
.up-arr { color: var(--green); }
.dn-arr { color: var(--red-dark); }

/* =========== SEND CARD =========== */
.send-card {
  background: linear-gradient(135deg, var(--blue-bg), var(--surface));
  border: 1px solid #dbeafe;
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.2s;
}

.send-card:hover { box-shadow: var(--shadow); }
.send-card h4 { font-size: var(--fs-14); font-weight: 600; margin-bottom: 3px; }
.send-card p { font-size: 12.5px; color: #52525b; }
.send-card .actions { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }

/* =========== QUICK ACTIONS =========== */
.qa-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--line-light);
  cursor: pointer;
  transition: background 0.15s;
}

.qa-item:last-child { border-bottom: 0; }
.qa-item:hover { background: var(--bg-alt); }

.qa-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-size: 14px;
  flex-shrink: 0;
}

.qa-body { flex: 1; }
.qa-body b { font-size: var(--fs-13); display: block; font-weight: 600; }
.qa-body small { color: var(--muted); font-size: 11.5px; }
.qa-chevron { color: var(--muted-light); font-size: 16px; display: flex; align-items: center; gap: 4px; }
.qa-chevron svg { width: 12px; height: 12px; stroke: var(--muted-light); fill: none; stroke-width: 2; }

/* =========== FOOTER =========== */
.foot {
  margin-top: auto;
  padding: 20px 28px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-12);
  color: var(--muted);
}

.foot a {
  color: #52525b;
  margin-left: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s;
}

.foot a:hover { color: var(--ink); }

/* =========== DROPDOWN =========== */
.dropdown-wrap { position: relative; display: inline-block; }

.dropdown-trigger {
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.dropdown-trigger:hover { background: var(--bg-alt); border-color: #d4d4d8; }
.dropdown-trigger.open { border-color: var(--blue); }

.dropdown-trigger svg {
  width: 12px;
  height: 12px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
  transition: transform 0.2s;
}

.dropdown-trigger.open svg { transform: rotate(180deg); }

.dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 100;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  padding: 4px;
}

.dropdown-panel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown-panel.right { left: auto; right: 0; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}

.dropdown-item:hover { background: var(--bg); color: var(--ink); }
.dropdown-item.active { background: var(--blue-bg); color: var(--blue-dark); }

/* =========== TOAST =========== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: var(--fs-13);
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toastIn 0.3s ease;
  max-width: 360px;
}

.toast.success { background: #065f46; }
.toast.info { background: var(--ink); }
.toast.warning { background: #92400e; }

.toast svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2; flex-shrink: 0; }

.toast.removing { animation: toastOut 0.25s ease forwards; }

/* =========== LOGIN =========== */
.login-container {
  width: 1440px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-box {
  width: 480px;
  animation: fadeIn 0.4s ease;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 48px;
  height: 48px;
  background: var(--blue);
  border-radius: var(--radius-lg);
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 16px;
}

.login-header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.login-header p {
  font-size: var(--fs-14);
  color: var(--muted);
}

.login-label {
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  display: block;
}

.user-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.user-card:hover { border-color: #d4d4d8; box-shadow: var(--shadow); }
.user-card.selected { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.user-card:active { transform: scale(0.98); }

.user-card .av { width: 36px; height: 36px; font-size: var(--fs-12); flex-shrink: 0; }
.user-card .info b { font-size: var(--fs-13); font-weight: 600; display: block; }
.user-card .info small { font-size: 11.5px; color: var(--muted); }
.user-card .info .cats { font-size: var(--fs-10); color: var(--muted-light); display: block; margin-top: 1px; }

.login-btn {
  width: 100%;
  height: 42px;
  border-radius: var(--radius);
  border: none;
  background: var(--blue);
  color: #fff;
  font-family: var(--font);
  font-size: var(--fs-14);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.login-btn:hover { background: var(--blue-dark); }
.login-btn:active { transform: scale(0.99); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: var(--fs-12);
  color: var(--muted-light);
}

/* =========== EMPTY STATE =========== */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-state .empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--green-bg);
  display: inline-grid;
  place-items: center;
  margin-bottom: 12px;
}

.empty-state .empty-icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--green);
  fill: none;
  stroke-width: 2;
}

.empty-state p {
  font-size: var(--fs-14);
  font-weight: 500;
}

/* =========== ANIMATIONS =========== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(24px); }
}

.stagger-1 { animation: slideUp 0.35s ease 0.05s both; }
.stagger-2 { animation: slideUp 0.35s ease 0.1s both; }
.stagger-3 { animation: slideUp 0.35s ease 0.15s both; }
.stagger-4 { animation: slideUp 0.35s ease 0.2s both; }
.stagger-5 { animation: slideUp 0.35s ease 0.25s both; }
.stagger-6 { animation: slideUp 0.35s ease 0.3s both; }
.stagger-7 { animation: slideUp 0.35s ease 0.35s both; }
