/* otgg-office — shared styles. Dark navy + warm gold, matching the main OTGG site palette. */

:root {
  --bg: #0b0e14;
  --surface: #14181f;
  --surface-2: #1b212b;
  --border: #232932;
  --border-strong: #2d3543;
  --text: #e9ebf0;
  --text-muted: #8b94a3;
  --gold: #cfa15a;
  --gold-hover: #e0b66c;
  --gold-dim: rgba(207, 161, 90, 0.15);
  --green: #5ec07a;
  --red: #e96b6b;
  --amber: #f0a648;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-hover); text-decoration: underline; }

/* Top nav */
.topnav {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topnav .brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--gold);
  font-size: 16px;
  white-space: nowrap;
}
.topnav .brand small {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 6px;
}
.topnav nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav nav a {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
}
.topnav nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.topnav nav a.active { color: var(--gold); background: var(--gold-dim); }
.topnav .who {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

/* Global refresh button on every page's top nav.
   Clicking it cleans orphan data + reloads the page. */
.topnav-refresh {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  letter-spacing: 0.02em;
  transition: all 0.15s;
  margin-left: 12px;
}
.topnav-refresh:hover {
  color: var(--gold);
  border-color: var(--gold);
  background: var(--gold-dim);
}
.topnav-refresh:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.topnav-refresh .refresh-icon {
  display: inline-block;
  font-size: 14px;
  line-height: 1;
}
.topnav-refresh .refresh-icon.spinning {
  animation: refresh-spin 0.9s linear infinite;
}
@keyframes refresh-spin {
  to { transform: rotate(360deg); }
}

/* Layout */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.page-header .sub {
  color: var(--text-muted);
  margin-top: 4px;
  font-size: 13px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: 0.02em; }

/* Metric grid (dashboard) */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.metric .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.metric .value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.metric .value.gold { color: var(--gold); }
.metric .value.green { color: var(--green); }
.metric .value.red { color: var(--red); }
.metric .value.amber { color: var(--amber); }
.metric .delta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
}
.btn:hover { background: var(--surface); border-color: var(--gold); color: var(--gold); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1409; font-weight: 600; }
.btn.primary:hover { background: var(--gold-hover); border-color: var(--gold-hover); color: #1a1409; }
.btn.danger { color: var(--red); border-color: rgba(233, 107, 107, 0.4); }
.btn.danger:hover { background: rgba(233, 107, 107, 0.1); color: var(--red); border-color: var(--red); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Forms */
input[type="text"], input[type="number"], input[type="date"], input[type="email"], input[type="tel"],
input[type="search"], select, textarea {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  align-items: end;
}
.filters .reset { align-self: end; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 13px;
}
table.data thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-strong);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
table.data tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody td .muted { color: var(--text-muted); font-size: 12px; }
table.data td.right, table.data th.right { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

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

/* Badges */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge.gray { background: var(--surface-2); color: var(--text-muted); border-color: var(--border-strong); }
.badge.gold { background: var(--gold-dim); color: var(--gold); border-color: rgba(207, 161, 90, 0.3); }
.badge.green { background: rgba(94, 192, 122, 0.12); color: var(--green); border-color: rgba(94, 192, 122, 0.3); }
.badge.red { background: rgba(233, 107, 107, 0.12); color: var(--red); border-color: rgba(233, 107, 107, 0.3); }
.badge.amber { background: rgba(240, 166, 72, 0.12); color: var(--amber); border-color: rgba(240, 166, 72, 0.3); }

/* Pagination */
.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 12px;
}

/* Upload drop zone */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 50px;
  text-align: center;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--gold);
  background: var(--gold-dim);
}
.dropzone .hint { color: var(--text-muted); margin-top: 8px; font-size: 13px; }
.dropzone input[type="file"] { display: none; }

.upload-log {
  margin-top: 18px;
  font-size: 13px;
}
.upload-log .row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  align-items: center;
}
.upload-log .filename { font-weight: 500; }
.upload-log .status { font-size: 12px; }

/* Detail view (single doc / single client) */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 980px) { .detail-grid { grid-template-columns: 1fr; } }

.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 6px 14px;
  font-size: 13px;
}
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; word-break: break-word; }

.pdf-frame {
  width: 100%;
  height: 600px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #2b2b2b;
}

pre.json {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 12px;
  overflow-x: auto;
  max-height: 480px;
  color: var(--text-muted);
}

