/* ===== Design Tokens ===== */
:root {
  --bg:            #3c3f43;
  --surface-1:     #45484c;
  --surface-2:     #525558;
  --surface-3:     #5c5f63;
  --border:        #5c5f63;
  --border-subtle: #4d5054;

  --primary:       #33cc99;
  --primary-dark:  #2ba877;
  --primary-glow:  rgba(51,204,153,.18);

  --success:       #4ade80;
  --danger:        #f87171;
  --danger-bg:     rgba(248,113,113,.1);
  --warning:       #fbbf24;
  --urgent:        #ef4444;
  --urgent-bg:     rgba(239,68,68,.08);
  --urgent-border: rgba(239,68,68,.35);

  --text:          #e2e8f0;
  --text-muted:    #94a3b8;
  --text-subtle:   #64748b;

  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     16px;
  --radius-full:   999px;

  --shadow-sm:     0 1px 3px rgba(0,0,0,.4);
  --shadow:        0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.6);

  --transition:    .2s ease;
  --header-h:      56px;
  --tabs-h:        48px;
  --fab-size:      56px;
  --safe-bottom:   env(safe-area-inset-bottom, 0px);
}

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

html { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== App Header ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  gap: .75rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}

.header-icon {
  width: 22px;
  height: 22px;
  color: var(--primary);
  flex-shrink: 0;
}

.header-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: .25rem;
}

.last-updated-badge {
  font-size: .7rem;
  color: var(--text);
  opacity: .5;
  white-space: nowrap;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary-dark);
  border: none;
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  transition: opacity var(--transition);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-avatar:hover { opacity: .85; }

/* ===== Shop Tabs ===== */
.shop-tabs-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 90;
  background: var(--bg);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  height: var(--tabs-h);
  padding: 0 .5rem 0 .25rem;
  gap: .25rem;
}

.shop-tabs-scroll {
  flex: 1;
  display: flex;
  gap: .375rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: .25rem .25rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.shop-tabs-scroll::-webkit-scrollbar { display: none; }

.shop-tab {
  flex-shrink: 0;
  height: 32px;
  padding: 0 .875rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: transparent;
  color: #fefefe;
  font-size: .825rem;
  font-weight: 500;
  white-space: nowrap;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.shop-tab:hover { border-color: var(--primary); color: var(--primary); }
.shop-tab.active {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
  font-weight: 600;
}

.add-shop-tab-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.add-shop-tab-btn:hover { border-color: var(--primary); color: var(--primary); }
.add-shop-tab-btn svg { width: 14px; height: 14px; }

/* ===== Boot Status ===== */
.boot-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: .9rem;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Main Content ===== */
.main-content {
  padding: .75rem .75rem 0;
  max-width: 720px;
  margin: 0 auto;
}

.items-list { display: flex; flex-direction: column; gap: .5rem; }

.bottom-spacer {
  height: calc(var(--fab-size) + 1.5rem + var(--safe-bottom));
}

/* ===== Shop Group ===== */
.shop-group {
  margin-bottom: .75rem;
}

.shop-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .375rem;
  padding: 0 .25rem;
}

.shop-group-name {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: #fefefe;
  user-select: none;
  cursor: default;
}
.shop-group-name.urgent-label-text { color: var(--urgent); }

.shop-group-count {
  font-size: .7rem;
  color: var(--text-subtle);
  background: var(--surface-2);
  padding: .1rem .45rem;
  border-radius: var(--radius-full);
}

.shop-delete-btn {
  opacity: 0;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  color: var(--text-subtle);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  padding: 0;
}
.shop-group-header:hover .shop-delete-btn { opacity: 1; }
.shop-delete-btn:hover { color: var(--danger); background: var(--danger-bg); }

/* ===== Other Shops Group ===== */
.other-shops-group {
  margin-top: .25rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border-subtle);
}
.other-shops-label {
  opacity: .75;
}
.other-shops-group .item-card {
  opacity: .72;
}
.other-shops-group .item-card:hover {
  opacity: 1;
}

