/* ============================================================
   DISASTER BOARD — Shared Stylesheet
   Theme: Professional Emergency Management
   Colors: Black, Grey, Red, Blue
   ============================================================ */

:root {
  --bg:          #1a1a1a;
  --bg2:         #232323;
  --bg3:         #2a2a2a;
  --nav:         #161616;
  --border:      #3a3a3a;
  --border-soft: #2e2e2e;
  --text:        #e8e8e6;
  --text-muted:  #999996;
  --red:         #c62828;
  --red-hover:   #d32f2f;
  --blue:        #1565c0;
  --blue-hover:  #1976d2;
  --blue-light:  #1e3a5f;
  --red-light:   #3a1a1a;
  --amber:       #b45309;
  --amber-hover: #d97706;
  --green:       #155724;
  --green-hover: #1a6b2e;
  --green-light: #1e3a2a;
  --link:        #58a6ff;
  --radius:      8px;
  --shadow:      0 4px 24px rgba(0,0,0,.5);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  min-height: 100vh;
}

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

.tel-link { color: var(--link); white-space: nowrap; }
.tel-link:hover { text-decoration: underline; }

/* ---- Demo mode banner (shared across all pages) ---- */
.demo-bar { background:#78350f; border-bottom:1px solid #d97706; padding:8px 20px; font-size:12px; color:#fde68a; text-align:center; }
.demo-bar strong { color:#fbbf24; }

/* ---- Unified page header bar — red-accented title + optional incident
   context badge + right-aligned actions. Used by every CRUD/list page. ---- */
.page-header-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; background: var(--bg3); border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.page-header-bar h1 {
  font-size: 18px; font-weight: 700; color: var(--text);
  border-left: 4px solid var(--red); padding-left: 12px;
  margin: 0; white-space: nowrap;
}
.page-header-bar .ctx-badge {
  display: flex; flex-direction: column; gap: 1px;
  padding-left: 14px; border-left: 1px solid var(--border);
}
.page-header-bar .ctx-badge .ctx-name { font-size: 13px; font-weight: 600; color: var(--text); }
.page-header-bar .ctx-badge .ctx-date { font-size: 11px; color: var(--text-muted); }
.page-header-bar .spacer { flex: 1; }
.page-header-bar .header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---- Shared form error message box ---- */
.err-msg {
  background: rgba(198,40,40,.15); border: 1px solid rgba(198,40,40,.4);
  border-radius: 7px; color: #ef9a9a; font-size: 13px;
  padding: 10px 14px; margin-top: 14px; display: none;
}
.err-msg.show { display: block; }

/* ---- Top Navigation Bar ---- */
:root { --rail-w: 56px; --sidebar-w: 230px; }

.topnav {
  display: flex; align-items: center; gap: 12px;
  padding: env(safe-area-inset-top) 20px 0; height: calc(56px + env(safe-area-inset-top));
  background: var(--nav); border-bottom: 2px solid var(--red);
  position: sticky; top: 0; z-index: 200;
  box-sizing: border-box;
}
.topnav .brand { display: flex; align-items: center; text-decoration: none; }
.topnav .brand .brand-logo { height: 38px; width: auto; }
.topnav .spacer { flex: 1; }
.topnav .org-badge {
  background: var(--blue-light); border: 1px solid #1565c0;
  border-radius: 20px; padding: 3px 12px;
  font-size: 12px; font-weight: 600; color: #90caf9;
  font-family: inherit; cursor: pointer;
}
.mobile-menu-toggle {
  display: none; background: none; border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-muted); width: 32px; height: 32px;
  flex-shrink: 0; cursor: pointer; align-items: center; justify-content: center;
}
.mobile-menu-toggle svg { width: 18px; height: 18px; }
.mobile-menu-toggle:hover { color: var(--text); border-color: var(--text-muted); }

/* ---- Incidents menu — Create/Open/Saved, in the topnav on every page ---- */
.incidents-menu { position: relative; }
.incidents-btn {
  display: flex; align-items: center; gap: 6px;
  background: #204d2e; border: 1px solid #388e3c;
  border-radius: 20px; padding: 3px 12px;
  color: #8fdb9a; font-family: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.incidents-btn:hover { border-color: #4caf50; }
.ib-chevron { width: 12px; height: 12px; transform: rotate(90deg); transition: transform .15s ease; flex-shrink: 0; }
.ib-chevron svg { width: 12px; height: 12px; }
.incidents-btn.open .ib-chevron { transform: rotate(-90deg); }

.incidents-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 250px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); z-index: 300; display: none; overflow: hidden;
}
.incidents-dropdown.open { display: block; }

