/* ═══════════════════════════════════════════════════
   Design Tokens — Light / Dark
   ═══════════════════════════════════════════════════ */
:root {
  /* Backgrounds */
  --bg:              #f5f5f7;
  --bg-secondary:    #e8e8ed;
  --surface:         #ffffff;
  --surface-2:       #f9f9fb;
  --surface-hover:   #f0f0f5;
  --surface-active:  #e8e8f0;
  --overlay:         rgba(0, 0, 0, 0.4);

  /* Text */
  --text:            #1d1d1f;
  --text2:           #86868b;
  --text3:           #a1a1a6;

  /* Borders */
  --border:          #d2d2d7;
  --border-light:    #e5e5ea;

  /* Accent */
  --accent:          #0071e3;
  --accent-hover:    #0077ed;
  --accent-light:    rgba(0, 113, 227, 0.1);
  --accent-ring:     rgba(0, 113, 227, 0.2);

  /* Status */
  --success:         #34c759;
  --success-bg:      #f0fdf4;
  --success-text:    #15803d;
  --error:           #ff3b30;
  --error-bg:        #fff1f0;
  --error-text:      #dc2626;
  --warning:         #ff9500;
  --warning-bg:      #fffbeb;
  --warning-text:    #b45309;
  --info:            #007aff;
  --info-bg:         #eff6ff;
  --info-text:       #1d4ed8;
  --muted-bg:        #f3f4f6;
  --muted-text:      #6b7280;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 2px 8px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.08);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.16), 0 6px 20px rgba(0,0,0,0.10);

  /* Typography */
  --font:      -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Cascadia Code", "Fira Code", monospace;

  /* Motion */
  --ease:        cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out:    cubic-bezier(0, 0, 0.2, 1);
  --t-fast:      0.12s;
  --t-base:      0.2s;
  --t-slow:      0.35s;

  /* Layout */
  --sidebar-width:      220px;
  --sidebar-icon-width: 64px;
  --bottom-nav-height:  64px;
  --header-height:      56px;
  --content-max:        1100px;
  --radius-sm:          8px;
  --radius:             12px;
  --radius-lg:          16px;
  --radius-xl:          20px;
  --radius-full:        9999px;
}

:root.dark {
  --bg:              #000000;
  --bg-secondary:    #0a0a0a;
  --surface:         #1c1c1e;
  --surface-2:       #242426;
  --surface-hover:   #2c2c2e;
  --surface-active:  #38383a;
  --overlay:         rgba(0, 0, 0, 0.7);

  --text:            #f5f5f7;
  --text2:           #98989d;
  --text3:           #636366;

  --border:          #38383a;
  --border-light:    #2c2c2e;

  --accent:          #0a84ff;
  --accent-hover:    #409cff;
  --accent-light:    rgba(10, 132, 255, 0.15);
  --accent-ring:     rgba(10, 132, 255, 0.25);

  --success:         #30d158;
  --success-bg:      rgba(48, 209, 88, 0.12);
  --success-text:    #4ade80;
  --error:           #ff453a;
  --error-bg:        rgba(255, 69, 58, 0.12);
  --error-text:      #f87171;
  --warning:         #ff9f0a;
  --warning-bg:      rgba(255, 159, 10, 0.12);
  --warning-text:    #fbbf24;
  --info:            #0a84ff;
  --info-bg:         rgba(10, 132, 255, 0.12);
  --info-text:       #60a5fa;
  --muted-bg:        rgba(255,255,255,0.06);
  --muted-text:      #9ca3af;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow:    0 2px 8px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.4);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.7), 0 6px 20px rgba(0,0,0,0.5);
}

/* ═══════════════════════════════════════════════════
   Base Reset
   ═══════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

[x-cloak] { display: none !important; }

html { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t-slow) var(--ease), color var(--t-slow) var(--ease);
  min-height: 100%;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }

/* ═══════════════════════════════════════════════════
   Responsive Layout Shell
   ═══════════════════════════════════════════════════ */

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

/* === Sidebar (desktop) === */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 30;
  transition: width var(--t-base) var(--ease), transform var(--t-base) var(--ease);
  overflow: hidden;
}

/* === Main Content === */
.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--t-base) var(--ease);
}

