:root {
  --bg: #ffffff;
  --card: #ffffff;
  --border: #d8dce3;
  --text: #1a1d24;
  --muted: #5f6368;
  --accent: #e91e8c;
  --accent-dim: #ad1457;
  --success: #1e8e3e;
  --error: #c5221f;
  --input-bg: #ffffff;
  --surface: #f5f6f8;
  --surface-elevated: #eef0f4;
  --topbar-bg: #ffffff;
  --alert-success-bg: #e6f4ea;
  --alert-success-text: #137333;
  --alert-error-bg: #fce8e6;
  --alert-error-text: #b3261e;
  --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: var(--topbar-bg);
}

.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;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.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: var(--input-bg);
  color: var(--text);
  font-size: 1rem;
}

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

input.pw-visible {
  -webkit-text-security: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  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;
  color: #ffffff;
}

.btn.danger {
  border-color: var(--error);
  color: var(--alert-error-text);
  background: var(--alert-error-bg);
}

.btn.danger:hover {
  background: #f9d7d4;
}

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

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

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

[hidden] {
  display: none !important;
}

.login-form {
  margin: 0;
}

.login-alert {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  background: var(--alert-success-bg);
  border: 1px solid var(--success);
  color: var(--alert-success-text);
  font-size: 0.92rem;
  line-height: 1.45;
}

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

.login-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--alert-error-bg);
  border: 1px solid var(--error);
  color: var(--alert-error-text);
  font-size: 0.92rem;
  line-height: 1.45;
}

.password-field {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.password-field input {
  flex: 1;
  min-width: 0;
}

.btn.icon-btn,
.btn.pw-toggle {
  flex: 0 0 auto;
  min-width: 52px;
  min-height: 44px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  position: relative;
  z-index: 2;
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 600;
}

.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: var(--surface-elevated);
  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: var(--alert-success-bg);
  border: 1px solid var(--success);
  color: var(--alert-success-text);
}

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

.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.35);
}

.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: var(--surface);
}

.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: var(--input-bg);
  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: var(--input-bg);
  color: var(--text);
}

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

.card-slot-table .card-bg-url-input {
  width: 100%;
  min-width: 12rem;
  box-sizing: border-box;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
}

.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: var(--input-bg);
  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: var(--alert-error-bg);
  border: 1px solid var(--error);
  color: var(--alert-error-text);
}

button.btn .btn-spinner {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 6px;
  vertical-align: -0.1em;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--accent);
  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: var(--input-bg);
  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;
}

.invite-poster-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

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

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.checkbox-field input[type='checkbox'] {
  width: 18px;
  height: 18px;
  margin: 0;
}

.embedded-website-preview-wrap {
  margin-top: 12px;
}

.embedded-website-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.embedded-preview-status {
  margin: 0;
}

.phone-preview-frame {
  position: relative;
  width: min(100%, 320px);
  margin: 0 auto;
  padding: 12px 10px 14px;
  border-radius: 28px;
  border: 3px solid #1a1a2e;
  background: linear-gradient(180deg, #2d2d44 0%, #1a1a2e 100%);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.phone-preview-notch {
  width: 88px;
  height: 6px;
  margin: 0 auto 8px;
  border-radius: 999px;
  background: #0f0f18;
}

.phone-preview-frame iframe {
  display: block;
  width: 100%;
  height: 520px;
  border: none;
  border-radius: 16px;
  background: #fff;
}

.brand-studio-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 12px 0 16px;
}

.brand-color-grid {
  margin-bottom: 8px;
}

.brand-native-preview-wrap {
  margin-top: 16px;
}

.phone-preview-frame.brand-native-preview {
  width: min(100%, 300px);
  padding-bottom: 10px;
}

.brand-preview-appbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  margin-bottom: 8px;
  border-radius: 14px;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 12px;
  background: linear-gradient(90deg, #c026d3, #ec4899, #fb7185);
}

.brand-preview-appbar img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.2);
}

.brand-preview-body {
  border-radius: 14px;
  padding: 12px;
  min-height: 200px;
  margin-bottom: 8px;
  background: #fff5f8;
}

.brand-preview-chip {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 12px;
  color: #fff;
  font-weight: 600;
  font-size: 0.78rem;
  margin-bottom: 10px;
  background: #ec4899;
}

.brand-preview-card {
  border-radius: 12px;
  padding: 14px;
  background: #fff;
  border: 1px solid rgba(236, 72, 153, 0.25);
  font-size: 0.75rem;
  color: #64748b;
}

.brand-preview-nav {
  display: flex;
  justify-content: space-around;
  padding: 8px 4px 4px;
  font-size: 0.62rem;
  color: #64748b;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: #fff;
  border-radius: 12px;
}

.brand-preview-nav span.on {
  color: #ec4899;
  font-weight: 700;
}

.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: var(--surface);
}

.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: var(--input-bg);
}

.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.1);
  border: 1px solid rgba(233, 30, 140, 0.35);
  color: var(--accent-dim);
  font-size: 0.82rem;
}

.staff-chip-remove {
  border: none;
  background: transparent;
  color: var(--accent-dim);
  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;
}

.booking-calendar-section-title {
  margin: 12px 0 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.calendar-services-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.calendar-services-table th,
.calendar-services-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
}

.calendar-services-table th {
  background: var(--input-bg);
  font-weight: 600;
  color: var(--muted);
}

.calendar-services-table input[type='text'],
.calendar-services-table select {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  color: inherit;
  font: inherit;
}

.calendar-services-empty {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 4px 0 8px;
}

.calendar-services-actions {
  display: flex;
  flex-wrap: wrap;
  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: #e6f4ea;
  color: #137333;
}

.badge.warn {
  background: #fef7e0;
  color: #b06000;
}

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

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