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

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface2: #f9f9f9;
  --border: #ddd;
  --border-strong: #bbb;
  --text: #1a1a1a;
  --text-muted: #666;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-border: #fca5a5;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --green-border: #86efac;
  --radius: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.card.wide {
  max-width: 900px;
}

/* ===== PAGE HEADER ===== */
.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.page-header p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  padding: 9px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  text-decoration: none;
  line-height: 1;
}

.btn:active { opacity: 0.85; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface2);
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

/* ===== ALERTS ===== */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.88rem;
  margin-bottom: 18px;
  border: 1px solid;
}

.alert-error {
  background: var(--red-bg);
  border-color: var(--red-border);
  color: var(--red);
}

.alert-success {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: var(--green);
}

/* ===== DIVIDER ===== */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* ===== NAV ===== */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 50;
  padding: 0 24px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

body.has-nav {
  justify-content: flex-start;
  padding-top: 74px;
}

/* ===== ADMIN DASHBOARD ===== */
.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.add-form {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.add-form-row {
  display: grid;
  grid-template-columns: 130px 120px 1fr auto;
  gap: 10px;
  align-items: end;
}

@media (max-width: 680px) {
  .add-form-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* Stores table */
.stores-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.stores-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  background: var(--surface2);
}

.stores-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.stores-table tr:last-child td {
  border-bottom: none;
}

.stores-table tbody tr:hover td {
  background: var(--surface2);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.status-pill.on {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.status-pill.off {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red-border);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.actions {
  display: flex;
  gap: 6px;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
  display: inline-block;
  vertical-align: middle;
}

.empty-state {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.modal h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ===== STORE STATUS PAGE ===== */
.store-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.store-label strong {
  color: var(--text);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  background: var(--surface2);
  transition: border-color 0.15s, background 0.15s;
}

.checkbox-row:hover {
  border-color: var(--accent);
}

.checkbox-row.checked {
  border-color: var(--green);
  background: var(--green-bg);
}

.checkbox-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--green);
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-row span {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.checkbox-row.checked span {
  color: var(--green);
}

.oos-section {
  margin-top: 16px;
}

.oos-section label {
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
}

.save-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  gap: 12px;
}

.save-status {
  font-size: 0.82rem;
  color: var(--text-muted);
  min-height: 20px;
}

.save-status.saved { color: var(--green); }
.save-status.saving { color: var(--accent); }
.save-status.error { color: var(--red); }

/* ===== HELPERS ===== */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.text-center { text-align: center; }

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.85em;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}
