/* Reports shared styles — for report_*.html pages
   Self-contained, no external deps */

:root {
  --indigo: #4f46e5;
  --indigo-dark: #4338ca;
  --violet: #7c3aed;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --amber: #f59e0b;
  --red: #ef4444;
  --cyan: #06b6d4;
  --violet-light: #8b5cf6;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow: 0 1px 3px 0 rgba(0,0,0,0.08), 0 1px 2px -1px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
}

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

/* Layout */
.report-shell { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
.report-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
}
.report-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.report-title h1 { font-size: 22px; font-weight: 700; margin: 0; color: var(--gray-900); }
.report-title .sub { color: var(--gray-500); font-size: 13px; }
.report-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Cards (big) */
.kpi-grid {
  display: grid; gap: 16px; margin-bottom: 24px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.kpi-card {
  background: #fff; border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
  position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--gray-300);
}
.kpi-card.kpi-ok::before { background: var(--emerald); }
.kpi-card.kpi-warn::before { background: var(--amber); }
.kpi-card.kpi-err::before { background: var(--red); }
.kpi-card.kpi-info::before { background: var(--cyan); }
.kpi-card.kpi-violet::before { background: var(--violet-light); }
.kpi-label { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--gray-900); margin-top: 6px; }
.kpi-sub { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
.kpi-delta { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; margin-left: 4px; }
.kpi-delta.up { background: #d1fae5; color: var(--emerald-dark); }
.kpi-delta.down { background: #fee2e2; color: var(--red); }

/* Card (content) */
.card {
  background: #fff; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
  margin-bottom: 20px;
}
.card h2 { font-size: 16px; font-weight: 600; margin: 0 0 16px; color: var(--gray-900); }
.card h3 { font-size: 14px; font-weight: 600; margin: 0 0 12px; color: var(--gray-700); }
.card-row { display: grid; gap: 16px; }
.card-row.two { grid-template-columns: 1fr 1fr; }
.card-row.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 768px) { .card-row.two, .card-row.three { grid-template-columns: 1fr; } }

/* Chart container */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap.tall { height: 320px; }
.chart-wrap.short { height: 180px; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--gray-200); background: #fff; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--gray-200); }
table.data th { background: var(--gray-50); font-weight: 600; color: var(--gray-700); font-size: 12px; text-transform: uppercase; letter-spacing: 0.3px; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--gray-50); }
table.data .mono { font-family: 'Menlo', 'Monaco', monospace; font-size: 12px; }
table.data .right { text-align: right; }
table.data .center { text-align: center; }

/* Badges */
.badge { display: inline-block; padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; background: var(--gray-200); color: var(--gray-700); }
.badge.ok { background: #d1fae5; color: var(--emerald-dark); }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.err { background: #fee2e2; color: var(--red); }
.badge.info { background: #dbeafe; color: #1e40af; }
.badge.violet { background: #ede9fe; color: #6d28d9; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--gray-700); font-weight: 600; }
.field input, .field select {
  padding: 8px 10px; border: 1px solid var(--gray-300); border-radius: 6px;
  font: inherit; background: #fff;
}
.field input:focus, .field select:focus { outline: 2px solid var(--indigo); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 6px; border: 1px solid var(--indigo);
  background: var(--indigo); color: #fff; font: inherit; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.btn:hover { background: var(--indigo-dark); }
.btn.ghost { background: #fff; color: var(--indigo); }
.btn.ghost:hover { background: var(--gray-50); }
.btn.tiny { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.filter-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 20px; }
.filter-bar .field { margin: 0; min-width: 140px; }

.live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 12px; background: #d1fae5; color: var(--emerald-dark);
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.live-pill::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--emerald);
  box-shadow: 0 0 0 0 var(--emerald); animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
  70% { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

.muted { color: var(--gray-500); }
.center { text-align: center; }
.right { text-align: right; }
.flex { display: flex; }
.gap { gap: 12px; }

.progress {
  background: var(--gray-200); height: 8px; border-radius: 4px; overflow: hidden;
  margin-top: 8px;
}
.progress-bar { background: var(--emerald); height: 100%; transition: width 0.4s ease; }

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--gray-200); border-top-color: var(--indigo);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 60px; gap: 12px; align-items: center; }
.bar-track { background: var(--gray-200); height: 22px; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--indigo); transition: width 0.4s; }
.bar-row .bar-count { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* Door list specific */
.door-list { list-style: none; padding: 0; margin: 0; }
.door-item {
  display: grid; grid-template-columns: 50px 1fr 140px 100px 80px; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--gray-200);
  align-items: center;
}
.door-item:hover { background: var(--gray-50); }
.door-item.checked { background: #ecfdf5; border-left: 3px solid var(--emerald); }
.door-num { font-family: monospace; color: var(--gray-500); font-size: 12px; }
.door-name { font-weight: 600; }
.door-name .party { color: var(--gray-500); font-weight: normal; font-size: 12px; margin-left: 6px; }
.door-phone { font-family: monospace; font-size: 12px; color: var(--gray-600); }
.door-status { font-size: 12px; }
.door-checkin { font-family: monospace; font-size: 11px; color: var(--gray-500); }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
  .report-header { border-bottom: 1px solid #999; }
  .door-item { page-break-inside: avoid; }
}
