/* ==========================================================
   Shared components: buttons, inputs, panels, badges, tables, lists,
   tabs, cards, modals, toasts, popovers, global search.
   ========================================================== */

/* ================= Buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px;
  background: var(--bg-3); color: var(--text-0);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 12.5px; font-weight: 600; line-height: 1;
  cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--bg-4); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--glow-accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { background: var(--danger-soft); border-color: rgba(224, 70, 75, .45); color: var(--danger-strong); }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.good { background: var(--good-soft); border-color: rgba(46, 170, 104, .45); color: var(--good-strong); }
.btn.good:hover { background: var(--good); border-color: var(--good); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-1); }
.btn.ghost:hover { background: var(--bg-3); color: var(--text-0); border-color: var(--border); }
.btn.outline { background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 11.5px; gap: 5px; border-radius: var(--radius-sm); }
.btn.xs { height: 24px; padding: 0 8px; font-size: 11px; gap: 4px; border-radius: var(--radius-xs); }
.btn.block { width: 100%; }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-icon { font-size: 12px; }
.btn-ico { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.btn-ico svg { width: 14px; height: 14px; display: block; }
.btn.sm .btn-ico svg { width: 13px; height: 13px; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ================= Inputs ================= */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field label, .field > .label {
  font-size: 11px; font-weight: 600; color: var(--text-1); letter-spacing: .2px;
}
.field .hint, .field-hint { font-size: 10.5px; color: var(--text-3); margin-top: -1px; }
.input, select.input, textarea.input {
  width: 100%;
  min-height: 34px; padding: 7px 11px;
  background: var(--bg-1); color: var(--text-0);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 12.8px; outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.input:hover { border-color: #474d6e; }
.input:focus { border-color: var(--accent); box-shadow: var(--glow-accent); background: var(--bg-1); }
.input::placeholder { color: var(--text-3); }
.input:disabled { opacity: .6; cursor: not-allowed; }
.input.invalid, .input:invalid:not(:placeholder-shown) { border-color: var(--danger); }
select.input {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c8299' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 14px;
}
select.input option { background: var(--bg-2); color: var(--text-0); }
textarea.input { resize: vertical; line-height: 1.55; font-family: var(--font-ui); min-height: 70px; }
input[type="date"].input, input[type="time"].input, input[type="datetime-local"].input { color-scheme: dark; }
html.mdt-light input[type="date"].input, html.mdt-light input[type="time"].input { color-scheme: light; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.form-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-2); margin: 6px 0 10px;
}
.form-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border-soft); }
.validation-msg { font-size: 11px; color: var(--danger-strong); margin-top: 2px; }

.search-bar {
  display: flex; gap: 8px; margin-bottom: 14px; align-items: center;
}
.search-bar .input {
  flex: 1; height: 38px; padding-left: 36px;
  background-color: var(--bg-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c8299' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10.8' cy='10.8' r='6.3'/%3E%3Cpath d='M15.5 15.5 20 20'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 12px center; background-size: 15px;
}
.search-bar select.input { flex: 0 0 auto; width: auto; padding-left: 11px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c8299' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-position: right 9px center; background-size: 14px; }
.search-bar .btn { height: 38px; }

/* Tag input (report form suspects/victims/charges etc.) */
.tag-input-box {
  position: relative;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 36px; padding: 5px 7px;
  background: var(--bg-1); border: 1px solid var(--border-strong); border-radius: var(--radius);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.tag-input-box:focus-within { border-color: var(--accent); box-shadow: var(--glow-accent); }
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 5px 0 9px;
  background: var(--bg-4); border: 1px solid var(--border-strong); color: var(--text-0);
  border-radius: var(--radius-xs); font-size: 11.5px; font-weight: 500;
}
.tag-chip button {
  display: flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 3px;
  background: none; border: none; color: var(--text-2); cursor: pointer; font-size: 11px; padding: 0; line-height: 1;
}
.tag-chip button:hover { color: #fff; background: var(--danger); }
.tag-input-box input { flex: 1; min-width: 110px; background: transparent; border: none; color: var(--text-0); outline: none; font-size: 12.5px; padding: 3px; }
.tag-suggest-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  max-height: 200px; overflow-y: auto; padding: 4px;
  background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.tag-suggest-item { padding: 7px 10px; font-size: 12px; color: var(--text-0); cursor: pointer; border-radius: var(--radius-xs); }
.tag-suggest-item:hover, .tag-suggest-item.active { background: var(--accent-soft); color: var(--text-0); }

/* ================= Panels ================= */
.panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-width: 0;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 44px; padding: 8px 14px 8px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 11.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: var(--text-1);
}
.panel-header .btn { text-transform: none; letter-spacing: 0; }
.panel-header .badge { letter-spacing: .3px; }
.panel-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.panel-title-ico { display: flex; color: var(--accent-strong); }
.panel-title-ico svg { width: 15px; height: 15px; }
.panel-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.panel-body.flush { padding: 0; gap: 0; }
.panel-body.scroll { overflow-y: auto; }
.panel-link {
  font-size: 11px; font-weight: 600; letter-spacing: .2px; text-transform: none;
  color: var(--accent-strong); cursor: pointer; white-space: nowrap;
}
.panel-link:hover { text-decoration: underline; }

/* KPI / stat cards */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card {
  position: relative;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 16px 13px;
  overflow: hidden;
}
.stat-card .stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--text-0); line-height: 1.1; letter-spacing: -.3px; }
.stat-card .stat-label { font-size: 11px; color: var(--text-2); margin-top: 4px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; }
.stat-card.warn .stat-value { color: var(--warn-strong); }
.stat-card.danger .stat-value { color: var(--danger-strong); }
.stat-card.good .stat-value { color: var(--good-strong); }
.stat-card.accent .stat-value { color: var(--accent-strong); }