.id-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  text-align: left; background: none; border: 0;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text); text-decoration: none;
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 11px 16px; cursor: pointer;
}
.id-item:last-child { border-bottom: 0; }
.id-item:hover { background: var(--bg3); text-decoration: none; }
.id-item-label { flex: 1; }
.id-badge {
  display: none; align-items: center; justify-content: center;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 999px; min-width: 18px; height: 18px; padding: 0 5px;
}
.id-badge.show { display: flex; }
.id-sub-chevron { width: 13px; height: 13px; flex-shrink: 0; transition: transform .15s ease; color: var(--text-muted); }
.id-sub-chevron svg { width: 13px; height: 13px; }
.id-parent.open .id-sub-chevron { transform: rotate(90deg); }

.id-submenu { max-height: 0; overflow: hidden; background: var(--bg3); transition: max-height .18s ease; }
.id-parent.open + .id-submenu { max-height: 260px; overflow-y: auto; }
.id-list-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  text-align: left; background: none; border: 0;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text); font-family: inherit; font-size: 13px;
  padding: 10px 16px 10px 28px; cursor: pointer;
}
.id-list-item:hover { background: var(--bg2); }
.id-date { margin-left: auto; font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.id-empty { padding: 12px 16px 12px 28px; color: var(--text-muted); font-size: 12px; font-style: italic; }

.time-simple { font-size: 18px; padding: 10px 14px; text-align: center; width: 140px; }

/* ---- Org switcher — org badge doubles as a dropdown trigger for
   the current Site/Region/Enterprise board + a link to switch it ---- */
.org-switcher { position: relative; }
.org-switcher-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 200px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); z-index: 300; display: none; overflow: hidden;
}
.org-switcher-dropdown.open { display: block; }
.org-switcher-current {
  padding: 10px 16px; border-bottom: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 2px;
}
.osw-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); }
.osw-board-name { font-size: 13px; font-weight: 600; color: var(--text); }