/* ===== Item Card ===== */
.item-card {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: .75rem;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.item-card:hover { border-color: var(--border); }
.item-card.urgent-card { border-left: 3px solid var(--urgent); background: var(--urgent-bg); }

/* left accent strip for urgent */
.item-card.urgent-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--urgent);
  border-radius: var(--radius) 0 0 var(--radius);
}

/* Check button (tap to mark done) */
.item-check-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  background: transparent;
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: .1rem;
  transition: all .15s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.item-check-btn:hover,
.item-check-btn:active {
  border-color: var(--success);
  background: rgba(74, 222, 128, .12);
  color: var(--success);
}
.item-check-btn svg { width: 14px; height: 14px; display: none; }
.item-check-btn:hover svg,
.item-check-btn:active svg { display: block; }

.urgent-card .item-check-btn { border-color: var(--urgent-border); }
.urgent-card .item-check-btn:hover { border-color: var(--urgent); background: rgba(239,68,68,.12); color: var(--urgent); }

/* Item body */
.item-body {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: .95rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
  line-height: 1.4;
}
.item-name a {
  color: var(--primary);
  text-decoration: none;
}
.item-name a:hover { text-decoration: underline; }

.item-shop-source-label {
  color: #fefefe;
  font-size: .8em;
  font-weight: 400;
  margin-left: .1em;
}

.item-badges {
  display: flex;
  align-items: center;
  gap: .375rem;
  flex-wrap: wrap;
  margin-top: .3rem;
}

.qty-badge {
  font-size: .7rem;
  font-weight: 600;
  background: var(--surface-3);
  color: var(--text-muted);
  padding: .1rem .45rem;
  border-radius: var(--radius-full);
}

.added-by-badge {
  font-size: .7rem;
  color: var(--text-muted);
}

.shop-source-badge {
  font-size: .7rem;
  color: var(--text-subtle);
  background: var(--surface-2);
  padding: .1rem .4rem;
  border-radius: var(--radius-full);
}

/* Item actions */
.item-actions {
  display: flex;
  align-items: center;
  gap: .375rem;
  flex-shrink: 0;
  margin-top: .05rem;
}

.item-action-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 600;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.item-action-btn:hover { background: var(--surface-2); color: var(--text); }

.item-action-btn.urgent-toggle-btn.is-urgent {
  border-color: var(--urgent);
  color: var(--urgent);
  background: rgba(239,68,68,.1);
}
.item-action-btn.urgent-toggle-btn:hover { border-color: var(--urgent); color: var(--urgent); background: rgba(239,68,68,.15); }

.item-action-btn.qty-inc-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-glow); }

.item-action-btn.delete-btn:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }

/* Pressing state for delete */
.item-check-btn[data-pressing="1"] {
  background: rgba(248,113,113,.15);
  border-color: var(--danger);
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--text-subtle);
}
.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: .75rem;
  opacity: .5;
}
.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: .5rem;
}
.empty-state p { font-size: .875rem; line-height: 1.6; }

/* ===== History Sections ===== */
.history-section {
  margin-top: .75rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.history-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .625rem .875rem;
  background: var(--surface-1);
  border: none;
  color: var(--text-muted);
  font-size: .825rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.history-header:hover { background: var(--surface-2); color: var(--text); }
.history-header[aria-expanded="true"] { color: var(--text); }

.history-icon { font-size: .9rem; }

.history-title { flex: 1; }

.history-chevron {
  font-size: .7rem;
  transition: transform var(--transition);
  color: var(--text-subtle);
}
.history-header[aria-expanded="true"] .history-chevron { transform: rotate(180deg); }

.history-list { background: var(--surface-1); }

.history-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .875rem;
  border-top: 1px solid var(--border-subtle);
  font-size: .825rem;
}
.history-item:first-child { border-top: none; }

.history-item-info { flex: 1; min-width: 0; }
.history-item-name {
  font-weight: 500;
  color: #fefefe;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item-meta {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: .1rem;
}

