@import url('https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300&family=Instrument+Serif:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

/* ── Dark theme (default) ── */
:root {
  --bg:        #0e0e0f;
  --bg2:       #141415;
  --bg3:       #1a1a1c;
  --bg4:       #202023;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.12);
  --text:      #e8e6e1;
  --text2:     #8a8880;
  --text3:     #555450;
  --accent:    #e8673a;
  --accent2:   #f0a876;
  --green:     #4caf82;
  --green-bg:  rgba(76,175,130,0.12);
  --amber:     #d4922a;
  --amber-bg:  rgba(212,146,42,0.12);
  --red:       #d95f5f;
  --red-bg:    rgba(217,95,95,0.12);
  --blue:      #5a9fd4;
  --blue-bg:   rgba(90,159,212,0.12);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --overlay:   rgba(0,0,0,0.65);
  --badge-green-text: #6dcfa0;
  --badge-amber-text: #d4a050;
  --badge-red-text:   #e07070;
  --badge-blue-text:  #7ab8de;
  --sidebar-w: 220px;
  --radius:    8px;
  --radius-lg: 12px;
  --mono:      'DM Mono', monospace;
  --sans:      'DM Sans', sans-serif;
  --serif:     'Instrument Serif', serif;
}

/* ── Light theme ── */
[data-theme="light"] {
  --bg:        #f5f4f1;
  --bg2:       #faf9f6;
  --bg3:       #f0efec;
  --bg4:       #e8e7e3;
  --border:    rgba(0,0,0,0.08);
  --border2:   rgba(0,0,0,0.14);
  --text:      #1a1a1c;
  --text2:     #6b6a65;
  --text3:     #9c9b95;
  --accent:    #e8673a;
  --accent2:   #d45a30;
  --green:     #2d8f62;
  --green-bg:  rgba(45,143,98,0.08);
  --amber:     #b57b1a;
  --amber-bg:  rgba(181,123,26,0.08);
  --red:       #c94444;
  --red-bg:    rgba(201,68,68,0.08);
  --blue:      #3a7fc2;
  --blue-bg:   rgba(58,127,194,0.08);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --overlay:   rgba(0,0,0,0.25);
  --badge-green-text: var(--green);
  --badge-amber-text: var(--amber);
  --badge-red-text:   var(--red);
  --badge-blue-text:  var(--blue);
}

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

html { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
html.theme-transition, html.theme-transition *, html.theme-transition *::before, html.theme-transition *::after {
  transition: background 0.3s ease, color 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 13px; line-height: 1.5; -webkit-font-smoothing: antialiased; }

/* ── Layout ── */
.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 0 0 16px;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

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

.brand-icon {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-left: 38px;
}

.nav-section {
  padding: 8px 12px 4px;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 14px;
  margin: 1px 8px;
  border-radius: var(--radius);
  font-size: 12.5px;
  color: var(--text2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}

.nav-item:hover { background: var(--bg3); color: var(--text); }

.nav-item.active {
  background: var(--bg4);
  color: var(--text);
}

.nav-item.active .nav-dot { background: var(--accent); }

.nav-icon { font-size: 13px; width: 16px; text-align: center; flex-shrink: 0; }

.nav-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: transparent;
  margin-left: auto;
  transition: background 0.12s;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 12px 0;
  border-top: 1px solid var(--border);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg3);
  border-radius: var(--radius);
  font-size: 11px;
  color: var(--text2);
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  box-shadow: 0 0 6px var(--green);
}

/* ── Main area ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: baseline; gap: 10px; }

.topbar-title {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.topbar-badge {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
  background: var(--bg4);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 20px;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.02em;
}

.topbar-refresh {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: background 0.12s, color 0.12s;
}
.topbar-refresh:hover { background: var(--bg3); color: var(--text); }

.theme-toggle {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: background 0.12s, color 0.12s;
}
.theme-toggle:hover { background: var(--bg3); color: var(--text); }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  scroll-behavior: smooth;
}

.content::-webkit-scrollbar { width: 4px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 2px; }

.page { display: none; animation: fadein 0.15s ease; }
.page.active { display: block; }

@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Alerts ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  margin-bottom: 8px;
  border: 1px solid;
}
.alert-red   { background: var(--red-bg);   color: var(--badge-red-text); border-color: rgba(217,95,95,0.2); }
.alert-amber { background: var(--amber-bg); color: var(--badge-amber-text); border-color: rgba(212,146,42,0.2); }
.alert-icon  { flex-shrink: 0; margin-top: 1px; }

/* ── Metric grid ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.metric-grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.metric-grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }

.metric-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}
.metric-card:hover { border-color: var(--border2); box-shadow: var(--shadow-md); }

.metric-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--card-accent, transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.metric-card.c-green { --card-accent: var(--green); }
.metric-card.c-amber { --card-accent: var(--amber); }
.metric-card.c-red   { --card-accent: var(--red); }
.metric-card.c-blue  { --card-accent: var(--blue); }

.metric-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 8px;
}

.metric-value {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 4px;
}

.metric-value.green { color: var(--green); }
.metric-value.amber { color: var(--amber); }
.metric-value.red   { color: var(--red); }
.metric-value.blue  { color: var(--blue); }

.metric-sub {
  font-size: 11px;
  color: var(--text3);
}

/* ── Section header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  font-weight: 500;
}

/* ── Tables ── */
.table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

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

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text3);
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th[onclick] { cursor: pointer; transition: color 0.12s; }
th[onclick]:hover { color: var(--text); }

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 12.5px;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }
tr { transition: background 0.08s; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
  border: 1px solid;
}