@media (max-width: 860px) {
  .topnav { gap: 8px; padding: env(safe-area-inset-top) 10px 0; }
  .topnav .brand-logo { height: 30px; }
  .incidents-btn[data-mode="menu"] span:first-child { display: none; }
  .incidents-btn { padding: 0 8px; }
  .topnav .org-badge { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
/* ---- Body/page reflow to reserve space for the persistent icon rail,
   and (when pinned) the fully expanded sidebar. The topnav and page
   header stay full width via a full-bleed compensation trick. ---- */
body.has-sidebar {
  margin-left: var(--rail-w);
  transition: margin-left .2s ease;
}
body.has-sidebar .topnav,
body.has-sidebar .page-header-bar {
  margin-left: calc(-1 * var(--rail-w));
  width: calc(100% + var(--rail-w));
}
body.has-sidebar.sidebar-pinned { margin-left: var(--sidebar-w); }
body.has-sidebar.sidebar-pinned .topnav,
body.has-sidebar.sidebar-pinned .page-header-bar {
  margin-left: calc(-1 * var(--sidebar-w));
  width: calc(100% + var(--sidebar-w));
}

/* ---- Sidebar — persistent icon rail; hover or pin to expand.
   Sits below the topnav + page header (see --sidebar-top, set by JS). ---- */
.sidebar {
  position: fixed; left: 0; bottom: 0;
  top: var(--sidebar-top, 56px);
  width: var(--rail-w); background: var(--nav);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 250; overflow: hidden;
  transition: width .16s ease; box-shadow: var(--shadow);
}
.sidebar.expanded { width: var(--sidebar-w); overflow-y: auto; }

.sidebar-pinbar {
  display: flex; align-items: center; justify-content: center;
  height: 40px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.sidebar.expanded .sidebar-pinbar { justify-content: flex-end; padding-right: 10px; }
.sidebar-pin {
  background: none; border: 0; color: var(--text-muted);
  width: 28px; height: 28px; border-radius: 6px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-pin svg { width: 16px; height: 16px; }
.sidebar-pin:hover { color: var(--text); background: rgba(255,255,255,.06); }
.sidebar-pin.active { color: var(--text); background: rgba(255,255,255,.1); }

.sidebar-mobile-close {
  display: none; background: none; border: 0; color: var(--text-muted);
  width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-mobile-close svg { width: 16px; height: 16px; }
.sidebar-mobile-close:hover { color: var(--text); background: rgba(255,255,255,.06); }

.sidebar-overlay {
  display: none; position: fixed; left: 0; right: 0; bottom: 0;
  top: var(--sidebar-top, 56px); background: rgba(0,0,0,.5);
  z-index: 240; opacity: 0; pointer-events: none; transition: opacity .18s ease;
}

.sidebar-nav { flex: 1; padding: 6px 0; }

/* Shared row style for Home, group headers, and sub-links — flat rows with
   a faint divider between them for a little definition without boxes. */
.sb-item {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 0 11px 18px; color: var(--text-muted);
  text-decoration: none; background: none;
  border: 0;
  border-left: 3px solid transparent;
  border-bottom: 1px solid rgba(255,255,255,.06);
  outline: none; appearance: none; text-align: left;
  font-family: inherit; font-size: 14px; font-weight: 600;
  white-space: nowrap; cursor: pointer; width: 100%;
  transition: color .15s, border-color .15s, background .15s;
}
.sb-item:hover { color: var(--text); background: rgba(255,255,255,.04); text-decoration: none; }
.sb-item.active { color: var(--text); border-left-color: var(--red); background: var(--red-light); }

/* Shade headings (Home, Incident, Organization) a touch lighter than the
   sub-items under them, so it's clear at a glance which rows are headings. */
.sb-top, .sb-group-toggle { background: var(--bg3); }
.sb-sub { background: rgba(0,0,0,.12); }

.sb-icon { position: relative; flex-shrink: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.sb-icon svg { width: 20px; height: 20px; }

.chat-badge {
  position: absolute; top: -5px; right: -8px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 15px; height: 15px; border-radius: 999px; line-height: 1;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
.sb-label {
  opacity: 0; width: 0; overflow: hidden; white-space: nowrap;
  transition: opacity .12s ease;
}
.sidebar.expanded .sb-label { opacity: 1; width: auto; }

.sb-group-toggle .sb-chevron {
  margin-left: auto; margin-right: 14px; flex-shrink: 0;
  width: 14px; height: 14px; opacity: 0;
  transition: transform .15s ease, opacity .12s ease;
}
.sb-group-toggle .sb-chevron svg { width: 14px; height: 14px; }
.sidebar.expanded .sb-group-toggle .sb-chevron { opacity: .7; }
.sb-group.open .sb-group-toggle .sb-chevron { transform: rotate(90deg); }

.sb-subitems { display: flex; flex-direction: column; }
.sb-group:not(.open) .sb-subitems { display: none; }
.sb-sub { padding-left: 18px; }
.sb-sub .sb-icon { width: 18px; height: 18px; }
.sb-sub .sb-icon svg { width: 17px; height: 17px; }

/* ---- Account footer — pinned to the bottom of the sidebar, links to Admin ---- */
.sidebar-account { flex-shrink: 0; padding: 10px; border-top: 1px solid var(--border-soft); }
/* Collapsed rail: just the avatar, centered, no chip framing — there's only
   36px of inner width here (56px rail − this element's own padding), not
   enough room for the bordered/padded "chip" look, which used to make the
   avatar overflow its own box. The chip only appears once expanded. */
.sa-link {
  display: flex; align-items: center; justify-content: center; gap: 0;
  padding: 3px; border-radius: 8px;
  border: 1px solid transparent; background: none;
  text-decoration: none; color: var(--text);
  transition: background .15s, border-color .15s, padding .15s, gap .15s;
}
.sa-link:hover { background: var(--bg3); text-decoration: none; }
.sidebar.expanded .sa-link {
  justify-content: flex-start; gap: 10px; padding: 7px;
  border-color: var(--border-soft); background: var(--bg2);
}
.sidebar.expanded .sa-link:hover { border-color: var(--text-muted); }
.sa-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--blue); color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.sa-text { opacity: 0; width: 0; overflow: hidden; transition: opacity .12s ease; }
.sidebar.expanded .sa-text { opacity: 1; width: auto; flex: 1; min-width: 0; }
.sa-name { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-chevron { flex-shrink: 0; width: 0; height: 14px; overflow: hidden; opacity: 0; transition: opacity .12s ease, width .12s ease; }
.sa-chevron svg { width: 14px; height: 14px; }
.sidebar.expanded .sa-chevron { opacity: .6; width: 14px; }

@media print {
  .topnav, .sidebar { display: none !important; }
  body.has-sidebar { margin-left: 0 !important; }
  body.has-sidebar .topnav, body.has-sidebar .page-header-bar { margin-left: 0 !important; width: 100% !important; }
}

/* ---- Bottom tab bar — quick jump between the 4 incident pages on mobile ---- */
.mobile-tabbar { display: none; }
.mtab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 10px; color: var(--text-muted); text-decoration: none;
  font-size: 10px; font-weight: 600;
}
.mtab-icon { position: relative; display: inline-flex; }
.mtab-icon svg { width: 20px; height: 20px; }
.mtab.active { color: var(--text); }
.mtab.active .mtab-icon { color: var(--red); }

/* ---- Mobile breakpoint — sidebar becomes a tap-to-open overlay drawer
   (no persistent rail, no hover, no pin) with a dimmed backdrop, and a
   fixed bottom tab bar covers the 4 pages used constantly during an incident. ---- */
@media (max-width: 860px) {
  .mobile-menu-toggle { display: flex; }
  .sidebar-overlay { display: block; }
  .sidebar-overlay.show { opacity: 1; pointer-events: auto; }

  .sidebar-pin { display: none; }
  .sidebar-mobile-close { display: flex; }
  .sidebar-pinbar { justify-content: flex-end; padding-right: 10px; }

  .sidebar { width: 0; border-right: 0; }
  .sidebar.expanded { width: min(240px, 78vw); border-right: 1px solid var(--border); }

  /* Real footprint of the fixed bottom tab bar, including the home-indicator
     safe area on notch/Dynamic-Island devices — every fixed element that
     needs to clear it (body padding, FABs, chat panel) anchors off this. */
  :root { --mtabbar-h: calc(56px + env(safe-area-inset-bottom)); }

  body.has-sidebar,
  body.has-sidebar.sidebar-pinned {
    margin-left: 0 !important; padding-bottom: var(--mtabbar-h);
  }
  body.has-sidebar .topnav, body.has-sidebar .page-header-bar,
  body.has-sidebar.sidebar-pinned .topnav, body.has-sidebar.sidebar-pinned .page-header-bar {
    margin-left: 0 !important; width: 100% !important;
  }

  .mobile-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 220;
    background: var(--nav); border-top: 2px solid var(--red);
    height: var(--mtabbar-h); padding-bottom: env(safe-area-inset-bottom); box-sizing: border-box;
  }

  /* !important here because the base (desktop) rules for these selectors
     are declared later in this file, which would otherwise win the cascade
     on mobile too despite this media query matching — see git history if
     reorganizing the stylesheet ever removes the need for this. */
  .fab-add-tile { bottom: calc(var(--mtabbar-h) + 88px) !important; right: 16px !important; }
  .tile-type-picker { bottom: calc(var(--mtabbar-h) + 152px) !important; right: 16px !important; }
  .chat-fab { bottom: calc(var(--mtabbar-h) + 20px) !important; right: 16px !important; }
  .chat-panel { inset: 0 !important; bottom: var(--mtabbar-h) !important; right: 0 !important; width: auto !important; height: auto !important; border-radius: 0 !important; }
}

@media print { .mobile-tabbar { display: none !important; } }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-radius: var(--radius);
  padding: 8px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background .15s, transform .1s;
  white-space: nowrap; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }

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

.btn-danger    { background: var(--red);   color: #fff; }
.btn-danger:hover  { background: var(--red-hover); }

.btn-warning   { background: var(--amber); color: #fff; }
.btn-warning:hover { background: var(--amber-hover); }

.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover { background: var(--green-hover); }

.btn-secondary {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg2); }

.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--link); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }

.btn-icon {
  background: transparent; border: 0;
  color: var(--text-muted); cursor: pointer;
  padding: 4px 8px; border-radius: 4px; font-size: 16px;
}
.btn-icon:hover { color: var(--red); background: rgba(255,255,255,.05); }

/* ---- Cards / Panels ---- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 16px; font-weight: 700;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}

.section-title {
  font-size: 18px; font-weight: 700;
  color: var(--text);
  border-left: 4px solid var(--red);
  padding-left: 12px;
  margin: 0 0 16px;
}

/* ---- Forms ---- */
label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .5px;
  margin: 14px 0 5px;
}

input[type=text], input[type=email], input[type=password],
input[type=tel], input[type=date], select, textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  /* 16px, not 14px: below 16px, iOS auto-zooms the whole page on focus and
     doesn't zoom back out until you navigate away — this is the fix, not
     a stylistic choice. */
  font-size: 16px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(21,101,192,.25);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
select option { background: var(--bg3); color: var(--text); }
textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  gap: 12px;
}
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ---- Tables ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .6px;
  border-bottom: 2px solid var(--border);
  background: var(--bg3);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:hover td { background: rgba(255,255,255,.025); }
.data-table td input, .data-table td select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 13px;
  padding: 5px 8px;
}