.history-undo-btn {
  flex-shrink: 0;
  height: 26px;
  padding: 0 .6rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 600;
  transition: all var(--transition);
}
.history-undo-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-glow); }

.history-view-more {
  width: 100%;
  padding: .5rem;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border-subtle);
  color: var(--primary);
  font-size: .78rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: background var(--transition);
}
.history-view-more:hover { background: var(--surface-2); }

/* ===== FAB ===== */
.fab {
  position: fixed;
  bottom: calc(1.25rem + var(--safe-bottom));
  right: 1.25rem;
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: var(--radius-full);
  background: var(--primary-dark);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow), 0 0 0 0 var(--primary-glow);
  transition: transform .15s ease, box-shadow .15s ease;
  z-index: 200;
  -webkit-tap-highlight-color: transparent;
}
.fab svg { width: 24px; height: 24px; transition: transform .15s ease; }
.fab:hover { transform: scale(1.06); }
.fab:active { transform: scale(.95); }
.fab.open { background: var(--surface-3); }
.fab.open svg { transform: rotate(45deg); }

/* ===== Sheet Backdrop ===== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.sheet-backdrop.visible { opacity: 1; pointer-events: auto; }

/* ===== Add Sheet (top-anchored) ===== */
.sheet {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 400;
  background: var(--surface-1);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: 0 1rem 1.25rem;
  transform: translateY(-100%);
  transition: transform .3s cubic-bezier(.32,.72,0,1);
  max-width: 600px;
  margin: 0 auto;
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet.open { transform: translateY(0); }

.sheet-handle-bar { display: none; }
.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.sheet-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.sheet-close-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  transition: all var(--transition);
}
.sheet-close-btn:hover { background: var(--surface-3); color: var(--text); }
.sheet-close-btn svg { width: 14px; height: 14px; }

/* Sheet — New item button */
.sheet-new-btn {
  height: 30px;
  padding: 0 .75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 500;
  white-space: nowrap;
  transition: all var(--transition);
}
.sheet-new-btn:hover { border-color: var(--primary); color: var(--primary); }

/* Sheet — Search */
.sheet-search-row { margin-bottom: .5rem; }
.sheet-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.sheet-search-icon {
  position: absolute;
  left: .75rem;
  width: 15px;
  height: 15px;
  color: rgba(226,232,240,.4);
  pointer-events: none;
  flex-shrink: 0;
}
.sheet-search-input {
  width: 100%;
  height: 42px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .9rem;
  font-family: inherit;
  padding: 0 2.25rem 0 2.5rem;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.sheet-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.sheet-search-input::placeholder { color: var(--text-subtle); }
.sheet-search-input::-webkit-search-cancel-button { display: none; }
.sheet-search-clear {
  position: absolute;
  right: .5rem;
  width: 22px;
  height: 22px;
  background: var(--surface-3);
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Sheet — Shop filter pills */
.sheet-shop-pills {
  display: flex;
  gap: .375rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding: .125rem 0 .625rem;
  scrollbar-width: none;
  flex-shrink: 0;
}
.sheet-shop-pills::-webkit-scrollbar { display: none; }
.sheet-shop-pill {
  flex-shrink: 0;
  height: 27px;
  padding: 0 .7rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: transparent;
  color: rgba(226,232,240,.55);
  font-size: .77rem;
  font-weight: 500;
  white-space: nowrap;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.sheet-shop-pill.active {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
  font-weight: 600;
}
.sheet-shop-pill:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* Sheet — Items checklist */
.sheet-items-list {
  flex: 1;
  overflow-y: auto;
  max-height: 42vh;
  margin: 0 -1rem;
  padding: 0 1rem;
  overscroll-behavior: contain;
}
.sheet-items-empty {
  text-align: center;
  padding: 1.5rem 0 .5rem;
  color: rgba(226,232,240,.55);
  font-size: .9rem;
}
.sheet-add-new-suggestion {
  display: block;
  width: 100%;
  margin-top: .75rem;
  padding: .6rem .875rem;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--primary);
  font-size: .875rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition);
}
.sheet-add-new-suggestion:hover { background: var(--surface-3); }

.sheet-item-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem .25rem;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition);
  border-radius: var(--radius-sm);
  margin: 0 -.25rem;
  -webkit-tap-highlight-color: transparent;
}
.sheet-item-row:hover { background: var(--surface-2); }
.sheet-item-row.selected { background: rgba(51,204,153,.1); }
.sheet-item-row:last-child { border-bottom: none; }