.content-area {
  flex: 1;
  min-width: 0;
  padding: 24px;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* === Bottom Nav (mobile) === */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  z-index: 30;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-inner {
  display: flex;
  height: var(--bottom-nav-height);
  align-items: center;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text3);
  transition: color var(--t-fast) var(--ease);
  min-height: 44px;
  font-family: var(--font);
}

.bottom-nav-item.active {
  color: var(--accent);
}

.bottom-nav-icon {
  font-size: 20px;
  line-height: 1;
  transition: transform var(--t-fast) var(--ease-spring);
}

.bottom-nav-item.active .bottom-nav-icon {
  transform: scale(1.1);
}

.bottom-nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* === Sidebar Icon Mode (tablet) === */
.sidebar-icon {
  width: var(--sidebar-icon-width);
}

.sidebar-icon .sidebar-label { display: none; }
.sidebar-icon .sidebar-brand-name { display: none; }

/* Breakpoints */
@media (max-width: 767px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding-bottom: var(--bottom-nav-height); }
  .bottom-nav { display: flex; }
  .content-area { padding: 12px; }
  .admin-card-header { padding: 12px 14px; }
  .admin-card-body { padding: 14px; }
  
  /* Prevent iOS Safari auto-zoom on input focus */
  .input, .segment-btn { font-size: 16px !important; }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .sidebar { width: var(--sidebar-icon-width); }
  .sidebar-label { display: none !important; }
  .sidebar-brand-name { display: none !important; }
  .main-content { margin-left: var(--sidebar-icon-width); }
  .content-area { padding: 20px; }
}

@media (min-width: 1200px) {
  .sidebar { width: var(--sidebar-width); }
  .main-content { margin-left: var(--sidebar-width); }
}

/* ═══════════════════════════════════════════════════
   Sidebar Components
   ═══════════════════════════════════════════════════ */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.sidebar-brand-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  width: 100%;
  text-align: left;
  white-space: nowrap;
}

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

.sidebar-nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
}

.sidebar-nav-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text2);
}

/* ═══════════════════════════════════════════════════
   Page Header
   ═══════════════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.03em;
}

@media (max-width: 767px) {
  .page-title { font-size: 18px; }
}

/* ═══════════════════════════════════════════════════
   Stats Bar
   ═══════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 767px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

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

.stat-card.stat-total::before { background: var(--accent); }
.stat-card.stat-instock::before { background: var(--success); }
.stat-card.stat-outofstock::before { background: var(--error); }
.stat-card.stat-error::before { background: var(--warning); }

.stat-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.stat-number {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-number.color-total    { color: var(--text); }
.stat-number.color-instock  { color: var(--success); }
.stat-number.color-outofstock { color: var(--error); }
.stat-number.color-error    { color: var(--warning); }

.stat-label {
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
  font-weight: 500;
}

.stat-icon {
  font-size: 20px;
  margin-bottom: 6px;
}

/* ═══════════════════════════════════════════════════
   Target Cards
   ═══════════════════════════════════════════════════ */
.target-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.target-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--t-fast) var(--ease);
  position: relative;
  border: 1px solid transparent;
}

.target-card:hover {
  box-shadow: var(--shadow);
}

/* In-stock flash animation */
@keyframes stockFlash {
  0%   { box-shadow: var(--shadow-sm); }
  30%  { box-shadow: 0 0 0 4px rgba(48, 209, 88, 0.35), var(--shadow-md); }
  100% { box-shadow: var(--shadow-sm); }
}

.target-card.just-in-stock {
  animation: stockFlash 1.2s var(--ease-out) forwards;
}

/* Status stripe on left */
.target-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.target-card.status-in_stock::before    { background: var(--success); }
.target-card.status-out_of_stock::before { background: var(--error); }
.target-card.status-checking::before   { background: var(--info); }
.target-card.status-error::before      { background: var(--warning); }
.target-card.status-pending::before    { background: var(--border); }

/* Card Header Row */
.target-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 12px 18px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.target-card-chevron {
  color: var(--text3);
  font-size: 11px;
  flex-shrink: 0;
  transition: transform var(--t-base) var(--ease-spring);
}

.target-card-chevron.open {
  transform: rotate(90deg);
}

.target-card-info {
  flex: 1;
  min-width: 0;
}

.target-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.target-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.target-card-sub {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}