/* ---- Modals ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: none; align-items: center; justify-content: center;
  z-index: 500; padding: 16px;
}
.modal-overlay.show { display: flex; }

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 560px; max-width: 100%; max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-box.modal-sm { width: 380px; }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 {
  margin: 0; font-size: 16px; font-weight: 700;
  color: var(--text);
}

.modal-body  { padding: 18px 20px; }
.modal-foot  {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ---- Home page tile editor — shared between home.html (inline) and
   home-editor.html (full list editor) ---- */
.btn-del-row {
  background: none; border: 1px solid var(--border); border-radius: 5px;
  color: var(--text-muted); font-size: 15px; padding: 3px 8px; cursor: pointer; transition: all .15s;
}
.btn-del-row:hover { background: var(--red); border-color: var(--red); color: #fff; }
.add-row-btn {
  display: flex; align-items: center; gap: 6px; color: #4ade80; background: none;
  border: 1px dashed #2d6a40; border-radius: 6px; padding: 7px 14px; cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: inherit; margin-top: 8px; transition: all .15s;
}
.add-row-btn:hover { background: rgba(74,222,128,.08); border-color: #4ade80; }
.tile-title-input {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 5px;
  color: var(--text); font-size: 13px; padding: 7px 10px; font-family: inherit; margin-bottom: 10px;
}
.tile-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tile-toolbar button {
  width: 30px; height: 30px; border-radius: 5px; background: var(--bg);
  border: 1px solid var(--border); color: var(--text); cursor: pointer; font-size: 13px;
}
.tile-toolbar button:hover { background: var(--bg2); }
.tile-toolbar select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 5px; padding: 5px 8px; font-size: 12px; font-family: inherit;
}
.tile-toolbar input[type=color] {
  width: 30px; height: 30px; padding: 2px; border-radius: 5px;
  border: 1px solid var(--border); background: var(--bg); cursor: pointer;
}
.tile-rich-box {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; min-height: 70px; font-size: 16px; color: var(--text); line-height: 1.5;
}
.tile-rich-box:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.tile-item-row { display: flex; gap: 8px; margin-bottom: 6px; }
.tile-item-row input {
  flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 5px;
  color: var(--text); font-size: 13px; padding: 6px 8px; font-family: inherit;
}
.tile-hint { font-size: 12px; color: var(--text-muted); margin: 0; font-style: italic; }

/* ---- Home page inline tile editing (Admins only) ---- */
.tile.tile-editable { position: relative; }
.tile.tile-editable[draggable="true"] { cursor: grab; }
.tile.tile-editable.dragging { opacity: .4; }
.tile.tile-editable.drag-over { outline: 2px dashed var(--blue); outline-offset: -2px; }
.tile-edit-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(0,0,0,.4); border: 1px solid var(--border);
  color: var(--text-muted); font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.tile-edit-btn:hover { background: rgba(0,0,0,.6); color: var(--text); border-color: var(--text-muted); }

/* Stacked above the global chat bubble (bottom:28px), which now occupies
   the universal bottom-right corner on every page including Home. */
.fab-add-tile {
  position: fixed; bottom: 96px; right: 28px; z-index: 150;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--blue); color: #fff; border: 0;
  font-size: 28px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); transition: background .15s, transform .1s;
}
.fab-add-tile:hover { background: var(--blue-hover); }
.fab-add-tile:active { transform: scale(.94); }