.sheet-item-check {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  background: transparent;
}
.sheet-item-row.selected .sheet-item-check {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}
.sheet-item-check svg { width: 11px; height: 11px; }

.sheet-item-info { flex: 1; min-width: 0; }
.sheet-item-name {
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet-item-shop {
  font-size: .74rem;
  color: rgba(226,232,240,.4);
  margin-top: .1rem;
}

/* Inline qty stepper (in sheet rows) */
.sheet-item-qty {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-shrink: 0;
}
.sheet-qty-btn-sm {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text);
  font-size: .95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.sheet-qty-btn-sm:active { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.sheet-qty-val {
  min-width: 22px;
  text-align: center;
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
}

/* Sheet — Confirm bar */
.sheet-confirm-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding-top: .875rem;
  margin-top: .5rem;
  border-top: 1px solid var(--border-subtle);
  position: sticky;
  bottom: 0;
  background: var(--surface-1);
  padding-bottom: calc(.5rem + var(--safe-bottom));
}
.sheet-confirm-btn {
  flex: 1;
  height: 46px;
  margin: 0;
}

/* Qty stepper */
.qty-stepper {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .25rem;
}
.qty-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--surface-3);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.qty-btn:hover { background: var(--border); }
.qty-btn:active { background: var(--primary-dark); color: #fff; }
.qty-display {
  min-width: 36px;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

/* Urgent toggle */
.urgent-label {
  display: flex;
  align-items: center;
  cursor: pointer;
}
.urgent-checkbox { position: absolute; opacity: 0; width: 0; height: 0; }
.urgent-pill {
  display: flex;
  align-items: center;
  gap: .3rem;
  height: 36px;
  padding: 0 .875rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: .825rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
}
.urgent-checkbox:checked + .urgent-pill {
  background: rgba(239,68,68,.15);
  border-color: var(--urgent);
  color: var(--urgent);
}

/* Add buttons */
.btn-primary {
  width: 100%;
  height: 50px;
  background: var(--primary-dark);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .01em;
  transition: filter var(--transition), transform .1s ease;
  margin-top: .25rem;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; filter: none; }

.btn-secondary {
  width: 100%;
  height: 50px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  transition: background var(--transition);
  margin-top: .25rem;
}
.btn-secondary:hover { background: var(--surface-3); }

/* ===== Modal Styles ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalPop .2s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .625rem;
}

.modal-message {
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.modal-input {
  width: 100%;
  height: 44px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
  padding: 0 .875rem;
  margin-bottom: 1rem;
  transition: border-color var(--transition);
}
.modal-input:focus { outline: none; border-color: var(--primary); }

.modal-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal-confirm {
  height: 40px;
  padding: 0 1.125rem;
  background: var(--primary-dark);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  font-family: inherit;
  transition: filter var(--transition);
}
.modal-confirm:hover { filter: brightness(1.1); }

.modal-cancel {
  height: 40px;
  padding: 0 1.125rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 500;
  font-family: inherit;
  transition: all var(--transition);
}
.modal-cancel:hover { border-color: var(--text-muted); color: var(--text); }

.modal-delete {
  height: 40px;
  padding: 0 1.125rem;
  background: #b91c1c;
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  font-family: inherit;
  transition: filter var(--transition);
}
.modal-delete:hover { filter: brightness(1.1); }

/* Shop selection modal (reused from original) */
.shop-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.shop-modal {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalPop .2s cubic-bezier(.34,1.56,.64,1);
}
.shop-modal h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .875rem;
  text-align: center;
}
.shop-modal-title { color: var(--text); }
.shop-modal-options {
  display: grid;
  gap: .5rem;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  margin-bottom: .875rem;
}
.shop-modal-options button {
  background: var(--primary-dark);
  border: none;
  color: #fff;
  padding: .6rem .75rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
  transition: filter var(--transition);
}
.shop-modal-options button:hover { filter: brightness(1.1); }
.shop-modal-cancel {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: .6rem .75rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}
.shop-modal-cancel:hover { border-color: var(--text-muted); color: var(--text); }
.shop-modal-delete {
  width: 100%;
  background: #b91c1c;
  border: none;
  color: #fff;
  padding: .6rem .75rem;
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  cursor: pointer;
  font-weight: 600;
  transition: filter var(--transition);
}
.shop-modal-delete:hover { filter: brightness(1.05); }
.shop-modal-info {
  background: rgba(251,191,36,.15);
  border: 1px solid rgba(251,191,36,.3);
  color: var(--warning);
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  margin-bottom: .875rem;
  text-align: center;
  font-size: .85rem;
}
.shop-modal-input {
  width: 100%;
  height: 44px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
  padding: 0 .875rem;
}
.shop-modal-input:focus { outline: none; border-color: var(--primary); }

/* ===== Offline banner ===== */
.offline-banner {
  background: rgba(251,191,36,.12);
  border: 1px solid rgba(251,191,36,.25);
  color: var(--warning);
  text-align: center;
  padding: .5rem 1rem;
  font-size: .825rem;
  border-radius: var(--radius-sm);
  margin-bottom: .75rem;
}

/* ===== Spin animation for refresh btn ===== */
.icon-btn.spinning svg { animation: spin .7s linear infinite; }

/* ===== User menu popup ===== */
.user-menu {
  position: fixed;
  top: calc(var(--header-h) + .5rem);
  right: .75rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .25rem;
  min-width: 160px;
  z-index: 600;
  box-shadow: var(--shadow-lg);
  animation: modalPop .15s ease;
}
.user-menu-item {
  display: block;
  width: 100%;
  padding: .6rem .875rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: .875rem;
  font-family: inherit;
  text-align: left;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.user-menu-item:hover { background: var(--surface-2); color: var(--text); }
.user-menu-item.danger:hover { color: var(--danger); }
.user-menu-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: .25rem 0;
}
.user-menu-name {
  padding: .5rem .875rem .25rem;
  font-size: .75rem;
  color: var(--text-subtle);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ===== Login page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo-icon {
  width: 52px;
  height: 52px;
  background: var(--primary-dark);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto .75rem;
}
.login-logo-icon svg { width: 28px; height: 28px; color: #fff; }
.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .25rem;
}
.login-logo p { font-size: .875rem; color: var(--text-subtle); }

.login-box {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.login-field { margin-bottom: 1rem; }
.login-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .375rem;
}
.login-input {
  width: 100%;
  height: 46px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
  padding: 0 .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.login-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.login-btn {
  width: 100%;
  height: 48px;
  background: var(--primary-dark);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  margin-top: .25rem;
  transition: filter var(--transition);
  cursor: pointer;
}
.login-btn:hover { filter: brightness(1.1); }
.login-btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.login-error {
  margin-top: .875rem;
  background: rgba(248,113,113,.1);
  border: 1px solid rgba(248,113,113,.3);
  color: var(--danger);
  padding: .625rem .875rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  display: none;
}
.login-hint {
  margin-top: .875rem;
  font-size: .78rem;
  color: var(--text-subtle);
  text-align: center;
}

/* ===== Responsive ===== */
@media (min-width: 640px) {
  .main-content { padding: 1rem 1rem 0; }
  .sheet { left: max(0px, calc(50% - 300px)); }
}

@media (max-width: 400px) {
  .item-name { font-size: .875rem; }
  .item-card { padding: .625rem; gap: .5rem; }
}

/* ===== Scrollbar styling ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }

