:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1c2333;
  --muted: #7a8399;
  --accent: #4f7cff;
  --accent-soft: #e8edff;
  --danger: #e5484d;
  --border: #e7eaf2;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 78px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.brand { font-weight: 700; font-size: 17px; }
.logout-form { margin: 0; }
.link-btn {
  background: none; border: none; color: var(--muted);
  font-size: 14px; cursor: pointer;
}

.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 16px 24px;
}

.page-title { font-size: 22px; margin: 4px 0 16px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(20, 30, 60, 0.05);
  border: 1px solid var(--border);
}
.card-label { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; font-weight: 600; }
.big-number { font-size: 32px; font-weight: 800; margin-bottom: 10px; }
.card-link { display: inline-block; margin-top: 10px; color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 600; }

.category-bars { display: flex; flex-direction: column; gap: 6px; }
.cat-row { display: flex; justify-content: space-between; font-size: 14px; padding: 4px 0; }

.weight-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.weight-row:last-child { border-bottom: none; }

.meal-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.meal-thumb {
  flex: 0 0 auto; width: 72px; height: 72px; border-radius: 12px; overflow: hidden;
  border: 2px solid; display: block;
}
.meal-thumb img { width: 100%; height: 100%; object-fit: cover; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

input, select, button {
  font-family: inherit;
  font-size: 15px;
}
input[type="text"], input[type="number"], input[type="date"], input[type="password"], select {
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fafbfd;
  width: 100%;
}
input[type="file"] {
  padding: 10px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: #fafbfd;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 13px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:active { opacity: 0.85; }
.btn-small {
  background: var(--accent); color: white; border: none;
  width: 42px; border-radius: 10px; font-size: 18px; cursor: pointer;
}

.inline-form { display: flex; gap: 8px; margin-bottom: 10px; }
.inline-form input { flex: 1; }

.shopping-list { list-style: none; padding: 0; margin: 0; }
.shopping-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.shopping-list li:last-child { border-bottom: none; }
.shopping-list form { margin: 0; }
.check-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--accent); }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; font-size: 14px; }
.list-item-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-amount { font-weight: 700; white-space: nowrap; }
.del-btn { background: none; border: none; color: var(--danger); font-size: 15px; cursor: pointer; padding: 4px 6px; }

.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gallery-item { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--card); }
.gallery-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.gallery-caption { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; font-size: 12px; }
.gallery-caption form { margin: 0; }

.muted { color: var(--muted); font-size: 14px; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 90vh; }
.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 32px 28px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(20,30,60,0.08);
}
.login-logo { font-size: 42px; margin-bottom: 8px; }
.login-card h1 { font-size: 20px; margin: 0 0 20px; }
.error-box {
  background: #fdecea; color: var(--danger); padding: 10px; border-radius: 10px;
  font-size: 13px; margin-bottom: 12px;
}
.success-box {
  background: #e6f7ed; color: #1a8a4a; padding: 10px; border-radius: 10px;
  font-size: 13px; margin-bottom: 12px;
}

.code-box { margin-top: 14px; text-align: center; }
.code-value {
  font-size: 28px; font-weight: 800; letter-spacing: 0.1em;
  background: var(--accent-soft); color: var(--accent);
  padding: 12px; border-radius: 12px; margin-bottom: 10px;
}

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  z-index: 10;
}
.bottomnav a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 11px; padding: 6px 0;
}
.bottomnav a.active { color: var(--accent); font-weight: 600; }
.bottomnav .icon { font-size: 20px; }
