/* =========================================================
   Rodicon — Inventario EPP · Estilos rediseñados
   Brand spec: yellow (oklch(84% 0.18 95)) as single accent
   ========================================================= */

/* ── Theme tokens ── */
:root {
  --bg:         oklch(96.5% 0.004 90);
  --surface:    oklch(100% 0 0);
  --surface2:   oklch(94% 0.006 95);
  --surface3:   oklch(90% 0.006 95);
  --fg:         oklch(22% 0.006 110);
  --muted:      oklch(48% 0.006 110);
  --text2:      var(--muted);
  --text3:      oklch(62% 0.006 110);
  --text4:      oklch(74% 0.004 100);
  --border:     oklch(88% 0.004 100);
  --border2:    oklch(82% 0.006 100);

  --accent:     oklch(84% 0.18 95);
  --accent-hover: oklch(88% 0.18 95);
  --accent-dim: oklch(92% 0.08 95);
  --accent-glow: oklch(84% 0.18 95 / 0.15);

  --success:    oklch(62% 0.14 145);
  --success-bg: oklch(94% 0.035 145);
  --danger:     oklch(57% 0.22 28);
  --danger-bg:  oklch(96% 0.04 28);
  --danger-hover: oklch(92% 0.08 28);
  --warn:       oklch(68% 0.14 85);
  --warn-bg:    oklch(95% 0.06 95);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px oklch(0% 0 0 / 0.06), 0 1px 2px oklch(0% 0 0 / 0.04);
  --shadow-md: 0 4px 12px oklch(0% 0 0 / 0.07), 0 2px 4px oklch(0% 0 0 / 0.04);
  --shadow-lg: 0 12px 36px oklch(0% 0 0 / 0.10), 0 4px 12px oklch(0% 0 0 / 0.06);
  --shadow-xl: 0 20px 60px oklch(0% 0 0 / 0.14), 0 8px 24px oklch(0% 0 0 / 0.08);

  --mono:  ui-monospace, 'JetBrains Mono', 'SFMono-Regular', Menlo, Consolas, monospace;
  --head: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html[data-theme="dark"] {
  --bg:         oklch(14% 0.006 110);
  --surface:    oklch(18% 0.006 110);
  --surface2:   oklch(22% 0.006 110);
  --surface3:   oklch(26% 0.006 110);
  --fg:         oklch(94% 0.006 100);
  --muted:      oklch(68% 0.006 100);
  --text2:      oklch(70% 0.006 100);
  --text3:      oklch(56% 0.006 100);
  --text4:      oklch(42% 0.006 100);
  --border:     oklch(30% 0.006 110);
  --border2:    oklch(36% 0.006 110);

  --accent:     oklch(84% 0.18 95);
  --accent-hover: oklch(78% 0.18 95);
  --accent-dim: oklch(30% 0.06 95);
  --accent-glow: oklch(84% 0.18 95 / 0.10);

  --success:    oklch(70% 0.13 145);
  --success-bg: oklch(22% 0.04 145);
  --danger:     oklch(68% 0.19 28);
  --danger-bg:  oklch(24% 0.04 28);
  --danger-hover: oklch(28% 0.06 28);
  --warn:       oklch(74% 0.12 85);
  --warn-bg:    oklch(26% 0.035 95);

  --shadow-sm: 0 1px 3px oklch(0% 0 0 / 0.2);
  --shadow-md: 0 4px 12px oklch(0% 0 0 / 0.3);
  --shadow-lg: 0 12px 36px oklch(0% 0 0 / 0.4);
  --shadow-xl: 0 20px 60px oklch(0% 0 0 / 0.5);
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ── */
.app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

.logo {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0;
}

.logo::before {
  content: "";
  display: block;
  width: 156px;
  height: 40px;
  margin-bottom: 10px;
  background: url("../rodicon-logo.png") left center / contain no-repeat;
}

html[data-theme="dark"] .logo::before {
  filter: brightness(1.05) drop-shadow(0 1px 0 oklch(100% 0 0 / 0.06));
}

.logo span {
  display: block;
  font-family: var(--head);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
}

/* ── Navigation ── */
nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--body);
  font-size: 0.88rem;
  font-weight: 550;
  text-align: left;
  transition: all 0.15s ease;
  position: relative;
}

nav button .nav-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: var(--surface2);
  font-size: 0.95rem;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

nav button:hover {
  background: var(--surface2);
  color: var(--fg);
}

nav button:hover .nav-icon {
  background: var(--surface3);
}

nav button.active {
  background: var(--accent-glow);
  color: var(--fg);
  font-weight: 600;
}

nav button.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

nav button.active .nav-icon {
  background: var(--accent);
  color: var(--fg);
}

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