/* Duty stats bar chart (Boss Menu) */
.duty-chart { display: flex; align-items: flex-end; gap: 3px; height: 96px; }
.duty-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; cursor: default; }
.duty-bar { width: 100%; max-width: 10px; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .85; }
.duty-bar-col:hover .duty-bar { opacity: 1; background: var(--accent-strong); }
.duty-bar-date { font-size: 8px; color: var(--text-3); margin-top: 4px; white-space: nowrap; }

/* ================= Badges ================= */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 20px; padding: 0 8px;
  font-size: 10px; font-weight: 700; letter-spacing: .5px; line-height: 1;
  border-radius: var(--radius-xs); text-transform: uppercase; white-space: nowrap;
  border: 1px solid transparent;
}
.badge.b-danger { background: var(--danger-soft); color: var(--danger-strong); border-color: rgba(224, 70, 75, .35); }
.badge.b-warn { background: var(--warn-soft); color: var(--warn-strong); border-color: rgba(232, 163, 23, .35); }
.badge.b-good { background: var(--good-soft); color: var(--good-strong); border-color: rgba(46, 170, 104, .35); }
.badge.b-info { background: var(--info-soft); color: var(--info-strong); border-color: rgba(74, 134, 232, .35); }
.badge.b-neutral { background: var(--neutral-soft); color: var(--text-1); border-color: var(--border); }
.badge.b-accent { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-border); }
.badge.solid.b-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.badge.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
html.mdt-light .badge.b-warn { color: #9a6700; }
html.mdt-light .badge.b-good { color: #16804a; }

.priority-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.priority-dot.p1 { background: var(--priority-1); box-shadow: 0 0 0 3px var(--danger-soft); }
.priority-dot.p2 { background: var(--priority-2); box-shadow: 0 0 0 3px var(--warn-soft); }
.priority-dot.p3 { background: var(--priority-3); }
.prio-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--text-2); }

/* ================= Tables ================= */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.data-table thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; white-space: nowrap;
  padding: 10px 14px;
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
  color: var(--text-2); font-size: 10.5px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
}
.data-table thead th.sortable { cursor: pointer; user-select: none; }
.data-table thead th.sortable:hover { color: var(--text-0); }
.data-table thead th .sort-ind { display: inline-block; margin-left: 5px; opacity: 0; font-size: 8px; transition: opacity var(--dur-fast) var(--ease); }
.data-table thead th.sortable:hover .sort-ind { opacity: .5; }
.data-table thead th.sorted .sort-ind { opacity: 1; color: var(--accent-strong); }
.data-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-0); vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--dur-fast) var(--ease); }
.data-table tbody tr:hover td { background: rgba(255, 255, 255, 0.018); }
html.mdt-light .data-table tbody tr:hover td { background: rgba(0, 0, 0, 0.02); }
.data-table.clickable-rows tbody tr { cursor: pointer; }
.data-table.clickable-rows tbody tr:hover td { background: var(--accent-soft); }
.data-table tbody tr.selected td { background: var(--accent-soft); }
.data-table tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.data-table td .mono, .data-table td.mono { color: var(--text-1); }
.table-wrap { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.table-scroll { max-height: calc(var(--mdt-h) - var(--topbar-h) - var(--statusbar-h) - 190px); overflow: auto; }
.table-scroll .data-table td { white-space: nowrap; }
.table-scroll .data-table td.wrap { white-space: normal; }
.data-table tr.table-group-row td {
  background: var(--bg-1); color: var(--accent-strong);
  font-size: 10.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  padding: 8px 14px;
}
.table-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border-soft); }
.table-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 14px; border-top: 1px solid var(--border-soft);
  font-size: 11px; color: var(--text-2);
}

