/* =========================================================
   Touristation Hub — Design System
   ========================================================= */

:root {
  /* Brand */
  --t-orange: #ee6420;
  --t-orange-soft: #ffe9dc;
  --t-magenta: #e91e63;
  --t-magenta-soft: #fce4ec;
  --t-purple: #7b2d8e;
  --t-purple-soft: #f1e4f5;

  /* Neutrals (warm) */
  --bg: #fafaf7;
  --bg-elev: #ffffff;
  --bg-sunk: #f4f3ee;
  --line: #e8e6df;
  --line-strong: #d8d5cb;

  --ink: #0f1115;
  --ink-2: #2a2d33;
  --ink-3: #5a5d63;
  --ink-4: #8c8e94;
  --ink-5: #b6b8bd;

  /* Semantic pairs */
  --ok: #1f8a52;
  --ok-soft: #e0f1e7;
  --warn: #b7791f;
  --warn-soft: #fbf1d6;
  --danger: #c7321b;
  --danger-soft: #fbe2dc;
  --info: #2563a8;
  --info-soft: #ddebf7;

  /* Geometry */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 17, 21, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 17, 21, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 17, 21, 0.1);

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }
input, textarea, select { font: inherit; color: inherit; }

/* Typography helpers */
.h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.h3 { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.muted { color: var(--ink-3); }
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }

.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  padding: 1px 5px;
  color: var(--ink-2);
  vertical-align: 1px;
}

/* =========================================================
   App shell
   ========================================================= */

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 8px;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--t-orange), var(--t-magenta));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}
.brand-name { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name strong { font-size: 14px; font-weight: 600; }
.brand-name span {
  font-size: 10.5px;
  color: var(--ink-4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

.nav-section { display: flex; flex-direction: column; gap: 2px; }
.nav-section-title {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding: 4px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--bg-sunk); }
.nav-item.is-active { background: var(--ink); color: #fff; }
.nav-item .count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--ink-4);
}
.nav-item.is-active .count { color: var(--ink-5); }
.nav-item .count.is-urgent { color: var(--t-orange); font-weight: 600; }
.nav-item.is-active .count.is-urgent { color: var(--t-orange-soft); }

.sidebar-footer { margin-top: auto; }
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 8px 4px;
  border-top: 1px solid var(--line);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--t-orange), var(--t-magenta));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.02em;
}
.user-name { font-size: 13px; font-weight: 500; }
.user-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  margin-top: 2px;
}

/* =========================================================
   Main column
   ========================================================= */

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 20;
}
.topbar .meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topbar .meta small {
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}
.topbar .grow { flex: 1; }

.content {
  padding: 24px 28px 64px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 1280px;
  width: 100%;
}

/* =========================================================
   Card
   ========================================================= */

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.card-header .grow { flex: 1; }
.card-body { padding: 18px; }
.card-sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--ink-3);
  max-width: 720px;
}
.card-hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}

/* =========================================================
   Form
   ========================================================= */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-4);
}
.field-stack { justify-content: flex-end; }

.input,
.textarea,
.select {
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 8px 12px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--ink);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px rgba(15, 17, 21, 0.06);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--ink-5);
}
.input[readonly] {
  background: var(--bg-sunk);
  cursor: default;
}

.textarea {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  resize: vertical;
  min-height: 120px;
}

.field-row { display: grid; gap: 12px; }
.field-row.cols-2 { grid-template-columns: 1fr 1fr; }
.field-row.cols-imap {
  grid-template-columns: minmax(180px, 2fr) 90px minmax(220px, 2fr) 110px;
}
.field-row.cols-pass {
  grid-template-columns: minmax(220px, 1fr) 1fr;
  margin-top: 12px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  color: var(--ink-2);
}
.checkbox input {
  width: 15px;
  height: 15px;
  accent-color: var(--ink);
}