/* ── Topbar ── */
.topbar {
  background: color-mix(in oklch, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 {
  font-family: var(--head);
  font-size: 1.4rem;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--fg);
}

.topbar .badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text3);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Theme toggle ── */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--surface2);
  border-color: var(--border2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ── Access button ── */
.access-btn {
  min-height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  padding: 7px 12px;
  font-family: var(--body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.access-btn:hover {
  background: var(--surface2);
  border-color: var(--border2);
  transform: translateY(-1px);
}

.access-btn.unlocked {
  border-color: var(--accent);
  color: var(--fg);
  background: var(--accent-glow);
}

/* ── Sync indicator ── */
.sync-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-family: var(--mono);
  cursor: default;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.3s ease;
}

.sync-dot.ok      { background: var(--success); box-shadow: 0 0 6px var(--success); }
.sync-dot.syncing { background: var(--accent);  box-shadow: 0 0 8px var(--accent);  animation: syncPulse 0.8s ease-in-out infinite; }
.sync-dot.error   { background: var(--danger);  box-shadow: 0 0 6px var(--danger); }
.sync-dot.locked  { background: var(--text4);   box-shadow: none; }
.sync-dot.offline { background: var(--warn);    box-shadow: 0 0 6px var(--warn); }
.sync-dot.pending { background: var(--accent);  box-shadow: 0 0 6px var(--accent); animation: syncPulse 2s ease-in-out infinite; }

@keyframes syncPulse {
  0%, 100% { opacity: 0.6; transform: scale(0.9); }
  50%      { opacity: 1;   transform: scale(1.2); }
}

.sync-label {
  color: var(--text3);
  font-size: 0.7rem;
  line-height: 1;
}

/* ── Install button ── */
.install-btn {
  min-height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--fg);
  padding: 7px 12px;
  font-family: var(--body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.install-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.install-btn[hidden] { display: none; }
.install-btn:disabled {
  cursor: default;
  opacity: 0.6;
  transform: none !important;
  box-shadow: none !important;
}

@media (max-width: 640px) {
  .sync-indicator {
    padding: 4px 8px;
    font-size: 0.65rem;
  }
  .sync-dot {
    width: 6px;
    height: 6px;
  }
}

/* ── Content ── */
.content {
  flex: 1;
  padding: 28px;
  overflow-y: auto;
}

/* ── Sections ── */
.section { display: none; }
.section.active { display: block; }

/* ════════════════════════════════════════════════════════
    STAT CARDS — Rediseñadas sin barras de colores
   ════════════════════════════════════════════════════════ */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 20px 18px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  border-color: var(--border2);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card .stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.stat-card:hover .stat-icon {
  background: var(--accent-glow);
  border-color: var(--accent-dim);
}

.stat-card .label {
  font-size: 0.7rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 650;
  margin-bottom: 6px;
}

.stat-card .value {
  font-family: var(--head);
  font-size: 2rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--fg);
}

.stat-card .sub {
  font-size: 0.78rem;
  color: var(--text3);
  margin-top: 6px;
}

/* ════════════════════════════════════════════════════════
    PANELS
   ════════════════════════════════════════════════════════ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.panel:hover {
  box-shadow: var(--shadow-sm);
}

.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
}

.panel-head h2 {
  font-family: var(--head);
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--fg);
}

.panel-head .actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ════════════════════════════════════════════════════════
    TABLES
   ════════════════════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th {
  padding: 10px 14px;
  text-align: left;
  font-family: var(--mono);
  font-size: 0.67rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 650;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--surface2);
}

/* ════════════════════════════════════════════════════════
    BADGES & TAGS
   ════════════════════════════════════════════════════════ */
.code-badge {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: var(--accent-dim);
  border: 1px solid color-mix(in oklch, var(--accent) 40%, var(--border));
  padding: 3px 8px;
  border-radius: 6px;
  color: oklch(30% 0.06 85);
  font-weight: 650;
  white-space: nowrap;
}

html[data-theme="dark"] .code-badge {
  color: oklch(88% 0.04 85);
}

.cat-badge {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
  display: inline-block;
  white-space: nowrap;
}

/* Stock indicators */
.stock-ok {
  color: var(--success);
  font-family: var(--mono);
  font-weight: 650;
}

.stock-low {
  color: var(--warn);
  font-family: var(--mono);
  font-weight: 650;
}

.stock-zero {
  color: var(--danger);
  font-family: var(--mono);
  font-weight: 650;
}

/* ════════════════════════════════════════════════════════
    PRODUCT THUMBNAIL
   ════════════════════════════════════════════════════════ */
.prod-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  overflow: hidden;
}

.prod-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ════════════════════════════════════════════════════════
    BUTTONS
   ════════════════════════════════════════════════════════ */
.btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 650;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  white-space: nowrap;
  line-height: 1.2;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent);
  color: var(--fg);
  border-color: color-mix(in oklch, var(--accent) 60%, var(--fg));
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--fg);
  border: 1px solid var(--border2);
}