/* ================= List items (search results) ================= */
.list-item {
  position: relative;
  padding: 10px 12px; margin-bottom: 3px;
  border: 1px solid transparent; border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.list-item:hover { background: var(--bg-3); }
.list-item.active { background: var(--accent-soft); border-color: var(--accent-border); }
.list-item.active::before {
  content: ''; position: absolute; left: -1px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.list-item-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-0); }
.list-item-sub { font-size: 11.5px; color: var(--text-2); margin-top: 3px; }
.list-item-meta { font-size: 10.5px; color: var(--text-3); margin-top: 3px; font-family: var(--font-mono); }
.list-item.active .list-item-meta { color: var(--text-2); }

/* Record row (richer search result card: avatar + fields + flags) */
.rec-row { display: flex; gap: 11px; align-items: flex-start; }
.rec-avatar {
  width: 42px; height: 42px; flex: none; border-radius: var(--radius);
  background: var(--bg-4); border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; color: var(--text-1); overflow: hidden;
}
.rec-avatar img { width: 100%; height: 100%; object-fit: cover; }
.rec-avatar.plate { width: 64px; height: 30px; font-family: var(--font-mono); font-size: 11px; letter-spacing: .5px; background: #e9e6d8; color: #1b2440; border: 2px solid #c9c4ae; margin-top: 2px; }
.rec-body { flex: 1; min-width: 0; }
.rec-name { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-0); }
.rec-name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-fields { display: flex; flex-wrap: wrap; gap: 3px 12px; margin-top: 4px; font-size: 11.2px; color: var(--text-2); }
.rec-fields b { color: var(--text-1); font-weight: 600; }
.rec-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.rec-flags .badge { height: 18px; font-size: 9.5px; padding: 0 6px; }

/* ================= Empty / loading / error states ================= */
.empty-state {
  height: 100%; min-height: 120px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 22px; text-align: center;
  color: var(--text-2); font-size: 12.5px;
}
.empty-state::before {
  content: ''; width: 34px; height: 34px; flex: none;
  border-radius: var(--radius-lg);
  background-color: var(--bg-3);
  border: 1px solid var(--border);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23535970' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7.5 3.5h6l4 4v13h-10z'/%3E%3Cpath d='M13.5 3.5v4h4'/%3E%3Cpath d='M9.5 12h5M9.5 15h3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center; background-size: 18px;
}
.empty-state[style*="height:"]::before, .empty-state.compact::before { display: none; }
.empty-state .es-title { font-size: 13px; font-weight: 600; color: var(--text-1); }
.empty-state .es-sub { font-size: 11.5px; color: var(--text-3); max-width: 320px; }
.loading-state { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 26px; color: var(--text-2); font-size: 12px; }
.error-state { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--danger-soft); border: 1px solid rgba(224,70,75,.35); color: var(--danger-strong); font-size: 12px; }
.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border-radius: var(--radius);
  background: var(--bg-3); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-1); line-height: 1.5;
}
.callout.info { background: var(--info-soft); border-color: rgba(74,134,232,.3); }
.callout.warn { background: var(--warn-soft); border-color: rgba(232,163,23,.3); }
.callout.accent { background: var(--accent-soft); border-color: var(--accent-border); }
.callout-ico { display: flex; flex: none; color: var(--accent-strong); margin-top: 1px; }
.callout-ico svg { width: 15px; height: 15px; }

/* ================= Profile / record detail ================= */
.profile-head {
  display: flex; gap: 18px; align-items: flex-start;
  padding-bottom: 16px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}
.profile-photo {
  width: 92px; height: 108px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-3); border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 22px; font-weight: 700; color: var(--text-2);
  cursor: pointer; overflow: hidden;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.profile-photo:hover { border-color: var(--accent); box-shadow: var(--glow-accent); }
