:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --border: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #e91e8c;
  --accent-dim: #ad1457;
  --success: #34a853;
  --error: #ea4335;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #14171d;
}

.brand .logo {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--accent);
}

.brand .subtitle {
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.card,
.dashboard {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card h1,
.dashboard h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 20px;
  line-height: 1.5;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field span {
  font-size: 0.8rem;
  color: var(--muted);
}

input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1115;
  color: var(--text);
  font-size: 1rem;
}

input:focus {
  outline: 2px solid var(--accent-dim);
  border-color: transparent;
}

.btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #252a33;
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border: none;
  font-weight: 600;
}

.btn.danger {
  border-color: var(--error);
  color: #f5b4b4;
  background: rgba(234, 67, 53, 0.15);
}

.btn.danger:hover {
  background: rgba(234, 67, 53, 0.28);
}

.btn.small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.error {
  color: var(--error);
  margin-top: 12px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.toolbar h1 {
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: #14171d;
  color: var(--muted);
  font-weight: 600;
}

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

.meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 12px;
}

.alert {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  background: #1e3a2f;
  border: 1px solid var(--success);
  color: #b7e1c4;
}

.alert.error {
  background: #3a1e1e;
  border-color: var(--error);
  color: #f5b4b4;
}

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  background: var(--card);
  color: var(--text);
  max-width: 480px;
  width: calc(100% - 32px);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.modal-inner {
  padding: 22px;
}

/* Form tạo salon dài: cuộn trong modal (tránh cắt mất ô mật khẩu trên màn nhỏ). */
#dlgCreateSalon .modal-inner {
  max-height: min(88vh, 720px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-inner h2 {
  margin: 0 0 16px;
  font-size: 1.15rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.topbar-actions .btn {
  font-size: 0.85rem;
}

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

.whoami {
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .whoami {
    display: none;
  }
}

.table-loading {
  padding: 10px 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.pager {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}

.pager-label {
  font-size: 0.88rem;
  color: var(--muted);
}

.modal.modal-wide {
  max-width: 560px;
}

.admin-list {
  max-height: min(50vh, 360px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}

.admin-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.admin-row:last-child {
  border-bottom: none;
}

.admin-row .email {
  color: var(--muted);
  font-size: 0.82rem;
}

.admin-row-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  text-align: right;
}

.admin-row-meta .role-line {
  color: var(--muted);
  font-size: 0.82rem;
}

.admin-pw-toolbar {
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.admin-pw-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.admin-pw-select-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 220px;
}

.admin-pw-select-wrap span {
  font-size: 0.82rem;
  color: var(--muted);
}

.admin-pw-select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1115;
  color: var(--text);
  font-size: 0.9rem;
  max-width: 100%;
}

.admin-pw-missing {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px dashed var(--border);
}

.card-slot-table {
  width: 100%;
  margin: 10px 0 12px;
  font-size: 0.88rem;
}

.card-slot-table .cell-slot-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.card-slot-table input[type='number'] {
  width: 4.2rem;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0f1115;
  color: var(--text);
}

.card-slot-table .pct-input {
  width: 3.5rem;
}

.card-json-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.config-subh {
  margin: 18px 0 8px;
  font-size: 1rem;
}

select.status-select {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0f1115;
  color: var(--text);
  font-size: 0.85rem;
}

.cell-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(234, 67, 53, 0.12);
  border: 1px solid var(--error);
}

button.btn .btn-spinner {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 6px;
  vertical-align: -0.1em;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: sa-spin 0.7s linear infinite;
}

@keyframes sa-spin {
  to {
    transform: rotate(360deg);
  }
}

.modal-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

details.login-advanced {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

details.login-advanced summary {
  cursor: pointer;
  user-select: none;
  color: var(--accent);
}

details.login-advanced .field {
  margin-top: 12px;
}

textarea {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1115;
  color: var(--text);
  font-size: 0.9rem;
  width: 100%;
  resize: vertical;
  min-height: 64px;
}

textarea:focus {
  outline: 2px solid var(--accent-dim);
  border-color: transparent;
}

textarea.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.4;
}

.modal.modal-app {
  max-width: min(720px, 100% - 24px);
  width: 100%;
}

#dlgAppConfig .modal-inner {
  max-height: min(90vh, 900px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.config-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.config-section:first-of-type {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.config-section h3 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

.closed-weekdays-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.closed-weekdays-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

.booking-calendars-host {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.booking-calendar-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #11141a;
}

.booking-calendar-card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 10px;
}

.booking-calendar-card-head .field {
  flex: 1 1 140px;
  margin: 0;
}

.booking-calendar-enabled {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  padding-bottom: 6px;
}

.staff-chip-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 38px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #11141a;
}

.staff-chip-empty {
  color: var(--muted);
  font-size: 0.82rem;
}

.staff-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 4px 8px 4px 10px;
  background: rgba(233, 30, 140, 0.16);
  border: 1px solid rgba(233, 30, 140, 0.35);
  color: #ffd5ea;
  font-size: 0.82rem;
}

.staff-chip-remove {
  border: none;
  background: transparent;
  color: #ffd5ea;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  font-size: 0.95rem;
}

.staff-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 8px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge.ok {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
}

.badge.warn {
  background: rgba(251, 191, 36, 0.15);
  color: #fcd34d;
}

.cell-legal .small {
  font-size: 0.75rem;
}

@media (max-width: 600px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
}