.btn-secondary:hover {
  background: var(--surface3);
  border-color: color-mix(in oklch, var(--accent) 50%, var(--border));
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-ghost {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface2);
  border-color: var(--border2);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid color-mix(in oklch, var(--danger) 30%, var(--border));
}

.btn-danger:hover {
  background: var(--danger-hover);
  border-color: color-mix(in oklch, var(--danger) 50%, var(--border));
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.76rem;
  min-height: 30px;
  border-radius: 6px;
}

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

.actions-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  white-space: nowrap;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  color: var(--text2);
  font-size: 0.82rem;
}

/* ════════════════════════════════════════════════════════
    SEARCH BOX
   ════════════════════════════════════════════════════════ */
.search-box {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--body);
  font-size: 0.88rem;
  outline: none;
  width: 220px;
  transition: all 0.15s ease;
}

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

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

/* ════════════════════════════════════════════════════════
    MODALS — Rediseñados
   ════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: oklch(12% 0.006 110 / 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
}

html[data-theme="dark"] .modal-overlay {
  background: oklch(0% 0 0 / 0.6);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-xl);
}

.modal-sm {
  max-width: 400px;
}

.modal h3 {
  font-family: var(--head);
  font-size: 1.15rem;
  font-weight: 650;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
  color: var(--fg);
}

.modal > p {
  color: var(--text2);
  font-size: 0.88rem;
  margin-bottom: 22px;
  line-height: 1.5;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ════════════════════════════════════════════════════════
    FORMS
   ════════════════════════════════════════════════════════ */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.7rem;
  color: var(--text3);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 650;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--body);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

.form-group select option {
  background: var(--surface);
  color: var(--fg);
  padding: 8px;
}

.form-group input[type="color"] {
  height: 40px;
  cursor: pointer;
  padding: 3px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.modal-actions .btn {
  min-width: 100px;
  justify-content: center;
}

/* ════════════════════════════════════════════════════════
    GENERATED CODE DISPLAY
   ════════════════════════════════════════════════════════ */
.generated-code {
  background: var(--warn-bg);
  border: 1px solid color-mix(in oklch, var(--accent) 50%, var(--border));
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 0.95rem;
  color: oklch(30% 0.06 85);
  text-align: center;
  letter-spacing: 0.08em;
  font-weight: 650;
}

html[data-theme="dark"] .generated-code {
  color: oklch(88% 0.04 85);
}

/* ════════════════════════════════════════════════════════
    IMAGE UPLOAD
   ════════════════════════════════════════════════════════ */
.img-upload-zone {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  background: var(--surface2);
}

.img-upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.img-upload-zone p {
  color: var(--text3);
  font-size: 0.86rem;
}

#prodImgPreview {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  object-fit: cover;
  margin: 0 auto 10px;
  border: 1px solid var(--border);
  display: none;
}

/* ════════════════════════════════════════════════════════
    ENTRY ROW / DESPACHO ITEMS
   ════════════════════════════════════════════════════════ */
.entry-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.entry-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px 5px 12px;
  font-size: 0.8rem;
}

.pill button {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: color 0.15s;
}

.pill button:hover {
  color: oklch(47% 0.22 28);
}

.items-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
  min-height: 36px;
}

/* ════════════════════════════════════════════════════════
    TABS
   ════════════════════════════════════════════════════════ */
.tab-strip {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  font-family: var(--body);
  font-size: 0.84rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  background: var(--surface2);
  color: var(--fg);
}

.tab-btn.active {
  background: var(--fg);
  color: #fff;
  border-color: var(--fg);
}

/* ════════════════════════════════════════════════════════
    MISC UTILITIES
   ════════════════════════════════════════════════════════ */