.target-card-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
  text-align: right;
}

.target-card-time {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

/* Quick actions bar */
.target-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 8px 18px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
}

/* Expanded body */
.target-card-body {
  border-top: 1px solid var(--border-light);
  padding: 14px 14px 14px 18px;
}

/* ═══════════════════════════════════════════════════
   Badges & Pills
   ═══════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.badge-note {
  background: rgba(255,149,0,0.12);
  color: var(--warning-text);
}

.badge-group {
  background: var(--accent-light);
  color: var(--accent);
}

.badge-status-in_stock {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-status-out_of_stock {
  background: var(--error-bg);
  color: var(--error-text);
}

.badge-status-checking {
  background: var(--info-bg);
  color: var(--info-text);
}

.badge-status-error {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-status-pending {
  background: var(--muted-bg);
  color: var(--muted-text);
}

.badge-driver-wecom {
  background: rgba(48, 209, 88, 0.1);
  color: var(--success-text);
}

.badge-driver-telegram {
  background: rgba(0, 122, 255, 0.1);
  color: var(--info-text);
}

/* Pulse for "checking" */
@keyframes pulseBadge {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

.badge-status-checking {
  animation: pulseBadge 1.4s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
  white-space: nowrap;
  min-height: 34px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

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

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

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover { background: var(--surface-hover); }

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

.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn-danger {
  background: transparent;
  color: var(--error-text);
  border-color: rgba(255,59,48,0.3);
}

.btn-danger:hover { background: var(--error-bg); }

.btn-danger-confirm {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

.btn-danger-confirm:hover { filter: brightness(1.1); }

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  min-height: 28px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
  min-height: 48px;
  border-radius: var(--radius);
  font-weight: 600;
}

.btn-block { width: 100%; }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* FAB — mobile add button */
.fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 26px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 113, 227, 0.4);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-spring), box-shadow var(--t-fast) var(--ease);
  z-index: 25;
}

.fab:active { transform: scale(0.92); }
.fab:hover  { box-shadow: 0 6px 24px rgba(0, 113, 227, 0.5); }

@media (min-width: 768px) { .fab { display: none; } }

/* ═══════════════════════════════════════════════════
   Form Controls
   ═══════════════════════════════════════════════════ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: 0.01em;
}

.input {
  width: 100%;
  min-width: 0;
  padding: 10px 14px;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  transition:
    border-color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
  text-overflow: ellipsis;
}

.input::placeholder { color: var(--text3); }

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.input-error { border-color: var(--error) !important; }

textarea.input { resize: vertical; min-height: 80px; }

/* Segment Control (driver picker) */
.segment {
  display: flex;
  gap: 4px;
  background: var(--surface-hover);
  border-radius: var(--radius);
  padding: 3px;
}

.segment-btn {
  flex: 1;
  padding: 7px 12px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  background: transparent;
  color: var(--text2);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  min-height: 36px;
}

.segment-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-xs);
}

/* ═══════════════════════════════════════════════════
   Add Panel (desktop inline / modal)
   ═══════════════════════════════════════════════════ */
.add-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.add-panel-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.add-panel-row .input-url { flex: 2; min-width: 220px; }
.add-panel-row .input-note { flex: 1; min-width: 120px; max-width: 200px; }
.add-panel-row .group-select-wrap { flex: 1; min-width: 150px; max-width: 220px; }

/* ═══════════════════════════════════════════════════
   Bottom Sheet Modal
   ═══════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 40;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-xl);
  z-index: 50;
  padding: 0 0 env(safe-area-inset-bottom, 0);
  max-height: 92vh;
  overflow-y: auto;
}

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
}

.bottom-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 0;
}

.bottom-sheet-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.bottom-sheet-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-hover);
  border: none;
  color: var(--text2);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
}

.bottom-sheet-body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Step indicator */
.step-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 8px 0;
}

.step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: all var(--t-fast) var(--ease);
}

.step-dot.active {
  width: 20px;
  border-radius: 3px;
  background: var(--accent);
}

/* ═══════════════════════════════════════════════════
   Log / History
   ═══════════════════════════════════════════════════ */
.log-list {
  display: flex;
  flex-direction: column;
}

.log-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light);
}

.log-item:last-child { border-bottom: none; }

