:root {
  --navy: #1b2432;
  --navy-2: #232f42;
  --accent: #3b82f6;
  --line: #e5e7eb;
  --text: #1f2933;
  --muted: #6b7280;
  --bg: #f4f6f9;
}

* { box-sizing: border-box; }

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

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 20px;
  background: var(--navy);
  color: #fff;
}
.topbar-brand { display: flex; align-items: center; }
.topbar-logo { height: 26px; width: auto; display: block; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-title { font-size: 15px; font-weight: 500; letter-spacing: .2px; }
.topbar-user { font-size: 13px; color: #cbd5e1; }
.topbar-logout button {
  background: transparent;
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.topbar-logout button:hover { background: rgba(255,255,255,.1); }

/* Primary nav */
.topbar-nav { display: flex; align-items: center; gap: 4px; margin-left: 20px; flex: 1; }
.topbar-link {
  color: #cbd5e1; text-decoration: none; font-size: 13px; font-weight: 500;
  padding: 7px 12px; border-radius: 6px; white-space: nowrap;
}
.topbar-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.topbar-link.active { background: var(--accent); color: #fff; }

/* ---------- Messages ---------- */
.convo-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.convo-list li { padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.convo-list li:last-child { border-bottom: none; }
.convo-list li:hover { background: #f8fafc; }
.convo-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.convo-name { font-weight: 600; }
.convo-time { font-size: 12px; color: var(--muted); }
.convo-preview { font-size: 13px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-members { color: var(--muted); font-size: 13px; margin: -6px 0 14px; }

/* Chat thread */
.chat { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.chat-msg { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 13px; max-width: 70%; align-self: flex-start; }
.chat-msg.mine { align-self: flex-end; background: #eff6ff; border-color: #bfdbfe; }
.chat-meta { display: flex; gap: 10px; align-items: baseline; margin-bottom: 3px; }
.chat-meta .mono { font-size: 12px; font-weight: 600; }
.chat-time { font-size: 11px; color: var(--muted); }
.chat-body { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.btn-send { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 0 18px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-send:hover { filter: brightness(1.05); }

/* Export PDF button on the incident detail */
.btn-export {
  margin-left: auto; background: #2563eb; color: #fff; text-decoration: none;
  font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 8px;
}
.btn-export:hover { filter: brightness(1.05); }

/* ---------- Content ---------- */
.content { max-width: 1000px; margin: 28px auto; padding: 0 20px; }
.content-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.content-head h1 { font-size: 20px; margin: 0; }
.count-badge {
  background: #e2e8f0;
  color: var(--muted);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.back-link { display: inline-block; margin-bottom: 14px; color: var(--accent); text-decoration: none; font-size: 14px; }
.back-link:hover { text-decoration: underline; }

/* ---------- Table ---------- */
.cad-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  font-size: 14px;
}
.cad-table th {
  text-align: left;
  padding: 11px 14px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--line);
}
.cad-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.cad-table tbody tr { cursor: pointer; }
.cad-table tbody tr:last-child td { border-bottom: none; }
.cad-table tbody tr:hover { background: #f8fafc; }
.mono { font-family: "SF Mono", Consolas, Menlo, monospace; font-size: 13px; }

/* APCO priority chips: Alpha (lowest) -> Echo (highest) */
.pri { display: inline-block; min-width: 62px; text-align: center; padding: 3px 8px; border-radius: 5px; font-weight: 700; font-size: 12px; color: #fff; }
.pri-alpha   { background: #16a34a; } /* green  - lowest */
.pri-bravo   { background: #65a30d; }
.pri-charlie { background: #ca8a04; } /* amber  - medium */
.pri-delta   { background: #ea580c; }
.pri-echo    { background: #dc2626; } /* red    - highest */
.pri-unknown { background: #6b7280; }

.status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-active, .status-on-scene { background: #dcfce7; color: #166534; }
.status-dispatched { background: #dbeafe; color: #1e40af; }
.status-pending { background: #fef9c3; color: #854d0e; }
.status-cleared { background: #e5e7eb; color: #374151; }

/* ---------- Detail ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px;
}
.detail-grid > div { display: flex; flex-direction: column; gap: 5px; }
.label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

/* ---------- Login (classic CAD Sign In) ---------- */
:root { --cad-blue: #003a9b; }

.login-page {
  min-height: 100vh;
  margin: 0;
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
}
.login-page .signin-box {
  margin: 60px auto 0;
}
.signin-box {
  width: 430px;
  max-width: 94vw;
  border: 1px solid #b9c3d6;
}
.signin-title {
  background: #eef1f6;
  color: var(--cad-blue);
  text-align: center;
  font-weight: bold;
  font-size: 18px;
  padding: 8px 0;
  border-bottom: 3px solid var(--cad-blue);
}
.signin-body {
  background: var(--cad-blue);
  padding: 18px 16px 20px;
  color: #fff;
}
.signin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.signin-row label {
  width: 78px;
  text-align: right;
  font-size: 13px;
  font-weight: bold;
}
.signin-row select,
.signin-row input {
  flex: 1;
  padding: 5px 6px;
  font-size: 13px;
  border: 1px solid #7f9bc4;
  background: #fff;
  color: #000;
}
.signin-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}
.btn {
  background: var(--cad-blue);
  color: #fff;
  border: 1px solid #fff;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
}
.btn:hover:not([disabled]) { background: #0050c8; }
.btn[disabled] { opacity: .8; cursor: not-allowed; }
.btn-wide { padding: 4px 16px; }
.signin-note {
  color: #ffd54a;
  font-weight: bold;
  font-size: 13px;
  margin-top: 22px;
}
.signin-error {
  background: #fff3cd;
  color: #7a1f1f;
  border: 1px solid #e0c36a;
  padding: 7px 10px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ---------- Extra ---------- */
.empty { text-align: center; color: var(--muted); padding: 22px; }
.section-title { font-size: 16px; margin: 26px 0 10px; }
.comments { display: flex; flex-direction: column; gap: 10px; }
.comment { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-size: 14px; }
.comment-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.status-active { background: #dcfce7; color: #166534; }
.status-pending { background: #fef9c3; color: #854d0e; }
.status-closed { background: #e5e7eb; color: #374151; }
.pri-x { background: #6b7280; }