.tile-type-picker {
  position: fixed; bottom: 160px; right: 28px; z-index: 150; min-width: 220px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); overflow: hidden; display: none;
}
.tile-type-picker.open { display: block; }
.tile-type-picker button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  border-bottom: 1px solid var(--border-soft); color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 600; padding: 11px 16px; cursor: pointer;
}
.tile-type-picker button:last-child { border-bottom: 0; }
.tile-type-picker button:hover { background: var(--bg3); }

/* ---- Global chat widget — floating bubble + popup panel on every page,
   tied to the currently-selected incident. ---- */
.chat-fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 400;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--blue); color: #fff; border: 0;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); transition: background .15s, transform .1s;
}
.chat-fab svg { width: 26px; height: 26px; }
.chat-fab:hover { background: var(--blue-hover); }
.chat-fab:active { transform: scale(.94); }
.chat-fab-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 20px; height: 20px; padding: 0 5px; font-size: 12px;
}
.chat-fab-badge.show { display: flex; }

.chat-panel {
  position: fixed; bottom: 96px; right: 28px; z-index: 400;
  width: 360px; height: 480px; max-height: calc(100vh - 120px);
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); display: none; flex-direction: column; overflow: hidden;
}
.chat-panel.open { display: flex; }
.chat-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.chat-panel-title { font-size: 14px; font-weight: 700; color: var(--text); }
.chat-panel-noinc { padding: 20px; font-size: 13px; color: var(--text-muted); }
.chat-panel-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.chat-to-row { position: relative; padding: 8px 12px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0; }
.chat-to-btn {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 6px 10px; cursor: pointer; display: flex; align-items: center; gap: 4px;
}
.chat-to-chevron { width: 11px; height: 11px; flex-shrink: 0; }
.chat-to-chevron svg { width: 11px; height: 11px; }
.chat-to-dropdown {
  position: absolute; top: calc(100% + 4px); left: 12px; min-width: 220px; max-height: 260px; overflow-y: auto;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); z-index: 5; display: none;
}
.chat-to-dropdown.open { display: block; }
.chat-to-everyone-btn {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  border-bottom: 1px solid var(--border-soft); color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 600; padding: 9px 14px; cursor: pointer;
}
.chat-to-everyone-btn:hover { background: var(--bg3); }
.chat-to-everyone-btn.active { background: var(--red-light); color: var(--red); }
.chat-to-divider { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); padding: 8px 14px 4px; }
.chat-to-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px;
  font-size: 13px; color: var(--text); cursor: pointer;
}
.chat-to-item:hover { background: var(--bg3); }

