* { box-sizing: border-box; }
body {
  font-family: "Segoe UI", "Noto Sans Thai", sans-serif;
  margin: 0;
  background: #f4f6f8;
  color: #222;
}
a { color: inherit; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #1f2937;
  color: white;
  flex-wrap: wrap;
  gap: 8px;
}
.topbar h1 { font-size: 1.1rem; margin: 0; }
.topbar nav a {
  color: #cbd5e1;
  text-decoration: none;
  margin-right: 14px;
  font-size: 0.9rem;
}
.topbar nav a:hover { color: white; text-decoration: underline; }
.topbar-actions button { margin-left: 8px; }

button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  background: #2563eb;
  color: white;
  font-size: 0.9rem;
}
button:hover { background: #1d4ed8; }
button.danger { background: #dc2626; }
button.danger:hover { background: #b91c1c; }
button.ghost { background: #e5e7eb; color: #111; }

.search-row, .filter-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 20px;
  flex-wrap: wrap;
}
input[type="text"], input[type="date"], input[type="password"], input[type="url"] {
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  min-width: 220px;
}
.autocomplete-wrap, .new-item-box { position: relative; }
.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 20;
}
.suggestions.hidden { display: none; }
.suggestions div { padding: 6px 10px; }
.suggestions div:hover { background: #eef2ff; cursor: pointer; }
.new-item-box.hidden { display: none; }

.table-container { padding: 0 20px 20px 20px; }
.day-group { margin-bottom: 20px; background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.day-group h2 { margin: 0; padding: 10px 14px; background: #e2e8f0; font-size: 1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid #eee; text-align: left; font-size: 0.9rem; }
th { background: #f8fafc; }
a.item-link { color: #2563eb; text-decoration: none; cursor: pointer; }
a.item-link:hover { text-decoration: underline; }
.affiliate-btn { padding: 2px 6px; margin-left: 6px; font-size: 0.85rem; }
.flag-cell { text-align: center; }
.row-actions button { margin-right: 4px; }

.footer {
  padding: 14px 20px;
  background: #1f2937;
  color: white;
  position: sticky;
  bottom: 0;
}

/* ---------- login page ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: white;
  padding: 32px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  width: 320px;
}
.login-card h1 { margin-top: 0; font-size: 1.2rem; }
.login-card input { width: 100%; margin-bottom: 12px; }
.login-card button { width: 100%; }
.login-error { color: #dc2626; font-size: 0.85rem; margin-bottom: 10px; }
.login-hint { font-size: 0.8rem; color: #64748b; margin-top: 14px; }

/* ---------- settings / admin forms ---------- */
.form-card {
  background: white;
  padding: 20px;
  margin: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  max-width: 480px;
}
.form-card label { display: block; margin-bottom: 10px; font-size: 0.9rem; }
.form-card input { width: 100%; margin-top: 4px; }
.form-row { display: flex; gap: 10px; }
.success-msg { color: #16a34a; font-size: 0.85rem; }