.profile-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.profile-photo-wrap { display: flex; flex-direction: column; align-items: stretch; gap: 6px; flex: none; }
#persons-clear-mugshot-btn { width: 92px; height: 24px; padding: 0 4px; font-size: 10px; }
.profile-head-main { flex: 1; min-width: 0; }
.profile-name { font-family: var(--font-display); font-size: 21px; font-weight: 700; color: var(--text-0); letter-spacing: .1px; line-height: 1.2; }
.profile-sub { font-size: 12px; color: var(--text-2); margin-top: 3px; }
.profile-flags { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.profile-facts { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 10px; }
.profile-fact { min-width: 0; }
.profile-fact .pf-label { font-size: 9.5px; font-weight: 700; letter-spacing: .9px; color: var(--text-3); text-transform: uppercase; }
.profile-fact .pf-value { font-size: 12.5px; font-weight: 600; color: var(--text-0); margin-top: 1px; }
.profile-head-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex: none; }

.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-bottom: 16px; background: var(--border-soft); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; }
.info-item { background: var(--bg-2); padding: 10px 13px; min-width: 0; }
.info-item .info-label { font-size: 9.5px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase; color: var(--text-3); margin-bottom: 3px; }
.info-item .info-value { font-size: 12.8px; font-weight: 500; color: var(--text-0); word-break: break-word; }
.info-grid.stacked { grid-template-columns: 1fr; }
.info-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.info-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.profile-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; margin-bottom: 14px; }
.profile-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.profile-section .panel-body { max-height: 300px; overflow-y: auto; }
.profile-section .panel-header { min-height: 40px; }

/* Record tabs (profile sub-navigation) */
.rec-tabs {
  display: flex; gap: 2px; flex-wrap: wrap;
  margin: 0 0 16px; padding: 3px;
  background: var(--bg-1); border: 1px solid var(--border-soft); border-radius: var(--radius);
}
.rec-tab {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 12px;
  background: transparent; border: none; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.rec-tab:hover { color: var(--text-0); background: var(--bg-3); }
.rec-tab.active { background: var(--bg-3); color: var(--text-0); box-shadow: inset 0 -2px 0 var(--accent); }
.rec-tab .count { min-width: 18px; height: 17px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: var(--bg-4); color: var(--text-1); font-size: 10px; font-weight: 700; }
.rec-tab .count.alert { background: var(--danger-soft); color: var(--danger-strong); }
.rec-tab-page { display: none; animation: viewIn 160ms var(--ease) both; }
.rec-tab-page.active { display: block; }
.rec-tab-page > .panel + .panel, .rec-tab-page > .panel + .profile-columns { margin-top: 14px; }

/* Notes */
.note-card { background: var(--bg-3); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 11px 13px; }
.note-card + .note-card { margin-top: 8px; }
.note-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.note-card-title { font-size: 12.5px; font-weight: 700; color: var(--text-0); }
.note-card-text { font-size: 12px; color: var(--text-1); line-height: 1.55; margin-top: 5px; white-space: pre-wrap; }
.note-card-pills { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.note-card-meta { font-size: 10.5px; color: var(--text-3); margin-top: 8px; }
.note-delete-btn { background: none; border: none; color: var(--text-3); cursor: pointer; padding: 3px; display: flex; flex: none; border-radius: var(--radius-xs); }
.note-delete-btn:hover { color: var(--danger-strong); background: var(--danger-soft); }
.note-delete-btn svg { width: 14px; height: 14px; display: block; }

.section-title {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 18px 0 9px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-2);
}

/* ================= Tabs (view-level filters) ================= */
.tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 14px; padding-bottom: 0;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px;
  background: transparent; border: none;
  color: var(--text-2); font-size: 12.2px; font-weight: 600; letter-spacing: .3px;
  cursor: pointer; white-space: nowrap; text-transform: capitalize;
  transition: color var(--dur-fast) var(--ease);
}
.tab-btn::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px;
  border-radius: 2px 2px 0 0; background: transparent;
  transition: background var(--dur-fast) var(--ease);
}
.tab-btn:hover { color: var(--text-0); }
.tab-btn.active { color: var(--text-0); }
.tab-btn.active::after { background: var(--accent); }
.tab-btn .count { min-width: 18px; height: 17px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: var(--bg-4); color: var(--text-1); font-size: 10px; font-weight: 700; }
.tab-btn.active .count { background: var(--accent-soft); color: var(--accent-strong); }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius); }
.seg button { height: 28px; padding: 0 12px; border: none; background: transparent; color: var(--text-2); font-size: 11.5px; font-weight: 600; border-radius: var(--radius-sm); cursor: pointer; }
.seg button:hover { color: var(--text-0); }
.seg button.active { background: var(--bg-3); color: var(--text-0); box-shadow: inset 0 -2px 0 var(--accent); }

