/* ╔══════════════════════════════════════════════════════════════╗
   ║  HotelWave Admin — Atelier Blanc                             ║
   ║  Swiss editorial precision. Ink on paper.                    ║
   ╚══════════════════════════════════════════════════════════════╝ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

/* ── Design Tokens ── */
:root {
  /* Backgrounds — warm off-white paper */
  --bg:          #f5f4f1;
  --surface:     #ffffff;
  --surface-2:   #f0efec;
  --surface-3:   #e9e8e4;
  --sidebar-bg:  #ffffff;
  --sidebar-w:   220px;

  /* Ink — near-black with slight warmth */
  --ink:         #111014;
  --ink-2:       #4a4852;
  --ink-3:       #99959f;
  --ink-4:       #cbc9d0;

  /* Borders */
  --border:      rgba(16,16,20,0.07);
  --border-2:    rgba(16,16,20,0.12);
  --border-3:    rgba(16,16,20,0.18);

  /* Status */
  --green:       #166534;
  --green-s:     rgba(22,101,52,0.07);
  --amber:       #92400e;
  --amber-s:     rgba(146,64,14,0.07);
  --red:         #991b1b;
  --red-s:       rgba(153,27,27,0.07);
  --purple:      #4c1d95;
  --purple-s:    rgba(76,29,149,0.07);

  /* Alias for JS vars */
  --accent:      var(--ink);
  --accent-2:    var(--ink-2);
  --accent-s:    rgba(16,16,20,0.05);

  /* Shadows — paper layers */
  --sh0:  0 1px 2px rgba(16,16,20,0.04), 0 0 0 1px rgba(16,16,20,0.06);
  --sh1:  0 4px 12px rgba(16,16,20,0.07), 0 0 0 1px rgba(16,16,20,0.06);
  --sh2:  0 20px 60px rgba(16,16,20,0.12), 0 0 0 1px rgba(16,16,20,0.07);

  --r:    10px;
  --rs:   7px;
  --ease: cubic-bezier(.16,1,.3,1);
}

html, body { height: 100%; }
body {
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  display: flex;
  min-height: 100vh;
  font-size: 13px;
  letter-spacing: -0.01em;
}

/* ═══════════════════════════════════════
   LOADING
   ═══════════════════════════════════════ */
#loadingOverlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.spinner {
  width: 28px; height: 28px;
  border: 1.5px solid var(--border-2);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════
   LOGIN
   ═══════════════════════════════════════ */
#loginView {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 100%; max-width: 360px;
  padding: 0 24px;
  animation: fadeUp 0.5s var(--ease) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 44px;
}
.login-logo-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--ink);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.login-logo-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px; font-weight: 600; font-style: italic;
  color: var(--ink); letter-spacing: -0.3px;
}
.login-logo-sub {
  font-size: 10.5px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.12em; margin-top: 1px;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--sh1);
}
.login-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px; font-weight: 600; color: var(--ink);
  margin-bottom: 8px; letter-spacing: -0.4px;
}
.login-sub { font-size: 12.5px; color: var(--ink-3); margin-bottom: 28px; line-height: 1.65; }
.btn-google {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--rs);
  padding: 11px 16px;
  font-family: 'Bricolage Grotesque', inherit;
  font-size: 13px; font-weight: 500; color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}
.btn-google:hover { border-color: var(--border-3); background: var(--surface-2); transform: translateY(-1px); }
.login-error {
  margin-top: 14px; padding: 10px 14px;
  background: var(--red-s); border: 1px solid rgba(153,27,27,0.12);
  border-radius: var(--rs); font-size: 12px; color: var(--red); display: none;
}
.login-error.visible { display: block; }

/* ═══════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════ */
#appView { display: flex; width: 100%; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 50;
  border-right: 1px solid var(--border);
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.sidebar-logo-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--ink);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo-text { flex: 1; min-width: 0; }
.sidebar-logo-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px; font-weight: 600; font-style: italic;
  color: var(--ink); letter-spacing: -0.2px;
}
.sidebar-logo-sub  {
  font-size: 9.5px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.12em;
}