.badge::before {
  content: '';
  width: 4px; height: 4px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-green { background: var(--green-bg); color: var(--badge-green-text); border-color: rgba(76,175,130,0.25); }
.badge-green::before { background: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--badge-amber-text); border-color: rgba(212,146,42,0.25); }
.badge-amber::before { background: var(--amber); }
.badge-red   { background: var(--red-bg);   color: var(--badge-red-text); border-color: rgba(217,95,95,0.25); }
.badge-red::before   { background: var(--red); }
.badge-blue  { background: var(--blue-bg);  color: var(--badge-blue-text); border-color: rgba(90,159,212,0.25); }
.badge-blue::before  { background: var(--blue); }

/* ── Progress bar ── */
.progress-wrap { display: flex; align-items: center; gap: 8px; min-width: 100px; }
.progress-bar {
  flex: 1;
  height: 3px;
  background: var(--bg4);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}
.progress-pct {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  min-width: 28px;
  text-align: right;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--sans);
  font-weight: 400;
  cursor: pointer;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg4); border-color: var(--border2); }
.btn:active { transform: scale(0.98); }

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

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text2);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }

.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-icon { padding: 6px; }

/* ── Inputs ── */
input[type="text"], input[type="search"], input[type="password"], input[type="date"], select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12.5px;
  padding: 7px 11px;
  outline: none;
  transition: border-color 0.12s;
  width: 100%;
}
input[type="text"]:focus, input[type="search"]:focus, input[type="password"]:focus, input[type="date"]:focus, select:focus, textarea:focus {
  border-color: var(--border2);
}
input::placeholder { color: var(--text3); }
select option { background: var(--bg3); }

/* ── Search bar ── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.search-bar input { flex: 1; }

/* ── AI / Invoice box ── */
.ai-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.ai-box-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.ai-upload {
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.ai-upload:hover { border-color: var(--accent); background: rgba(232,103,58,0.04); }

.ai-upload-icon {
  font-size: 24px;
  margin-bottom: 10px;
  opacity: 0.6;
}

.ai-upload-title {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
}

.ai-upload-sub {
  font-size: 11.5px;
  color: var(--text3);
  margin-bottom: 14px;
  line-height: 1.6;
}

/* ── Parsed items ── */
.parsed-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }

.parsed-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 13px;
  background: var(--green-bg);
  border: 1px solid rgba(76,175,130,0.15);
  border-radius: var(--radius);
  animation: slide-in 0.2s ease both;
}

@keyframes slide-in {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: none; }
}

.parsed-item:nth-child(1) { animation-delay: 0.05s; }
.parsed-item:nth-child(2) { animation-delay: 0.10s; }
.parsed-item:nth-child(3) { animation-delay: 0.15s; }
.parsed-item:nth-child(4) { animation-delay: 0.20s; }

