/* =============================================================
 *  TASK FORCE WARANGAL — app.css
 *  Mobile-first, React-style, dark navy + brand red
 *  CRITICAL: bottom nav + content padding ensures NO overlap
 * ============================================================= */

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

:root {
  --bg:        #f3f4f6;
  --surface:   #ffffff;
  --ink:       #0b1220;
  --ink-2:     #1f2937;
  --muted:     #64748b;
  --muted-2:   #94a3b8;
  --line:      #e5e7eb;
  --line-2:    #f1f5f9;

  --brand:     #1e3a8a;       /* navy */
  --brand-2:   #2563eb;       /* royal blue */
  --accent:    #dc2626;       /* police red */
  --accent-2:  #f59e0b;       /* gold/amber */
  --success:   #059669;
  --warn:      #ea580c;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow:    0 4px 14px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 30px rgba(15, 23, 42, .14);

  --radius-sm: 10px;
  --radius:    14px;
  --radius-lg: 20px;

  /* CRITICAL layout numbers — used everywhere */
  --header-h:    56px;
  --bottomnav-h: 64px;
  --aibar-h:     58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont,
               'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-size: 14.5px;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; outline: none; }
img { max-width: 100%; display: block; }

/* =============================================================
 *  APP SHELL
 * ============================================================= */
.app {
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  /* CRITICAL: padding so bottom nav + AI bar never cover content */
  padding-bottom: calc(var(--bottomnav-h) + var(--aibar-h) + var(--safe-bottom) + 12px);
}
@media (min-width: 481px) {
  .app {
    box-shadow: 0 0 50px rgba(15, 23, 42, .08);
  }
}

/* =============================================================
 *  HEADER (sticky)
 * ============================================================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: linear-gradient(135deg, #0b1220 0%, #1e3a8a 100%);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  box-shadow: 0 1px 0 rgba(255,255,255,.05), var(--shadow);
}
.app-header .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent) 0%, #b91c1c 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.18);
  overflow: hidden;
}
.app-header .logo.has-img{
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.app-header .logo img{
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.app-header .ttl {
  flex: 1; min-width: 0;
}
.app-header .ttl h1 {
  font-size: 15px; font-weight: 700; color: #fff; margin: 0;
  letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-header .ttl p {
  font-size: 11px; color: rgba(255,255,255,.55); margin: 1px 0 0;
  font-weight: 500;
}
.app-header .iconbtn {
  width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.85);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; transition: .15s;
}
.app-header .iconbtn:active { background: rgba(255,255,255,.18); transform: scale(.94); }

/* sub-header (page title bar) */
.subhead {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 16px 12px;
}
.subhead h2 { font-size: 18px; font-weight: 800; margin: 0; letter-spacing: -.01em; }
.subhead p  { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

/* =============================================================
 *  HOME GRID (Rowdies / Suspects / Trouble / Hotels / Analytics)
 * ============================================================= */
.home-hero {
  margin: 14px;
  padding: 18px 18px 16px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(220, 38, 38, .25), transparent 50%),
    linear-gradient(135deg, #0b1220 0%, #1e3a8a 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.home-hero::after {
  content: ''; position: absolute; right: -40px; top: -40px;
  width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 158, 11, .25), transparent 70%);
}
.home-hero h3 { margin: 0 0 4px; font-size: 13px; opacity: .65; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.home-hero h2 { margin: 0; font-size: 20px; font-weight: 800; line-height: 1.2; }
.home-hero .stats { display: flex; gap: 10px; margin-top: 14px; }
.home-hero .stat {
  flex: 1; padding: 10px 12px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px; backdrop-filter: blur(8px);
}
.home-hero .stat b { display: block; font-size: 18px; font-weight: 800; }
.home-hero .stat span { font-size: 10px; opacity: .7; text-transform: uppercase; letter-spacing: .05em; }

.home-grid {
  margin: 4px 14px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tile {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 14px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  position: relative;
  transition: .18s ease;
  min-height: 120px;
}
.tile:active { transform: scale(.97); }
.tile .ic {
  width: 40px; height: 40px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.tile.rowdy   .ic { background: #fef2f2; color: #dc2626; }
.tile.suspect .ic { background: #fff7ed; color: #ea580c; }
.tile.trouble .ic { background: #faf5ff; color: #7c3aed; }
.tile.cdr     .ic { background: #f0fdf4; color: #15803d; }
.tile.hotel   .ic { background: #ecfeff; color: #0891b2; }
.tile.analytics .ic { background: #f0fdf4; color: #16a34a; }
.tile.users   .ic { background: #eff6ff; color: #2563eb; }
.tile.counseling .ic { background: #ecfdf5; color: #059669; }
.tile.counseling-admin .ic { background: #f0fdf4; color: #166534; }
.tile h4 { margin: 0; font-size: 14px; font-weight: 700; }
.tile p  { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.35; }
.tile .count {
  position: absolute; top: 14px; right: 14px;
  font-size: 13px; font-weight: 800; color: var(--ink);
  background: var(--line-2); padding: 2px 9px; border-radius: 99px;
}

/* Home divider between main tiles and admin section */
.home-divider {
  margin: 10px 14px 8px;
  display: flex; align-items: center; gap: 10px;
}
.home-divider span {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
  white-space: nowrap;
}
.home-divider::before, .home-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.home-grid-bottom { margin-top: 0; }

/* =============================================================
 *  CARDS LIST (records / hotel guests)
 * ============================================================= */
.list-wrap { padding: 0 12px; }

.list-toolbar {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px 4px;
  flex-wrap: wrap;
}
.tabs {
  display: flex; gap: 6px; padding: 6px 12px 10px;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0;
  padding: 7px 14px;
  font-size: 12.5px; font-weight: 600;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  white-space: nowrap;
  transition: .15s;
}
.tab.on {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.search-wrap {
  position: relative;
  margin: 8px 12px 6px;
}
.search-wrap input {
  width: 100%;
  height: 42px;
  padding: 0 14px 0 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14px;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.search-wrap input:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.search-wrap .ico {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 15px;
}

/* Date range filter (hotels) */
.hh-filter-bar{
  background:rgba(255,255,255,.18); color:#fff;
  border:1px solid rgba(255,255,255,.3); border-radius:99px;
  padding:5px 12px; font-size:12px; display:inline-flex; align-items:center;
  gap:6px; margin:6px 0 4px; backdrop-filter: blur(6px);
}
.hh-filter-bar i{ color:#fbbf24; }
.hh-filter-bar strong{ color:#fff; font-weight:700; }
.date-filter{ padding: 4px 12px 6px; }
.dr-row{ display:flex; gap:6px; align-items:flex-end; flex-wrap:wrap; }
.dr-col{ flex:1; min-width:120px; display:flex; flex-direction:column; gap:3px; }
.dr-col label{ font-size:10.5px; font-weight:700; color:var(--muted); letter-spacing:.3px; }
.dr-col label i{ color:var(--brand-2); margin-right:3px; }
.dr-col input[type=date]{
  height:36px; padding:0 8px; font-size:12.5px;
  border:1px solid var(--line); border-radius:8px;
  background:var(--surface); color:var(--ink); font-family:inherit;
  width:100%;
}
.dr-col input[type=date]:focus{ outline:none; border-color:var(--brand-2); box-shadow:0 0 0 3px rgba(37,99,235,.12); }
.dr-btn{
  height:36px; padding:0 12px; border:0; border-radius:8px;
  background:var(--brand); color:#fff; font-size:12px; font-weight:700;
  cursor:pointer; display:inline-flex; align-items:center; gap:5px;
}
.dr-btn:active{ transform:scale(.96); }
.dr-clear{
  height:36px; width:36px; border-radius:8px; background:#fee2e2; color:#dc2626;
  display:inline-flex; align-items:center; justify-content:center;
  text-decoration:none; border:1px solid #fecaca; font-size:13px;
}
.dr-presets{ display:flex; gap:5px; flex-wrap:wrap; margin-top:6px; }
.dr-chip{
  font-size:11px; font-weight:600; padding:4px 10px; border-radius:99px;
  background:#f1f5f9; color:#475569; border:1px solid #e2e8f0;
  text-decoration:none; transition: background .12s;
}
.dr-chip:hover{ background:#e2e8f0; }
.dr-chip.on{ background:var(--brand); color:#fff; border-color:var(--brand); }

/* action buttons row (CSV / PDF / View All) — the bug area */
.action-row {
  display: flex; gap: 8px; padding: 6px 12px 10px;
  flex-wrap: wrap;
}
.btn {
  flex: 1; min-width: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2);
  font-size: 12.5px; font-weight: 600;
  transition: .15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(.96); }
.btn i { font-size: 14px; }
.btn.csv     { color: #059669; border-color: #d1fae5; background: #f0fdf4; }
.btn.pdf     { color: #dc2626; border-color: #fecaca; background: #fef2f2; }
.btn.view    { color: #2563eb; border-color: #dbeafe; background: #eff6ff; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.danger  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.ghost   { background: transparent; color: var(--muted); border-color: var(--line); }
.btn.full    { flex: 1 1 100%; }

/* record card */
.rec-card {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 14px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 0 12px 10px;
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: .15s;
}
.rec-card:active { transform: scale(.99); background: #fafbff; }
.rec-sno {
  position: absolute; top: 4px; left: 8px;
  font-size: 9.5px; font-weight: 800; color: #64748b;
  font-family: ui-monospace, monospace;
  background: #fff; border: 1px solid #cbd5e1;
  padding: 1px 6px; border-radius: 4px;
  letter-spacing: .3px; line-height: 1.4;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
  z-index: 2;
}
.rec-card .avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(135deg, #dbeafe, #c7d2fe);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
  overflow: hidden;
}
.rec-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.rec-card .body { flex: 1; min-width: 0; }
.rec-card .body h5 {
  font-size: 14px; font-weight: 700; margin: 0 0 2px;
  color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rec-card .body p {
  font-size: 11.5px; color: var(--muted); margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rec-card .meta {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  flex-shrink: 0;
}
.badge {
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 99px;
  letter-spacing: .02em;
}
.badge.zone-c { background: #eff6ff; color: #1d4ed8; }
.badge.zone-e { background: #f0fdf4; color: #15803d; }
.badge.zone-w { background: #fef3c7; color: #b45309; }
.badge.cat-rowdy   { background: #fee2e2; color: #b91c1c; }
.badge.cat-suspect { background: #ffedd5; color: #c2410c; }
.badge.cat-trouble { background: #ede9fe; color: #6d28d9; }
.badge.cat-cdr     { background: #dcfce7; color: #15803d; }

.empty {
  text-align: center; padding: 50px 20px; color: var(--muted);
}
.empty i { font-size: 40px; opacity: .3; }
.empty p { margin: 12px 0 0; font-size: 13px; }

/* =============================================================
 *  FORMS
 * ============================================================= */
.form {
  background: var(--surface);
  margin: 12px;
  padding: 18px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.form .row { margin-bottom: 14px; }
.form label {
  display: block; font-size: 12px; font-weight: 600; color: var(--ink-2);
  margin-bottom: 6px; letter-spacing: .01em;
}
.form input[type=text], .form input[type=tel], .form input[type=number],
.form input[type=password], .form input[type=email], .form input[type=date],
.form input[type=datetime-local], .form select, .form textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fafbfc;
  font-size: 14px;
  color: var(--ink);
  transition: .15s;
}
.form input:focus, .form select:focus, .form textarea:focus {
  border-color: var(--brand-2);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.form textarea { min-height: 80px; resize: vertical; }
.form .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .actions { display: flex; gap: 8px; margin-top: 18px; }

.file-pick {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fafbfc;
}
.file-pick .preview {
  width: 50px; height: 50px; border-radius: 10px;
  background: var(--line-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 18px;
  overflow: hidden; flex-shrink: 0;
}
.file-pick .preview img { width: 100%; height: 100%; object-fit: cover; }
.file-pick label {
  font-size: 12px; color: var(--brand-2); font-weight: 600;
  cursor: pointer; margin: 0;
}
.file-pick input[type=file] { display: none; }
.file-pick small { display: block; color: var(--muted); margin-top: 2px; font-size: 11px; }

/* =============================================================
 *  ANALYTICS
 * ============================================================= */
.kpi-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 12px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.kpi .lbl { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .val { font-size: 24px; font-weight: 800; margin-top: 4px; color: var(--ink); }
.kpi .delta { font-size: 11px; font-weight: 600; margin-top: 2px; color: var(--success); }

.chart-card {
  margin: 12px; padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.chart-card h4 { font-size: 14px; margin: 0 0 12px; font-weight: 700; }
.chart-card canvas { max-width: 100% !important; }

/* =============================================================
 *  FAB
 * ============================================================= */
.fab {
  position: fixed;
  right: 18px;
  /* CRITICAL: sits above bottom nav + AI bar */
  bottom: calc(var(--bottomnav-h) + var(--aibar-h) + var(--safe-bottom) + 14px);
  width: 54px; height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #b91c1c);
  color: #fff;
  border: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 8px 24px rgba(220, 38, 38, .35);
  z-index: 30;
  transition: .2s;
}
.fab:active { transform: scale(.92); }
@media (min-width: 481px) {
  .fab { right: calc(50% - 240px + 18px); }
}

/* =============================================================
 *  AI SEARCH BAR  (sits ABOVE bottom nav — properly stacked)
 * ============================================================= */
.ai-bar {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--bottomnav-h) + var(--safe-bottom));
  height: var(--aibar-h);
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 8px 12px;
  z-index: 110;
  box-shadow: 0 -2px 12px rgba(15, 23, 42, .04);
}
@media (min-width: 481px) {
  .ai-bar { left: 50%; transform: translateX(-50%); width: 480px; }
}
.ai-bar .input {
  flex: 1; position: relative;
}
.ai-bar input {
  width: 100%;
  height: 42px;
  padding: 0 50px 0 38px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: #f8fafc;
  font-size: 13.5px;
  color: var(--ink);
}
.ai-bar input:focus {
  border-color: var(--brand-2);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}
.ai-bar .ico {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  font-size: 14px;
  background: linear-gradient(135deg, var(--brand-2), #6366f1);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.ai-bar .send {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-2), #4f46e5);
  color: #fff;
  border: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, .35);
}
.ai-bar .send:active { transform: translateY(-50%) scale(.92); }

/* =============================================================
 *  BOTTOM NAVIGATION (CRITICAL — fixed, with safe-area)
 * ============================================================= */
.bottom-nav {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  height: calc(var(--bottomnav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 120;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, .06);
}
@media (min-width: 481px) {
  .bottom-nav { left: 50%; transform: translateX(-50%); width: 480px; }
}
.bottom-nav a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 10.5px; font-weight: 600;
  transition: .15s;
}
.bottom-nav a i { font-size: 19px; }
.bottom-nav a.on { color: var(--brand-2); }
.bottom-nav a.on i { transform: translateY(-1px); }
.bottom-nav a:active { transform: scale(.94); }

/* =============================================================
 *  AI RESULT MODAL / BOTTOM SHEET
 *  Sits ABOVE the AI bar + bottom nav so they remain visible
 * ============================================================= */
.sheet-bg {
  position: fixed; left:0; right:0; top:0;
  bottom: calc(var(--bottomnav-h) + 62px + var(--safe-bottom));
  background: rgba(15, 23, 42, .25);
  z-index: 100; display: none;
  animation: fade .2s ease;
}
.sheet-bg.on { display: block; }
.sheet {
  position: fixed; left: 0; right: 0;
  /* Bottom: sit above bottomnav (62px) + ai-bar (~58px) + safe-area */
  bottom: calc(var(--bottomnav-h) + 62px + var(--safe-bottom));
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  z-index: 101;
  max-height: calc(85vh - var(--bottomnav-h) - 62px - var(--safe-bottom));
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .25s ease;
  padding: 8px 16px 14px;
  box-shadow: 0 -8px 24px rgba(15,23,42,.18);
}
@media (min-width: 481px) {
  .sheet { left: 50%; transform: translate(-50%, 100%); width: 480px; }
  .sheet.on { transform: translate(-50%, 0); }
}
.sheet.on { transform: translateY(0); }
.sheet .grip {
  width: 40px; height: 4px; background: var(--line);
  border-radius: 99px; margin: 8px auto 14px;
}
.sheet h3 {
  margin: 0 16px 12px; font-size: 17px; font-weight: 800;
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.sheet .ai-badge {
  font-size: 9.5px; padding: 3px 8px; border-radius: 99px;
  background: linear-gradient(135deg, var(--brand-2), #6366f1);
  color: #fff; font-weight: 700; letter-spacing: .04em;
}

.ai-result {
  margin: 0 16px;
  padding: 14px;
  background: linear-gradient(135deg, #f0f7ff, #faf5ff);
  border: 1px solid #dbeafe;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
  white-space: pre-wrap;
  font-family: 'SF Mono', Menlo, monospace;
}
.ai-counts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin: 14px 16px 0;
}
.ai-counts .c {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.ai-counts .c .l { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.ai-counts .c .v { font-size: 18px; font-weight: 800; color: var(--ink); }

.ai-actions { display: flex; gap: 8px; padding: 14px 16px 0; }

/* =============================================================
 *  TOAST
 * ============================================================= */
.toast {
  position: fixed;
  top: 70px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 99px;
  font-size: 13px; font-weight: 600;
  z-index: 200;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  animation: drop .25s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--accent); }

/* =============================================================
 *  LOGIN PAGE
 * ============================================================= */
.login-screen {
  min-height: 100vh;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(220,38,38,.18), transparent 50%),
    radial-gradient(100% 80% at 100% 100%, rgba(245,158,11,.12), transparent 50%),
    linear-gradient(135deg, #0b1220 0%, #1e3a8a 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 22px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 30px 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .4);
}
.login-card .crest {
  width: 60px; height: 60px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #b91c1c);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #fff;
  margin: 0 auto 16px;
  box-shadow: 0 8px 24px rgba(220, 38, 38, .4);
}
.login-card h1 {
  font-size: 20px; font-weight: 800; text-align: center;
  margin: 0 0 4px; letter-spacing: -.01em;
}
.login-card p.tag {
  text-align: center; font-size: 12px; color: rgba(255,255,255,.6);
  margin: 0 0 24px; letter-spacing: .02em;
}
.login-card label {
  display: block; font-size: 11.5px; font-weight: 600;
  color: rgba(255,255,255,.65); margin: 14px 0 6px;
  text-transform: uppercase; letter-spacing: .04em;
}
.login-card input {
  width: 100%; padding: 12px 14px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 12px;
  color: #fff;
  font-size: 14px;
}
.login-card input:focus {
  border-color: rgba(255,255,255,.4);
  background: rgba(255,255,255,.10);
}
.login-card input::placeholder { color: rgba(255,255,255,.35); }
.login-card .btn-login {
  width: 100%; height: 46px;
  border: 0; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #b91c1c);
  color: #fff;
  font-weight: 700; font-size: 14px;
  margin-top: 22px;
  transition: .15s;
  box-shadow: 0 8px 20px rgba(220, 38, 38, .35);
}
.login-card .btn-login:active { transform: scale(.97); }
.login-err {
  margin-top: 14px; padding: 10px 12px;
  background: rgba(220, 38, 38, .15);
  border: 1px solid rgba(220, 38, 38, .35);
  border-radius: 10px;
  font-size: 12.5px; color: #fecaca;
  text-align: center;
}

/* =============================================================
 *  DETAIL VIEW
 * ============================================================= */
.detail-hero {
  margin: 12px;
  padding: 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  display: flex; gap: 14px; align-items: center;
  box-shadow: var(--shadow);
}
.detail-hero .avatar-lg {
  width: 70px; height: 70px; border-radius: 50%;
  background: rgba(255,255,255,.15);
  border: 2px solid rgba(255,255,255,.25);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800;
  flex-shrink: 0;
}
.detail-hero .avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero h2 { margin: 0; font-size: 20px; font-weight: 800; line-height: 1.2; }
.detail-hero p  { margin: 4px 0 0; font-size: 12px; opacity: .8; }
.detail-hero .tags { display: flex; gap: 6px; margin-top: 8px; }
.detail-hero .tags span {
  font-size: 10px; padding: 3px 8px; border-radius: 99px;
  background: rgba(255,255,255,.18); font-weight: 600;
}

.detail-section {
  margin: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.detail-section h4 {
  margin: 0; padding: 14px 16px;
  font-size: 13px; font-weight: 700;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  letter-spacing: .02em;
}
.detail-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-2);
  gap: 12px;
}
.detail-row:last-child { border-bottom: 0; }
.detail-row .l {
  font-size: 11px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em;
  flex-shrink: 0; min-width: 110px;
}
.detail-row .v { font-size: 13.5px; color: var(--ink-2); font-weight: 500; text-align: right; word-break: break-word; }

/* =============================================================
 *  ANIMATIONS
 * ============================================================= */
@keyframes drop  { from { transform: translate(-50%, -10px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes fade  { from { opacity: 0; } to { opacity: 1; } }

/* loading spinner */
.spin {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: rotate .7s linear infinite;
  display: inline-block;
}
.spin.dark {
  border-color: rgba(15,23,42,.15);
  border-top-color: var(--brand);
}
@keyframes rotate { to { transform: rotate(360deg); } }

/* utility */
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }

/* =============================================================
 *  AI SEARCH — ChatGPT-style conversational UI (v2)
 * ============================================================= */
.ai-thread{ display:flex; flex-direction:column; }
.ai-typing-host{ }

.ai-conv {
  display: flex; gap: 10px; padding: 10px 16px 6px;
  align-items: flex-start;
}
/* USER bubble (right side) */
.ai-conv-user{ justify-content:flex-end; }
.ai-conv-user .ai-bubble-user{
  background:linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
  color:#fff; border-radius:14px 14px 4px 14px; max-width:78%;
  border-color:#1e3a8a;
}
.ai-conv-user .ai-bubble-user .ai-text{ color:#fff; }
.ai-avatar-user{
  background:linear-gradient(135deg, #94a3b8, #64748b)!important;
  box-shadow:0 2px 8px rgba(100,116,139,.3)!important;
}

.ai-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99,102,241,.3);
}
.ai-bubble {
  flex: 1; background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border: 1px solid #ddd6fe; border-radius: 14px 14px 14px 4px;
  padding: 10px 14px; max-width:78%;
}
.ai-meta {
  font-size: 11px; font-weight: 700; color: #6366f1;
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px;
}
.ai-text {
  font-size: 14px; color: #1e293b; line-height: 1.55;
  word-wrap:break-word; overflow-wrap:break-word;
}
.ai-text strong { color: #6366f1; font-weight: 700; }
.ai-conv-user .ai-text strong{ color:#fbbf24; }

/* Typing dots */
.ai-dots{ display:inline-flex; gap:4px; align-items:center; padding:4px 0; }
.ai-dots span{
  width:7px; height:7px; border-radius:50%; background:#a78bfa;
  animation:tfBlink 1.2s infinite ease-in-out;
}
.ai-dots span:nth-child(2){ animation-delay:.18s; }
.ai-dots span:nth-child(3){ animation-delay:.36s; }
@keyframes tfBlink{ 0%,80%,100%{transform:scale(.6); opacity:.4;} 40%{transform:scale(1); opacity:1;} }

/* Typing caret */
.ai-caret{
  display:inline-block; margin-left:1px; color:#6366f1; font-weight:700;
  animation:tfCaret .9s infinite steps(1);
}
@keyframes tfCaret{ 0%,49%{ opacity:1; } 50%,100%{ opacity:0; } }

/* Fade-in for streamed items */
.ai-fadein{ animation: tfFade .25s ease-out both; }
.ai-fadein-row{ animation: tfFadeRow .22s ease-out both; }
@keyframes tfFade{ from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:none;} }
@keyframes tfFadeRow{ from{opacity:0; transform:translateX(-6px);} to{opacity:1; transform:none;} }

/* Counts grid */
.ai-counts-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 6px; padding: 8px 16px;
}
.ai-counts-grid.ai-counts-5{ grid-template-columns: repeat(5, 1fr); }
.ai-cnt {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 8px 4px; text-align: center; transition: transform .15s;
}
.ai-cnt:hover { transform: translateY(-1px); }
.ai-cnt .n {
  display: block; font-size: 20px; font-weight: 800; line-height: 1;
}
.ai-cnt .l {
  display: block; font-size: 10px; color: #64748b;
  text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; font-weight: 600;
}
.ai-cnt.rowdy   { border-top: 3px solid #dc2626; } .ai-cnt.rowdy .n   { color: #dc2626; }
.ai-cnt.suspect { border-top: 3px solid #d97706; } .ai-cnt.suspect .n { color: #d97706; }
.ai-cnt.trouble { border-top: 3px solid #7c3aed; } .ai-cnt.trouble .n { color: #7c3aed; }
.ai-cnt.cdr     { border-top: 3px solid #15803d; } .ai-cnt.cdr .n     { color: #15803d; }
.ai-cnt.hotel   { border-top: 3px solid #2563eb; } .ai-cnt.hotel .n   { color: #2563eb; }

.ai-actions {
  display: flex; gap: 8px; padding: 4px 16px 12px;
}
.ai-actions .btn { flex: 1; justify-content: center; }

/* Breakdowns (zone-wise / PS-wise / hotel-wise / commissionerate) */
.ai-break{
  margin: 8px 16px 0; padding:8px 10px;
  background:#fff; border:1px solid #e2e8f0; border-radius:12px;
}
.ai-break-h{
  font-size:11px; font-weight:800; color:#0f172a;
  letter-spacing:.4px; margin-bottom:6px; text-transform:uppercase;
  display:flex; align-items:center; gap:5px;
}
.ai-break-h i{ color:#1e3a8a; }
.ai-break-chips{ display:flex; flex-wrap:wrap; gap:5px; }
.ai-chip{
  display:inline-flex; align-items:center; gap:5px;
  background:#f1f5f9; color:#0f172a;
  padding:3px 9px; border-radius:99px;
  font-size:11px; border:1px solid #e2e8f0; font-weight:600;
}
.ai-chip b{ color:#1e3a8a; font-weight:800; font-size:11.5px; }
.ai-chip-zone{ background:#dbeafe; border-color:#93c5fd; color:#1e40af; }
.ai-chip-zone b{ color:#1e3a8a; }
.ai-chip-cmsr{ background:#fef3c7; border-color:#fde68a; color:#92400e; }
.ai-chip-cmsr b{ color:#92400e; }
.ai-chip-hotel{ background:#dbeafe; border-color:#bfdbfe; color:#1d4ed8; }
.ai-chip-hotel b{ color:#1d4ed8; }
.ai-chip-div{ background:#dcfce7; border-color:#86efac; color:#15803d; }
.ai-chip-div b{ color:#14532d; }

/* Suggestion chips panel — shown when AI bar focused */
.ai-suggest-panel{
  background:linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border:1px solid #ddd6fe; border-radius:14px;
  padding:12px; margin:10px 16px;
}
.ai-suggest-h{
  font-size:13px; font-weight:800; color:#6366f1;
  margin-bottom:8px; letter-spacing:.4px;
  display:flex; align-items:center; gap:5px;
}
.ai-suggest-h i{ color:#a78bfa; }
.ai-suggest-group{ margin-bottom:8px; }
.ai-suggest-group:last-child{ margin-bottom:0; }
.ai-suggest-label{
  font-size:10.5px; font-weight:700; color:#64748b;
  text-transform:uppercase; letter-spacing:.5px;
  margin-bottom:4px;
}
.ai-suggest-chips{ display:flex; flex-wrap:wrap; gap:5px; }
.ai-sug-chip{
  background:#fff; color:#0f172a;
  border:1px solid #e2e8f0; border-radius:99px;
  padding:6px 12px; font-size:12px; font-weight:600;
  cursor:pointer; font-family:inherit;
  transition: all .12s;
  display:inline-flex; align-items:center; gap:4px;
}
.ai-sug-chip:hover{
  background:#1e3a8a; color:#fff; border-color:#1e3a8a;
  transform:translateY(-1px);
}
.ai-sug-chip:active{ transform:scale(.97); }
.ai-sug-div{ border-color:#86efac; background:#f0fdf4; color:#15803d; }
.ai-sug-div:hover{ background:#15803d; color:#fff; border-color:#15803d; }
.ai-sug-ps{ border-color:#fca5a5; background:#fef2f2; color:#dc2626; }
.ai-sug-ps:hover{ background:#dc2626; color:#fff; border-color:#dc2626; }
.ai-sug-hotel{ border-color:#bfdbfe; background:#eff6ff; color:#1d4ed8; }
.ai-sug-hotel:hover{ background:#1d4ed8; color:#fff; border-color:#1d4ed8; }

/* Clickable PS chips */
.ai-chip-clickable{
  cursor:pointer; transition: all .12s; font-family: inherit;
  position:relative; padding-right:22px;
}
.ai-chip-clickable::after{
  content:'›'; position:absolute; right:8px; top:50%; transform:translateY(-50%);
  font-size:14px; font-weight:800; color:#1e3a8a; line-height:1;
}
.ai-chip-clickable:hover{ background:#dbeafe; border-color:#60a5fa; color:#1e40af; transform:translateY(-1px); }
.ai-chip-clickable:active{ transform:scale(.97); }

/* PS filter panel (expanded records when chip is clicked) */
.ai-ps-filter-panel{
  background:#fff; border:2px solid #1e3a8a; border-radius:12px;
  margin: 10px 16px; box-shadow: 0 4px 16px rgba(30,58,138,.18);
}
.ai-ps-filter-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 14px; background:linear-gradient(135deg,#1e3a8a,#3b82f6);
  color:#fff; border-radius:10px 10px 0 0;
}
.ai-ps-filter-title{
  font-size:14px; font-weight:800; display:flex; align-items:center; gap:6px;
}
.ai-ps-filter-title i{ color:#fbbf24; }
.ai-ps-filter-close{
  background:rgba(255,255,255,.2); color:#fff; border:0;
  width:28px; height:28px; border-radius:6px; cursor:pointer;
  display:flex; align-items:center; justify-content:center; font-size:14px;
  transition: background .12s;
}
.ai-ps-filter-close:hover{ background:rgba(255,255,255,.35); }
.ai-ps-cat-head{
  padding:8px 14px; font-size:12px; font-weight:800;
  background:#f8fafc; border-bottom:1px solid #e2e8f0;
  letter-spacing:.4px;
}
.ai-ps-list{ }
.ai-ps-list .ai-item{ padding:10px 14px; }

/* Grouped result sections */
.ai-group {
  background: #fff; margin: 8px 16px;
  border: 1px solid #e2e8f0; border-left:3px solid #6366f1;
  border-radius: 12px;
  overflow: hidden;
}
.ai-group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: #f8fafc;
  font-size: 13px; font-weight: 700;
  border-bottom: 1px solid #e2e8f0;
}
.ai-grp-icon { font-size: 16px; }
.ai-grp-name { flex: 1; }
.ai-grp-count {
  background: #fff; border: 1px solid #e2e8f0;
  padding: 2px 8px; border-radius: 10px;
  font-size: 11px; color: #64748b; font-weight: 600;
}
.ai-grp-actions{ display:flex; gap:4px; }
.ai-grp-btn{
  background:#fff; border:1px solid #e2e8f0;
  width:28px; height:26px; border-radius:6px;
  font-size:13px; cursor:pointer; color:#0f172a;
  display:inline-flex; align-items:center; justify-content:center;
  transition: background .12s, transform .1s;
}
.ai-grp-btn:hover{ background:#f1f5f9; }
.ai-grp-btn:active{ transform:scale(.94); }

.ai-grp-list { padding: 4px 0; }

.ai-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; text-decoration: none; color: #0f172a;
  border-bottom: 1px solid #f1f5f9; transition: background .12s;
  position:relative;
}
.ai-sno{
  position:absolute; top:6px; right:30px;
  font-size:10px; font-weight:800; color:#94a3b8;
  font-family: ui-monospace, monospace;
  background:#f8fafc; border:1px solid #e2e8f0;
  padding:2px 6px; border-radius:4px;
}
.ai-item:last-child { border-bottom: 0; }
.ai-item:hover { background: #f8fafc; }
.ai-photo {
  width: 44px; height: 44px; border-radius: 10px;
  overflow: hidden; flex-shrink: 0; background: #e0e7ff;
}
.ai-photo img { width: 100%; height: 100%; object-fit: cover; }
.ai-init {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #6366f1;
}
.ai-body { flex: 1; min-width: 0; }
.ai-row1 {
  display: flex; align-items: center; gap: 8px; margin-bottom: 2px;
}
.ai-name {
  flex: 1; font-size: 14px; font-weight: 700; color: #0f172a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-ref {
  font-size: 10px; color: #64748b; font-family: ui-monospace, monospace;
  background: #f1f5f9; padding: 2px 6px; border-radius: 4px; flex-shrink: 0;
}
.ai-row2 { font-size: 12px; color: #475569; margin-bottom: 1px; }
.ai-row3 { font-size: 11px; color: #64748b; }
.ai-addr {
  font-size: 11px; color: #94a3b8; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-addr i { color: #cbd5e1; margin-right: 2px; }
/* Counseling dates row in AI search cards */
.ai-csl-row {
  font-size: 10.5px; color: #059669; margin-top: 3px;
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  font-weight: 600;
}
.ai-csl-row i { font-size: 11px; color: #059669; }
.ai-arrow { color: #cbd5e1; font-size: 14px; flex-shrink: 0; }
