:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #dfe3e8;
  --text: #1c2430;
  --muted: #6b7684;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --ok: #16a34a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0.8rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

header h1 { font-size: 1.05rem; margin: 0; white-space: nowrap; }
header .spacer { flex: 1; }
header .muted { color: var(--muted); font-size: 0.85rem; }

/* Fourteen top-level sections don't fit in a single-row top nav at normal
   zoom on a laptop-width viewport — a left sidebar scales with the tab
   count instead of fighting it for horizontal space. */
.app-body { display: flex; align-items: flex-start; }
.sidebar {
  flex-shrink: 0;
  width: 190px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 1rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  align-self: stretch;
}
.sidebar button {
  background: none;
  border: none;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--muted);
  border-radius: 6px;
  text-align: left;
}
.sidebar button.active { background: var(--accent); color: #fff; }

main { flex: 1; min-width: 0; max-width: 1250px; margin: 1.2rem auto; padding: 0 1rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}

.scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 600; }

input, select, textarea {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  width: 100%;
}

label { font-size: 0.8rem; color: var(--muted); display: block; margin-bottom: 0.2rem; }

button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
button.primary:disabled { opacity: 0.6; cursor: default; }

button.small {
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}
button.small.danger { color: var(--danger); border-color: var(--danger); }

.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.7rem 1rem;
  margin-bottom: 0.9rem;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
}
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.bad { background: #fee2e2; color: var(--danger); }

.login-box { max-width: 360px; margin: 12vh auto; }
.login-box input { margin-bottom: 0.7rem; }

.error { color: var(--danger); font-size: 0.85rem; min-height: 1.2em; }
.success { color: var(--ok); font-size: 0.85rem; min-height: 1.2em; }
.muted { color: var(--muted); }

.pager {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.7rem;
  font-size: 0.85rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 1rem;
  overflow-y: auto;
  /* Sticky table columns (th/td.row-actions) create their own stacking
     context; without an explicit z-index here this backdrop had z-index:auto
     and could render behind them, leaving the modal's form fields hidden
     under the table on pages like Admins. */
  z-index: 100;
}
.modal {
  background: var(--panel);
  border-radius: 12px;
  padding: 1.4rem;
  width: 100%;
  max-width: 620px;
}
.modal h3 { margin-top: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 10px;
  padding: 1rem 1.2rem;
}
.stat-value { font-size: 1.9rem; font-weight: 700; }
.stat-label { font-size: 0.9rem; margin-top: 0.2rem; }
.stat-sub { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }
.chart { width: 100%; max-width: 680px; height: auto; }

.badge.warn { background: #fef3c7; color: #b45309; }
.badge.info { background: #dbeafe; color: #1d4ed8; }
.badge.neutral { background: #e5e7eb; color: #374151; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--accent); }

.dash-two { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.dash-two .panel { margin-bottom: 0; }
@media (max-width: 800px) { .dash-two { grid-template-columns: 1fr; } }
.donut-wrap { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.donut { width: 160px; height: 160px; }
.donut-legend { font-size: 0.85rem; display: flex; flex-direction: column; gap: 0.4rem; }
.donut-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 0.4rem; }
/* Occupancy bar: fixed-width track with a proportional fill (progress-bar). */
.occupancy { display: flex; align-items: center; gap: 0.6rem; }
.occupancy-track { width: 120px; height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; flex: 0 0 auto; }
.occupancy-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.occupancy span { font-variant-numeric: tabular-nums; }

/* Platform settings table: keep the action buttons visible by letting the
   value column wrap instead of stretching the row off-screen. */
.settings-table { width: 100%; table-layout: fixed; }
.settings-table th, .settings-table td { white-space: normal; vertical-align: top; }
.settings-table .key-col { width: 34%; word-break: break-word; }
.settings-table .value-col { width: 46%; }
.settings-table .value-col code { white-space: pre-wrap; word-break: break-word; }
.settings-table .actions-col { width: 20%; white-space: nowrap; text-align: right; }

/* Row action buttons (Edit/Delete/etc.): pinned to the right edge so they
   stay visible and never clip even when the table is wider than the panel. */
.scroll { position: relative; }
th.row-actions, td.row-actions {
  position: sticky;
  right: 0;
  white-space: nowrap;
  text-align: right;
  background: var(--panel);
  box-shadow: -6px 0 6px -6px rgba(0, 0, 0, 0.15);
}
td.row-actions > * {
  display: inline-flex;
  margin-left: 0.4rem;
  vertical-align: middle;
}
td.row-actions button { flex-shrink: 0; }

/* Boolean columns rendered as a green tick / red cross (Filament IconColumn). */
.icon-bool { font-weight: 700; font-size: 1.05rem; line-height: 1; }
.icon-bool.ok { color: var(--ok); }
.icon-bool.bad { color: var(--danger); }

/* Table filter dropdowns (Filament table filters). */
.filter-control { display: flex; flex-direction: column; gap: 0.15rem; }
.filter-control label { margin-bottom: 0; font-size: 0.72rem; }
.filter-control select { width: auto; min-width: 130px; font-size: 0.82rem; padding: 0.3rem 0.5rem; }

/* Platform settings tabbed form. */
.settings-tabs { display: flex; gap: 0.2rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.settings-tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--muted);
}
.settings-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.settings-field .field-help { font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; line-height: 1.3; }

/* Dedicated edit-page header (back link + title). */
.page-head { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.8rem; }
.page-head h2 { margin: 0; font-size: 1.15rem; }

/* Read-only informational field values in edit forms (Filament disabled inputs). */
.readonly-value {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.9rem;
  min-height: 2.1rem;
}

/* Notification bell + dropdown panel. */
.notif-bell { position: relative; }
.notif-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1.4;
}
.notif-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  width: 340px;
  max-height: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  gap: 0.5rem;
}
.notif-panel-actions { display: flex; gap: 0.35rem; }
.notif-list { overflow-y: auto; }
.notif-empty { padding: 1rem 0.8rem; color: var(--muted); font-size: 0.85rem; }
.notif-item {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--accent-soft); cursor: pointer; }
.notif-item:not(.unread) { cursor: default; }
.notif-title { font-size: 0.85rem; font-weight: 600; }
.notif-message { font-size: 0.8rem; color: var(--text); margin-top: 0.1rem; }
.notif-meta { font-size: 0.72rem; color: var(--muted); margin-top: 0.25rem; }

/* Print-friendly notifications report. */
.notif-report { max-width: 900px; margin: 0 auto; }
.notif-report-toolbar { display: flex; justify-content: space-between; margin-bottom: 1rem; }
.notif-report-table th, .notif-report-table td { white-space: normal; }

@media print {
  .no-print { display: none !important; }
  header, nav { display: none !important; }
  body { background: #fff; }
  .notif-report { max-width: none; }
}

/* Generic app-wide toasts (see ToastContainer). Fixed above everything,
   including modals, so a toast from an action taken inside a modal (or
   right after it closes) is never hidden behind the backdrop. */
.toast-stack {
  position: fixed;
  /* Below the header, not overlapping it — header is ~51px tall. */
  top: calc(51px + 1rem);
  right: 1.2rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
}
.toast {
  padding: 0.7rem 1rem;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  font-size: 0.88rem;
  color: #fff;
  cursor: pointer;
  animation: toast-in 0.15s ease-out;
}
.toast-success { background: var(--ok); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--accent); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
