:root {
  --blue: #1a73e8;
  --blue-dark: #1765cc;
  --accent: #4285f4;
  --text: #1f2329;
  --text-muted: #5f6368;
  --line: #e8eaed;
  --hover: #f1f4f9;
  --sel: #e8f0fe;
  --sel-text: #1a73e8;
  --danger: #d93025;
  --bg: #f6f8fc;
  --card: #ffffff;
  --star: #f9ab00;
  --on-accent: #ffffff;
  --low-bg: #fce8e6;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(60,64,67,.08), 0 1px 3px rgba(60,64,67,.10);
  --shadow-md: 0 2px 6px rgba(60,64,67,.10), 0 6px 18px rgba(60,64,67,.10);
  --font: "Google Sans", "Product Sans", Roboto, "Segoe UI", system-ui, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ------------------------------------------------------------- Login */
.login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #e9f0ff 0%, var(--bg) 55%);
}
.login-card {
  width: 360px; padding: 44px 40px; background: var(--card);
  border-radius: 20px; box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 18px;
}
.login-logo { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 6px; }
.login-logo h1 { font-size: 28px; font-weight: 500; margin: 0; letter-spacing: -.3px; }
.login-card input {
  height: 50px; padding: 0 16px; font-size: 15px;
  border: 1.5px solid var(--line); border-radius: var(--radius); outline: none;
  background: var(--card); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26,115,232,.15); }
.login-card button[type=submit] {
  height: 48px; background: var(--blue); color: var(--on-accent); font-size: 15px; font-weight: 500;
  border-radius: 24px; transition: background .15s, box-shadow .15s; margin-top: 4px;
}
.login-card button[type=submit]:hover { background: var(--blue-dark); box-shadow: 0 4px 12px rgba(26,115,232,.35); }
.login-error { color: var(--danger); font-size: 13.5px; margin: 0; min-height: 18px; text-align: center; }

/* --------------------------------------------------------------- App */
.app { display: flex; height: 100%; }

/* sidebar */
.sidebar {
  width: 264px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 10px; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 10px 14px 16px; font-size: 21px; font-weight: 500; letter-spacing: -.2px; }
.lists { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.list-item {
  display: flex; align-items: center; gap: 16px; height: 46px; padding: 0 16px;
  border-radius: 24px; font-size: 14px; color: var(--text-muted);
  text-align: left; width: 100%; white-space: nowrap; overflow: hidden; transition: background .12s;
}
.list-item .li-icon { flex-shrink: 0; display: flex; }
.list-item .li-name { overflow: hidden; text-overflow: ellipsis; }
.list-item:hover { background: var(--hover); }
.list-item.active { background: var(--sel); color: var(--sel-text); font-weight: 500; }
.list-item.active .li-icon svg path { fill: var(--sel-text); }
.new-list, .logout {
  display: flex; align-items: center; gap: 16px; height: 46px; padding: 0 16px;
  border-radius: 24px; font-size: 14px; color: var(--text-muted); transition: background .12s;
}
.new-list:hover, .logout:hover { background: var(--hover); }

/* main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-y: auto; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 32px 16px; position: sticky; top: 0; z-index: 10;
  background: linear-gradient(var(--bg) 70%, rgba(246,248,252,0));
}
.topbar h2 { font-size: 24px; font-weight: 500; margin: 0; outline: none; letter-spacing: -.3px; padding: 2px 4px; border-radius: 6px; }
.topbar h2[contenteditable=true] { background: var(--card); box-shadow: inset 0 0 0 2px var(--blue); }
.topbar-actions { display: flex; gap: 4px; position: relative; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: var(--text-muted); transition: background .12s;
}
.icon-btn:hover { background: var(--hover); }

.menu {
  position: absolute; top: 48px; right: 0; background: var(--card); min-width: 230px;
  border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 8px 0; z-index: 20;
}
.menu button { display: block; width: 100%; text-align: left; padding: 11px 20px; font-size: 14px; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }

/* content card */
.content {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-sm);
  padding: 10px 12px 20px; max-width: 720px; width: calc(100% - 48px);
  margin: 0 auto 40px; min-height: 200px;
}
.add-task {
  display: flex; align-items: center; gap: 18px; height: 50px; width: 100%; padding: 0 16px;
  font-size: 14px; font-weight: 500; color: var(--blue); border-radius: var(--radius); transition: background .12s;
}
.add-task:hover { background: var(--hover); }
.add-task-form { padding: 8px 16px; }
.add-task-form input {
  width: 100%; height: 46px; border: none; border-bottom: 2px solid var(--blue);
  font-size: 15px; outline: none; padding: 0 4px; background: transparent;
}

/* task list */
.task-list { list-style: none; margin: 4px 0 0; padding: 0; }
.task-wrap { list-style: none; }
.task {
  display: flex; align-items: flex-start; gap: 16px; padding: 11px 16px;
  border-radius: var(--radius); position: relative; transition: background .12s;
}
.task:hover { background: var(--hover); }
.task.sub { margin-left: 40px; }
.task.dragging { opacity: .4; }

