:root {
  --bg: #0f1115;
  --bg-elev: #191c22;
  --bg-elev-2: #1f232b;
  --border: #262a33;
  --text: #e6e8ec;
  --text-dim: #9aa1ad;
  --accent: #4ade80;
  --accent-press: #22c55e;
  --danger: #f87171;
  --done: #5b6472;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

input,
button {
  font-family: inherit;
}

/* ───── Login ───── */

.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
}

.login-card .sub {
  color: var(--text-dim);
  margin: 0 0 20px;
  font-size: 14px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.1s ease;
}

.input:focus {
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 600;
  background: var(--accent);
  color: #0a0d11;
  min-height: 44px;
  width: 100%;
  transition: background 0.1s ease, transform 0.05s ease;
}

.btn:active {
  background: var(--accent-press);
  transform: translateY(1px);
}

.btn.secondary {
  background: var(--bg-elev-2);
  color: var(--text);
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin: 8px 0 0;
  min-height: 20px;
}

/* ───── List ───── */

.topbar {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--bg-elev);
  color: var(--text);
}

.addbar {
  position: sticky;
  top: 53px;
  background: var(--bg);
  padding: 10px 16px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  z-index: 9;
}

.addbar .input {
  flex: 1;
}

.add-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent);
  color: #0a0d11;
  border: none;
  font-size: 26px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.add-btn:active {
  background: var(--accent-press);
}

.qty-input {
  width: 72px;
  flex: 0 0 72px;
}

main {
  flex: 1;
  padding: 8px 0 120px;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 60px;
  user-select: none;
}

.row .check {
  flex: 0 0 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 22px;
  line-height: 1;
}

.row.done .check {
  background: var(--accent);
  color: #0a0d11;
  border-color: var(--accent);
}

.row .body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row .name {
  font-size: 17px;
  overflow-wrap: anywhere;
}

.row.done .name {
  color: var(--done);
  text-decoration: line-through;
}

.row .meta {
  font-size: 12px;
  color: var(--text-dim);
}

.qty-badge {
  display: inline-block;
  font-size: 13px;
  color: var(--text-dim);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  margin-left: 4px;
}

.row.done .qty-badge {
  opacity: 0.5;
}

.trash {
  flex: 0 0 44px;
  height: 44px;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.trash:hover,
.trash:focus-visible {
  background: var(--bg-elev);
  color: var(--danger);
}

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 48px 16px;
  font-size: 15px;
}

.footer-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(
    180deg,
    rgba(15, 17, 21, 0) 0%,
    rgba(15, 17, 21, 0.95) 40%,
    var(--bg) 100%
  );
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.footer-actions .btn {
  max-width: 420px;
  pointer-events: auto;
  width: auto;
  padding: 10px 20px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
}

.footer-actions .btn:active {
  background: var(--bg-elev-2);
}

.footer-actions .btn[hidden] {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
}

/* ───── Admin panel ───── */

dialog.sheet {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0;
  width: calc(100% - 32px);
  max-width: 420px;
}

dialog.sheet::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.sheet-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 17px;
  flex: 1;
}

.sheet-body {
  padding: 16px 20px 20px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.user-row:last-child {
  border-bottom: none;
}

.user-row .u-name {
  flex: 1;
}

.badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
}

.badge.admin {
  color: var(--accent);
}

.apk-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}

.apk-link:hover {
  text-decoration: underline;
}
