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

:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #18181f;
  --bg4: #1e1e28;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --text: #f0f0f5;
  --text2: #9090a8;
  --text3: #5a5a6e;
  --accent: #6c63ff;
  --accent2: #8b7fff;
  --accent-glow: rgba(108,99,255,0.25);
  --green: #22d3a0;
  --green-dim: rgba(34,211,160,0.15);
  --red: #ff5470;
  --red-dim: rgba(255,84,112,0.12);
  --orange: #ff9f43;
  --orange-dim: rgba(255,159,67,0.15);
  --yellow: #ffd166;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.6);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ---- NOISE TEXTURE ---- */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0; opacity: 0.4;
}

/* ---- AUTH SCREEN ---- */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

#auth-screen::after {
  content: '';
  position: fixed;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(108,99,255,0.12) 0%, transparent 70%);
  top: -100px; left: -100px;
  pointer-events: none;
}

.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(108,99,255,0.1);
  animation: fadeInUp 0.5s ease;
}

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

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.auth-logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.auth-logo h1 {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.auth-logo span { color: var(--accent2); }

.auth-tabs {
  display: flex;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 28px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  color: var(--text3);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--bg4);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  transition: all 0.2s;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg4);
}

.form-input.error { border-color: var(--red); }
.form-input.success { border-color: var(--green); }

.input-hint {
  font-size: 12px;
  margin-top: 5px;
  color: var(--text3);
}

.input-hint.error { color: var(--red); }
.input-hint.success { color: var(--green); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  margin-top: 8px;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-glow);
}

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

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

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255,84,112,0.2);
}

.btn-danger:hover { background: rgba(255,84,112,0.2); }

.btn-success {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(34,211,160,0.2);
}

.btn-success:hover { background: rgba(34,211,160,0.25); }

.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 6px; }
.btn-icon { padding: 8px; border-radius: 8px; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-error { background: var(--red-dim); color: var(--red); border: 1px solid rgba(255,84,112,0.2); }
.alert-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34,211,160,0.2); }
.alert-info { background: var(--accent-glow); color: var(--accent2); border: 1px solid rgba(108,99,255,0.2); }

/* ---- APP LAYOUT ---- */
#app-screen { display: none; min-height: 100vh; flex-direction: column; }
#app-screen.visible { display: flex; }

/* ---- HEADER ---- */
.header {
  background: rgba(10,10,15,0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.3px;
}

.header-logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}

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

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px 6px 8px;
  font-size: 13px;
  font-weight: 500;
}

.user-avatar {
  width: 26px; height: 26px;
  background: linear-gradient(135deg, var(--accent), var(--green));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
}

/* ---- MAIN CONTENT ---- */
.main {
  flex: 1;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ---- STATS BAR ---- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 60px; height: 60px;
  border-radius: 50%;
  opacity: 0.1;
  transform: translate(20px, -20px);
}

.stat-card.total::before { background: var(--accent); }
.stat-card.checked::before { background: var(--green); }
.stat-card.remaining::before { background: var(--orange); }

.stat-number {
  font-family: 'Syne', sans-serif;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card.total .stat-number { color: var(--accent2); }
.stat-card.checked .stat-number { color: var(--green); }
.stat-card.remaining .stat-number { color: var(--orange); }

.stat-label {
  font-size: 12px;
  color: var(--text3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---- PROGRESS BAR ---- */
.progress-section {
  margin-bottom: 28px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text2);
}

.progress-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 3px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- ADD FORM ---- */
.add-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.add-section-title {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text2);
}

.add-form-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 10px;
}

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

.form-select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a5a6e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

.form-select option { background: var(--bg3); }

.add-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.add-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px var(--accent-glow); }
.add-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---- TOOLBAR ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar-search {
  flex: 1;
  min-width: 180px;
  position: relative;
}

.toolbar-search input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px 10px 38px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

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

.toolbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 15px;
  pointer-events: none;
}

.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- CATEGORY FILTER ---- */
.category-filter {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--bg4) transparent;
}

.category-filter::-webkit-scrollbar { height: 3px; }
.category-filter::-webkit-scrollbar-track { background: transparent; }
.category-filter::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 2px; }

.cat-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.cat-chip:hover { border-color: var(--border2); color: var(--text); }
.cat-chip.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent2); }

/* ---- ITEMS LIST ---- */
.items-section { }

.category-group { margin-bottom: 24px; }