.parsed-name { font-size: 12.5px; font-weight: 500; color: var(--green); }
.parsed-qty  { font-family: var(--mono); font-size: 12px; color: var(--green); }

/* ── Two-col reconciliation ── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.recon-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.recon-header {
  padding: 11px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.recon-body { padding: 10px 14px; }

.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.breakdown-row:last-child { border-bottom: none; }
.breakdown-row .label { color: var(--text2); }
.breakdown-row .val   { font-family: var(--mono); font-size: 11.5px; }
.breakdown-row.total  {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border2);
  font-weight: 500;
}

/* ── Loading skeleton ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
  height: 12px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Empty state ── */
.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--text3);
  font-size: 12px;
}

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ── Accent number (mono) ── */
.mono { font-family: var(--mono); }

/* ── Tag row (for category chips) ── */
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tag {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.1s;
  background: transparent;
}
.tag:hover   { border-color: var(--border2); color: var(--text); }
.tag.active  { background: var(--bg4); border-color: var(--border2); color: var(--text); }

/* ── Inline stat row (for POS) ── */
.stat-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.stat-big  { font-family: var(--mono); font-size: 20px; color: var(--text); }
.stat-unit { font-size: 11px; color: var(--text3); }

/* ── Responsive ── */
/* ══ Tablet (≤900px) ══ */
@media (max-width: 900px) {
  :root { --sidebar-w: 180px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
  .metric-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; }
  .content { padding: 14px 16px; }
}

/* ══ Mobile (≤640px) — bottom nav replaces sidebar ══ */
@media (max-width: 640px) {
  .shell { flex-direction: column; height: 100dvh; }
  .sidebar { display: none; }

  .bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 58px;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    z-index: 50;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text3);
    font-size: 9px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: color 0.1s, background 0.1s;
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav-item:active { background: var(--bg3); }
  .bottom-nav-item.active { color: var(--accent); }
  .bottom-nav-icon { font-size: 18px; line-height: 1; }

  .main { flex: 1; min-height: 0; padding-bottom: 58px; }

  .topbar { padding: 0 14px; height: 46px; }
  .topbar-title { font-size: 14px; }
  .topbar-date { display: none; }
  .topbar-badge { display: none; }

  .content { padding: 12px 12px; }

  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; margin-bottom: 14px; }
  .metric-grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .metric-grid.cols-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .metric-card { padding: 12px 10px; }
  .metric-value { font-size: 18px; }
  .metric-label { font-size: 9px; }

  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 480px; }
  th, td { padding: 8px 10px; font-size: 11.5px; }
  .col-hide-mobile { display: none; }

  .two-col { grid-template-columns: 1fr; gap: 10px; }

  .search-bar { flex-direction: column; gap: 6px; }
  .search-bar select { width: 100% !important; }

  .alert { font-size: 11px; padding: 8px 10px; }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 92dvh;
  }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  .field-row, .field-row-3 { grid-template-columns: 1fr; }

  .toast-container { bottom: 70px; right: 12px; left: 12px; }
  .toast { min-width: unset; }

  .tag-row { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .tag-row::-webkit-scrollbar { display: none; }
  .tag { flex-shrink: 0; }

  .row-actions { opacity: 1; }
  .action-btn { font-size: 10px; padding: 3px 6px; }
}

/* ══ Very small (≤380px) ══ */
@media (max-width: 380px) {
  .metric-value { font-size: 16px; }
  .content { padding: 10px; }
  .bottom-nav-item { font-size: 8px; }
}

/* ── Modal overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: overlay-in 0.15s ease;
  padding: 20px;
}
@keyframes overlay-in { from { opacity:0; } to { opacity:1; } }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in 0.18s ease;
  box-shadow: var(--shadow-lg);
}
@keyframes modal-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--text);
}
.modal-close {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: all 0.1s;
}
.modal-close:hover { background: var(--bg3); color: var(--text); }

.modal-body { padding: 18px 20px; }
.modal-footer {
  padding: 14px 20px 18px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}

/* ── Form fields ── */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 6px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