.check {
  flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px; border-radius: 50%;
  border: 2px solid #80868b; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
.check:hover { border-color: var(--blue); transform: scale(1.08); }
.check svg { opacity: 0; transition: opacity .15s; }
.check:hover svg path { fill: var(--blue); }
.check:hover svg { opacity: .55; }
.task.done .check { background: var(--text-muted); border-color: var(--text-muted); }
.task.done .check svg { opacity: 1; }
.task.done .check svg path { fill: #fff; }

.task-body { flex: 1; min-width: 0; cursor: pointer; padding-top: 1px; }
.task-title { font-size: 14.5px; line-height: 20px; word-break: break-word; }
.task.done .task-title { color: var(--text-muted); text-decoration: line-through; }
.task-meta { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; align-items: center; }
.task-notes-preview { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.due-chip {
  font-size: 12px; color: var(--text-muted); background: var(--hover);
  padding: 3px 9px; border-radius: 14px; display: inline-flex; align-items: center; gap: 5px;
}
.due-chip.overdue { color: var(--danger); background: var(--low-bg); }

.star {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; opacity: 0; color: #9aa0a6; transition: opacity .12s, background .12s;
}
.star:hover { background: rgba(0,0,0,.05); }
.task:hover .star { opacity: 1; }
.star.on { opacity: 1; color: var(--star); }
.star.on svg path { fill: var(--star); }

/* task editor (expanded) */
.task-editor {
  margin: 2px 8px 10px 8px; padding: 14px 16px 16px 52px;
  background: var(--hover); border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 14px;
}
.task-editor textarea, .task-editor input[type=text] {
  width: 100%; border: none; font-family: inherit; font-size: 14px; outline: none; resize: none;
  color: var(--text); background: transparent;
}
.editor-row { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 13px; }
.editor-row .field {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; cursor: pointer; transition: box-shadow .12s;
}
.editor-row .field:hover { box-shadow: var(--shadow-sm); }
.editor-row input[type=date] { border: none; outline: none; font-family: inherit; color: var(--text); background: transparent; }
.clear-date { display: inline-flex; color: var(--text-muted); }
.editor-actions { display: flex; gap: 8px; }
.editor-actions button { padding: 8px 16px; border-radius: 20px; font-size: 13px; font-weight: 500; color: var(--text-muted); transition: background .12s; }
.editor-actions button:hover { background: var(--card); }
.editor-actions .delete { color: var(--danger); }
.add-sub { color: var(--blue); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }

/* completed */
.completed-section { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 8px; }
.completed-toggle {
  display: flex; align-items: center; gap: 12px; height: 46px; padding: 0 16px;
  font-size: 14px; color: var(--text); font-weight: 500; width: 100%; border-radius: var(--radius); transition: background .12s;
}
.completed-toggle:hover { background: var(--hover); }
.completed-toggle .chev { transition: transform .18s; }
.completed-section.collapsed .chev { transform: rotate(-90deg); }
.completed-section.collapsed .task-list { display: none; }

/* empty */
.empty-state { text-align: center; color: var(--text-muted); padding: 56px 20px; }
.empty-state svg { opacity: .8; }
.empty-state p { font-size: 18px; margin: 18px 0 6px; color: var(--text); font-weight: 500; }
.empty-state span { font-size: 14px; }

/* toast / banner for errors */
.banner {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #322f2f; color: #fff; padding: 13px 20px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow-md); z-index: 100; max-width: 90%;
}

/* -------------------------------------------------------- app rail */
.rail {
  width: 68px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 8px;
}
.rail-spacer { flex: 1; }
.rail-btn {
  width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center;
  justify-content: center; color: var(--text-muted); transition: background .12s, color .12s;
}
.rail-btn:hover { background: var(--hover); }
.rail-btn.active { background: var(--sel); color: var(--sel-text); }

.view { flex: 1; display: flex; min-width: 0; }
#inventoryView .content { max-width: 1080px; }

/* sidebar count + divider (shared with inventory) */
.li-count { margin-left: auto; font-size: 12px; color: var(--text-muted); padding-left: 8px; }
.list-item.active .li-count { color: var(--sel-text); }
.list-divider { height: 1px; background: var(--line); margin: 8px 14px; }

/* -------------------------------------------------- inventory page */
.inv-toolbar { display: flex; gap: 12px; align-items: center; margin: 4px 4px 12px; }
.inv-search {
  flex: 1; display: flex; align-items: center; gap: 10px; background: var(--hover);
  border-radius: 24px; padding: 0 16px; height: 46px; color: var(--text-muted);
}
.inv-search input { flex: 1; border: none; background: transparent; outline: none; font-size: 14px; color: var(--text); font-family: inherit; }
.btn-primary {
  background: var(--blue); color: var(--on-accent); height: 46px; padding: 0 20px; border-radius: 23px;
  font-weight: 500; font-size: 14px; display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap; transition: box-shadow .15s, filter .15s;
}
.btn-primary:hover { box-shadow: var(--shadow-md); filter: brightness(1.03); }

.comp-list { display: flex; flex-direction: column; }
.comp-item {
  display: flex; align-items: center; gap: 16px; padding: 12px 14px;
  border-bottom: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: background .12s;
}
.comp-item:hover { background: var(--hover); }
.comp-main { flex: 1; min-width: 0; }
.comp-name { font-weight: 500; font-size: 14.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.comp-pn { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.comp-sub { display: flex; align-items: center; gap: 7px; margin-top: 5px; font-size: 13px; color: var(--text-muted); flex-wrap: wrap; }
.comp-sub .dot { opacity: .5; }
.comp-loc { white-space: nowrap; }
.muted { color: var(--text-muted); }
.cat-chip { font-size: 12px; padding: 3px 11px; border-radius: 12px; background: var(--sel); color: var(--sel-text); display: inline-block; white-space: nowrap; }
.low-badge {
  font-size: 11px; font-weight: 500; padding: 2px 8px 2px 6px; border-radius: 10px;
  background: var(--low-bg); color: var(--danger); display: inline-flex; align-items: center; gap: 3px;
}
.low-badge svg { width: 13px; height: 13px; }

.qty-stepper { display: inline-flex; align-items: center; gap: 10px; }
.qty-btn {
  width: 30px; height: 30px; border-radius: 50%; background: var(--hover); display: flex;
  align-items: center; justify-content: center; color: var(--text-muted); transition: background .12s, color .12s;
}
.qty-btn:hover { background: var(--sel); color: var(--sel-text); }
.qty-val { min-width: 26px; text-align: center; font-weight: 500; font-variant-numeric: tabular-nums; }
.qty-stepper.low .qty-val { color: var(--danger); }

/* ------------------------------------------------------------ modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: var(--card); border-radius: 16px; width: 540px; max-width: 100%; max-height: 90vh;
  overflow: auto; box-shadow: var(--shadow-md); animation: pop .12s ease-out;
}
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 6px; }
.modal-head h3 { margin: 0; font-size: 20px; font-weight: 500; }
.modal-body { padding: 10px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-body .full { grid-column: 1 / 3; }
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.field-group input, .field-group select, .field-group textarea {
  border: 1.5px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px;
  font-family: inherit; background: var(--card); color: var(--text); outline: none; transition: border-color .12s;
}
.field-group input:focus, .field-group select:focus, .field-group textarea:focus { border-color: var(--blue); }
.field-group textarea { resize: vertical; }

/* image picker (component photo + location photo) */
.img-picker {
  position: relative; height: 128px; border: 1.5px dashed var(--line); border-radius: 10px;
  overflow: hidden; cursor: pointer; display: flex; align-items: center; justify-content: center;
  background: var(--hover); transition: border-color .12s;
}
.img-picker:hover { border-color: var(--blue); }
.img-picker img { width: 100%; height: 100%; object-fit: cover; }
.img-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-muted); font-size: 13px; }
.img-remove {
  position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; display: flex; align-items: center; justify-content: center;
}
.img-remove:hover { background: rgba(0,0,0,.75); }

/* list-row thumbnail */
.comp-thumb { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.comp-thumb.placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--hover); color: var(--text-muted);
}
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 16px 24px 22px; }
.modal-foot .spacer { flex: 1; }
.modal-foot button { padding: 10px 18px; border-radius: 22px; font-size: 14px; font-weight: 500; }
.btn-text { color: var(--text-muted); } .btn-text:hover { background: var(--hover); }
.btn-danger { color: var(--danger); } .btn-danger:hover { background: var(--low-bg); }

@media (max-width: 640px) {
  .sidebar { width: 60px; }
  .brand span, .list-item .li-name, .new-list span { display: none; }
  .li-count { display: none; }
  .new-list { justify-content: center; }
  .content { width: calc(100% - 24px); }
  .topbar { padding: 18px 16px 12px; }
  .modal-body { grid-template-columns: 1fr; }
  .modal-body .full { grid-column: 1; }
  .inv-table th.package-h, .inv-table td.package-c { display: none; }
}

/* =============================================================== DARK */
html[data-theme="dark"] {
  --blue: #8ab4f8;
  --blue-dark: #aecbfa;
  --accent: #8ab4f8;
  --text: #e8eaed;
  --text-muted: #9aa0a6;
  --line: #3c4043;
  --hover: #35363a;
  --sel: #283548;
  --sel-text: #8ab4f8;
  --danger: #f28b82;
  --bg: #202124;
  --card: #292a2d;
  --star: #fdd663;
  --on-accent: #202124;
  --low-bg: #4a2b28;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 2px 8px rgba(0,0,0,.55), 0 8px 24px rgba(0,0,0,.45);
}
html[data-theme="dark"] .login {
  background: radial-gradient(1200px 600px at 50% -10%, #263045 0%, var(--bg) 55%);
}
html[data-theme="dark"] .star:hover { background: rgba(255,255,255,.08); }
html[data-theme="dark"] .qty-btn:hover,
html[data-theme="dark"] .rail-btn.active,
html[data-theme="dark"] .list-item.active { color: var(--sel-text); }
html[data-theme="dark"] .banner { background: #e8eaed; color: #202124; }
html[data-theme="dark"] .topbar {
  background: linear-gradient(var(--bg) 70%, rgba(32,33,36,0));
}