/* Toolbar row (filters above lists/tables) */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { width: auto; }
.toolbar .grow { flex: 1; min-width: 200px; }

/* ================= Cards grid (warrants / bolos) ================= */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; align-items: start; }
.alert-card {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px 13px 18px;
  overflow: hidden;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.alert-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--priority-3); }
.alert-card.p1::before { background: var(--priority-1); }
.alert-card.p2::before { background: var(--priority-2); }
.alert-card.p3::before { background: var(--priority-3); }
.alert-card:hover { border-color: var(--border-strong); }
.alert-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.alert-card-title { font-size: 13.5px; font-weight: 700; color: var(--text-0); line-height: 1.3; }
.alert-card-id { font-family: var(--font-mono); font-size: 11px; color: var(--accent-strong); font-weight: 600; letter-spacing: .3px; }
.alert-card-reason { font-size: 12px; color: var(--text-1); line-height: 1.55; margin-bottom: 10px; }
.alert-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--text-2); margin-top: 4px; }
.alert-card-meta .mono { color: var(--text-2); }
.alert-card-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin: 8px 0 10px; padding: 10px 0; border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); }
.acf-label { font-size: 9.5px; font-weight: 700; letter-spacing: .9px; text-transform: uppercase; color: var(--text-3); }
.acf-value { font-size: 12px; color: var(--text-0); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-card-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ================= Offences (penal code cards) ================= */
.offence-cat { margin-bottom: 22px; }
.offence-cat-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.offence-cat-header h3 { margin: 0; font-size: 14px; font-weight: 700; color: var(--text-0); }
.offence-card {
  position: relative;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px 12px 16px; cursor: pointer; overflow: hidden;
  transition: border-color var(--dur-fast) var(--ease);
}
.offence-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--border-strong); }
.offence-card:hover { border-color: var(--border-strong); }
.offence-card.oc-misdemeanor::before { background: var(--warn); }
.offence-card.oc-felony::before { background: var(--danger); }
.offence-card.oc-infraction::before { background: var(--good); }
.offence-card.oc-neutral::before { background: var(--text-3); }
.offence-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.offence-card-title { font-size: 12.8px; font-weight: 700; color: var(--text-0); line-height: 1.35; }
.offence-card-code { font-size: 10.5px; color: var(--accent-strong); margin-top: 2px; font-family: var(--font-mono); }
.offence-card-class { font-size: 9.5px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--text-2); white-space: nowrap; padding: 3px 7px; border-radius: var(--radius-xs); background: var(--bg-3); }
.oc-felony .offence-card-class { color: var(--danger-strong); background: var(--danger-soft); }
.oc-misdemeanor .offence-card-class { color: var(--warn-strong); background: var(--warn-soft); }
.oc-infraction .offence-card-class { color: var(--good-strong); background: var(--good-soft); }
.offence-card-penalty { font-size: 11.5px; color: var(--text-1); }

/* ================= Reports (card list) ================= */
.reports-list-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.reports-list-toolbar .input { height: 36px; }
.reports-list-toolbar select.input { width: auto; flex: 0 0 auto; }
.report-card-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.report-card {
  position: relative;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 13px 16px; cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.report-card:hover { border-color: var(--accent-border); background: var(--bg-3); }
.report-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.report-card-title { font-size: 13.2px; font-weight: 700; color: var(--text-0); }
.report-card-excerpt {
  font-size: 12px; color: var(--text-1); line-height: 1.5; margin-bottom: 9px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.report-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--text-2); }
.report-card-meta .mono { color: var(--accent-strong); }