input[type="number"] {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 7px 11px;
  outline: none;
  transition: border-color 0.12s;
  width: 100%;
}
input[type="number"]:focus { border-color: var(--border2); }

/* ── Toast notification ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: var(--radius);
  font-size: 12.5px;
  border: 1px solid;
  min-width: 240px;
  animation: toast-in 0.2s ease;
  box-shadow: var(--shadow-md);
}
@keyframes toast-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-success { background: var(--bg2); color: var(--green); border-color: rgba(76,175,130,0.3); }
.toast-error   { background: var(--bg2); color: var(--red);   border-color: rgba(217,95,95,0.3); }
.toast-info    { background: var(--bg2); color: var(--text2); border-color: var(--border2); }

/* ── Inline row actions ── */
.row-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.1s; }
tr:hover .row-actions { opacity: 1; }
.action-btn {
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 10.5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.1s;
  white-space: nowrap;
}
.action-btn:hover { background: var(--bg4); color: var(--text); border-color: var(--border2); }
.action-btn.danger:hover { background: var(--red-bg); color: var(--red); border-color: rgba(217,95,95,0.3); }
.action-btn.success:hover { background: var(--green-bg); color: var(--green); border-color: rgba(76,175,130,0.3); }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px;
  gap: 10px;
}
.pg-info {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
}
.pg-btns {
  display: flex;
  align-items: center;
  gap: 2px;
}
.pg-btn {
  min-width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.pg-btn:hover:not(:disabled) {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border2);
}
.pg-btn:active:not(:disabled) {
  transform: scale(0.95);
}
.pg-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.pg-active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}
.pg-dots {
  padding: 0 4px;
  color: var(--text3);
  font-size: 12px;
}
@media (max-width: 640px) {
  .pagination { padding: 10px 0; }
  .pg-btn { min-width: 28px; height: 28px; font-size: 11px; }
  .pg-info { font-size: 10px; }
}

/* ── CSV import drop zone ── */
.csv-drop-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  font-size: 12px;
  color: var(--text3);
  transition: all 0.15s;
}
.csv-drop-zone:hover {
  border-color: var(--accent);
  color: var(--text2);
  background: rgba(232,103,58,0.03);
}
.csv-drop-active {
  border-color: var(--accent) !important;
  background: rgba(232,103,58,0.06) !important;
  color: var(--text) !important;
}

/* ── Barcode badge (inline in table rows) ── */
.barcode-badge {
  display: inline-block;
  padding: 1px 5px;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 9.5px;
  font-family: var(--mono);
  color: var(--text3);
  vertical-align: middle;
  margin-left: 4px;
}

/* ── Sale tiles grid ── */
.sale-tiles-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sale-tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.sale-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tile-accent, var(--text3));
  border-radius: var(--radius-lg);
  padding: 18px 12px;
  cursor: pointer;
  transition: all 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  text-align: center;
  min-height: 90px;
  font-family: var(--sans);
}
.sale-tile:hover {
  background: var(--bg3);
  border-color: var(--border2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.sale-tile:active {
  transform: scale(0.97);
  box-shadow: none;
}

.sale-tile-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.25;
}

.sale-tile-price {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent2);
}

.sale-tile-cat {
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Sale confirmation modal ── */
.sale-modal-product {
  text-align: center;
  padding: 10px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.sale-modal-name {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--text);
  margin-bottom: 4px;
}
.sale-modal-price {
  font-family: var(--mono);
  font-size: 16px;
  color: var(--accent2);
}
.sale-modal-each {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--sans);
}

.sale-modal-qty-section {
  text-align: center;
  margin-bottom: 20px;
}

.sale-modal-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.sale-stepper-btn {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  font-size: 24px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.sale-stepper-btn:hover { background: var(--bg4); }
.sale-stepper-btn:active { transform: scale(0.93); }
.sale-stepper-plus { color: var(--green); border-color: rgba(76,175,130,0.3); }
.sale-stepper-plus:hover { background: rgba(76,175,130,0.08); }

.sale-stepper-input {
  width: 80px;
  height: 56px;
  text-align: center;
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  -moz-appearance: textfield;
}
.sale-stepper-input::-webkit-inner-spin-button,
.sale-stepper-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.sale-modal-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text2);
}
.sale-modal-total-num {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 500;
  color: var(--green);
}

