:root {
  --primary: #667eea;
  --primary-dark: #5a67d8;
  --bg: #f4f6fb;
  --card-bg: #fff;
  --border: #e6e9f2;
  --text: #2b2b33;
  --text-muted: #767a8a;
  --danger: #ff6b6b;
  --success: #40c057;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Sarabun', -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea, #764ba2);
  padding: 20px;
}

.login-box {
  background: #fff;
  width: 100%;
  max-width: 380px;
  border-radius: 18px;
  padding: 40px 32px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

.login-box h1 {
  text-align: center;
  font-size: 20px;
  margin: 0 0 4px;
}
.login-box p.sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 28px;
}

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fafbff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.88; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-block { width: 100%; justify-content: center; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-muted { background: #eef0f6; color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  margin-bottom: 18px;
}
.alert-error { background: #fff0f0; color: #c92a2a; border: 1px solid #ffc9c9; }
.alert-success { background: #ebfbee; color: #2b8a3e; border: 1px solid #b2f2bb; }

/* ---------- Dashboard layout ---------- */
.admin-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  background: #1e1e2d;
  color: #cfd2e8;
  padding: 24px 16px;
  flex-shrink: 0;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: #fff;
  font-size: 15px;
  margin-bottom: 30px;
  padding: 0 8px;
}
.sidebar .brand .badge {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex; align-items: center; justify-content: center;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  color: #cfd2e8;
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 4px;
}
.sidebar a:hover, .sidebar a.active { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar .divider { height: 1px; background: rgba(255,255,255,0.08); margin: 16px 0; }

.main {
  flex: 1;
  padding: 28px 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.topbar h1 { font-size: 20px; margin: 0; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
}
.card h2 { font-size: 16px; margin: 0 0 18px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.form-grid .full { grid-column: 1 / -1; }

table.svc-table { width: 100%; border-collapse: collapse; }
table.svc-table th, table.svc-table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
table.svc-table th { color: var(--text-muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px; }

.icon-preview {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 17px; flex-shrink: 0;
}
.icon-preview img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }

.row-flex { display: flex; align-items: center; gap: 10px; }
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-on { background: #ebfbee; color: #2b8a3e; }
.status-off { background: #fff0f0; color: #c92a2a; }

.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.color-swatches span {
  width: 26px; height: 26px; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent;
}
.color-swatches span.active { border-color: #333; }

@media (max-width: 800px) {
  .admin-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
}
