/* ============================================================
   Dispatch Visualizer — Global Styles
   Philosophy: server-driven UI, minimal JS. CSS handles all
   visual polish — animations, transitions, responsive layout.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --bg-base:        #0d1117;
  --bg-surface:     #161b22;
  --bg-card:        #1c2128;
  --bg-hover:       #21262d;
  --border:         #30363d;
  --border-subtle:  #21262d;

  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;

  --accent:         #2f81f7;
  --accent-hover:   #388bfd;
  --accent-glow:    rgba(47, 129, 247, 0.25);

  --success:        #3fb950;
  --danger:         #f85149;
  --warning:        #d29922;

  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      16px;

  --shadow-sm:      0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:      0 8px 40px rgba(0,0,0,0.6);

  --transition:     180ms ease;
}

/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

/* ── Flash messages ────────────────────────────────────────── */
.flash-error {
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid rgba(248, 81, 73, 0.4);
  color: #f85149;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.875rem;
  margin-bottom: 20px;
  animation: fadeIn 0.2s ease;
}

/* ── LOGIN PAGE ────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(47, 129, 247, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(63, 185, 80, 0.04) 0%, transparent 50%),
    var(--bg-base);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--accent);
  filter: drop-shadow(0 0 12px var(--accent-glow));
}

.login-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-header p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Form ──────────────────────────────────────────────────── */
.login-form { display: flex; flex-direction: column; gap: 18px; }

.form-field { display: flex; flex-direction: column; gap: 6px; }

.form-field label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.form-field input {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  padding: 10px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}

.form-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-field input::placeholder { color: var(--text-muted); }

.btn-login {
  margin-top: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 11px;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  width: 100%;
}

.btn-login:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 16px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-login:active { transform: translateY(0); }

/* ── DASHBOARD PAGE ────────────────────────────────────────── */
.dashboard-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 60px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.header-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  background: rgba(47, 129, 247, 0.15);
  color: var(--accent);
  border: 1px solid rgba(47, 129, 247, 0.3);
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 10px;
}

.user-name {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8125rem;
  padding: 5px 12px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.btn-logout:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* ── Welcome block (legacy — kept for compat) ─────────────── */
.dashboard-main {
  flex: 1;
  padding: 0 24px 40px;
  overflow-y: auto;
}

.welcome-block {
  max-width: 520px;
  text-align: center;
  animation: slideUp 0.4s ease;
}

.welcome-block h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

.welcome-block p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.welcome-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

/* ── TAB BAR ──────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 6px;
  padding: 12px 28px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: 20px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}

.tab-btn--active {
  color: var(--text-primary);
  background: rgba(47, 129, 247, 0.1);
  border-color: rgba(47, 129, 247, 0.3);
  box-shadow: 0 0 12px rgba(47, 129, 247, 0.08);
}

.tab-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}
.tab-btn--active .tab-icon { opacity: 1; color: var(--accent); }

/* ── TAB CONTENT ──────────────────────────────────────────── */
.tab-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 0;
  animation: fadeIn 0.3s ease;
}

/* ── STATS GRID ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 28px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(47, 129, 247, 0.06);
}

.stat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-dot--ticket       { background: #569480; }
.stat-dot--response     { background: #84bd71; }
.stat-dot--service      { background: #c7d3ff; }
.stat-dot--category     { background: #c29f57; }
.stat-dot--emergencytype { background: #95ba5b; }
.stat-dot--code         { background: #a4e8f4; }
.stat-dot--location     { background: #efbbe3; }
.stat-dot--secategory   { background: #c5d348; }

.stat-info { display: flex; flex-direction: column; }
.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* ── SECTION TITLES ───────────────────────────────────────── */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.section-sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── WORKLOAD CARDS ───────────────────────────────────────── */
.workload-section { margin-bottom: 28px; }

.workload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.workload-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
}

.workload-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.workload-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.workload-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
}

.workload-stat { display: flex; flex-direction: column; }
.ws-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}
.ws-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.workload-stat--emergency .ws-value { color: var(--danger); }

.workload-bar {
  height: 4px;
  background: var(--bg-hover);
  border-radius: 2px;
  overflow: hidden;
}

.workload-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #388bfd);
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── GRAPH CONTAINER ──────────────────────────────────────── */
.graph-section { margin-bottom: 28px; }

.graph-canvas {
  width: 100%;
  height: 500px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 12px;
}