.chat-panel-scroll { flex: 1; overflow-y: auto; padding: 12px 14px; min-height: 0; }
.chat-panel-empty { font-size: 13px; color: var(--text-muted); text-align: center; margin-top: 20px; }
.chat-panel .chat-msg { margin-bottom: 12px; max-width: 85%; }
.chat-panel .chat-msg:last-child { margin-bottom: 0; }
.chat-panel .chat-msg.own { margin-left: auto; }
.chat-panel .chat-msg-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 2px; }
.chat-panel .chat-msg.own .chat-msg-head { flex-direction: row-reverse; }
.chat-panel .chat-msg-user { font-size: 11px; font-weight: 700; color: var(--text); }
.chat-panel .chat-msg-time { font-size: 10px; color: var(--text-muted); }
.chat-panel .chat-msg-audience { font-size: 10px; color: var(--amber); margin-bottom: 2px; }
.chat-panel .chat-msg.own .chat-msg-audience { text-align: right; }
.chat-panel .chat-bubble {
  font-size: 13px; color: var(--text); white-space: pre-wrap; line-height: 1.4;
  background: var(--bg3); border-radius: 10px; padding: 7px 11px; display: inline-block;
}
.chat-panel .chat-msg.own .chat-bubble { background: var(--blue); color: #fff; }

.chat-panel-input-row {
  display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.chat-panel-input-row textarea {
  flex: 1; resize: none; min-height: 36px; max-height: 90px;
  font-family: inherit; font-size: 13px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg); color: var(--text);
}

@media print { .chat-fab, .chat-panel { display: none !important; } }

/* ---- Confirmation Dialog ---- */
.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.confirm-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  width: 420px; max-width: 90%;
  text-align: center;
  box-shadow: var(--shadow);
}
.confirm-box h3 {
  margin: 0 0 12px;
  font-size: 18px; font-weight: 700;
  color: var(--text);
}
.confirm-box p {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 14px; line-height: 1.5;
}
.confirm-foot {
  display: flex; gap: 12px; justify-content: center;
}