.log-text {
  font-size: 12px;
  font-family: var(--font-mono);
  line-height: 1.5;
  color: var(--text);
}

.log-text.log-error    { color: var(--error-text); }
.log-text.log-checking { color: var(--info-text); }
.log-text.log-in_stock { color: var(--success-text); }

.log-detail {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text3);
  padding-left: 10px;
  word-break: break-all;
  margin-top: 1px;
}

/* ═══════════════════════════════════════════════════
   Section Header
   ═══════════════════════════════════════════════════ */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  margin-bottom: 8px;
}

/* ═══════════════════════════════════════════════════
   Toast
   ═══════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 12px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  z-index: 60;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  pointer-events: none;
}

@media (min-width: 768px) {
  .toast {
    top: 20px;
    bottom: auto;
  }
}

.toast-success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid rgba(48, 209, 88, 0.2);
}

.toast-error {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid rgba(255, 59, 48, 0.2);
}

/* ═══════════════════════════════════════════════════
   Empty State
   ═══════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text2);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  display: block;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}

/* ═══════════════════════════════════════════════════
   Skeleton Loading
   ═══════════════════════════════════════════════════ */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.skeleton {
  background: var(--border-light);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 6px;
}

/* ═══════════════════════════════════════════════════
   Error Banner
   ═══════════════════════════════════════════════════ */
.error-banner {
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  border: 1px solid rgba(255, 59, 48, 0.15);
}

/* ═══════════════════════════════════════════════════
   Admin Panel Cards
   ═══════════════════════════════════════════════════ */
.admin-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-card-body {
  border-top: 1px solid var(--border-light);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ═══════════════════════════════════════════════════
   WS Status Dot
   ═══════════════════════════════════════════════════ */
.ws-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.ws-dot.connected    { background: var(--success); }
.ws-dot.disconnected { background: var(--error); }
.ws-dot.connecting   { background: var(--warning); animation: pulseBadge 1s infinite; }
.ws-dot.error        { background: var(--error); }

/* ═══════════════════════════════════════════════════
   Tabs
   ═══════════════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-hover);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 20px;
  width: fit-content;
}

.tab-btn {
  padding: 7px 16px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  background: transparent;
  color: var(--text2);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  min-height: 36px;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

/* ═══════════════════════════════════════════════════
   Tom Select Overrides (theme tokens)
   ═══════════════════════════════════════════════════ */
.ts-wrapper { min-height: 44px; }

.ts-control {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--radius) !important;
  min-height: 44px;
  padding: 8px 12px !important;
  font-size: 14px;
  font-family: var(--font);
  box-shadow: none !important;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.ts-wrapper.focus .ts-control {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-ring) !important;
}

.ts-control input { color: var(--text) !important; font-family: var(--font) !important; }
.ts-control input::placeholder { color: var(--text3) !important; }

.ts-item {
  background: var(--accent-light) !important;
  color: var(--accent) !important;
  border-radius: var(--radius-sm) !important;
  padding: 2px 8px !important;
  margin: 2px 3px 2px 0 !important;
  border: none !important;
}

.ts-item a { border-left-color: var(--accent) !important; }

.ts-dropdown {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-lg) !important;
  margin-top: 4px !important;
}

.ts-dropdown [data-selectable] {
  color: var(--text) !important;
  padding: 8px 12px !important;
  border-radius: var(--radius-sm) !important;
  margin: 2px !important;
}

.ts-dropdown .active  { background: rgba(0,0,0,0.05) !important; }
.ts-dropdown .selected { background: rgba(0,0,0,0.03) !important; }
.ts-dropdown .create  { color: var(--text2) !important; }
:root.dark .ts-dropdown .active  { background: rgba(255,255,255,0.08) !important; }
:root.dark .ts-dropdown .selected { background: rgba(255,255,255,0.05) !important; }

.ts-wrapper .items-placeholder { color: var(--text3) !important; }
.ts-wrapper.disabled .ts-control { opacity: 0.5; background: var(--surface) !important; }

/* ═══════════════════════════════════════════════════
   Scrollbar
   ═══════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ═══════════════════════════════════════════════════
   Utility
   ═══════════════════════════════════════════════════ */
.divider {
  height: 1px;
  background: var(--border-light);
  margin: 12px 0;
}

.text-muted { color: var(--text2); }
.text-subtle { color: var(--text3); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
