/* MW Sheriff Dashboard — Dark Theme */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --teal:    #2A9D8F;
  --navy:    #000000;
  --green:   #1D9E75;
  --green-b: #0F6E56;
  --red:     #E24B4A;
  --red-b:   #A32D2D;
  --orange:  #E76F00;
  --amber:   #F59E0B;
  --purple:  #7C3AED;
  --bg:      #0a0a0a;
  --card:    #141414;
  --border:  #252525;
  --text:    #e8e8e8;
  --muted:   #888888;
  --radius:  8px;
}

html, body {
  min-height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
}

.text-green { color: var(--green); }
.text-red   { color: var(--red); }

/* ── Header Band ──────────────────────────────────────────── */
.header-band {
  background: var(--navy); color: #fff; padding: 10px 28px;
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
}
.header-logo { height: 100%; max-height: 78px; }
.header-brand {
  font-size: 14px; font-weight: 700; letter-spacing: 3px; color: var(--teal);
}
.header-center { text-align: center; }
.header-county { font-size: 20px; font-weight: 600; }
.header-contact { font-size: 12px; color: rgba(255,255,255,0.65); margin-top: 2px; }
.header-right { text-align: right; }
.header-date { font-size: 12px; color: rgba(255,255,255,0.65); }
.header-nav { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.header-nav-link {
  font-size: 12px; color: rgba(255,255,255,0.5); text-decoration: none;
  padding: 3px 8px; border-radius: 4px;
}
.header-nav-link:hover { color: #fff; }
.header-nav-link.active { color: #fff; background: rgba(255,255,255,0.1); }
.header-logout { font-size: 12px; color: rgba(255,255,255,0.5); text-decoration: none; }
.header-logout:hover { color: #fff; }

/* ── Dashboard Container ──────────────────────────────────── */
.dashboard {
  max-width: 1200px; margin: 0 auto; padding: 28px 24px;
}

/* ── Sections ─────────────────────────────────────────────── */
.section {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 28px; margin-bottom: 20px;
}
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.section-title {
  font-size: 16px; font-weight: 600; color: var(--text);
  border-left: 3px solid var(--teal); padding-left: 12px;
}
h2.section-title { margin-bottom: 16px; }
.section-header h2.section-title { margin-bottom: 0; }

/* ── KPI Cards ────────────────────────────────────────────── */
.kpi-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}
.kpi-card {
  text-align: center; padding: 20px 12px;
  background: var(--bg); border-radius: var(--radius);
}
.kpi-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); margin-bottom: 6px;
}
.kpi-value { font-size: 32px; font-weight: 500; color: var(--text); }
.kpi-of { font-size: 16px; font-weight: 400; color: var(--muted); }
.kpi-context { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Chart Legend ─────────────────────────────────────────── */
.chart-legend {
  display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; font-size: 12px; color: var(--muted);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-line { width: 24px; height: 3px; border-radius: 2px; display: inline-block; }
.legend-dashed { background: repeating-linear-gradient(90deg, var(--orange) 0 6px, transparent 6px 10px) !important; }
.legend-box { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }

/* ── Range Buttons ────────────────────────────────────────── */
.range-buttons { display: flex; gap: 4px; }
.range-btn {
  padding: 4px 12px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--card); color: var(--muted); font-size: 12px; font-weight: 500;
  cursor: pointer;
}
.range-btn.active { background: var(--teal); color: #fff; border-color: var(--teal); }

/* ── Pipeline Bars ────────────────────────────────────────── */
.pipeline-bars { margin-bottom: 16px; }
.pipeline-row {
  display: flex; align-items: center; gap: 16px; margin-bottom: 12px;
}
.pipeline-label { flex: 0 0 360px; }
.pipeline-stage {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 4px; color: #fff; margin-right: 8px;
}
.stage1 { background: var(--teal); }
.stage2 { background: var(--amber); }
.stage3 { background: var(--red); }
.pipeline-desc { font-size: 12px; color: var(--muted); }
.pipeline-bar-wrap {
  flex: 1; height: 28px; background: var(--bg); border-radius: 4px;
  position: relative; overflow: hidden;
}
.pipeline-bar {
  height: 100%; border-radius: 4px; transition: width 0.6s ease;
}
.stage1-bg { background: var(--teal); }
.stage2-bg { background: var(--amber); }
.stage3-bg { background: var(--red); }
.pipeline-count {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 13px; font-weight: 600; color: var(--text);
}
.pipeline-callout {
  background: rgba(42,157,143,0.1); border: 1px solid rgba(42,157,143,0.3); border-radius: var(--radius);
  padding: 14px 18px; font-size: 14px; color: var(--teal);
}

/* ── Mail Grid ────────────────────────────────────────────── */
.mail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.mail-col h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.mail-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--bg); }
.mail-label { font-size: 13px; color: var(--text); }
.mail-val { font-size: 13px; font-weight: 600; }
.mail-callout {
  background: rgba(231,111,0,0.1); border: 1px solid rgba(231,111,0,0.3); border-radius: 6px;
  padding: 10px 14px; font-size: 12px; color: var(--orange); margin-top: 12px;
}

/* ── Field Activity ───────────────────────────────────────── */
.field-layout { display: grid; grid-template-columns: 240px 1fr 220px; gap: 20px; }
.field-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-card {
  background: var(--bg); border-radius: var(--radius); padding: 16px; text-align: center;
}
.field-val { font-size: 24px; font-weight: 600; color: var(--text); }
.field-label { font-size: 11px; color: var(--muted); text-transform: uppercase; margin-top: 4px; }

/* Leaderboard */
.field-leaderboard h3 {
  font-size: 13px; font-weight: 600; text-transform: uppercase; color: var(--muted);
  margin-bottom: 12px;
}
.leaderboard-list { }
.leaderboard-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--bg);
}
.leaderboard-rank {
  width: 22px; height: 22px; border-radius: 50%; background: var(--bg);
  font-size: 11px; font-weight: 700; color: var(--muted);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.leaderboard-rank.top { background: var(--teal); color: #fff; }
.leaderboard-dot {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.15);
}
.leaderboard-name { font-size: 13px; font-weight: 500; flex: 1; }
.leaderboard-count { font-size: 14px; font-weight: 700; color: var(--text); }

/* ── Activity Feed ────────────────────────────────────────── */
.feed-list { max-height: 400px; overflow-y: auto; }
.feed-date {
  font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  padding: 8px 0 4px; border-bottom: 1px solid var(--border); margin-top: 8px;
}
.feed-item {
  padding: 6px 0; font-size: 13px; color: var(--text); border-bottom: 1px solid var(--bg);
}
.feed-badge {
  display: inline-block; font-size: 10px; font-weight: 600; padding: 1px 6px;
  border-radius: 3px; margin-right: 6px;
}
.feed-badge-green { background: rgba(29,158,117,0.2); color: var(--green); }
.feed-badge-red   { background: rgba(226,75,74,0.2); color: var(--red); }
.feed-badge-blue  { background: rgba(42,157,143,0.2); color: var(--teal); }
.feed-badge-gray  { background: rgba(255,255,255,0.08); color: var(--muted); }
.feed-loading { color: var(--muted); font-size: 13px; padding: 12px 0; }

/* ── Ranking ──────────────────────────────────────────────── */
.ranking-summary {
  font-size: 15px; color: var(--text); margin-bottom: 16px;
}
.ranking-summary strong { color: var(--teal); }

/* ── Login ────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-box {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 40px 44px; width: 380px; text-align: center;
}
.login-logo { height: 48px; margin-bottom: 8px; }
.login-brand {
  font-size: 16px; font-weight: 700; letter-spacing: 3px; color: var(--navy); margin-bottom: 4px;
}
.login-subtitle { color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.login-footer { color: var(--muted); font-size: 11px; margin-top: 20px; }
.form-group { margin-bottom: 16px; text-align: left; }
.form-group label {
  font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  display: block; margin-bottom: 6px;
}
.form-group input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; background: var(--card); color: var(--text);
}
.form-group input:focus { outline: none; border-color: var(--teal); }
.error-msg {
  background: rgba(226,75,74,0.1); color: var(--red); border: 1px solid rgba(226,75,74,0.3);
  border-radius: 6px; padding: 10px; margin-bottom: 16px; font-size: 13px;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  padding: 10px 24px; border: none; border-radius: 6px; cursor: pointer;
  font-size: 14px; font-weight: 600; transition: background 0.2s;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: #238B7E; }

/* ── Tables (users/team pages) ────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
     color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--border); }
td { padding: 8px 10px; border-bottom: 1px solid var(--bg); }
.muted { color: var(--muted); }

.section-desc { font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.count-badge {
  font-size: 11px; font-weight: 600; background: var(--bg); color: var(--muted);
  padding: 1px 8px; border-radius: 10px; margin-left: 6px;
}

.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.form-group-inline { display: flex; flex-direction: column; gap: 4px; }
.form-group-inline label {
  font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--muted);
}
.form-group-inline input {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: var(--card); color: var(--text); width: 150px;
}
.form-group-inline input:focus { outline: none; border-color: var(--teal); }

.role-badge {
  font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 3px;
  text-transform: uppercase;
}
.role-badge.deputy { background: rgba(255,255,255,0.08); color: var(--muted); }
.role-badge.sergeant { background: rgba(42,157,143,0.2); color: var(--teal); }

.status-badge {
  font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 3px;
}
.status-badge.active { background: rgba(29,158,117,0.2); color: var(--green); }
.status-badge.inactive { background: rgba(226,75,74,0.2); color: var(--red); }

.btn-sm-light {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--card); color: var(--text); font-size: 12px; cursor: pointer;
}
.btn-sm-light:hover { background: rgba(255,255,255,0.05); }
.btn-sm-light.warn { color: var(--red); border-color: var(--red); }
.btn-sm-light.warn:hover { background: rgba(226,75,74,0.1); }
.btn-sm-light.good { color: var(--green); border-color: var(--green); }
.btn-sm-light.good:hover { background: rgba(29,158,117,0.1); }

.btn-secondary {
  padding: 10px 24px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--card); color: var(--text); font-size: 14px; cursor: pointer;
}

.edit-input {
  padding: 5px 8px; border: 1px solid var(--teal); border-radius: 4px;
  font-size: 12px; background: var(--card); color: var(--text); width: 140px;
}

.alert-success {
  background: rgba(42,157,143,0.1); border: 1px solid rgba(42,157,143,0.3); border-radius: 6px;
  padding: 10px 16px; font-size: 13px; color: var(--teal); margin-bottom: 16px;
}
.alert-error {
  background: rgba(226,75,74,0.1); border: 1px solid rgba(226,75,74,0.3); border-radius: 6px;
  padding: 10px 16px; font-size: 13px; color: var(--red); margin-bottom: 16px;
}

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  z-index: 100; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 28px 32px; width: 400px; max-width: 90vw;
}
.modal-box h3 { font-size: 16px; margin-bottom: 16px; }

/* ── Print ────────────────────────────────────────────────── */
.print-footer { display: none; }

@media print {
  .no-print { display: none !important; }
  .header-logout, .header-nav { display: none; }
  body, .dashboard, .section { background: #fff !important; color: #111 !important; }
  .section { break-inside: avoid; page-break-inside: avoid; border: 1px solid #ddd !important; margin-bottom: 12px; }
  .dashboard { max-width: 100%; padding: 0 16px; }
  .page-break-before { page-break-before: always; }
  .kpi-value, .field-val, .pipeline-count { color: #111 !important; }
  .kpi-card, .field-card { background: #f5f5f5 !important; }
  canvas { max-width: 100% !important; }
  .print-footer {
    display: block; text-align: center; font-size: 11px; color: #666;
    padding: 20px 0; border-top: 1px solid #ddd; margin-top: 20px;
  }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .mail-grid { grid-template-columns: 1fr; }
  .field-layout { grid-template-columns: 1fr; }
  .pipeline-row { flex-direction: column; align-items: stretch; }
  .pipeline-label { flex: none; }
}
@media (max-width: 600px) {
  .kpi-row { grid-template-columns: 1fr; }
  .header-inner { flex-direction: column; text-align: center; }
}