.sidebar-nav { flex: 1; padding: 8px 10px; overflow-y: auto; }
.nav-section-label {
  font-size: 9px; font-weight: 600; color: var(--ink-4);
  text-transform: uppercase; letter-spacing: 0.14em;
  padding: 14px 8px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: var(--rs);
  cursor: pointer;
  font-size: 12.5px; font-weight: 400; color: var(--ink-3);
  transition: color 0.12s, background 0.12s;
  margin-bottom: 1px;
  user-select: none;
  position: relative;
}
.nav-item:hover { color: var(--ink-2); background: var(--surface-2); }
.nav-item.active {
  color: var(--ink);
  font-weight: 600;
  background: var(--surface-2);
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-icon { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.3; transition: opacity 0.12s; }
.nav-item:hover .nav-icon { opacity: 0.5; }
.nav-badge {
  margin-left: auto;
  background: var(--surface-3); color: var(--ink-3);
  font-size: 10px; font-weight: 600;
  font-family: 'IBM Plex Mono', monospace;
  padding: 1px 7px; border-radius: 99px;
  border: 1px solid var(--border);
}

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex; align-items: center; gap: 9px;
  padding: 10px;
  border-radius: var(--rs);
  transition: background 0.12s;
}
.sidebar-user:hover { background: var(--surface-2); }
.sidebar-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: white;
  flex-shrink: 0; overflow: hidden;
}
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name  { font-size: 11.5px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { font-size: 9.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 1px; }
.btn-logout {
  background: none; border: none; cursor: pointer;
  color: var(--ink-3); padding: 4px;
  border-radius: 5px; display: flex; align-items: center;
  transition: color 0.12s; flex-shrink: 0;
}
.btn-logout:hover { color: var(--ink); }

/* ── Main ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column; min-height: 100vh;
}
.main-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.main-header-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 19px; font-weight: 600; font-style: italic;
  color: var(--ink); letter-spacing: -0.3px;
}
.main-header-right { display: flex; align-items: center; gap: 10px; }
.header-badge {
  font-size: 9.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 99px;
  background: var(--surface-2);
  color: var(--ink-3);
  border: 1px solid var(--border-2);
  text-transform: uppercase; letter-spacing: 0.1em;
}

.page-body {
  padding: 32px;
  flex: 1;
  animation: fadeUp 0.3s var(--ease) both;
}

/* ═══════════════════════════════════════
   STATS GRID
   ═══════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px;
  margin-bottom: 32px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--sh0);
}
.stat-card {
  background: var(--surface);
  padding: 22px 24px 20px;
  position: relative;
  transition: background 0.12s;
}
.stat-card:hover { background: var(--surface-2); }
.stat-label {
  font-size: 9.5px; font-weight: 600; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.12em;
  margin-bottom: 10px;
}
.stat-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 40px; font-weight: 600; font-style: italic;
  color: var(--ink); letter-spacing: -2px; line-height: 1;
  margin-bottom: 6px;
}
.stat-sub { font-size: 11px; color: var(--ink-3); line-height: 1.4; }

/* Section header */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.section-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px; font-weight: 600; font-style: italic;
  color: var(--ink); letter-spacing: -0.2px;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh0);
  overflow: hidden;
}

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  padding: 10px 18px;
  font-size: 9.5px; font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.12em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.08s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
tbody td { padding: 12px 18px; color: var(--ink-2); font-size: 12.5px; vertical-align: middle; }
td.font-semibold { font-weight: 600; color: var(--ink); }

/* Badges — soft, refined */
.badge {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px;
  white-space: nowrap;
  letter-spacing: 0.04em;
}
.badge-green  { background: var(--green-s);  color: var(--green); }
.badge-amber  { background: var(--amber-s);  color: var(--amber); }
.badge-red    { background: var(--red-s);    color: var(--red);   }
.badge-purple { background: var(--purple-s); color: var(--purple); }
.badge-gray   { background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--border); }

/* Buttons */
.btn {
  font-family: 'Bricolage Grotesque', inherit;
  font-size: 12.5px; font-weight: 500;
  padding: 8px 16px; border-radius: var(--rs);
  border: none; cursor: pointer;
  transition: all 0.12s var(--ease);
  display: inline-flex; align-items: center; gap: 6px;
  letter-spacing: -0.01em;
}
.btn-primary { background: var(--ink); color: white; }
.btn-primary:hover { background: #2a2830; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,16,20,0.2); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--ink-2);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-3); color: var(--ink); }
.btn-sm { font-size: 11.5px; padding: 5px 12px; }
.btn-danger { background: var(--red-s); color: var(--red); border: 1px solid rgba(153,27,27,0.12); }
.btn-danger:hover { background: rgba(153,27,27,0.12); }
.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: var(--ink-3);
  background: none; border: none; cursor: pointer;
  padding: 4px 0; margin-bottom: 16px;
  transition: color 0.12s;
}
.btn-back:hover { color: var(--ink); }

/* Toggle */
.toggle-wrap { display: flex; align-items: center; gap: 8px; }
.toggle { position: relative; width: 34px; height: 19px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 99px;
  transition: background 0.18s, border-color 0.18s;
}
.toggle input:checked + .toggle-track { background: var(--ink); border-color: var(--ink); }
.toggle-thumb {
  position: absolute;
  width: 13px; height: 13px;
  background: white;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform 0.18s var(--ease);
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(16,16,20,0.15);
}
.toggle input:checked ~ .toggle-thumb { transform: translateX(15px); }

/* Module chips */
.module-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.module-chip {
  font-size: 9.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 4px;
  background: var(--surface-2); color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.07em;
  border: 1px solid var(--border);
}
.module-chip.on { background: var(--ink); color: white; border-color: var(--ink); }

/* Form elements */
.field-label {
  font-size: 10px; font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-bottom: 6px; display: block;
}
.field-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--rs);
  padding: 9px 12px;
  font-family: 'Bricolage Grotesque', inherit;
  font-size: 12.5px; color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(16,16,20,0.06); }