.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.category-emoji { font-size: 18px; }

.category-name {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
  flex: 1;
}

.category-count {
  font-size: 11px;
  background: var(--bg3);
  color: var(--text3);
  padding: 2px 8px;
  border-radius: 10px;
}

.item-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.2s;
  cursor: pointer;
  user-select: none;
  animation: slideIn 0.25s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

.item-card:hover { border-color: var(--border2); transform: translateX(2px); }
.item-card.checked { opacity: 0.55; }
.item-card.checked .item-name { text-decoration: line-through; color: var(--text3); }

.item-checkbox {
  width: 22px; height: 22px;
  border: 2px solid var(--border2);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  font-size: 13px;
}

.item-card.checked .item-checkbox {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

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

.item-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.item-qty {
  font-size: 12px;
  color: var(--text3);
  background: var(--bg3);
  padding: 2px 8px;
  border-radius: 4px;
}

.item-note {
  font-size: 12px;
  color: var(--text3);
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.priority-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.priority-dot.high { background: var(--red); box-shadow: 0 0 4px var(--red); }
.priority-dot.normal { background: var(--accent); }
.priority-dot.low { background: var(--text3); }

.item-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.item-card:hover .item-actions { opacity: 1; }

.item-action-btn {
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  background: var(--bg3);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  color: var(--text2);
}

.item-action-btn:hover { background: var(--bg4); color: var(--text); border-color: var(--border2); }
.item-action-btn.delete:hover { background: var(--red-dim); color: var(--red); border-color: rgba(255,84,112,0.3); }
.item-action-btn.edit:hover { background: var(--accent-glow); color: var(--accent2); border-color: rgba(108,99,255,0.3); }

/* ---- EDIT MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

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

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}

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

.empty-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.7; }
.empty-title { font-family: 'Syne', sans-serif; font-size: 18px; color: var(--text2); margin-bottom: 8px; }
.empty-text { font-size: 14px; line-height: 1.6; }

/* ---- SETTINGS PANEL ---- */
.settings-panel {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: 320px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 200;
  padding: 24px;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.settings-panel.open { transform: translateX(0); box-shadow: -20px 0 60px rgba(0,0,0,0.5); }

.settings-overlay {
  position: fixed; inset: 0;
  z-index: 150;
  display: none;
}

.settings-overlay.open { display: block; }

.settings-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-close {
  width: 30px; height: 30px;
  background: var(--bg3);
  border: none;
  border-radius: 6px;
  color: var(--text2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.settings-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.settings-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
}

/* ---- TOAST ---- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  max-width: 300px;
}

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

.toast.success { border-color: rgba(34,211,160,0.3); }
.toast.error { border-color: rgba(255,84,112,0.3); }
.toast.info { border-color: rgba(108,99,255,0.3); }

/* ---- CONFIRM DIALOG ---- */
.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.confirm-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 28px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s ease;
}

.confirm-icon { font-size: 40px; margin-bottom: 12px; }
.confirm-title { font-family: 'Syne', sans-serif; font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.confirm-text { font-size: 14px; color: var(--text2); margin-bottom: 20px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }

/* ---- LOADING ---- */
.loading-spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-full {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
  color: var(--text2);
  font-size: 14px;
}

.loading-full .loading-spinner {
  width: 36px; height: 36px;
  border-color: var(--bg3);
  border-top-color: var(--accent);
}

/* ---- SORT CONTROLS ---- */
.sort-select {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 32px 9px 12px;
  color: var(--text2);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235a5a6e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all 0.2s;
}

.sort-select:focus { border-color: var(--accent); color: var(--text); }
.sort-select option { background: var(--bg3); }

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
  .stats-bar { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-number { font-size: 22px; }
  .add-form-row { grid-template-columns: 1fr 1fr; }
  .add-form-grid { grid-template-columns: 1fr; }
  .add-btn { width: 100%; }
  .header { padding: 0 16px; }
  .main { padding: 20px 16px; }
  .auth-card { padding: 32px 24px; }
  .settings-panel { width: 100%; }
  .item-actions { opacity: 1; }
  .toolbar { gap: 8px; }
}

@media (max-width: 400px) {
  .add-form-row { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: 1fr; }
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* hidden/show utilities */
.hidden { display: none !important; }

/* ---- CONFIRM MODAL ---- */
.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px);
  z-index: 1500;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.confirm-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 36px 32px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,84,112,0.15);
  animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.confirm-icon { font-size: 44px; margin-bottom: 14px; display: block; }
.confirm-title {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}
.confirm-text {
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 28px;
  line-height: 1.6;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.confirm-actions .btn { min-width: 110px; }

/* ---- HEADER MOBILE ---- */
.user-name-text {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- FORM CATEGORY ROW ---- */
.add-form-category {
  margin-bottom: 10px;
}

.add-form-category .form-select {
  width: 100%;
}

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

@media (max-width: 640px) {
  /* Header : réduire le badge pseudo pour laisser place aux boutons */
  .header { gap: 8px; }
  .user-badge { padding: 5px 10px 5px 6px; }
  .user-name-text { max-width: 80px; }
  .header-logout { display: flex !important; }

  /* Catégorie pleine largeur */
  .add-form-category .form-select { width: 100%; }

  /* Quantité + priorité côte à côte */
  .add-form-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 360px) {
  .user-name-text { display: none; }
}

/* ---- ANDROID DOWNLOAD BUTTON ---- */
.android-dl {
  color: #22d3a0;
  border-color: rgba(34,211,160,0.25);
  display: none;
}

.android-dl:hover {
  background: rgba(34,211,160,0.1);
  border-color: rgba(34,211,160,0.4);
  color: #22d3a0;
}

/* Visible sur mobile et tablette (header-row1 visible seulement sur mobile) */
@media (max-width: 640px) {
  .android-dl { display: flex !important; }
}

/* ---- HEADER RESTRUCTURÉ ---- */
.header {
  height: auto !important;
  padding: 0 24px !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 0;
}

.header-row1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}

.header-row2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  border-top: 1px solid var(--border);
  padding-top: 0;
}

/* Sur desktop : tout sur une seule ligne */
@media (min-width: 641px) {
  .header {
    flex-direction: row !important;
    height: 64px !important;
    align-items: center !important;
  }
  .header-row1 {
    flex: 1;
    height: auto;
    border: none;
  }
  .header-row2 {
    height: auto;
    border: none;
    gap: 8px;
  }
}


/* Sur mobile : deux lignes */
@media (max-width: 640px) {
  .header { padding: 0 16px !important; }
  .header-row2 { gap: 8px; }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---- SYNC INDICATOR ---- */
.sync-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--bg3);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text3);
  font-weight: 500;
  transition: all 0.3s;
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 4px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.sync-indicator.syncing {
  border-color: var(--green);
  background: var(--green-dim);
  color: var(--green);
}

.sync-indicator.syncing .sync-dot {
  animation: none;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  transform: scale(1.3);
}

.sync-label { letter-spacing: 0.5px; text-transform: uppercase; }

/* ---- PRIORITY BADGE ---- */
.item-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.priority-badge {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.2s;
}

.priority-urgent {
  background: var(--red);
  box-shadow: 0 0 6px var(--red), 0 0 12px rgba(255,84,112,0.4);
  animation: pulse-urgent 1.8s ease-in-out infinite;
}

.priority-normal {
  background: #2196F3;
  box-shadow: 0 0 4px rgba(33,150,243,0.6);
}

@keyframes pulse-urgent {
  0%, 100% { box-shadow: 0 0 6px var(--red), 0 0 12px rgba(255,84,112,0.4); }
  50% { box-shadow: 0 0 10px var(--red), 0 0 20px rgba(255,84,112,0.6); }
}

/* Liseré gauche selon priorité */
.item-card.urgent {
  border-left: 3px solid var(--red);
}

.item-card:not(.urgent) {
  border-left: 3px solid #2196F3;
}

.item-card.urgent.checked,
.item-card.checked {
  border-left-color: var(--border);
}

/* Cacher la pastille sur les articles cochés */
.item-card.checked .priority-badge {
  opacity: 0.25;
}

/* ---- PRIORITY GROUPS (vue tri priorité) ---- */
.priority-group { margin-bottom: 24px; }

.priority-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.urgent-header { color: var(--red); border-bottom-color: rgba(255,84,112,0.3); }
.normal-header { color: #2196F3; border-bottom-color: rgba(33,150,243,0.3); }

/* ---- STORE SELECTOR ---- */
.add-form-store-cat {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

@media (max-width: 480px) {
  .add-form-store-cat { grid-template-columns: 1fr; }
}

.item-store {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent2);
  background: var(--accent-glow);
  border: 1px solid rgba(108,99,255,0.2);
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