.actions-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.excel-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.excel-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* =========================================================
   Buttons
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-sunk); }
.btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.btn--primary:hover { background: #000; }

.btn--brand {
  background: var(--t-orange);
  color: #fff;
  border-color: var(--t-orange);
}
.btn--brand:hover { background: #d45418; border-color: #d45418; }
.btn--brand:disabled { background: var(--t-orange); border-color: var(--t-orange); }

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-3);
}
.btn--ghost:hover { background: var(--bg-sunk); color: var(--ink); }

/* =========================================================
   Badges & Tags
   ========================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge.is-urgent { color: var(--t-orange); background: var(--t-orange-soft); }
.badge.is-ok { color: var(--ok); background: var(--ok-soft); }
.badge.is-warn { color: var(--warn); background: var(--warn-soft); }
.badge.is-danger { color: var(--danger); background: var(--danger-soft); }
.badge.is-info { color: var(--info); background: var(--info-soft); }
.badge.is-magenta { color: var(--t-magenta); background: var(--t-magenta-soft); }
.badge.is-purple { color: var(--t-purple); background: var(--t-purple-soft); }
.badge.is-neutral { color: var(--ink-3); background: var(--bg-sunk); }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  font-size: 11px;
  color: var(--ink-3);
  background: var(--bg-elev);
}

/* =========================================================
   Chips (selectable filter)
   ========================================================= */

.chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.chip:hover { background: var(--bg-sunk); }
.chip.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.chip .count {
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
  font-size: 11px;
}

/* =========================================================
   Tabs
   ========================================================= */

.tabs {
  display: inline-flex;
  gap: 2px;
  background: var(--bg-sunk);
  padding: 3px;
  border-radius: var(--r-md);
}
.tab {
  background: transparent;
  border: 0;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-3);
  font-weight: 500;
  font-size: 13px;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.tab:hover { color: var(--ink); }
.tab.is-active {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* =========================================================
   Table
   ========================================================= */

.table-wrap {
  overflow: auto;
  max-height: 520px;
}
table.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.t thead th {
  position: sticky;
  top: 0;
  background: var(--bg-sunk);
  text-align: left;
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  z-index: 1;
}
table.t tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.t tbody tr:hover td { background: var(--bg-sunk); }
table.t tbody tr:last-child td { border-bottom: 0; }
.cell-pnr {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

/* =========================================================
   Status dot
   ========================================================= */

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
  box-shadow: 0 0 0 3px var(--bg-elev);
}
.status-dot.s-pending { background: var(--ink-5); }
.status-dot.s-running { background: var(--info); animation: pulse 1.2s ease-in-out infinite; }
.status-dot.s-success { background: var(--ok); }
.status-dot.s-failed { background: var(--danger); }
.status-dot.s-skipped { background: var(--warn); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* =========================================================
   Log
   ========================================================= */

.log {
  background: #0f1115;
  color: #e8e6df;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  padding: 14px 18px;
  max-height: 360px;
  min-height: 160px;
  overflow: auto;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.log > div { white-space: pre-wrap; word-break: break-word; }
.log .ts { color: #8c8e94; margin-right: 10px; user-select: none; }
.log .log-empty { color: #5a5d63; font-style: italic; }
.log .level-err { color: #ff8a72; }
.log .level-ok { color: #8be0a8; }

/* =========================================================
   Empty state
   ========================================================= */

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-4);
  font-size: 13px;
}

/* =========================================================
   Toast
   ========================================================= */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  max-width: 380px;
  z-index: 100;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.is-danger { background: var(--danger); }
.toast.is-ok { background: var(--ok); }
.toast.is-warn { background: var(--warn); color: #fff; }

/* =========================================================
   Progress
   ========================================================= */

.progress {
  width: 220px;
  height: 6px;
  background: var(--bg-sunk);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--t-orange), var(--t-magenta));
  transition: width 0.25s ease;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
  }
  .sidebar-footer { margin: 0 0 0 auto; }
  .user-card { border-top: 0; padding: 0; }
  .nav-section { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .nav-section-title { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .field-row.cols-imap { grid-template-columns: 1fr 1fr; }
  .field-row.cols-pass { grid-template-columns: 1fr; }
  .excel-row { flex-direction: column; align-items: stretch; }
  .progress { width: 120px; }
}