.sale-confirm-btn {
  min-width: 160px;
}

/* ── Sales tables side-by-side ── */
.sales-tables-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Barcode scanner ── */
.barcode-video-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  min-height: 200px;
}
.barcode-video-wrap video {
  width: 100%;
  display: block;
  border-radius: var(--radius);
}
.barcode-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.barcode-scan-line {
  width: 70%;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent), 0 0 4px var(--accent);
  animation: barcode-sweep 2s ease-in-out infinite;
}
@keyframes barcode-sweep {
  0%,100% { transform: translateY(-40px); opacity: 0.7; }
  50% { transform: translateY(40px); opacity: 1; }
}
.barcode-status {
  position: absolute;
  bottom: 8px;
  left: 0; right: 0;
  text-align: center;
  font-size: 11px;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  font-family: var(--mono);
}

/* ── Responsive: sales tiles ── */
@media (max-width: 900px) {
  .sale-tiles-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
  .sales-tables-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .sale-tiles-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .sale-tile { padding: 14px 8px; min-height: 78px; }
  .sale-tile-name { font-size: 13px; }
  .sale-tile-price { font-size: 11px; }
  .sale-tiles-header { flex-wrap: wrap; gap: 8px; }
  .sales-tables-grid { grid-template-columns: 1fr; gap: 10px; }

  .sale-stepper-btn { width: 52px; height: 52px; font-size: 22px; }
  .sale-stepper-input { width: 70px; height: 52px; font-size: 24px; }
  .sale-modal-name { font-size: 18px; }
}
@media (max-width: 380px) {
  .sale-tiles-grid { grid-template-columns: repeat(2, 1fr); }
  .sale-tile { padding: 12px 6px; min-height: 70px; }
  .sale-tile-name { font-size: 12px; }
}

/* ── POS sale log form ── */
.sale-form {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

/* ── Management page ──────────────────────────────────────────────────── */

/* Team list — capped at 5 rows, scrollable */
/* Management page layout */
.mgmt-layout {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mgmt-layout .section-header { margin-bottom: 6px; }
.mgmt-layout .search-bar { margin-bottom: 8px; }
.mgmt-layout .tag-row { margin-bottom: 6px; }
.mgmt-layout .pagination { padding: 6px 4px; }
.mgmt-tab-btn {
  font-size: 11px !important;
  padding: 4px 10px !important;
  border-radius: 6px !important;
}
.mgmt-tab-btn.active {
  background: var(--bg4) !important;
  border-color: var(--border2) !important;
  color: var(--text) !important;
}

/* Settings — compact single card with inline groups */
.mgmt-settings-row {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 10px 14px;
}
.mgmt-settings-group {
  flex: 1;
  min-width: 0;
}
.mgmt-settings-divider {
  width: 1px;
  background: var(--border);
  margin: 0 16px;
  align-self: stretch;
}

/* Team avatar in table */
.mgmt-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; color: #fff;
  flex-shrink: 0;
}
.mgmt-role-select { padding: 3px 8px; font-size: 11px; }
.mgmt-btn-danger {
  color: var(--red) !important;
  border-color: rgba(217,95,95,0.3) !important;
}

/* Responsive */
@media (max-width: 640px) {
  .mgmt-layout { gap: 8px; }
  .mgmt-role-select { font-size: 10px; }
  .mgmt-settings-row { flex-direction: column; gap: 10px; }
  .mgmt-settings-divider { width: auto; height: 1px; margin: 0; }
}

/* ── Agent feed ── */
.dashboard-columns {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .dashboard-columns { grid-template-columns: 1fr; }
}

.agent-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.agent-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  animation: fadein 0.2s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.agent-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.agent-icon { font-size: 16px; }
.agent-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text2);
  flex: 1;
}
.agent-time {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text3);
}

.agent-body {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.5;
}

/* Draft specific styles */
.draft-card {
  border-color: rgba(232,103,58,0.3);
  background: rgba(232,103,58,0.03);
}
.draft-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}

.agent-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(232,103,58,0.15);
}