/* Modal — themed dark/gold confirm + result dialog */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 16px 16px;
  z-index: 1000;
  animation: modal-fade 0.15s ease-out;
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  animation: modal-pop 0.15s ease-out;
}
@keyframes modal-pop { from { transform: translateY(-12px); } to { transform: translateY(0); } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.02em;
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
  font-family: inherit;
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 16px 18px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
  overflow-y: auto;
  flex: 1 1 auto;
}
.modal-body p { margin: 0 0 10px; }
.modal-body p:last-child { margin-bottom: 0; }
.modal-body strong { color: var(--gold); }
.modal-body .risk-list {
  margin: 10px 0 0;
  padding: 12px 14px;
  background: rgba(233, 107, 107, 0.08);
  border: 1px solid rgba(233, 107, 107, 0.25);
  border-radius: var(--radius-sm);
  list-style: none;
  font-size: 12px;
}
.modal-body .risk-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  font-variant-numeric: tabular-nums;
}
.modal-body .risk-list li strong { color: var(--red); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Duplicate-scan result panel inside a modal */
.dup-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
}
.dup-group-header {
  padding: 10px 14px;
  background: var(--surface-2);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dup-group-header .dup-key { color: var(--gold); font-weight: 600; }
.dup-group-header .dup-count {
  background: rgba(233, 107, 107, 0.15);
  color: var(--red);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.dup-group-rows { padding: 0; }
.dup-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  align-items: center;
}
.dup-row:last-child { border-bottom: none; }
.dup-row .dup-id {
  color: var(--text-muted);
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}
.dup-row .dup-actions {
  display: flex;
  gap: 4px;
}
.dup-empty {
  padding: 36px;
  text-align: center;
  color: var(--green);
  font-size: 13px;
}

/* Stat chips (High / Low / Monthly avg labels next to chart totals) */
.stat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.stat-chips .chip {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat-chips .chip-k {
  color: var(--text-muted);
  margin-right: 4px;
  font-size: 11px;
}
.stat-chips .chip strong {
  color: var(--gold);
  font-weight: 600;
}

/* Bar-chart hover state */
.chart-wrap .bar-g .bar { transition: opacity 0.1s; }
.chart-wrap .bar-hit { cursor: pointer; }

/* Sub-tabs (Bookings / Clients / Partners on the Performance page) */
.subtabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  padding: 0 4px;
}
.subtabs button {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: 0.01em;
}
.subtabs button:hover { color: var(--text); }
.subtabs button.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* Filter pills (partner-type filter) */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.filter-pills button {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-muted);
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.filter-pills button:hover { color: var(--text); border-color: var(--gold); }
.filter-pills button.active {
  background: var(--gold);
  color: #1a1409;
  border-color: var(--gold);
  font-weight: 600;
}

/* Initials bubble used in Top Clients table */
.avatar-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold-dim);
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
  border: 1px solid rgba(207, 161, 90, 0.35);
}

/* CBV chart — wrapper, tooltip, and legend */
.chart-wrap {
  position: relative;
  width: 100%;
}
.chart-wrap svg .chart-hit { cursor: crosshair; }

.chart-tooltip {
  position: absolute;
  top: 8px;
  background: #0b0e14ee;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  /* Was pointer-events:none — now AUTO so the user can mouse into the tooltip
     to scroll the group list or click the "View all" link. */
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  min-width: 220px;
  max-width: 340px;
  max-height: calc(100% - 16px);
  display: flex;
  flex-direction: column;
  z-index: 5;
  font-size: 12px;
  color: var(--text);
  backdrop-filter: blur(6px);
}
.chart-tooltip[hidden] { display: none; }
.chart-tooltip .tt-head {
  font-weight: 600;
  color: var(--gold);
  font-size: 13px;
  margin-bottom: 2px;
  letter-spacing: 0.02em;
}
.chart-tooltip .tt-sub {
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.chart-tooltip .tt-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 0;
  font-variant-numeric: tabular-nums;
}
.chart-tooltip .tt-k { color: var(--text-muted); }
.chart-tooltip .tt-v { color: var(--text); font-weight: 500; }
.chart-tooltip .tt-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* Group-trip booking list inside the tooltip — scrollable when many clients */
.chart-tooltip .tt-list {
  overflow-y: auto;
  max-height: 220px;
  margin: 0 -4px;
  padding: 0 4px;
}
.chart-tooltip .tt-list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}
.chart-tooltip .tt-list-row:last-child { border-bottom: none; }
.chart-tooltip .tt-list-name {
  font-weight: 500;
  color: var(--text);
  font-size: 12px;
  line-height: 1.3;
}
.chart-tooltip .tt-list-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chart-tooltip .tt-list-cbv {
  color: var(--gold);
  font-weight: 600;
  font-size: 12px;
}
.chart-tooltip .tt-link {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--gold-dim);
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.chart-tooltip .tt-link:hover {
  background: rgba(207, 161, 90, 0.22);
  text-decoration: none;
}

.chart-legend {
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 4px 0;
  justify-content: center;
}
.chart-legend .dot {
  display: inline-block;
  width: 18px;
  height: 0;
  border-top: 2px solid var(--gold);
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  top: -2px;
}
.chart-legend .dot.dashed {
  border-top: 2px dashed var(--text-muted);
}

/* Disclosure (collapsed by default) — used for raw JSON, debug panels, etc. */
.json-disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 0;
}
.json-disclosure > summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-sm);
}
.json-disclosure > summary::-webkit-details-marker { display: none; }
.json-disclosure > summary::before {
  content: '▸';
  display: inline-block;
  color: var(--gold);
  transition: transform 0.15s ease;
  font-size: 12px;
  width: 12px;
}
.json-disclosure[open] > summary::before {
  transform: rotate(90deg);
}
.json-disclosure > summary:hover { color: var(--gold); }
.json-disclosure > summary .muted {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
  margin-left: 4px;
}
.json-disclosure > pre.json {
  margin: 0 14px 14px;
  width: calc(100% - 28px);
}

/* Inline notices */
.notice {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 14px;
  font-size: 13px;
}
.notice.error { color: var(--red); border-color: rgba(233, 107, 107, 0.3); background: rgba(233, 107, 107, 0.06); }
.notice.success { color: var(--green); border-color: rgba(94, 192, 122, 0.3); background: rgba(94, 192, 122, 0.06); }
.notice.warn { color: var(--amber); border-color: rgba(240, 166, 72, 0.3); background: rgba(240, 166, 72, 0.06); }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--text-muted);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.row-actions { white-space: nowrap; display: flex; gap: 4px; }

/* Scrollbar polish */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }
