/* ============================================================
   iCheap Dashboard — Design System
   ============================================================ */

:root {
  --ink: #18181b;
  --ink-soft: #52525b;
  --muted: #71717a;
  --paper: #fafafa;
  --surface: #ffffff;
  --surface-soft: #f4f4f5;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --accent: #18181b;
  --accent-dark: #09090b;
  --lime: #e4e4e7;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --amber: #a16207;
  --amber-soft: #fefce8;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(24,24,27,.06), 0 1px 2px rgba(24,24,27,.04);
  --shadow-md: 0 4px 16px rgba(24,24,27,.08);
  --shadow-lg: 0 10px 40px rgba(24,24,27,.12);
  --ease-out: cubic-bezier(.16,1,.3,1);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); -webkit-font-smoothing: antialiased; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); letter-spacing: -.005em; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.hidden { display: none !important; }
h1, h2, h3 { line-height: 1.15; }
p { margin: 0; }
code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }

/* ============================================================
   Animations / Keyframes
   ============================================================ */
@keyframes fade-in        { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up       { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes slide-down     { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes scale-in       { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
@keyframes scale-spring   { from { opacity: 0; transform: scale(.88); } to { opacity: 1; transform: scale(1); } }
@keyframes spin           { to { transform: rotate(360deg); } }
@keyframes pulse-dot      { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
@keyframes toast-in       { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out      { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes confirm-in     { from { opacity: 0; transform: scale(.92) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes confirm-out    { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(.95); } }
@keyframes overlay-in     { from { opacity: 0; } to { opacity: 1; } }
@keyframes bar-fill       { from { width: 0; } to { width: var(--width); } }
@keyframes number-pop     { 0% { transform: scale(1); } 50% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes shimmer        { from { background-position: -600px 0; } to { background-position: 600px 0; } }

.animate-in { animation: slide-up .28s var(--ease-out) both; }
.animate-in:nth-child(2) { animation-delay: .04s; }
.animate-in:nth-child(3) { animation-delay: .08s; }
.animate-in:nth-child(4) { animation-delay: .12s; }
.animate-in:nth-child(5) { animation-delay: .16s; }

/* ============================================================
   Typography helpers
   ============================================================ */
.eyebrow, .panel-kicker, .topbar-title p, .mini-kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.required-dot { color: var(--red); }

/* ============================================================
   Login Page
   ============================================================ */
.login-shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(228,228,231,.56) 1px, transparent 1px),
    linear-gradient(90deg, rgba(228,228,231,.56) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
}
.login-orb { display: none; }
.login-panel {
  width: min(100%, 440px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow-lg);
  animation: scale-in .32s var(--ease-out) both;
}
.login-brand, .sidebar-brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.04em;
}
.brand-word { font-size: 20px; font-weight: 700; letter-spacing: -.045em; }
.brand-word span { color: inherit; }
.login-copy { margin: 32px 0 26px; }
.login-copy h1 { margin: 0; font-size: clamp(30px,7vw,38px); font-weight: 700; line-height: 1.08; letter-spacing: -.055em; }
.login-copy > p:last-child { margin-top: 13px; color: var(--ink-soft); font-size: 14px; line-height: 1.55; }
.login-form { display: grid; gap: 16px; }
.login-footnote { margin: 20px 0 0; color: var(--muted); font-size: 12px; }
.login-aside { display: none; }
.form-error { min-height: 18px; margin: -4px 0 0; color: var(--red); font-size: 12px; animation: slide-down .18s var(--ease-out); }

/* ============================================================
   Form Controls
   ============================================================ */
.field { display: grid; gap: 7px; }
.field > span { color: var(--ink); font-size: 12px; font-weight: 500; }
.field-hint { color: var(--muted); font-size: 10px; }
.field input, .field textarea, .field select,
.filter-bar select, .search-field {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(24,24,27,.02);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.field input, .field select, .filter-bar select { height: 40px; padding: 0 12px; font-size: 13px; }
.field textarea { min-height: 104px; padding: 11px 12px; font-size: 13px; line-height: 1.55; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #a1a1aa; }
.field input:focus, .field textarea:focus, .field select:focus,
.filter-bar select:focus, .search-field:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(24,24,27,.10);
}
.field input.input-error, .field textarea.input-error { border-color: var(--red); box-shadow: 0 0 0 3px rgba(220,38,38,.12); }
.prompt-input {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  font-size: 14px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.prompt-input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(24,24,27,.10); }

/* ============================================================
   Buttons
   ============================================================ */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease, transform .14s var(--ease-out);
}
.button:active { transform: scale(.98); }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button svg { width: 15px; height: 15px; flex-shrink: 0; }
.button-primary { background: var(--ink); color: #fafafa; }
.button-primary:hover:not(:disabled) { background: #27272a; }
.button-secondary, .button-ghost { border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
.button-secondary:hover:not(:disabled), .button-ghost:hover:not(:disabled) { background: var(--surface-soft); }
.button-danger { color: var(--red); border-color: #fca5a5; background: var(--red-soft); }
.button-danger:hover:not(:disabled) { background: #fee2e2; border-color: #f87171; }
.button-full { width: 100%; min-height: 40px; }
.button-full svg { width: 17px; }
.btn-back { color: var(--ink-soft); gap: 6px; }
.btn-back:hover { color: var(--ink); }
.text-button { padding: 0; border: 0; background: none; color: var(--ink); font-size: 11px; font-weight: 600; }
.text-button span { color: inherit; }
.text-button:hover { opacity: .7; }
.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  transition: background .14s ease, color .14s ease;
}
.icon-button:hover { background: var(--surface-soft); color: var(--ink); }
.icon-button svg { width: 17px; height: 17px; }

/* ============================================================
   App Shell — Layout
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

/* ─── Sidebar ─── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: 248px;
  padding: 20px 14px 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
}
.sidebar-brand { padding: 2px 8px 25px; }
.sidebar .brand-mark { width: 30px; height: 30px; border-radius: 7px; font-size: 13px; }
.sidebar .brand-word { font-size: 19px; }
.sidebar-close { margin-left: auto; display: none; }
.menu-button { display: none; }
.sidebar-overlay { position: fixed; inset: 0; z-index: 25; display: none; visibility: hidden; background: rgba(24,24,27,.36); opacity: 0; transition: opacity .2s ease, visibility .2s ease; }
.sidebar-overlay.open { visibility: visible; opacity: 1; }

.nav-list { display: grid; gap: 3px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  transition: background .14s ease, color .14s ease;
}
.nav-item:hover { color: var(--ink); background: var(--surface-soft); }
.nav-item.active { color: var(--ink); background: var(--surface-soft); font-weight: 600; }
.nav-item.active svg { stroke-width: 2.2; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-count {
  margin-left: auto;
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--surface-soft);
  font-size: 10px;
  text-align: center;
}

.sidebar-card {
  margin: auto 2px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.sidebar-card-icon { display: grid; place-items: center; width: 31px; height: 31px; margin-bottom: 12px; border-radius: 7px; color: var(--ink-soft); background: var(--surface-soft); }
.sidebar-card-icon svg { width: 16px; }
.sidebar-card strong { font-size: 12px; font-weight: 600; }
.sidebar-card p { margin: 5px 0 9px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.sidebar-footer {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  padding: 12px 4px 0;
  border-top: 1px solid var(--line);
}
.sidebar-footer > div { display: grid; gap: 2px; min-width: 0; }
.sidebar-footer strong { overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer span { color: var(--muted); font-size: 10px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--ink-soft); background: var(--surface-soft); font-size: 12px; font-weight: 700; }

/* ─── Main shell ─── */
.main-shell { min-width: 0; width: calc(100% - 248px); margin-left: 248px; }

/* ─── Topbar ─── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px clamp(20px,3.5vw,48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px);
}
.topbar-title { display: flex; align-items: center; gap: 11px; }
.topbar-title p { margin-bottom: 2px; }
.topbar-title h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.035em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.realtime-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 500;
}
.realtime-pill i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(22,163,74,.12);
  animation: pulse-dot 2s ease infinite;
}
.realtime-pill.offline i { background: var(--red); box-shadow: 0 0 0 3px rgba(220,38,38,.10); animation: none; }

/* ─── Content shell / views ─── */
.content-shell { max-width: 1600px; padding: clamp(24px,3vw,40px) clamp(20px,3.5vw,48px) 56px; }
.view { display: none; }
.view.active { display: block; animation: slide-up .28s var(--ease-out) both; }

/* ============================================================
   Overview
   ============================================================ */
.welcome-row, .section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.welcome-row h2, .section-heading h2 { margin: 0; font-size: clamp(25px,2.7vw,34px); font-weight: 650; letter-spacing: -.045em; }
.welcome-row h2 span { color: inherit; }
.welcome-row > div > p:last-child,
.section-heading > div > p:last-child { margin-top: 8px; color: var(--muted); font-size: 13px; }
.mobile-import { display: none; }

/* ─── Metric cards ─── */
.metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.metric-card {
  min-height: 142px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: box-shadow .2s ease, transform .2s ease;
}
.metric-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.metric-card.metric-dark { color: var(--ink); }
.metric-card-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 500; }
.metric-icon {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  color: var(--ink-soft);
  background: var(--surface-soft);
}
.metric-icon svg { width: 16px; height: 16px; }
.metric-icon.warm { color: var(--amber); background: var(--amber-soft); font-size: 11px; font-weight: 800; }
.metric-icon.green { color: var(--green); background: var(--green-soft); }
.metric-icon.blue { color: var(--blue); background: var(--blue-soft); }
.metric-card > strong {
  display: block;
  overflow: hidden;
  margin-top: 18px;
  font-size: clamp(26px,2.4vw,33px);
  font-weight: 650;
  letter-spacing: -.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
  animation: number-pop .35s var(--ease-out);
}
.metric-card > p { display: flex; align-items: center; gap: 7px; margin: 8px 0 0; color: var(--muted); font-size: 10px; }
.positive-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

/* ─── Overview grid ─── */
.overview-grid { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(300px,.75fr); gap: 14px; margin-top: 14px; }
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.stock-panel, .activity-panel, .composer-panel, .history-panel, .api-guide { padding: 20px; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.soft-badge, .audience-badge {
  padding: 4px 9px;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  color: #15803d;
  background: var(--green-soft);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ─── Stock chart ─── */
.stock-chart { display: grid; gap: 16px; margin-top: 22px; }
.stock-row { display: grid; grid-template-columns: minmax(100px,1fr) 2.3fr 44px; align-items: center; gap: 12px; }
.stock-name strong { display: block; overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.stock-name span { color: var(--muted); font-size: 9px; }
.stock-track { height: 7px; overflow: hidden; border-radius: 99px; background: var(--surface-soft); }
.stock-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #27272a;
  animation: bar-fill .55s var(--ease-out) both;
}
.stock-row:nth-child(3n) .stock-track span { background: #71717a; }
.stock-amount { font-size: 11px; font-weight: 700; text-align: right; color: var(--ink-soft); }

/* ─── Activity ─── */
.activity-list { display: grid; margin-top: 16px; }
.activity-item { position: relative; display: grid; grid-template-columns: 32px 1fr; gap: 11px; padding: 10px 0; }
.activity-item:not(:last-child)::after { position: absolute; left: 15px; top: 40px; bottom: -6px; width: 1px; content: ""; background: var(--line); }
.activity-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--ink-soft); background: var(--surface-soft); flex-shrink: 0; }
.activity-icon svg { width: 14px; height: 14px; }
.activity-copy strong { display: block; overflow: hidden; font-size: 11px; font-weight: 600; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.activity-copy span { color: var(--muted); font-size: 9px; }
.empty-state-compact { display: grid; place-items: center; min-height: 180px; color: var(--muted); font-size: 12px; }

/* ============================================================
   Table Panel
   ============================================================ */
.table-panel { overflow: hidden; }
.table-summary { display: flex; justify-content: space-between; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.table-summary span:first-child { color: var(--ink); font-weight: 600; }
.table-scroll { overflow-x: auto; scrollbar-color: #a1a1aa transparent; scrollbar-width: thin; }
.table-scroll::-webkit-scrollbar { height: 6px; }
.table-scroll::-webkit-scrollbar-thumb { border-radius: 999px; background: #d4d4d8; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th {
  padding: 11px 18px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
td { padding: 14px 18px; border-top: 1px solid var(--line); font-size: 12px; vertical-align: middle; }
.align-right { text-align: right; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #fafafa; }
.customer-row { cursor: pointer; }
.customer-row:hover { background: var(--surface-soft) !important; }

.product-cell { display: flex; align-items: center; gap: 11px; }
.product-letter, .customer-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 8px;
  color: var(--ink-soft);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 700;
}
.customer-avatar { border-radius: 50%; }
.product-cell > div { min-width: 0; }
.product-cell strong { display: block; max-width: 220px; overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.product-cell span { display: block; max-width: 230px; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.stock-number { font-weight: 700; }
.stock-number.low { color: var(--red); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.status-badge::before { width: 5px; height: 5px; border-radius: 50%; content: ""; background: currentColor; }
.status-available, .status-active { border-color: #bbf7d0; color: #15803d; background: var(--green-soft); }
.status-reserved { border-color: #fde68a; color: var(--amber); background: var(--amber-soft); }
.status-sold, .status-inactive, .status-disabled { border-color: var(--line); color: var(--ink-soft); background: var(--surface-soft); }

.table-actions { display: flex; justify-content: flex-end; gap: 5px; }
.table-action {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink-soft);
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.table-action:hover { border-color: var(--line-strong); background: var(--surface-soft); color: var(--ink); }
.table-action.danger:hover { border-color: #fca5a5; color: var(--red); background: var(--red-soft); }
.table-action svg { width: 14px; height: 14px; }
.table-code { display: inline-block; max-width: 170px; overflow: hidden; padding: 4px 7px; border-radius: 6px; color: var(--ink-soft); background: var(--surface-soft); font-size: 10px; text-overflow: ellipsis; vertical-align: middle; white-space: nowrap; }

.status-select {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: var(--surface);
  font-size: 10px;
  text-transform: capitalize;
  transition: border-color .12s ease;
}
.status-select:focus { border-color: var(--ink); }

/* ─── Filter bar ─── */
.filter-bar { display: grid; grid-template-columns: 1fr 190px 160px; gap: 9px; padding: 14px 18px; background: #fcfcfc; border-bottom: 1px solid var(--line); }
.filter-bar select { height: 38px; padding: 0 10px; font-size: 11px; }
.search-field { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.search-field svg { width: 15px; flex-shrink: 0; color: var(--muted); }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 11px; }

/* ─── Empty state ─── */
.empty-state { padding: 48px 20px 54px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 16px; border-radius: 10px; color: var(--ink-soft); background: var(--surface-soft); }
.empty-icon svg { width: 20px; height: 20px; }
.empty-state h3 { margin: 0; font-size: 16px; font-weight: 600; }
.empty-state p { max-width: 400px; margin: 8px auto 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

/* ─── Pagination ─── */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-height: 54px; padding: 10px 18px; border-top: 1px solid var(--line); }
.page-button { min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); font-size: 10px; }
.page-button.active { color: #fff; border-color: var(--ink); background: var(--ink); }
.page-button:disabled { cursor: default; opacity: .4; }

/* ============================================================
   Customer Page
   ============================================================ */
.customer-metrics { margin-bottom: 20px; }

/* ============================================================
   Customer Detail Page
   ============================================================ */
.detail-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.detail-hero-left { display: flex; align-items: flex-start; gap: 18px; }
.detail-hero-avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 64px; height: 64px;
  border-radius: 50%;
  color: var(--ink);
  background: var(--surface-soft);
  font-size: 26px;
  font-weight: 700;
}
.detail-hero-info h2 { margin: 0 0 4px; font-size: 22px; font-weight: 650; letter-spacing: -.04em; }
.detail-hero-info p { color: var(--ink-soft); font-size: 13px; }
.detail-hero-info code { color: var(--ink-soft); font-size: 11px; }
.detail-hero-badges { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.detail-joined { color: var(--muted); font-size: 11px; }
.detail-hero-right { display: flex; gap: 24px; flex-shrink: 0; }
.detail-hero-stat { text-align: right; }
.detail-hero-stat span { display: block; color: var(--muted); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.detail-hero-stat strong { display: block; margin-top: 4px; font-size: 20px; font-weight: 650; letter-spacing: -.04em; }

.detail-stats-grid {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.detail-stat-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: box-shadow .2s ease, transform .2s ease;
}
.detail-stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.detail-stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 500; }
.detail-stat-card > strong { display: block; margin-top: 14px; font-size: clamp(20px,2vw,26px); font-weight: 650; letter-spacing: -.04em; animation: number-pop .3s var(--ease-out); }
.detail-stat-card > p { margin-top: 5px; color: var(--muted); font-size: 10px; }

.detail-section { margin-bottom: 20px; }
.detail-section h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }

/* ─── Timeline ─── */
.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; display: grid; grid-template-columns: 24px 1fr; gap: 14px; padding: 12px 0 12px 8px; }
.timeline-item:not(:last-child)::after { position: absolute; left: 19px; top: 36px; bottom: 0; width: 1px; content: ""; background: var(--line); }
.timeline-dot { width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--line-strong); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--line); }
.timeline-dot.order { background: var(--green); box-shadow: 0 0 0 2px #bbf7d0; }
.timeline-dot.payment { background: var(--blue); box-shadow: 0 0 0 2px #bfdbfe; }
.timeline-content { min-width: 0; }
.timeline-content strong { display: block; font-size: 12px; font-weight: 600; }
.timeline-content span { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; }
.timeline-amount { color: var(--ink) !important; font-weight: 600 !important; }
.timeline-date { color: var(--muted); font-size: 9px !important; }

/* ============================================================
   Broadcast
   ============================================================ */
.broadcast-grid { display: grid; grid-template-columns: minmax(0,1.12fr) minmax(300px,.88fr); gap: 14px; }
.composer-panel form { margin-top: 22px; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 11px; color: var(--muted); font-size: 10px; }
.warning-note { display: flex; align-items: flex-start; gap: 9px; margin-top: 18px; padding: 12px; border: 1px solid #fde68a; border-radius: var(--radius-sm); color: #854d0e; background: var(--amber-soft); font-size: 11px; line-height: 1.5; }
.warning-note svg { flex-shrink: 0; width: 15px; height: 15px; }
.notification-list { display: grid; margin-top: 17px; }
.notification-item { padding: 13px 0; border-bottom: 1px solid var(--line); }
.notification-item:last-child { border-bottom: 0; }
.notification-message { display: -webkit-box; overflow: hidden; color: var(--ink); font-size: 12px; line-height: 1.5; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notification-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 7px; color: var(--muted); font-size: 9px; }
.delivery-count { color: var(--green); font-weight: 700; }

/* ============================================================
   Integrations
   ============================================================ */
.integration-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.integration-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow); transition: box-shadow .2s ease; }
.integration-card:hover { box-shadow: var(--shadow-md); }
.integration-card-main { padding: 19px; }
.integration-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.integration-logo { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--ink-soft); background: var(--surface-soft); }
.integration-logo svg { width: 18px; height: 18px; }
.integration-title h3 { margin: 13px 0 0; font-size: 15px; font-weight: 600; }
.integration-title p { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.config-badge { flex-shrink: 0; padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 9px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.config-badge.ready { border-color: #bbf7d0; color: #15803d; background: var(--green-soft); }
.config-badge.pending { border-color: #fde68a; color: var(--amber); background: var(--amber-soft); }
.endpoint-block { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 13px; border-top: 1px solid var(--line); background: #fcfcfc; }
.endpoint-block code { overflow: hidden; color: var(--ink-soft); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.endpoint-block button { flex-shrink: 0; width: 28px; height: 28px; }
.api-guide { margin-top: 14px; }
.flow-grid { display: grid; grid-template-columns: 1fr 32px 1fr 32px 1fr; align-items: center; gap: 8px; margin-top: 22px; }
.flow-step { min-height: 130px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fcfcfc; }
.flow-step > span { color: var(--muted); font-size: 10px; font-weight: 700; }
.flow-step strong { display: block; margin-top: 22px; font-size: 12px; font-weight: 600; }
.flow-step p { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.flow-arrow { color: var(--line-strong); text-align: center; font-size: 18px; }

/* ============================================================
   Modals (native <dialog>)
   ============================================================ */
.modal {
  width: min(560px,calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  box-shadow: none;
}
.modal.modal-wide { width: min(760px,calc(100vw - 28px)); }
.modal::backdrop { background: rgba(24,24,27,.32); backdrop-filter: blur(4px); animation: overlay-in .18s ease; }
.modal-card { overflow: auto; max-height: calc(100dvh - 28px); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: 0 25px 70px rgba(24,24,27,.18); animation: scale-spring .24s var(--ease-out) both; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 19px 22px 16px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.04em; }
.modal-body { padding: 20px 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: #fcfcfc; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field-wide { grid-column: 1 / -1; }

/* ─── Import modal ─── */
.import-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 2px; }
.drop-zone {
  display: grid;
  place-items: center;
  min-height: 120px;
  margin-top: 16px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fcfcfc;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease;
}
.drop-zone:hover, .drop-zone.dragging { border-color: var(--ink); background: var(--surface-soft); }
.drop-zone input { display: none; }
.drop-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: var(--ink-soft); background: var(--surface-soft); }
.drop-icon svg { width: 16px; }
.drop-zone strong { margin-top: 9px; color: var(--ink); font-size: 12px; }
.drop-zone > span:last-child { margin-top: 3px; font-size: 10px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--muted); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.divider::before, .divider::after { flex: 1; height: 1px; content: ""; background: var(--line); }
.code-input, .code-block { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace !important; font-size: 11px !important; }
.format-hint { margin-top: 9px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.format-hint code { color: #7c3aed; }

/* ─── Account detail modal ─── */
.detail-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.detail-chip { padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink-soft); background: var(--surface-soft); font-size: 10px; }
.detail-chip strong { color: var(--ink); }
.code-block-wrap { position: relative; }
.code-block {
  min-height: 220px;
  max-height: 400px;
  overflow: auto;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: #fafafa;
  font-size: 11px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.copy-code {
  position: absolute;
  top: 9px;
  right: 9px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 9px;
}
.copy-code svg { width: 12px; }

/* ============================================================
   Custom Confirm / Prompt Dialog
   ============================================================ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(24,24,27,.32);
  backdrop-filter: blur(4px);
  animation: overlay-in .18s ease both;
}
.confirm-overlay.closing { animation: overlay-in .18s ease reverse both; }
.confirm-card {
  width: min(420px,100%);
  padding: 28px 28px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(24,24,27,.18);
  animation: confirm-in .24s var(--ease-spring) both;
  text-align: center;
}
.confirm-overlay.closing .confirm-card { animation: confirm-out .18s ease both; }
.confirm-icon-wrap {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--surface-soft);
}
.confirm-icon-wrap svg { width: 24px; height: 24px; }
.confirm-icon-wrap.danger { color: var(--red); background: var(--red-soft); }
.confirm-icon-wrap.info { color: var(--blue); background: var(--blue-soft); }
.confirm-icon-wrap.warning { color: var(--amber); background: var(--amber-soft); }
.confirm-title { margin: 0 0 10px; font-size: 18px; font-weight: 650; letter-spacing: -.04em; }
.confirm-message { margin: 0 0 24px; color: var(--ink-soft); font-size: 13px; line-height: 1.55; }
.confirm-actions { display: flex; gap: 9px; justify-content: center; }
.confirm-actions .button { min-width: 110px; }

/* ============================================================
   Toast System
   ============================================================ */
.toast-region {
  position: fixed;
  z-index: 600;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px,calc(100vw - 28px));
  pointer-events: none;
}
.toast {
  display: grid;
  grid-template-columns: 36px 1fr 28px;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(24,24,27,.14);
  pointer-events: all;
  animation: toast-in .22s var(--ease-out) both;
  position: relative;
  overflow: hidden;
}
.toast.removing { animation: toast-out .25s var(--ease-out) forwards; }
.toast-icon {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 9px;
  color: var(--green);
  background: var(--green-soft);
  flex-shrink: 0;
}
.toast-icon svg { width: 16px; height: 16px; }
.toast.error .toast-icon { color: var(--red); background: var(--red-soft); }
.toast.info .toast-icon { color: var(--blue); background: var(--blue-soft); }
.toast.error { border-left: 3px solid var(--red); }
.toast.success { border-left: 3px solid var(--green); }
.toast.info { border-left: 3px solid var(--blue); }
.toast-body { min-width: 0; }
.toast-body strong { display: block; font-size: 12px; font-weight: 600; }
.toast-body span { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-close { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.toast-close:hover { background: var(--surface-soft); color: var(--ink); }
.toast-close svg { width: 13px; }
.toast-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  width: 100%;
  background: var(--line);
  transform-origin: left;
  animation: toast-progress 5s linear forwards;
}
.toast.error .toast-progress { background: #fca5a5; }
.toast.success .toast-progress { background: #86efac; }
.toast.info .toast-progress { background: #93c5fd; }
@keyframes toast-progress { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ============================================================
   Keyboard focus ring
   ============================================================ */
:where(button,input,textarea,select,[tabindex]):focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ============================================================
   Responsive — 1120px
   ============================================================ */
@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .detail-stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .integration-grid { grid-template-columns: 1fr; }
  .integration-card-main { display: grid; grid-template-columns: 1fr auto; gap: 12px; }
  .integration-title { flex-direction: column; gap: 6px; }
}

/* ============================================================
   Responsive — 900px
   ============================================================ */
@media (max-width: 900px) {
  .sidebar { width: 248px; transform: translateX(-104%); transition: transform .22s var(--ease-out); }
  .sidebar.open { transform: none; box-shadow: 12px 0 40px rgba(24,24,27,.14); }
  .sidebar-close, .menu-button { display: grid; }
  .sidebar-overlay { display: block; }
  .main-shell { width: 100%; margin-left: 0; }
  .overview-grid, .broadcast-grid { grid-template-columns: 1fr; }
  .activity-panel { min-height: 300px; }
  body.sidebar-open { overflow: hidden; }
  .detail-hero { flex-direction: column; gap: 16px; }
  .detail-hero-right { flex-direction: row; gap: 20px; }
  .detail-hero-stat { text-align: left; }
}

/* ============================================================
   Responsive — 760px
   ============================================================ */
@media (max-width: 760px) {
  .topbar-actions .desktop-action { display: none; }
  .integration-card-main { display: block; }
}

/* ============================================================
   Responsive — 640px
   ============================================================ */
@media (max-width: 640px) {
  .login-shell { place-items: start center; padding: 16px; }
  .login-panel { margin-top: max(20px,8vh); padding: 24px; }
  .login-copy { margin: 28px 0 22px; }
  .topbar { min-height: 60px; padding: 10px 16px; }
  .content-shell { padding: 22px 16px 44px; }
  .welcome-row, .section-heading { align-items: flex-start; flex-direction: column; }
  .mobile-import { display: inline-flex; }
  .metric-grid, .detail-stats-grid { grid-template-columns: 1fr; }
  .metric-card, .detail-stat-card { min-height: 120px; }
  .stock-panel, .activity-panel, .composer-panel, .history-panel, .api-guide { padding: 16px; }
  .filter-bar { grid-template-columns: 1fr; }
  .form-grid, .import-options { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .modal-header, .modal-body { padding-left: 16px; padding-right: 16px; }
  .modal-footer { padding-left: 16px; padding-right: 16px; }
  .flow-grid { grid-template-columns: 1fr; }
  .flow-arrow { transform: rotate(90deg); }
  .table-summary span:last-child { display: none; }
  .realtime-pill span { display: none; }
  .realtime-pill { width: 32px; padding: 0; justify-content: center; }
  .toast-region { right: 12px; bottom: 12px; }
  .confirm-card { padding: 22px 18px 18px; }
  .confirm-actions { flex-direction: column; }
  .confirm-actions .button { width: 100%; }
  .detail-hero { padding: 16px; }
  .detail-hero-left { flex-direction: column; gap: 12px; }
  .detail-hero-right { flex-wrap: wrap; }
  .composer-footer { align-items: stretch; flex-direction: column; }
  .composer-footer .button { width: 100%; }
  th, td { padding-left: 14px; padding-right: 14px; }
  .table-summary, .filter-bar { padding-left: 14px; padding-right: 14px; }
}