/* ================= Modal ================= */
#modal-root { position: fixed; inset: 0; z-index: 100; display: none; }
#modal-root.open { display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6, 7, 12, 0.72); animation: fadeIn var(--dur-med) var(--ease); }
.modal-box {
  position: relative;
  width: 500px; max-width: 94vw; max-height: 88vh; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: var(--shadow-lg);
  animation: modalIn 190ms var(--ease);
}
.modal-box.wide { width: 760px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-header {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 20px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border-soft);
}
.modal-header::before { content: ''; position: absolute; left: 0; top: 0; right: 0; height: 2px; background: var(--accent); border-radius: 10px 10px 0 0; }
.modal-header h3 { margin: 0; font-family: var(--font-display); font-size: 15.5px; font-weight: 700; color: var(--text-0); letter-spacing: .1px; }
.modal-body { padding: 18px 20px; }
.modal-body p { color: var(--text-1); }
.modal-footer {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; justify-content: flex-end; align-items: center; gap: 8px;
  padding: 13px 20px;
  background: var(--bg-1);
  border-top: 1px solid var(--border-soft);
}

/* ================= Toasts ================= */
#toast-root {
  position: fixed;
  bottom: calc((100vh - var(--mdt-h)) / 2 + var(--statusbar-h) + 14px);
  right: calc((100vw - var(--mdt-w)) / 2 + 18px);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; width: 340px;
  pointer-events: none;
}
.toast {
  position: relative; pointer-events: auto;
  display: grid; grid-template-columns: 28px 1fr; column-gap: 10px;
  padding: 12px 14px 11px 12px;
  background: var(--bg-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  animation: toastIn 200ms var(--ease);
  overflow: hidden;
}
.toast::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--info); }
.toast.t-danger::before { background: var(--danger); }
.toast.t-warn::before { background: var(--warn); }
.toast.t-good::before { background: var(--good); }
.toast.t-neutral::before { background: var(--text-3); }
@keyframes toastIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.toast-title { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; font-size: 12.8px; font-weight: 700; color: var(--text-0); }
.toast-title > span:first-child {
  width: 26px; height: 26px; flex: none; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: var(--info-soft); color: var(--info-strong); font-size: 13px;
}
.toast.t-danger .toast-title > span:first-child { background: var(--danger-soft); color: var(--danger-strong); }
.toast.t-warn .toast-title > span:first-child { background: var(--warn-soft); color: var(--warn-strong); }
.toast.t-good .toast-title > span:first-child { background: var(--good-soft); color: var(--good-strong); }
.toast-msg { grid-column: 2; font-size: 11.8px; color: var(--text-1); margin-top: 1px; line-height: 1.45; }
.toast-time { grid-column: 2; font-size: 10px; color: var(--text-3); margin-top: 4px; font-family: var(--font-mono); }

/* ================= Popovers (status, notifications, profile menu) ================= */
.tb-popover {
  background: var(--bg-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: popIn 150ms var(--ease);
  color: var(--text-0);
}
@keyframes popIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.tb-popover .panel-header { min-height: 42px; }
.tb-popover .panel-body { padding: 6px; gap: 2px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 34px; padding: 0 10px;
  background: transparent; border: none; border-radius: var(--radius-sm);
  color: var(--text-1); font-size: 12.5px; font-weight: 500; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--bg-3); color: var(--text-0); }
.menu-item.active { background: var(--accent-soft); color: var(--text-0); }
.menu-item .mi-ico { display: flex; color: var(--text-2); }
.menu-item .mi-ico svg { width: 15px; height: 15px; }
.menu-item .mi-right { margin-left: auto; font-size: 11px; color: var(--text-3); }
.menu-item.danger { color: var(--danger-strong); }
.menu-item.danger .mi-ico { color: var(--danger-strong); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; background: var(--border-soft); margin: 4px 2px; }
.menu-head { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); display: flex; gap: 10px; align-items: center; }

/* Notification center rows */
.notif-list { max-height: 420px; overflow-y: auto; padding: 4px; }
.notif-item { display: flex; gap: 11px; align-items: flex-start; padding: 10px; border-radius: var(--radius); }
.notif-item.clickable { cursor: pointer; }
.notif-item:hover { background: var(--bg-3); }
.notif-item.unread { background: rgba(203, 152, 7, 0.05); }
.notif-ico { width: 30px; height: 30px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); background: var(--info-soft); color: var(--info-strong); }
.notif-ico svg { width: 15px; height: 15px; }
.notif-ico.t-danger { background: var(--danger-soft); color: var(--danger-strong); }
.notif-ico.t-warn { background: var(--warn-soft); color: var(--warn-strong); }
.notif-ico.t-good { background: var(--good-soft); color: var(--good-strong); }
.notif-ico.t-neutral { background: var(--neutral-soft); color: var(--text-1); }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 12.5px; font-weight: 600; color: var(--text-0); }
.notif-msg { font-size: 11.5px; color: var(--text-2); margin-top: 2px; line-height: 1.4; }
.notif-time { font-size: 10px; color: var(--text-3); font-family: var(--font-mono); white-space: nowrap; }
.notif-unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex: none; }