/* ---- Tabs ---- */
.tabs {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}
.tab-btn {
  background: none; border: none; border-bottom: 3px solid transparent;
  color: var(--text-muted); font-family: inherit;
  font-size: 14px; font-weight: 600;
  padding: 10px 20px; cursor: pointer; margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--red); border-bottom-color: var(--red); }

.tab-panel { display: none; }
.tab-panel.show { display: block; }

/* ---- Badges / Pills ---- */
.badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
}
.badge-active  { background: #1a3a1a; color: #4caf50; border: 1px solid #2e7d32; }
.badge-ended   { background: #3a1a1a; color: #ef9a9a; border: 1px solid #c62828; }

/* ---- Page layout ---- */
.page-wrap {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 20px;
}
.page-wrap-wide {
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 20px;
}

/* ---- Utility ---- */
.flex       { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.mb-16  { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-danger { color: #ef9a9a; }
.text-center { text-align: center; }
.bold   { font-weight: 700; }
.w-full { width: 100%; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state p     { font-size: 14px; margin: 0; }

/* ---- Loading spinner ---- */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Dropdown ---- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px); left: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 260px;
  box-shadow: var(--shadow);
  z-index: 300;
  display: none;
  overflow: hidden;
}
.dropdown-menu.open { display: block; }

.dropdown-menu a,
.dropdown-menu button {
  display: block; width: 100%;
  text-align: left; background: none; border: none;
  color: var(--text); font-family: inherit; font-size: 13px;
  padding: 10px 16px; cursor: pointer;
  text-decoration: none;
  transition: background .1s;
}
.dropdown-menu a:hover,
.dropdown-menu button:hover { background: var(--bg3); }

.dropdown-divider {
  border: none; border-top: 1px solid var(--border);
  margin: 4px 0;
}

.dropdown-header {
  padding: 6px 16px 4px;
  font-size: 10px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .6px;
}

/* ---- Print ---- */
@media print { .no-print { display: none !important; } }

/* ============================================================
   Multi-page redesign additions
   ============================================================ */

/* Count badge (absolute on cards) */
.count-badge {
  position: absolute; top: -8px; right: -8px;
  background: var(--red); color: #fff; border-radius: 50%;
  min-width: 22px; height: 22px; font-size: 11px; font-weight: 700;
  display: none; align-items: center; justify-content: center; padding: 0 4px;
}
.count-badge.show { display: flex; }

/* Incident banner (shows on Initial Actions, etc.) */
.incident-banner {
  background: var(--bg3); border-bottom: 1px solid var(--border);
  padding: 10px 20px; display: flex; align-items: center; gap: 16px; font-size: 13px;
}
.incident-banner .inc-title { font-weight: 700; color: var(--text); font-size: 15px; }
.incident-banner .inc-meta  { color: var(--text-muted); }
.no-incident-banner {
  background: rgba(180,83,9,.15); border: 1px solid var(--amber);
  border-radius: 8px; padding: 16px 20px; color: #fde68a;
  font-size: 13px; text-align: center; margin: 24px auto; max-width: 520px;
}
.no-incident-banner a { color: #fbbf24; }

/* Checklist */
.checklist-list { list-style: none; padding: 0; margin: 0; }
.checklist-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border-soft);
  transition: background .1s;
}
.checklist-item:hover { background: rgba(255,255,255,.02); }
.checklist-item input[type=checkbox] {
  width: 18px; height: 18px; cursor: pointer; flex-shrink: 0;
  margin-top: 2px; accent-color: var(--red);
}
.checklist-item label {
  font-size: 14px; cursor: pointer; color: var(--text);
  text-transform: none; letter-spacing: 0;
  margin: 0; font-weight: 400; line-height: 1.4; flex: 1;
}
.checklist-item.checked label { text-decoration: line-through; color: var(--text-muted); }

/* Reorder buttons (shared across pages) */
.reorder-btn {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  color: var(--text-muted); font-size: 11px; padding: 2px 6px;
  cursor: pointer; line-height: 1; transition: all .1s; flex-shrink: 0;
}
.reorder-btn:hover { background: var(--bg3); color: var(--text); }
.reorder-btn:disabled { opacity: .3; cursor: default; }

/* Drag handle (shared across pages — Contacts, Links) */
.drag-handle {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); cursor: grab; flex-shrink: 0;
  padding: 4px; touch-action: none;
}
.drag-handle:hover { color: var(--text); }
.drag-handle:active { cursor: grabbing; }

/* Agency rows (Contacts page) */
.agency-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border-soft);
  transition: background .1s;
}
.agency-row:hover { background: var(--bg3); }
.agency-row .agency-name { flex: 1; font-size: 15px; font-weight: 600; color: var(--text); cursor: pointer; }
.agency-row .agency-count { font-size: 12px; color: var(--text-muted); white-space: nowrap; cursor: pointer; }

/* Contact cards (inside agency modal) */
.contact-card {
  padding: 12px; border: 1px solid var(--border-soft); border-radius: 8px; margin-bottom: 10px;
}
.contact-card:last-child { margin-bottom: 0; }
.cf-label { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 2px; }
.cf-value { font-size: 13px; color: var(--text); margin-bottom: 6px; }
.cf-value:last-child { margin-bottom: 0; }

/* Link rows (Links page) */
.link-row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border-soft);
}
.link-row a { flex: 1; font-size: 15px; font-weight: 600; color: var(--link); text-decoration: none; word-break: break-all; }
.link-row a:hover { text-decoration: underline; }
.link-actions { display: flex; gap: 6px; }

/* Modify-checklist modal specifics */
.cl-edit-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border-soft);
}
.cl-edit-row input[type=text] { flex: 1; }

/* Template tab strip */
.tmpl-tabs { display: flex; gap: 0; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tmpl-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 14px; cursor: pointer; transition: color .15s, border-color .15s; display: flex; align-items: center; gap: 4px;
}
.tmpl-tab.active { color: var(--text); border-bottom-color: var(--red); }
.tmpl-tab-del { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; padding: 0 2px; }
.tmpl-tab-del:hover { color: var(--red); }