.graph-canvas svg {
  width: 100%;
  height: 100%;
}

/* ── EXPANDED PANEL ───────────────────────────────────────── */
.expanded-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  animation: slideUp 0.25s ease;
  margin-bottom: 28px;
}

.expanded-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.expanded-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.expanded-count {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.btn-close {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 1rem;
  padding: 4px 10px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.btn-close:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* ── PLACEHOLDER TAB ──────────────────────────────────────── */
.tab-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

.placeholder-card {
  text-align: center;
  padding: 48px;
  animation: slideUp 0.3s ease;
}

.placeholder-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  opacity: 0.6;
}

.placeholder-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.placeholder-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Navigation ────────────────────────────────────────────── */
.header-nav {
  display: flex;
  gap: 4px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}

.nav-link:hover { color: var(--text-primary); background: var(--bg-hover); }

.nav-link--active {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ── Flash messages ────────────────────────────────────────── */
.flash-info {
  background: rgba(47, 129, 247, 0.1);
  border: 1px solid rgba(47, 129, 247, 0.3);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.875rem;
  margin-top: 16px;
  animation: fadeIn 0.2s ease;
}

/* ── IMPORT PAGE ───────────────────────────────────────────── */
.import-main {
  flex: 1;
  padding: 36px 24px;
  overflow-y: auto;
}

.import-container {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.page-header { margin-bottom: 8px; }
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.page-header p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.import-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  animation: slideUp 0.3s ease;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-sub {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.card-sub code {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8em;
  color: var(--accent);
}

.card-sub a { color: var(--accent); text-decoration: none; }
.card-sub a:hover { text-decoration: underline; }

/* ── Token form ────────────────────────────────────────────── */
.token-form { display: flex; flex-direction: column; gap: 14px; }

.token-textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.5;
}

.token-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.token-textarea::placeholder { color: var(--text-muted); }

.token-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.token-status--set {
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid rgba(63, 185, 80, 0.3);
  color: var(--success);
}

.token-status svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  padding: 0;
  margin-left: auto;
  text-decoration: underline;
}

.btn-link:hover { color: var(--accent-hover); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 9px 20px;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 0 12px var(--accent-glow);
}

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

.action-row { margin-top: 16px; }

/* ── Connection result ─────────────────────────────────────── */
.conn-result {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  animation: fadeIn 0.2s ease;
}

.conn-result--success {
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid rgba(63, 185, 80, 0.3);
  color: var(--success);
}

.conn-result--warning {
  background: rgba(210, 153, 34, 0.1);
  border: 1px solid rgba(210, 153, 34, 0.3);
  color: var(--warning);
}

.conn-result--error {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: var(--danger);
}

/* ── Data tables ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin-top: 4px; }

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

.data-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 12px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }

.mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.8em; }
.text-muted { color: var(--text-muted); }

.badge {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 8px;
  color: var(--text-secondary);
}

/* Emergency type badges */
.badge-type {
  display: inline-block;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-type--emergency { background: rgba(248,81,73,0.15); color: #f85149; }
.badge-type--code      { background: rgba(210,153,34,0.15); color: #d29922; }
.badge-type--non       { background: rgba(63,185,80,0.15);  color: #3fb950; }
.badge-type--default   { background: var(--bg-surface);      color: var(--text-muted); }

/* ── EXPERIMENTS TAB ──────────────────────────────────────── */

/* Experiment button accent */
.tab-btn--experiment { color: #3fb950; }
.tab-btn--experiment.tab-btn--active {
  background: rgba(63, 185, 80, 0.1);
  border-color: rgba(63, 185, 80, 0.3);
  box-shadow: 0 0 12px rgba(63, 185, 80, 0.08);
  color: #3fb950;
}
.tab-btn--experiment .tab-icon { color: #3fb950; }

/* Fullscreen tab content */
.tab-content--fullscreen {
  max-width: none;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 135px);  /* viewport minus header + tab bar */
}

/* Experiment header */
.experiment-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 4px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.experiment-legend {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.legend-item svg { flex-shrink: 0; }

/* Experiment canvas — fills remaining height */
.experiment-canvas {
  flex: 1;
  min-height: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.experiment-canvas svg {
  width: 100%;
  height: 100%;
}

/* Pulse animation for hub nodes */
@keyframes pulse {
  0%   { stroke-opacity: 0.3; transform: scale(1); }
  50%  { stroke-opacity: 0.7; transform: scale(1.08); }
  100% { stroke-opacity: 0.3; transform: scale(1); }
}

.pulse-ring {
  animation: pulse 3s ease-in-out infinite;
  transform-origin: center center;
}

/* Dash animation for links */
@keyframes dash {
  to { stroke-dashoffset: -100; }
}

/* ── TICKET DETAIL PAGE ───────────────────────────────────── */

.ticket-detail {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: slideUp 0.3s ease;
}

.ticket-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.ticket-id {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.ticket-meta {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.ticket-meta strong { color: var(--text-primary); font-weight: 600; }

.ticket-badges {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Response cards */
.response-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.response-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: border-color 0.2s;
}

.response-card--fast {
  border-left: 3px solid #3fb950;
}

.response-card--slow {
  border-left: 3px solid #f85149;
}

.response-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.response-service {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.response-time-badge {
  font-size: 0.875rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
}

.rtb--fast {
  background: rgba(63, 185, 80, 0.15);
  color: #3fb950;
}

.rtb--slow {
  background: rgba(248, 81, 73, 0.15);
  color: #f85149;
}

/* Response timeline */
.response-timeline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tl-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.tl-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.tl-time {
  font-size: 0.8rem;
  color: var(--text-primary);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 500;
}

.tl-arrow {
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0 4px;
}

/* Time bar */
.time-bar-container {
  height: 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  position: relative;
  overflow: visible;
}

.time-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.time-bar--fast { background: #3fb950; }
.time-bar--slow { background: #f85149; }

.time-bar-threshold {
  position: absolute;
  top: -14px;
  transform: translateX(-50%);
}

.threshold-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg-card);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Raw properties table */
.ticket-raw {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.prop-key {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8rem;
  width: 180px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── IMPORT PAGE — Date & Log ─────────────────────────────── */
.date-range-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.date-input {
  background: var(--bg-base);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
  width: 160px;
}

.date-input:focus { outline: none; border-color: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--accent-hover);
  color: var(--accent-hover);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.25rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: background var(--transition);
}

.btn-secondary:hover { background: rgba(56,139,253,0.1); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.import-log {
  margin-top: 1rem;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse;
}

.log-entry {
  display: flex;
  gap: 1rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--bg-surface);
}

.log-time { color: var(--text-muted); white-space: nowrap; }
.log-msg  { color: var(--text-primary); white-space: pre-wrap; word-break: break-all; }

/* Side-by-side panels */
.twin-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 900px) { .twin-panels { grid-template-columns: 1fr; } }

.panel-half { margin: 0 !important; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  font-size: 1rem;
  transition: all var(--transition);
}

.btn-icon:hover { border-color: var(--accent-hover); color: var(--accent-hover); }

/* ── Profile Page ─────────────────────────────────────────── */

.profile-page { max-width: 600px; margin: 2rem auto; padding: 0 1.5rem; }
.profile-page .page-title { font-size: 1.5rem; margin-bottom: 1.5rem; }

.profile-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 2rem;
}

.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.5rem;
}
.avatar-initial { font-size: 1.5rem; font-weight: 700; color: #fff; }

.profile-details { margin-bottom: 1.5rem; }
.detail-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.6rem 0; border-bottom: 1px solid var(--border);
}
.detail-label { color: var(--text-dim); font-size: 0.85rem; }
.detail-value { font-weight: 500; }

.password-form {
  margin-top: 1.5rem; padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.password-form .form-field { margin-bottom: 1rem; }
.password-form label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; color: var(--text-dim); }
.password-form input {
  width: 100%; padding: 0.6rem 0.8rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 0.95rem;
}
.password-form input:focus { border-color: var(--accent); outline: none; }

/* ── Admin Page ───────────────────────────────────────────── */

.admin-page { max-width: 960px; margin: 2rem auto; padding: 0 1.5rem; }
.admin-page .page-title { font-size: 1.5rem; margin-bottom: 0.3rem; }
.admin-page .page-sub { color: var(--text-dim); margin-bottom: 1.5rem; }

.admin-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.5rem;
}
.admin-card .panel-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 1rem;
}

.create-user-form {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 1.5rem; margin-bottom: 1.5rem;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.form-field label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; color: var(--text-dim); }
.form-field input, .form-field select {
  width: 100%; padding: 0.6rem 0.8rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 0.95rem;
}
.form-field input:focus, .form-field select:focus { border-color: var(--accent); outline: none; }

/* ── Role badges ──────────────────────────────────────────── */

.role-badge {
  padding: 0.15rem 0.6rem; border-radius: 4px;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
}
.role-badge--admin { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.role-badge--viewer { background: rgba(34, 197, 94, 0.2); color: #4ade80; }

/* ── Clickable username ───────────────────────────────────── */

.user-name--link {
  text-decoration: none; color: var(--text);
  transition: color var(--transition);
}
.user-name--link:hover { color: var(--accent); }

.nav-link--admin {
  font-size: 0.85rem; opacity: 0.7;
  transition: opacity var(--transition);
}
.nav-link--admin:hover { opacity: 1; }

/* ── Flash messages ───────────────────────────────────────── */

.flash-msg {
  padding: 0.7rem 1rem; border-radius: 8px;
  margin-bottom: 1rem; font-size: 0.9rem;
}
.flash-msg--ok { background: rgba(34, 197, 94, 0.15); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.flash-msg--error { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

/* ── Buttons ──────────────────────────────────────────────── */

.btn { padding: 0.5rem 1.2rem; border-radius: 8px; font-size: 0.9rem; cursor: pointer; border: none; transition: all var(--transition); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }

/* ── Theme selector grid ──────────────────────────────────── */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.7rem;
  margin-top: 1rem;
}

.theme-swatch {
  display: flex; flex-direction: column; align-items: center;
  padding: 0.6rem 0.3rem;
  background: var(--bg-base);
  border: 2px solid var(--border);
  border-radius: 10px; cursor: pointer;
  transition: all var(--transition);
}
.theme-swatch:hover { border-color: var(--text-secondary); transform: translateY(-2px); }
.theme-swatch--active { border-color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); }

.swatch-color {
  width: 32px; height: 32px; border-radius: 50%;
  margin-bottom: 0.4rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.swatch-label {
  font-size: 0.7rem; color: var(--text-secondary);
  text-transform: capitalize;
}

.profile-card .card-title { font-size: 1.1rem; margin-bottom: 0.3rem; }
.profile-card .card-sub { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.5rem; }

/* ── Home page ────────────────────────────────────────────── */

.home-page { min-height: 100vh; }
.home-main { max-width: 880px; margin: 0 auto; padding: 3rem 1.5rem; }

.home-welcome { text-align: center; margin-bottom: 3rem; }
.home-welcome h1 { font-size: 2rem; font-weight: 300; letter-spacing: -0.02em; }
.home-sub { color: var(--text-secondary); font-size: 0.95rem; margin-top: 0.4rem; }
.accent-text { color: var(--accent); font-weight: 600; }

.home-link {
  display: inline-flex; align-items: center; gap: 0.5rem;
  text-decoration: none; color: inherit;
  transition: color var(--transition);
}
.home-link:hover { color: var(--accent); }

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2rem;
}

.home-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.3rem 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none; color: var(--text-primary);
  transition: all 180ms ease;
}
.home-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}

.home-card-icon { font-size: 2rem; flex-shrink: 0; }
.home-card-body { flex: 1; }
.home-card-body h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; }
.home-card-body p { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.5; }
.home-card-arrow { font-size: 1.2rem; color: var(--text-muted); transition: color var(--transition); }
.home-card:hover .home-card-arrow { color: var(--accent); }

.home-card--admin { border-color: rgba(99, 102, 241, 0.3); }
.home-card--admin:hover { border-color: #818cf8; }
.home-card--dev { border-color: rgba(167, 139, 250, 0.2); }
.home-card--dev:hover { border-color: #a78bfa; }

.home-card-badge {
  display: inline-block; margin-top: 0.4rem;
  font-size: 0.6rem; font-weight: 700; color: #a78bfa;
  background: rgba(167, 139, 250, 0.12); padding: 0.15rem 0.5rem;
  border-radius: 4px; border: 1px solid rgba(167, 139, 250, 0.25);
  letter-spacing: 0.05em;
}

/* ── Sub-header (profile, admin, etc.) ────────────────────── */

.sub-header {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.8rem 0; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.sub-header-title {
  font-size: 1.1rem; font-weight: 600;
  color: var(--text-primary); text-decoration: none;
}
