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

html { font-size: 15px; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f0f4f7;
  color: #222;
  min-height: 100vh;
}

a { color: #1da1d2; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border-bottom: 3px solid #1da1d2;
  padding: 12px 24px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.07);
}

.header-logo-link { display: block; margin-bottom: 8px; }
.header-logo { height: 36px; width: auto; display: block; }

.site-nav {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0 4px;
}

.nav-spacer {
  flex: 1;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  justify-content: center;
}

.nav-user-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.nav-user {
  font-size: 0.8rem;
  color: #888;
  white-space: nowrap;
  font-weight: 600;
  padding: 0 4px;
}

.nav-link {
  display: inline-block;
  padding: 8px 22px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #555;
  border-radius: 6px 6px 0 0;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  border: 1px solid transparent;
  border-bottom: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.nav-link:hover { background: #f1f5f9; color: #1da1d2; text-decoration: none; }

.nav-active {
  background: #e0f2fe;
  color: #1da1d2 !important;
  border-color: #bae6fd;
}

.nav-logout {
  font-size: 0.8rem;
  padding: 6px 14px;
  color: #94a3b8;
  text-transform: none;
  letter-spacing: 0;
}
.nav-logout:hover { background: #fdecea; color: #c0392b; }

/* legacy header classes (unused but kept for safety) */
.header-left { display: flex; align-items: center; }
.header-center { flex: 1; text-align: center; }
.header-page-title { font-size: 35px; font-weight: 600; color: #333; }
.header-location { display: inline-flex; align-items: center; gap: 12px; }
.header-loc-name { font-size: 35px; font-weight: 600; color: #333; }
.header-right { display: flex; align-items: center; gap: 12px; }
.username { font-size: 0.82rem; color: #666; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  background: #1da1d2;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 8px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: #178cb8; }

.btn-sm {
  background: #f0f4f7;
  color: #444;
  border: 1px solid #d0d8e0;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.btn-sm:hover { background: #e2eaf0; }

.btn-danger {
  background: #fdecea;
  color: #c0392b;
  border-color: #f5c6c0;
}
.btn-danger:hover { background: #f5c6c0; }

.btn-warn {
  background: #fef9ec;
  color: #b7770d;
  border-color: #f5d97a;
}
.btn-warn:hover { background: #f5d97a; }

.btn-icon {
  padding: 2px 6px;
  font-size: 0.85rem;
  line-height: 1;
}

.btn-outline {
  background: transparent;
  color: #1da1d2;
  border-color: #1da1d2;
}
.btn-outline:hover { background: #e8f7fc; }

.btn-link {
  font-size: 0.82rem;
  color: #1da1d2;
  padding: 4px 8px;
}
.btn-link:hover { text-decoration: underline; }

/* ── Main ─────────────────────────────────────────────────────────────────── */
main { padding: 24px; max-width: 1400px; margin: 0 auto; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-head h3 { font-size: 0.95rem; font-weight: 700; color: #333; }
.card-sub { font-size: 0.75rem; color: #888; }
.card-note { font-size: 0.82rem; color: #666; margin-bottom: 12px; }
.card-date { font-size: 0.8rem; color: #888; }
.log-last-received { font-size: 0.78rem; color: #888; white-space: nowrap; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  border-radius: 5px;
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: 0.88rem;
}
.alert-error { background: #fdecea; color: #c0392b; border: 1px solid #f5c6c0; }
.alert-success { background: #e8f8ee; color: #1e8449; border: 1px solid #a9dfbf; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge-connected { color: #1e8449; font-weight: 700; font-size: 0.82rem; }
.badge-inactive  { color: #999; font-size: 0.82rem; }
.badge-admin     { background: #1da1d2; color: #fff; border-radius: 3px; padding: 2px 7px; font-size: 0.75rem; font-weight: 700; }

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 80px;
}

.login-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  padding: 36px 40px;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo-name {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: #1da1d2;
}
.login-logo-sub {
  font-size: 0.8rem;
  color: #888;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d0d8e0;
  border-radius: 5px;
  font-size: 0.88rem;
  color: #333;
  background: #fff;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #1da1d2;
  box-shadow: 0 0 0 2px rgba(29,161,210,0.15);
}
.form-group small { display: block; font-size: 0.75rem; color: #888; margin-top: 4px; }

.form-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.form-row .form-group { flex: 1; min-width: 160px; }

/* ── Locations tile dashboard ─────────────────────────────────────────────── */
.page-locations { }

.loc-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 18px;
}

.loc-tile {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.07);
  padding: 20px;
  border-left: 5px solid #d0d8e0;
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.18s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 280px;
}
.loc-tile:hover {
  box-shadow: 0 8px 22px rgba(0,0,0,0.13);
  transform: translateY(-4px);
  text-decoration: none;
  color: inherit;
}
.loc-tile.status-connected { border-left-color: #27ae60; }
.loc-tile.status-lost      { border-left-color: #e74c3c; }
.loc-tile.status-inactive  { border-left-color: #ccc; opacity: 0.78; }

/* Tile header */
.tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tile-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: #1a1a2e;
  letter-spacing: -0.2px;
}
.tile-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-ok   { background: #e8f8ee; color: #1e8449; }
.badge-lost { background: #fdecea; color: #c0392b; }
.badge-off  { background: #f0f0f0; color: #999; }

/* Info boxes row */
.tile-boxes {
  display: flex;
  gap: 10px;
}
.tile-box {
  flex: 1;
  background: #f0f7ff;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}
.box-temp { background: #f8f4ff; }
.box-show { background: #f5f5f5; }

.box-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: #1da1d2;
  letter-spacing: 0.5px;
  line-height: 1.2;
}
.box-lbl {
  font-size: 0.68rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 3px;
}

.val-green { color: #27ae60; }
.val-gray  { color: #aaa; }

/* Detail rows */
.tile-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.tile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: #555;
  border-bottom: 1px solid #f4f6f8;
  padding-bottom: 4px;
}
.tile-row:last-child { border-bottom: none; }
.tile-row span:first-child { color: #999; }
.tile-row span:last-child  { font-weight: 600; color: #333; text-align: right; max-width: 60%; }

.tile-bsfile {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px !important;
  font-size: 0.75rem !important;
}

.tile-no-data {
  font-size: 0.82rem;
  color: #bbb;
  text-align: center;
  padding: 20px 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile-drag-handle {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 1rem;
  color: #ccc;
  cursor: grab;
  line-height: 1;
  user-select: none;
}
.loc-tile { position: relative; }
.loc-tile:hover .tile-drag-handle { color: #aaa; }
.tile-dragging { opacity: 0.45; box-shadow: none !important; }
.tile-drag-over { outline: 2px dashed #1da1d2; outline-offset: 2px; }

/* ── Dashboard info bar ───────────────────────────────────────────────────── */
.dash-info-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  margin-bottom: 18px;
  overflow: hidden;
  flex-wrap: wrap;
}

.info-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px;
  border-right: 1px solid #edf0f3;
  flex: 1;
  min-width: 100px;
}
.info-item:last-child { border-right: none; }

.info-label { font-size: 0.7rem; color: #888; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; }
.info-val { font-size: 0.95rem; font-weight: 700; color: #222; }

.status-ok       { color: #1e8449; }
.status-inactive { color: #999; }

.temp-hot  { color: #c0392b; }
.temp-warm { color: #e67e22; }

@keyframes flash-red {
  0%, 100% { color: #c0392b; }
  50%       { color: #fdecea; }
}
.flash-red { animation: flash-red 1s ease-in-out infinite; font-weight: 700; }

/* ── Dashboard layout ─────────────────────────────────────────────────────── */
.dash-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
  align-items: start;
}

.dash-left, .dash-right { display: flex; flex-direction: column; gap: 0; min-width: 0; }

/* ── Brightness rules ─────────────────────────────────────────────────────── */
.bright-rules-section { margin-top: 14px; border-top: 1px solid #e8ecf0; padding-top: 10px; }
.bright-rules-head { font-size: 0.75rem; font-weight: 700; color: #555; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }

/* ── Uptime row ───────────────────────────────────────────────────────────── */
.uptime-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.uptime-item {
  display: flex;
  flex-direction: column;
}
.uptime-item-right {
  text-align: right;
}
.uptime-label { font-size: 0.7rem; color: #888; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; }
.uptime-val   { font-size: 0.95rem; font-weight: 700; color: #222; font-variant-numeric: tabular-nums; }
.uptime-sub   { font-size: 0.75rem; color: #888; margin-top: 2px; }

/* ── Event log ────────────────────────────────────────────────────────────── */
.log-scroll {
  max-height: 280px;
  overflow-y: auto;
  font-size: 0.82rem;
  border: 1px solid #edf0f3;
  border-radius: 5px;
}

.log-row {
  display: flex;
  gap: 10px;
  padding: 5px 10px;
  border-bottom: 1px solid #f5f7fa;
  align-items: flex-start;
}
.log-row:last-child { border-bottom: none; }

.log-time { color: #888; white-space: nowrap; flex-shrink: 0; font-size: 0.78rem; padding-top: 1px; }
.log-msg  { color: #333; line-height: 1.4; }

/* Event type colouring */
.log-info       { }
.log-power_on   { background: #f0fff4; }
.log-power_off  { background: #fafafa; }
.log-warning    { background: #fffbee; }
.log-error      { background: #fdecea; }
.log-heartbeat  { opacity: 0.65; }
.log-system     { background: #f0f0ff; font-style: italic; }
.log-show_start { background: #e8f7fc; }
.log-show_end   { background: #f5f7fa; }

.log-empty { padding: 20px; text-align: center; color: #bbb; font-size: 0.85rem; }
.log-alert { background: #fef2f2 !important; }
.log-alert .log-time, .log-alert .log-msg { color: #dc2626; }
.log-date { color: #aaa; white-space: nowrap; flex-shrink: 0; font-size: 0.78rem; padding-top: 1px; }
.log-card-footer {
  display: flex; gap: 8px; align-items: center;
  border-top: 1px solid #e2e8f0; padding: 8px 12px;
}

/* ── Bar charts ───────────────────────────────────────────────────────────── */
.chart-wrap { overflow-x: auto; }
.proj-scroll-wrap { overflow-x: auto; width: 100%; min-width: 0; }
.proj-scroll-inner { min-width: max-content; }
.proj-chart-name { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: #64748b; margin: 0.75rem 0 0.25rem; }
.proj-chart-name:first-child { margin-top: 0; }

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-height: 120px;
  padding: 8px 4px 0;
}

.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex: 0 0 28px;
  width: 28px;
}

.bar-label-top {
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
  min-height: 18px;
}

.bar-outer {
  width: 100%;
  height: 80px;
  background: #f0f4f7;
  border-radius: 3px 3px 0 0;
  display: flex;
  align-items: flex-end;
}

.bar-inner {
  width: 100%;
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  transition: height 0.3s ease;
}

.bar-label-bot {
  font-size: 0.65rem;
  color: #888;
  text-align: center;
  white-space: nowrap;
}

.chart-empty {
  flex: 1;
  text-align: center;
  color: #bbb;
  font-size: 0.85rem;
  padding: 20px;
  align-self: center;
}

/* ── Snapshot ─────────────────────────────────────────────────────────────── */
.snapshot-wrap { width: 100%; }
.snap-name-label { font-size: 0.8rem; font-weight: 700; color: #334155; margin-bottom: 6px; min-height: 1.1em; letter-spacing: 0.02em; }
.snapshot-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  object-fit: cover;
}
.snapshot-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.8rem;
  color: #888;
}
.snapshot-nav button {
  background: none;
  border: 1px solid #d0d8e0;
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 0.85rem;
}
.snapshot-nav button:disabled { opacity: 0.35; cursor: default; }
.snapshot-nav button:not(:disabled):hover { background: #e8f7fc; }
.snapshot-placeholder {
  padding: 20px;
  background: #f8fafb;
  border-radius: 6px;
  color: #aaa;
  font-size: 0.85rem;
  text-align: center;
}

/* ── iFrame view modal ────────────────────────────────────────────────────── */
.modal-iframe-box {
  background: #fff;
  border-radius: 8px;
  width: 90vw;
  height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.modal-iframe-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #e0e8f0;
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.modal-iframe-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #f8fafb;
}

/* ── Calendar ─────────────────────────────────────────────────────────────── */
.calendar-wrap { }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  font-size: 0.78rem;
}

.cal-hdr {
  text-align: center;
  font-weight: 700;
  color: #888;
  padding: 4px 0;
  font-size: 0.7rem;
}

.cal-blank { }

.cal-day {
  text-align: center;
  padding: 5px 2px;
  border-radius: 4px;
  cursor: pointer;
  color: #555;
  transition: background 0.1s;
}
.cal-day:hover { background: #e8f7fc; color: #1da1d2; }

.cal-today { font-weight: 700; color: #27ae60; }
.cal-has-data { font-weight: 600; color: #1da1d2; }
.cal-selected { background: #1da1d2 !important; color: #fff !important; border-radius: 4px; }

.calendar-legend {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  font-size: 0.72rem;
  color: #888;
  align-items: center;
}

.cal-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.dot-data  { background: #1da1d2; }   /* blue = has data */
.dot-today { background: #27ae60; }   /* green = today */

.cal-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}
.cal-nav button {
  background: none;
  border: 1px solid #d0d8e0;
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 1rem;
  color: #555;
}
.cal-nav button:hover { background: #e8f7fc; }

/* ── Placeholder text ─────────────────────────────────────────────────────── */
.dash-alert-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.dash-alert-table th { text-align: left; padding: 6px 10px; font-size: 0.75rem; color: #94a3b8; font-weight: 600; border-bottom: 1px solid #e2e8f0; }
.dash-alert-table td { padding: 7px 10px; border-bottom: 1px solid #f1f5f9; }
.dash-alert-table tr:last-child td { border-bottom: none; }

.log-mgmt-admin { border-top: 1px solid #e2e8f0; padding: 10px 0 2px; margin-top: 4px; }
.alert-rules-edit { margin-top: 14px; border-top: 1px solid #e2e8f0; padding-top: 14px; }
.alert-rules-field { margin-bottom: 10px; }
.alert-rules-field label { display: block; font-size: 0.78rem; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.alert-rules-field input[type=text] { width: 100%; box-sizing: border-box; }
.rule-threshold-input { width: 64px; padding: 4px 6px; border: 1px solid #cbd5e1; border-radius: 5px; font-size: 0.85rem; }

.placeholder-text {
  font-size: 0.82rem;
  color: #aaa;
  padding: 14px;
  background: #f8fafb;
  border-radius: 5px;
  text-align: center;
}

/* ── Showtimes button ─────────────────────────────────────────────────────── */
.btn-showtimes {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 24px 16px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid var(--teal, #00b4d8);
  border-radius: 10px;
  color: var(--teal, #00b4d8);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}
.btn-showtimes:hover {
  background: linear-gradient(135deg, #16213e 0%, #0f3460 100%);
  box-shadow: 0 0 18px rgba(0,180,216,0.35);
  transform: translateY(-1px);
}
.btn-showtimes:active { transform: translateY(0); }
.showtimes-icon {
  width: 64px;
  height: 74px;
  fill: currentColor;
}

/* ── iFrame cards ─────────────────────────────────────────────────────────── */
.card-iframe-frame {
  width: 100%;
  height: 320px;
  border: none;
  border-radius: 5px;
  background: #f8fafb;
}

.iframe-edit {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.iframe-edit input[type="text"] {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #d0d8e0;
  border-radius: 5px;
  font-size: 0.85rem;
  min-width: 180px;
}
.iframe-edit input:focus {
  outline: none;
  border-color: #1da1d2;
}

/* ── Admin page ───────────────────────────────────────────────────────────── */
.admin-wrap { }
.admin-section { margin-bottom: 32px; }
.admin-section h2 { font-size: 1.05rem; font-weight: 700; color: #333; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid #e8f7fc; }
.admin-section h3 { font-size: 0.92rem; font-weight: 700; color: #444; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.admin-table th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 8px 10px;
  border-bottom: 2px solid #edf0f3;
  background: #f8fafb;
}
.admin-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #f0f4f7;
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #fafcfd; }

.admin-table code.token-display {
  font-size: 0.75rem;
  background: #f0f4f7;
  padding: 2px 6px;
  border-radius: 3px;
  color: #555;
  font-family: monospace;
}

.url-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  color: #666;
}

.loc-edit-row td {
  background: #f8fafb;
  padding: 12px 10px;
}

.inline-form {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.85rem;
}
.inline-form label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #555;
  font-size: 0.82rem;
}
.inline-form input[type="text"] {
  padding: 5px 8px;
  border: 1px solid #d0d8e0;
  border-radius: 4px;
  font-size: 0.82rem;
}
.inline-form input[type="text"]:focus {
  outline: none;
  border-color: #1da1d2;
}

.create-form {
  background: #f8fafb;
  border: 1px solid #edf0f3;
  border-radius: 7px;
  padding: 16px;
  margin-top: 16px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px 14px;
  margin-top: 6px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: #444;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.check-label:hover { background: #f0f7fc; }

/* ── Account page ─────────────────────────────────────────────────────────── */
.account-wrap { }
.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.account-form { }

/* ── Alert config & rules ─────────────────────────────────────────────────── */
.admin-hint { font-size: 0.82rem; color: #64748b; margin: -6px 0 14px; }
.log-mgmt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 700px) { .log-mgmt-grid { grid-template-columns: 1fr; } }
.log-mgmt-panel { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 18px 20px; }
.log-mgmt-panel h3 { margin: 0 0 6px; font-size: 0.95rem; color: #1e293b; }
.log-mgmt-label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; font-weight: 600; color: #475569; margin-bottom: 10px; }
.log-mgmt-select { margin-top: 2px; }
.log-mgmt-date { margin-top: 2px; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.88rem; }
.log-mgmt-textarea { width: 100%; box-sizing: border-box; padding: 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.82rem; font-family: monospace; resize: vertical; margin-bottom: 10px; }
.alert-config-form .ig-row { align-items: flex-start; }
.alert-config-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; font-weight: 600; color: #475569; }
.alert-config-form input[type="email"],
.alert-config-form input[type="password"],
.alert-config-form input[type="text"] { margin-top: 2px; }

/* Gmail OAuth modal */
.oauth-modal-backdrop { position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:900;display:flex;align-items:center;justify-content:center; }
.oauth-modal { background:#fff;border-radius:10px;width:min(640px,94vw);max-height:88vh;overflow-y:auto;box-shadow:0 8px 32px rgba(0,0,0,.22); }
.oauth-modal-head { display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid #e2e8f0;font-weight:700;font-size:1rem; }
.oauth-modal-close { background:none;border:none;font-size:1.2rem;cursor:pointer;color:#64748b;padding:0 4px;line-height:1; }
.oauth-modal-close:hover { color:#1e293b; }
.oauth-modal-body { padding:20px 24px; }
.oauth-steps { padding-left:20px;line-height:1.9;font-size:0.88rem;color:#334155; }
.oauth-steps li { margin-bottom:8px; }
.oauth-steps ul { margin:4px 0 4px 12px; }
.oauth-steps code { background:#f1f5f9;border-radius:3px;padding:1px 5px;font-size:0.82rem; }
.oauth-uri { display:block;margin-top:4px;word-break:break-all;font-size:0.82rem;background:#f8fafc;border:1px solid #e2e8f0;border-radius:4px;padding:6px 8px; }
.btn-info { width:20px;height:20px;border-radius:50%;background:#3b82f6;color:#fff;border:none;font-size:0.72rem;font-weight:700;cursor:pointer;vertical-align:middle;margin-left:6px;padding:0;line-height:20px; }
.btn-info:hover { background:#2563eb; }

/* OAuth connection status */
.gmail-oauth-status { display:flex;align-items:center;gap:10px;margin:14px 0 0;padding:10px 14px;background:#f8fafc;border:1px solid #e2e8f0;border-radius:6px;flex-wrap:wrap; }
.oauth-badge { font-size:0.83rem;font-weight:600; }
.oauth-badge-ok  { color:#16a34a; }
.oauth-badge-off { color:#94a3b8; }

.alert-test-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.alert-test-row input[type="email"] { flex: 1; min-width: 220px; max-width: 320px; }
#testEmailStatus { font-size: 0.83rem; }
.test-email-ok      { color: #16a34a; }
.test-email-err     { color: #dc2626; }
.test-email-sending { color: #94a3b8; }

.alert-loc-block { border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 10px; overflow: hidden; }
.alert-loc-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: #f8fafc; cursor: pointer; user-select: none; }
.alert-loc-head:hover { background: #f1f5f9; }
.alert-loc-name { font-weight: 700; font-size: 0.9rem; color: #1e293b; }
.alert-loc-toggle { color: #94a3b8; font-size: 0.75rem; }
.alert-loc-body { padding: 16px; }

.alert-recipients { margin-bottom: 14px; }
.alert-recipients label { display: block; font-size: 0.8rem; font-weight: 600; color: #475569; margin-bottom: 4px; }
.alert-recipients input { width: 100%; }

.alert-rules-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.alert-rules-table thead tr { border-bottom: 2px solid #e2e8f0; }
.alert-rules-table th { text-align: left; padding: 6px 10px; font-size: 0.75rem; color: #64748b; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.alert-rules-table td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.alert-rules-table tbody tr:last-child td { border-bottom: none; }
.rule-name-cell { font-weight: 600; color: #334155; }
.rule-thresh-wrap { display: flex; align-items: center; gap: 6px; }
.rule-thresh-input { width: 70px; padding: 4px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.85rem; text-align: center; }
.rule-thresh-unit { font-size: 0.8rem; color: #64748b; }
.rule-last-cell { font-size: 0.78rem; color: #64748b; }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: #cbd5e1; border-radius: 24px; transition: 0.2s; }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.2s; }
.toggle-switch input:checked + .toggle-slider { background: #22c55e; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Hidden utility ───────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Custom confirm modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 28px 32px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  max-width: 380px; width: 90%;
  text-align: center;
}
.modal-msg { font-size: 0.95rem; color: #333; margin-bottom: 20px; line-height: 1.5; }
.modal-btns { display: flex; gap: 12px; justify-content: center; }
.modal-box-lg {
  max-width: 780px; width: 95%; max-height: 82vh;
  padding: 0; text-align: left;
  display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid #e2e8f0; flex-shrink: 0;
}
.modal-title { font-weight: 700; font-size: 0.95rem; color: #1e293b; }
.full-log-scroll { overflow-y: auto; flex: 1; padding: 4px 0; }

/* ── Password strength checker ────────────────────────────────────────────── */
.pw-check-list {
  display: flex; flex-direction: column; gap: 3px;
  margin-top: 8px;
  font-size: 0.78rem;
}
.pw-rule       { color: #bbb; }
.pw-rule.pw-ok { color: #27ae60; }
.pw-rule.pw-fail { color: #e74c3c; }

/* ── Admin inline grid form ───────────────────────────────────────────────── */
.inline-form-grid { display: flex; flex-direction: column; gap: 10px; }
.ig-row {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
}
.ig-row label {
  display: flex; flex-direction: column;
  font-size: 0.75rem; color: #666; gap: 3px; flex: 1; min-width: 110px;
}
.ig-row label input[type="text"],
.ig-row label input[type="email"],
.ig-row label input[type="password"] {
  padding: 5px 8px;
  border: 1px solid #d0d8e0;
  border-radius: 4px;
  font-size: 0.82rem;
}
.ig-row label input:focus { outline: none; border-color: #1da1d2; }
.check-inline { flex-direction: row !important; align-items: center; gap: 6px; flex: 0 !important; white-space: nowrap; }
.pw-strength-row { padding: 6px 0; }

/* ── Table actions cell ───────────────────────────────────────────────────── */
.table-actions { white-space: nowrap; display: flex; gap: 6px; }

/* ── Location history panel ───────────────────────────────────────────────── */
.history-panel { padding: 10px 14px; background: #f8fafb; border-radius: 6px; font-size: 0.82rem; }
.hist-entry { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid #edf0f3; }
.hist-entry:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.hist-meta { color: #777; font-size: 0.78rem; }
.hist-fields { margin: 6px 0 0 14px; padding: 0; list-style: disc; }
.hist-fields li { margin-bottom: 3px; color: #444; }
.hist-old { color: #c0392b; text-decoration: line-through; font-family: monospace; }
.hist-new { color: #27ae60; font-family: monospace; }

/* ── Add panel ────────────────────────────────────────────────────────────── */
.add-panel summary { list-style: none; }
.add-panel summary::-webkit-details-marker { display: none; }
.add-panel > .inline-form-grid,
.add-panel > .create-form {
  background: #f8fafb;
  border: 1px solid #edf0f3;
  border-radius: 7px;
  padding: 14px;
}

/* ── Field note ───────────────────────────────────────────────────────────── */
.field-note { font-size: 0.72rem; color: #999; font-weight: 400; }

/* ── Scrollbar styling (WebKit) ───────────────────────────────────────────── */
.log-scroll::-webkit-scrollbar { width: 5px; }
.log-scroll::-webkit-scrollbar-track { background: #f0f4f7; }
.log-scroll::-webkit-scrollbar-thumb { background: #ccd4db; border-radius: 3px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .dash-layout { grid-template-columns: 1fr; }
  .account-grid { grid-template-columns: 1fr; }
}

/* ── Tablet / large phone ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  main { padding: 10px; }

  /* Header: compact on tablet */
  .site-header { padding: 8px 12px 0; }
  .nav-link { padding: 6px 14px; font-size: 0.9rem; }

  /* Info bar: force ~3 items per row → 2 rows for 5-6 items */
  .info-item {
    flex: 1 1 30%;      /* at most ~3 per row */
    min-width: 0;
    padding: 9px 10px;
    border-right: 1px solid #edf0f3;
    border-bottom: 1px solid #edf0f3;
  }
  /* Kill the right border on every 3rd item and on the last row */
  .info-item:nth-child(3n) { border-right: none; }
  .dash-info-bar { border-radius: 8px; }
  /* Admin bar stays single row on all screen sizes */
  .dash-admin-bar { flex-wrap: nowrap; overflow-x: auto; }

  /* Cards: tighten padding */
  .card { padding: 14px 14px; }
}

/* ── Small phone ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  main { padding: 8px; }

  .header-logo { height: 26px; }

  /* Info bar: 2 per row on very small screens */
  .info-item {
    flex: 1 1 45%;
  }
  .info-item:nth-child(3n)  { border-right: 1px solid #edf0f3; }   /* reset 3-col rule */
  .info-item:nth-child(even) { border-right: none; }

  .info-label { font-size: 0.65rem; }
  .info-val   { font-size: 0.85rem; }

  /* Log management grid stacks */
  .log-mgmt-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  main { padding: 14px; }
  .site-header { padding: 0 14px; }
  .dash-info-bar { gap: 0; }
  .info-item { padding: 10px 12px; min-width: 80px; }
}

/* ── Dashboard — local time (centered above info bar) ─────────────────────── */
.dash-local-time {
  text-align: center;
  font-size: 2.8rem;
  font-weight: 800;
  color: #1a1a2e;
  letter-spacing: 3px;
  font-variant-numeric: tabular-nums;
  padding: 8px 0 10px;
}

/* ── Dashboard — page title (location name + site number below header) ──────── */
.dash-title-wrapper {
  position: relative;
  margin-bottom: 14px;
}
.dash-title-edit-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}
.dash-page-title {
  text-align: center;
}
.dash-loc-name-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.dash-loc-name {
  font-size: 2.8rem;
  font-weight: 800;
  color: #1a1a2e;
  line-height: 1.15;
}
.dash-site-num {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a1a2e;
}

/* ── Dashboard header — name row with site number ─────────────────────────── */
.header-loc-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.header-site-num {
  font-size: 1rem;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

/* Inline edit forms in header and admin bar */
.field-edit-inline {
  margin-top: 6px;
}
.edit-inline-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.edit-inline-input {
  padding: 5px 8px;
  border: 1px solid #d0d8e0;
  border-radius: 5px;
  font-size: 0.88rem;
  color: #222;
  min-width: 160px;
}
.edit-inline-input:focus { outline: none; border-color: #1da1d2; }
.edit-inline-select {
  padding: 5px 8px;
  border: 1px solid #d0d8e0;
  border-radius: 5px;
  font-size: 0.88rem;
  color: #222;
  background: #fff;
  min-width: 220px;
}
.edit-inline-select:focus { outline: none; border-color: #1da1d2; }

/* ── Admin info bar — single flat line ────────────────────────────────────── */
.dash-admin-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: #f8fafb;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 9px 16px;
  flex-wrap: nowrap;
  overflow: hidden;
}
.abar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
}
.abar-group-token {
  flex: 2;
}
.abar-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}
.abar-val {
  font-size: 0.88rem;
  font-weight: 700;
  color: #222;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.abar-sep {
  color: #d0d8e0;
  font-size: 1rem;
  flex-shrink: 0;
  margin: 0 2px;
}
.abar-token {
  font-size: 0.72rem;
  background: #f0f4f7;
  padding: 2px 7px;
  border-radius: 3px;
  color: #555;
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  max-width: 280px;
}
.abar-regen {
  font-size: 0.72rem;
  padding: 2px 8px;
  flex-shrink: 0;
}

/* ── Locations page — tile site number ────────────────────────────────────── */
.tile-name-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tile-site-num {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ── Locations page — add (+) tile ───────────────────────────────────────── */
.loc-tile-add {
  background: #f8fafb;
  border: 2px dashed #d0d8e0;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 280px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
  text-decoration: none;
}
.loc-tile-add:hover { border-color: #1da1d2; background: #eaf6fc; }
.tile-add-btn {
  background: none;
  border: none;
  font-size: 3rem;
  color: #d0d8e0;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}
.loc-tile-add:hover .tile-add-btn { color: #1da1d2; }
.tile-add-label {
  font-size: 0.82rem;
  color: #94a3b8;
  font-weight: 600;
  pointer-events: none;
}
