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

:root {
  --primary: #1a3a5c;
  --secondary: #2d6ea3;
  --accent: #5b9bd5;
  --bg: #f4f6f9;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --checked-bg: #dbeafe;
  --danger: #dc2626;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* LOGIN */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-icon {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 1rem;
}

.login-card h1 {
  color: var(--primary);
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--primary);
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, select:focus {
  border-color: var(--secondary);
}

.btn-primary {
  width: 100%;
  padding: 0.7rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

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

.btn-secondary {
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.btn-danger {
  padding: 0.5rem 1rem;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

/* APP HEADER */
.app-header {
  background: var(--primary);
  color: white;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left { display: flex; align-items: center; gap: 0.5rem; }
.header-icon { font-size: 1.3rem; }
.header-title { font-size: 1.1rem; font-weight: 600; }

.btn-user {
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.4);
  border-radius: var(--radius);
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 1rem;
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 0.3rem;
  z-index: 20;
}

.user-dropdown button {
  display: block;
  width: 100%;
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.user-dropdown button:hover { background: var(--checked-bg); }

/* TABS */
.tabs {
  display: flex;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab-btn {
  flex: 0 0 auto;
  padding: 0.7rem 1.2rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* LIST SELECTOR */
.list-selector {
  padding: 0.75rem 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: white;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.list-selector select { flex: 1; background: #f8fafc; }

.btn-new-list {
  padding: 0.6rem 0.85rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.15s;
  touch-action: manipulation;
}
.btn-new-list:hover { background: var(--secondary); }

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-content {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.modal-content h3 {
  margin-bottom: 1rem;
  color: var(--primary);
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400 !important;
  margin-bottom: 0.3rem !important;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.2rem;
}

/* LIST VIEW */
.list-view {
  padding: 1rem;
  max-width: 600px;
  margin: 0 auto;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.list-header h2 { color: var(--primary); font-size: 1.15rem; font-weight: 700; }

.list-subtitle {
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.btn-delete-list {
  background: transparent;
  color: #d0d5dd;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.5rem;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
  touch-action: manipulation;
}
.btn-delete-list:hover { color: var(--danger); background: rgba(220,38,38,0.08); }

/* NOTIFICATION BELL */
.btn-notif {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s;
  touch-action: manipulation;
}
.btn-notif:hover { background: rgba(255,255,255,0.25); }

.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #ef4444;
  color: white;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  pointer-events: none;
}

.notif-popup {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  min-width: 260px;
  max-width: 320px;
  overflow: hidden;
  z-index: 200;
}

.notif-popup-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--primary);
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
}

.notif-empty {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.notif-item {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  text-align: left;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.notif-item:hover { background: #f5f8fc; }
.notif-item-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.15rem;
}
.notif-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ITEM CARDS */
.items-list { display: flex; flex-direction: column; gap: 0.5rem; }

.item-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.25rem 0.6rem 0.75rem;
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.04);
  transition: background 0.15s;
  touch-action: none;
  user-select: none;
}

.item-card.checked { background: #edf4fb; }
.item-card.checked .item-name { text-decoration: line-through; color: #aaa; }

.item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.item-name {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: #1a1a2e;
  outline: none;
  border-bottom: 1px dashed transparent;
  cursor: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-name:focus {
  border-bottom-color: var(--secondary);
  white-space: normal;
  overflow: visible;
}

.item-num-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.65rem;
  color: #9aa3ae;
  font-weight: 500;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.item-num {
  width: 56px;
  min-width: 56px;
  max-width: 56px;
  padding: 0.3rem 0.25rem;
  border: 1px solid #e4e8ef;
  border-radius: 8px;
  text-align: center;
  font-size: 0.9rem;
  background: #f9fafb;
  touch-action: manipulation;
  -moz-appearance: textfield;
}
.item-price {
  width: 84px;
  min-width: 84px;
  max-width: 84px;
}
.item-num::-webkit-outer-spin-button,
.item-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.item-num:focus { border-color: var(--secondary); background: white; outline: none; }

/* Toggle on right */
.item-toggle {
  flex: 0 0 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.75rem;
  color: #d0d5dd;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.item-toggle.is-checked { color: var(--primary); }
.item-toggle:active { background: rgba(30,58,95,0.08); }

/* ADD ITEM */
.add-item-row { margin-top: 1rem; }

.btn-add-item {
  width: 100%;
  padding: 0.9rem;
  background: transparent;
  color: var(--secondary);
  border: 2px dashed #c8dff0;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-add-item:hover, .btn-add-item:active { background: #f0f7ff; }

.add-item-nums {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0;
}
.add-item-nums .form-group { flex: 1; }

.btn-primary-sm {
  padding: 0.6rem 1.2rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.2s;
  touch-action: manipulation;
}
.btn-primary-sm:hover { background: var(--secondary); }

/* EMPTY STATE */
.empty-state {
  max-width: 420px;
  margin: 2.5rem auto;
  padding: 2rem 1.5rem;
  text-align: center;
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.empty-state h3 { color: var(--primary); margin-bottom: 0.5rem; }
.empty-state p { color: #667085; margin-bottom: 1.5rem; font-size: 0.9rem; }
.empty-state .btn-primary { width: auto; padding: 0.7rem 2rem; display: inline-block; }

/* RESPONSIVE */
@media (min-width: 640px) {
  .list-selector { padding: 0.8rem 1.5rem; }
  .list-view { padding: 1.5rem; }
  .item-card { padding: 0.8rem 0.75rem 0.8rem 0.5rem; }
}
