:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #7b8794;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --line: #e4e7eb;
}

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

body {
  font-family: "Segoe UI", "Noto Sans Thai", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
}

.screen { min-height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* Login */
.login-box {
  margin: auto;
  padding: 32px 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-box h1 { font-size: 28px; letter-spacing: 1px; color: var(--accent); }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { font-weight: 700; color: var(--accent); }

/* Controls */
.controls { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
input, button { font: inherit; }
input[type="search"], input[type="password"], input[type="number"], input[type="file"] {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  width: 100%;
}
button {
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:active { opacity: 0.85; }
.link-btn { background: none; color: var(--accent); padding: 6px; }

.meta { padding: 0 16px 4px; color: var(--muted); font-size: 13px; }

/* Results */
#results { padding: 8px 16px 96px; display: flex; flex-direction: column; gap: 10px; }
.empty, .hint { text-align: center; color: var(--muted); padding: 24px 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.card-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.card-head .sku { font-size: 12px; color: var(--muted); font-weight: 600; }
.card-head .pname { font-weight: 600; }

.prices { display: flex; flex-direction: column; gap: 4px; }
.price-line {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}
.price-line.highlight { background: var(--accent-soft); font-weight: 700; }
.price-line .price { font-variant-numeric: tabular-nums; }
.price-line input.price-edit { width: 110px; padding: 4px 6px; }
.no-price { padding: 8px 10px; color: var(--danger); font-size: 14px; }

.add-price-btn {
  margin-top: 8px;
  background: none;
  color: var(--accent);
  border: 1px dashed var(--line);
  width: 100%;
}

/* Floating add-product button */
.fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  border-radius: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Manage */
.manage-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.manage-body hr { border: none; border-top: 1px solid var(--line); margin: 8px 0; }
.manage-body h3 { font-size: 15px; }
.warn { color: var(--danger); font-size: 14px; }
#backup-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
#backup-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}
#backup-list button { padding: 6px 12px; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  max-width: 90%;
  text-align: center;
  z-index: 20;
}
.toast.error { background: var(--danger); }
.error-text { color: var(--danger); font-size: 14px; min-height: 18px; }

@media (min-width: 640px) {
  #results, .controls, .manage-body { max-width: 640px; margin-left: auto; margin-right: auto; }
}