.field-input::placeholder { color: var(--ink-4); }
select.field-input { cursor: pointer; }
textarea.field-input { resize: vertical; line-height: 1.6; }

/* Panel */
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--sh0);
  padding: 24px; margin-top: 20px;
  animation: fadeUp 0.22s var(--ease) both;
}
.detail-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.detail-panel-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px; font-weight: 600; font-style: italic; color: var(--ink);
}
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 700px) { .panel-grid { grid-template-columns: 1fr; } }

/* Toast */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9998; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast-item {
  background: var(--ink); color: white;
  font-size: 12.5px; font-weight: 400;
  padding: 10px 16px; border-radius: var(--rs);
  box-shadow: var(--sh2);
  animation: toastIn 0.28s var(--ease) both;
  pointer-events: auto;
  letter-spacing: -0.01em;
}
.toast-item.ok     { background: var(--green); }
.toast-item.error  { background: var(--red);   }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

/* Empty state */
.empty-state { padding: 48px 24px; text-align: center; color: var(--ink-3); font-size: 12.5px; }
.empty-icon  { font-size: 22px; margin-bottom: 10px; opacity: 0.4; }

/* Divider */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Row actions */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Subscription form */
.sub-form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

/* MRR highlight */
.mrr-highlight {
  font-family: 'Cormorant Garamond', serif;
  font-size: 30px; font-weight: 600; font-style: italic;
  color: var(--ink); letter-spacing: -1px; line-height: 1;
}

/* ═══════════════════════════════════════
   TABS
   ═══════════════════════════════════════ */
.tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.tab-btn {
  font-family: 'Bricolage Grotesque', inherit;
  font-size: 12px; font-weight: 400; color: var(--ink-3);
  background: none; border: none;
  border-bottom: 1.5px solid transparent;
  padding: 10px 16px; margin-bottom: -1px;
  cursor: pointer; transition: color 0.12s, border-color 0.12s;
}
.tab-btn:hover { color: var(--ink-2); }
.tab-btn.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }

/* ═══════════════════════════════════════
   MODAL
   ═══════════════════════════════════════ */
#modalOverlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(16,16,20,0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.18s;
}
#modalOverlay.open { opacity: 1; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  box-shadow: var(--sh2);
  width: 100%; max-width: 500px;
  margin: 16px;
  transform: translateY(12px) scale(0.99);
  transition: transform 0.22s var(--ease);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 80px);
}
#modalOverlay.open .modal { transform: none; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px; font-weight: 600; font-style: italic;
  color: var(--ink); letter-spacing: -0.3px;
}
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--ink-3); padding: 3px 6px; border-radius: 5px;
  transition: color 0.12s, background 0.12s; font-size: 18px; line-height: 1;
}
.modal-close:hover { color: var(--ink); background: var(--surface-2); }
.modal-body   { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  flex-shrink: 0;
}

/* Form grid */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .form-field { display: flex; flex-direction: column; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.form-field { margin-bottom: 0; display: flex; flex-direction: column; }

/* ═══════════════════════════════════════
   QUICK ACTION CARDS
   ═══════════════════════════════════════ */
.quick-action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 22px 16px 18px;
  text-align: center;
  cursor: pointer;
  font-family: 'Bricolage Grotesque', inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s var(--ease);
  box-shadow: var(--sh0);
}
.quick-action-card:hover {
  border-color: var(--border-3);
  box-shadow: var(--sh1);
  transform: translateY(-2px);
}
.quick-action-icon  { font-size: 22px; margin-bottom: 10px; display: block; opacity: 0.75; }
.quick-action-label { font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.quick-action-sub   { font-size: 11px; color: var(--ink-3); }

/* ═══════════════════════════════════════
   ONLINE DOT
   ═══════════════════════════════════════ */
.online-dot {
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--surface-3);
  margin-right: 8px; flex-shrink: 0;
  vertical-align: middle;
}
.online-dot.online { background: var(--green); }

/* ═══════════════════════════════════════
   AUDIT LOG
   ═══════════════════════════════════════ */
.audit-list { display: flex; flex-direction: column; }
.audit-entry {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.audit-entry:last-child { border-bottom: none; }
.audit-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-4);
  flex-shrink: 0; margin-top: 6px;
}
.audit-body { flex: 1; min-width: 0; }
.audit-action { font-size: 12.5px; color: var(--ink); margin-bottom: 3px; line-height: 1.4; }
.audit-meta {
  display: flex; gap: 16px;
  font-size: 10.5px; color: var(--ink-3);
  font-family: 'IBM Plex Mono', monospace;
}

/* ═══════════════════════════════════════
   DANGER ZONE
   ═══════════════════════════════════════ */
.danger-zone {
  background: var(--surface);
  border: 1px solid rgba(153,27,27,0.15);
  border-radius: var(--r);
  padding: 22px 24px;
}
.danger-zone-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 15px; font-weight: 600; font-style: italic; color: var(--red);
  margin-bottom: 4px;
}
.danger-zone-desc { font-size: 12px; color: var(--ink-3); margin-bottom: 18px; line-height: 1.55; }