/* ================= Global search dropdown ================= */
.gsearch-drop {
  position: absolute; top: calc(100% + 8px); left: 0;
  width: max(100%, 560px); max-height: min(560px, 70vh);
  display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  overflow: hidden; z-index: 60;
  animation: popIn 150ms var(--ease);
}
.gsearch-scopes { display: flex; gap: 4px; flex-wrap: wrap; padding: 10px 10px 8px; border-bottom: 1px solid var(--border-soft); }
.gs-scope {
  height: 24px; padding: 0 9px; border-radius: 12px;
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text-2);
  font-size: 11px; font-weight: 600; cursor: pointer;
}
.gs-scope:hover { color: var(--text-0); }
.gs-scope.active { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-strong); }
.cmdk-results { overflow-y: auto; padding: 6px; }
.cmdk-group-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px 5px; font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3);
}
.cmdk-item { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--radius); cursor: pointer; }
.cmdk-item.active { background: var(--bg-3); box-shadow: inset 2px 0 0 var(--accent); }
.cmdk-item-icon {
  width: 30px; height: 30px; flex: none; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); background: var(--bg-3); border: 1px solid var(--border); color: var(--text-2);
}
.cmdk-item.active .cmdk-item-icon { color: var(--accent-strong); border-color: var(--accent-border); }
.cmdk-item-icon svg { width: 15px; height: 15px; }
.cmdk-item-main { flex: 1; min-width: 0; }
.cmdk-item-title { font-size: 12.8px; color: var(--text-0); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item-sub { font-size: 11.2px; color: var(--text-2); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item-flag { flex: none; }
.cmdk-empty { padding: 28px 14px; text-align: center; color: var(--text-2); font-size: 12px; }
.cmdk-footer {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 12px; border-top: 1px solid var(--border-soft);
  font-size: 10.5px; color: var(--text-3);
}
.cmdk-footer .kbd { margin-right: 4px; }
.cmdk-loading { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 11.5px; color: var(--text-2); }
#cmdk-root { display: none; }

/* ================= Misc ================= */
.divider-line { height: 1px; background: var(--border-soft); margin: 14px 0; border: none; }
.kv-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; padding: 7px 0; border-bottom: 1px solid var(--border-soft); }
.kv-row:last-child { border-bottom: none; }
.kv-row .k { color: var(--text-2); }
.loading-spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .7s linear infinite; display: inline-block; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--bg-3) 0%, var(--bg-4) 50%, var(--bg-3) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: var(--radius-xs); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Compact tables (MDT Settings toggle) */
body.compact-tables .data-table thead th { padding-top: 7px; padding-bottom: 7px; }
body.compact-tables .data-table tbody td { padding: 6px 14px; font-size: 12px; }

/* Keyboard shortcuts help (press ?) */
.shortcuts-grid { display: flex; flex-direction: column; }
.shortcuts-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 2px; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; color: var(--text-1); }
.shortcuts-row:last-child { border-bottom: none; }
.shortcuts-row .keybind-chip { flex-shrink: 0; }

/* ================= Responsive ================= */
@media (max-width: 1440px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .info-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1320px) {
  .profile-columns { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .stat-card .stat-value { font-size: 22px; }
  .profile-photo { width: 76px; height: 90px; }
  #persons-clear-mugshot-btn { width: 76px; }
  .profile-name { font-size: 18px; }
  .modal-box.wide { width: 700px; }
}

/* Legacy modal forms use bare <label>s inside .modal-body.panel-body */
.modal-body.panel-body { gap: 7px; }
.modal-body > label, .modal-body label:not(.switch):not(.check) {
  font-size: 11px; font-weight: 600; color: var(--text-1); letter-spacing: .2px; margin-top: 4px;
}
.modal-body .form-section-title:first-child, .modal-body #rf-referrals:empty + .form-section-title { margin-top: 0; }
@media (max-width: 1320px) {
  .data-table thead th, .data-table tbody td { padding-left: 10px; padding-right: 10px; }
  .data-table { font-size: 12px; }
}