.flex-gap {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.hint {
  font-size: 0.73rem;
  color: var(--text3);
  margin-top: 4px;
}

.empty {
  text-align: center;
  padding: 36px;
  color: var(--text3);
  font-size: 0.9rem;
}

.empty .big {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.section-title {
  font-family: var(--head);
  font-size: 1.05rem;
  font-weight: 650;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

/* ════════════════════════════════════════════════════════
    BACKUP SECTION
   ════════════════════════════════════════════════════════ */
.backup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.backup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 220px;
  transition: box-shadow 0.2s ease;
}

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

.backup-card h3 {
  font-family: var(--head);
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.backup-card p {
  color: var(--text2);
  font-size: 0.88rem;
  max-width: 56ch;
  line-height: 1.5;
}

.sync-status {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text3);
  min-height: 20px;
}

.backup-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.backup-meta .mini {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.backup-meta .mini span {
  display: block;
  color: var(--text3);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 650;
  margin-bottom: 4px;
}

.backup-meta .mini strong {
  font-family: var(--mono);
  font-size: 1.2rem;
  color: var(--fg);
}

.backup-file {
  display: none;
}

.backup-warn {
  background: var(--warn-bg);
  border: 1px solid color-mix(in oklch, var(--warn) 30%, var(--border));
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--fg);
  font-size: 0.82rem;
  line-height: 1.5;
}

/* ════════════════════════════════════════════════════════
    EXPORT DROPDOWN
   ════════════════════════════════════════════════════════ */
.export-group {
  position: relative;
  display: inline-block;
}

.export-menu {
  position: absolute;
  right: 0;
  top: 110%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 170px;
  z-index: 50;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: none;
  animation: fadeIn 0.12s ease;
}

.export-menu.open {
  display: block;
}

.export-menu button {
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--fg);
  cursor: pointer;
  font-family: var(--body);
  font-size: 0.84rem;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s;
}

.export-menu button:hover {
  background: var(--surface2);
}

/* ════════════════════════════════════════════════════════
    SCROLLBAR
   ════════════════════════════════════════════════════════ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border2);
}

/* ════════════════════════════════════════════════════════
    RESPONSIVE — Tablet (≤ 960px)
   ════════════════════════════════════════════════════════ */
@media (max-width: 960px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: 0;
    height: auto;
    position: sticky;
    top: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .logo {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .logo::before {
    width: 120px;
    height: 32px;
    margin-bottom: 0;
  }

  .logo span {
    display: none;
  }

  nav {
    padding: 8px 12px 10px;
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  nav::-webkit-scrollbar {
    display: none;
  }

  nav button {
    width: auto;
    white-space: nowrap;
    flex: 0 0 auto;
    padding: 8px 12px;
  }

  nav button.active::before {
    display: none;
  }

  nav button.active {
    background: var(--accent-glow);
    border: 1px solid color-mix(in oklch, var(--accent) 40%, var(--border));
  }

  .topbar {
    position: static;
    padding: 14px 16px;
  }

  .topbar h1 {
    font-size: 1.2rem;
  }

  .content {
    padding: 20px 16px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .panel {
    overflow-x: auto;
  }

  .table-wrap {
    margin: 0 -16px;
    padding: 0 16px;
  }

  .backup-grid {
    grid-template-columns: 1fr;
  }
}

/* ════════════════════════════════════════════════════════
    RESPONSIVE — Mobile (≤ 640px)
   ════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .topbar h1 {
    font-size: 1.1rem;
    text-align: center;
  }

  .topbar-actions {
    width: 100%;
    justify-content: center;
  }

  .topbar-actions .badge {
    width: 100%;
    text-align: center;
  }

  .topbar > .topbar-actions:first-of-type {
    order: 2;
  }

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

  .stat-card {
    padding: 16px;
  }

  .stat-card .value {
    font-size: 1.6rem;
  }

  .stat-card .stat-icon {
    width: 30px;
    height: 30px;
    font-size: 0.95rem;
    margin-bottom: 10px;
  }

  .content {
    padding: 14px 12px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .backup-meta {
    grid-template-columns: 1fr;
  }

  .search-box {
    width: 100%;
  }

  .flex-gap {
    width: 100%;
  }

  .flex-gap > .btn {
    flex: 1;
    justify-content: center;
  }

  .entry-row {
    flex-direction: column;
    align-items: stretch;
  }

  .entry-row .form-group {
    width: 100%;
  }

  /* ── Mobile modals ── */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
    backdrop-filter: blur(4px);
  }

  .modal {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 24px 20px 28px;
    margin-top: 0;
    animation: modalSlideUpMobile 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

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

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .panel-head .actions {
    width: 100%;
  }

  .panel-head .actions > * {
    flex: 1;
    justify-content: center;
  }

  .tab-strip {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tab-strip::-webkit-scrollbar {
    display: none;
  }

  .backup-card {
    min-height: auto;
    padding: 18px;
  }

  .btn {
    min-height: 40px;
    font-size: 0.88rem;
  }

  .access-btn, .install-btn {
    min-height: 40px;
    font-size: 0.85rem;
  }

  .theme-toggle {
    width: 40px;
    height: 40px;
  }
}

/* ════════════════════════════════════════════════════════
    RESPONSIVE — Very small (≤ 400px)
   ════════════════════════════════════════════════════════ */
@media (max-width: 400px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .topbar-actions .badge {
    order: -1;
  }

  nav button {
    font-size: 0.82rem;
    padding: 7px 10px;
  }

  nav button .nav-icon {
    width: 24px;
    height: 24px;
    font-size: 0.85rem;
  }
}
