/* Makkal Nalam AI — design system (spec §10) */
:root {
  --navy: #0B2554; --navy-800: #123068; --navy-700: #1a3d7c;
  --green: #148C5A; --saffron: #F59E0B; --bg: #F8FAFC; --card: #FFFFFF;
  --red: #DC2626; --amber: #F59E0B; --success: #16A34A; --info: #2563EB;
  --ink: #0f172a; --ink-2: #475569; --ink-3: #94a3b8; --line: #e2e8f0;
  --surface-2: #f8fafc; --surface-3: #eef2f7; --heading: var(--navy);
  --radius: 12px; --shadow: 0 1px 3px rgba(15,23,42,.08);
  font-size: 15px;
}
:root[data-theme="dark"] {
  --navy: #12213f; --navy-800: #17284a; --navy-700: #1c3157; --green: #1fae74;
  --bg: #0b1220; --card: #17213a;
  --ink: #e5e7eb; --ink-2: #94a3b8; --ink-3: #64748b; --line: #2b3752;
  --surface-2: #1c2740; --surface-3: #223050; --heading: #8fb4f5;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}
:root[data-theme="red"] {
  --navy: #7f1d1d; --navy-800: #8f2323; --navy-700: #9f2b2b; --green: #dc2626;
  --bg: #fff5f5; --card: #ffffff;
  --ink: #1f1315; --ink-2: #7f4d4d; --ink-3: #b98787; --line: #f3d4d4;
  --surface-2: #fdf1f1; --surface-3: #fbe4e4; --heading: #7f1d1d;
  --shadow: 0 1px 3px rgba(127,29,29,.12);
}
:root[data-theme="green"] {
  --navy: #14532d; --navy-800: #1a663a; --navy-700: #1f7a45; --green: #16a34a;
  --bg: #f2faf4; --card: #ffffff;
  --ink: #12241a; --ink-2: #4d7a5e; --ink-3: #8fbc9f; --line: #d4ecdc;
  --surface-2: #eefaf2; --surface-3: #e0f3e6; --heading: #14532d;
  --shadow: 0 1px 3px rgba(20,83,45,.12);
}
:root[data-theme="blue"] {
  --navy: #1e3a8a; --navy-800: #24469f; --navy-700: #2a52b4; --green: #2563eb;
  --bg: #f3f7ff; --card: #ffffff;
  --ink: #131c2e; --ink-2: #4d5f7a; --ink-3: #8ea0bc; --line: #d6e2f7;
  --surface-2: #eef4ff; --surface-3: #e1ecfd; --heading: #1e3a8a;
  --shadow: 0 1px 3px rgba(30,58,138,.12);
}
:root[data-theme="purple"] {
  --navy: #4c1d95; --navy-800: #5b23ac; --navy-700: #6a29c3; --green: #7c3aed;
  --bg: #f8f5ff; --card: #ffffff;
  --ink: #1e1530; --ink-2: #6b5c8a; --ink-3: #a692c4; --line: #e4d9f7;
  --surface-2: #f6f1ff; --surface-3: #ede2fc; --heading: #4c1d95;
  --shadow: 0 1px 3px rgba(76,29,149,.12);
}
:root[data-theme="pink"] {
  --navy: #9d174d; --navy-800: #b01d59; --navy-700: #c32365; --green: #ec4899;
  --bg: #fff5f8; --card: #ffffff;
  --ink: #2c1420; --ink-2: #8a4d67; --ink-3: #c48ba3; --line: #f7d4e4;
  --surface-2: #fef1f6; --surface-3: #fce4ee; --heading: #9d174d;
  --shadow: 0 1px 3px rgba(157,23,77,.12);
}
:root[data-theme="yellow"] {
  --navy: #78350f; --navy-800: #8a3f12; --navy-700: #9c4915; --green: #d97706;
  --bg: #fffbeb; --card: #ffffff;
  --ink: #241a08; --ink-2: #8a6d3b; --ink-3: #c7a76a; --line: #f5e3b3;
  --surface-2: #fef9ec; --surface-3: #fcf0d1; --heading: #78350f;
  --shadow: 0 1px 3px rgba(120,53,15,.12);
}
* { box-sizing: border-box; margin: 0; }
body { font-family: -apple-system, 'Segoe UI', Roboto, 'Noto Sans Tamil', sans-serif;
       background: var(--bg); color: var(--ink); transition: background .2s ease, color .2s ease; }
.hidden { display: none !important; }
a { color: var(--info); text-decoration: none; }
button { font: inherit; cursor: pointer; }
.display-panel-wrap { position: fixed; bottom: 66px; right: 22px; z-index: 90; }
.theme-toggle { width: 44px; height: 44px;
  border-radius: 50%; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 19px; display:flex; align-items:center; justify-content:center; box-shadow: var(--shadow); }
.theme-toggle:hover { border-color: var(--info); }
.display-popover { position: absolute; bottom: 54px; right: 0; width: 220px; background: var(--card);
  border: 1.5px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(15,23,42,.25);
  padding: 14px; }
.dp-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-3); margin-bottom: 8px; }
.dp-section + .dp-section { margin-top: 14px; }
.dp-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.dp-swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer;
  padding: 0; }
.dp-swatch.active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--info); }
.dp-toggle-row { display: flex; gap: 8px; }
.dp-toggle-row .btn { flex: 1; justify-content: center; }
.dp-toggle-row .btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.app-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 88; height: 52px;
  background: linear-gradient(180deg, #ffffff, #eef2f8); border-top: 2px solid var(--navy);
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px; }
.app-footer img { display: block; height: 28px; width: auto; }
.footer-left { display: flex; align-items: center; gap: 10px; }
.footer-tagline { font-size: 12px; font-weight: 600; color: var(--heading); white-space: nowrap; }
.footer-right { display: flex; align-items: center; gap: 10px; }
.footer-psi { display: flex; align-items: center; }
.footer-copyright { font-size: 11px; color: #475569; white-space: nowrap; }
@media (max-width: 640px) {
  .app-footer { height: 44px; padding: 0 12px; }
  .app-footer img { height: 20px; }
  .footer-copyright { font-size: 9.5px; }
  .footer-tagline { display: none; }
}
.player-bar { position: fixed; left: 50%; bottom: 66px; transform: translateX(-50%); z-index: 91;
  display: flex; align-items: center; gap: 12px; background: var(--card); border: 1.5px solid var(--line);
  border-radius: 999px; padding: 8px 16px; box-shadow: 0 10px 30px rgba(15,23,42,.25); max-width: min(560px, 92vw); }
.player-bar #player-label { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 160px; }
.player-bar audio { height: 34px; max-width: 260px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, var(--navy) 0%, #0e3a63 55%, var(--green) 130%); padding: 24px; }
.login-card { background: var(--card); border-radius: 18px; padding: 38px 36px; width: 420px; max-width: 100%;
  box-shadow: 0 18px 50px rgba(2,12,32,.45); }
.login-card .emblem { display:flex; align-items:center; gap:12px; margin-bottom: 18px; }
.emblem-badge { width: 52px; height: 52px; border-radius: 50%; background: var(--navy);
  color: #fff; display:flex; align-items:center; justify-content:center; font-size: 26px; }
.login-card h1 { font-size: 22px; color: var(--heading); }
.login-card .ta { color: var(--green); font-size: 14px; font-weight: 600; }
.login-card .sub { color: var(--ink-2); font-size: 13px; margin: 4px 0 20px; }
.field { margin-bottom: 14px; }
.field label { display:block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 11px 12px; border: 1.5px solid var(--line);
  border-radius: 9px; font: inherit; background: var(--card); color: var(--ink); }
.field input:focus, .field textarea:focus { outline: 2px solid var(--info); border-color: transparent; }
.btn { display:inline-flex; align-items:center; gap:8px; padding: 11px 18px; border-radius: 9px;
  border: none; font-weight: 600; font-size: 14px; }
.btn-primary { background: var(--green); color: #fff; width: 100%; justify-content: center; }
.btn-primary:hover { background: #0f7048; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-ghost { background: var(--card); border: 1.5px solid var(--line); color: var(--ink-2); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-danger { background: var(--red); color: #fff; }
.demo-roles { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.demo-roles p { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.role-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.role-chip { font-size: 11.5px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-2); }
.role-chip:hover { background: var(--navy); color: #fff; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.shell.sidebar-collapsed { grid-template-columns: 1fr; }
.shell.sidebar-collapsed .sidebar { display: none; }
.shell.layout-horizontal { grid-template-columns: 1fr; }
.shell.layout-horizontal .sidebar { position: sticky; top: 0; height: auto; width: 100%;
  display: flex; flex-wrap: wrap; align-items: center; padding: 8px 16px; z-index: 40; }
.shell.layout-horizontal .sidebar .brand { border-bottom: none; border-right: 1px solid rgba(255,255,255,.15);
  margin: 0 12px 0 0; padding: 4px 16px 4px 0; }
.shell.layout-horizontal .nav-item { width: auto; margin-bottom: 0; }
.shell.layout-horizontal .nav-sep { display: none; }
.sidebar { background: var(--navy); color: #cbd5e1; padding: 18px 12px; position: sticky; top:0; height:100vh; overflow:auto; }
.sidebar .brand { display:flex; gap: 10px; align-items:center; padding: 4px 8px 16px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 14px; }
.sidebar .brand .logo { width: 38px; height: 38px; background: var(--green); border-radius: 10px;
  display:flex; align-items:center; justify-content:center; font-size: 20px; }
.sidebar .brand b { color:#fff; font-size: 14.5px; display:block; line-height: 1.15; }
.sidebar .brand small { font-size: 10.5px; color: #7f96bd; }
.nav-item { display:flex; align-items:center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  font-size: 13.5px; color: #b9c7de; margin-bottom: 2px; cursor: pointer; border: none; background: none; width: 100%; text-align:left; }
.nav-item:hover { background: var(--navy-800); color: #fff; }
.nav-item.active { background: var(--green); color: #fff; font-weight: 600; }
.nav-sep { font-size: 10.5px; letter-spacing: .08em; color: #64789e; padding: 14px 12px 6px; text-transform: uppercase; }
.main { padding: 0 26px 76px; }
.topbar { display:flex; align-items:center; justify-content: space-between; padding: 16px 0; margin-bottom: 8px; }
.topbar h2 { font-size: 20px; color: var(--heading); flex: 1; }
.topbar .who { display:flex; align-items:center; gap: 12px; font-size: 13px; color: var(--ink-2); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--green); color:#fff;
  display:flex; align-items:center; justify-content:center; font-weight: 700; }
.menu-toggle { display:inline-block; background:none; border:none; font-size: 22px; color: var(--heading); padding: 4px 10px 4px 0; cursor:pointer; }
.nav-overlay { display:none; }

/* ---------- components ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.kpi .v { font-size: 26px; font-weight: 750; color: var(--heading); letter-spacing: -0.5px; }
.kpi .l { font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.kpi.good .v { color: var(--success); } .kpi.bad .v { color: var(--red); } .kpi.warn .v { color: #b45309; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 980px){
  .shell{grid-template-columns:1fr}
  .sidebar{position:fixed; top:0; left:0; height:100vh; width:240px; z-index:60; transform:translateX(-100%); transition:transform .25s ease;}
  .shell.nav-open .sidebar{transform:translateX(0);}
  .shell.nav-open .nav-overlay{display:block; position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:50;}
  .menu-toggle{display:inline-block;}
  .grid-2,.grid-2b{grid-template-columns:1fr}
}
.card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); margin-bottom: 16px;}
.card h3 { font-size: 14.5px; color: var(--heading); margin-bottom: 12px; display:flex; justify-content:space-between; align-items:center;}
.chart-box { position: relative; height: 260px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -2px; padding: 0 2px; }
table.dt { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13px; }
table.dt th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing:.04em;
  color: var(--ink-3); padding: 8px 10px; border-bottom: 1.5px solid var(--line); }
table.dt td { padding: 9px 10px; border-bottom: 1px solid var(--surface-3); vertical-align: top; }
table.dt tr:hover td { background: var(--surface-2); }
.badge { display:inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.b-critical { background:#fee2e2; color:#b91c1c; } .b-high { background:#ffedd5; color:#c2410c; }
.b-medium { background:#fef9c3; color:#a16207; } .b-low { background:#dcfce7; color:#15803d; }
.b-positive { background:#dcfce7; color:#15803d; } .b-negative { background:#fee2e2; color:#b91c1c; }
.b-neutral { background:#e2e8f0; color:#475569; } .b-mixed { background:#fef9c3; color:#a16207; }
.b-open { background:#dbeafe; color:#1d4ed8; } .b-assigned { background:#e0e7ff; color:#4338ca; }
.b-in_progress { background:#fef9c3; color:#a16207; } .b-resolved { background:#dcfce7; color:#15803d; }
.b-closed { background:#e2e8f0; color:#475569; } .b-escalated { background:#fee2e2; color:#b91c1c; }
.b-waiting_for_response { background:#fce7f3; color:#be185d; } .b-reopened { background:#ffedd5; color:#c2410c; }
.b-exhausted { background:#fee2e2; color:#b91c1c; } .b-completed { background:#dcfce7; color:#15803d; }
.b-no_answer { background:#fef9c3; color:#a16207; } .b-busy { background:#fef9c3; color:#a16207; }
.b-failed { background:#fee2e2; color:#b91c1c; } .b-opted_out { background:#e2e8f0; color:#475569; }
.b-scheduled { background:#dbeafe; color:#1d4ed8; }
.insight { display:flex; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 10px; background: var(--surface-2); }
.insight .ic { font-size: 22px; } .insight b { font-size: 13.5px; color: var(--heading); display:block; }
.insight p { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--navy); color:#fff; padding: 13px 20px;
  border-radius: 10px; font-size: 13.5px; box-shadow: 0 8px 30px rgba(0,0,0,.35); z-index: 100; }
.filters { display:flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters select { padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--line); font-size: 13px; background: var(--card); color: var(--ink); }
.empty { text-align:center; color: var(--ink-3); padding: 40px 0; font-size: 13.5px; }
.placeholder-card { text-align:center; padding: 60px 20px; color: var(--ink-3); }
.placeholder-card .big { font-size: 40px; margin-bottom: 10px; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(2,12,32,.55); display:flex; align-items:center;
  justify-content:center; z-index: 50; padding: 20px; }
.modal { background: var(--card); border-radius: 14px; width: 720px; max-width: 100%; max-height: 88vh; overflow:auto; padding: 24px; }
.modal h3 { color: var(--heading); margin-bottom: 4px; }
.timeline { border-left: 2px solid var(--line); margin: 12px 0 12px 6px; padding-left: 16px; }
.timeline .tl { position: relative; padding-bottom: 12px; font-size: 12.5px; color: var(--ink-2); }
.timeline .tl::before { content:''; position:absolute; left: -21px; top: 4px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--green); }

/* ---------- patient chat ---------- */
.chat-wrap { min-height: 100vh; background: linear-gradient(160deg, var(--navy), #0e3a63);
  display:flex; align-items:center; justify-content:center; padding: 18px; }
.chat-card { width: 480px; max-width: 100%; background: var(--card); border-radius: 20px; overflow:hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.4); display:flex; flex-direction:column; height: 86vh; }
.chat-head { background: var(--green); color:#fff; padding: 16px 20px; display:flex; gap: 12px; align-items:center;}
.chat-head .bot { width: 42px; height: 42px; background:#fff; color: var(--green); border-radius:50%;
  display:flex; align-items:center; justify-content:center; font-size: 22px; }
.chat-head b { display:block; font-size: 15px; } .chat-head small { font-size: 11.5px; opacity:.85; }
.chat-body { flex: 1; overflow-y: auto; padding: 18px; background: var(--surface-2); }
.msg { max-width: 82%; padding: 11px 14px; border-radius: 14px; margin-bottom: 10px; font-size: 14px; line-height: 1.45; }
.msg.ai { background: var(--card); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.me { background: var(--navy); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.chat-input { display:flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--card); }
.chat-input input { flex:1; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 999px; font: inherit; }
.chat-input button { border-radius: 999px; }
.result-box { padding: 14px; background:#f0fdf4; border:1px solid #bbf7d0; border-radius: 12px; margin-top: 10px; font-size: 13.5px; }
.typing { display:inline-block; } .typing span { display:inline-block; width:7px;height:7px;border-radius:50%;
  background:#94a3b8; margin-right:3px; animation: blink 1.2s infinite; }
.typing span:nth-child(2){animation-delay:.2s} .typing span:nth-child(3){animation-delay:.4s}
@keyframes blink { 0%,80%,100%{opacity:.25} 40%{opacity:1} }
.consent-box { background:#fffbeb; border:1px solid #fde68a; padding: 14px; border-radius: 12px; font-size: 13px; color:#92400e; }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 1100px){ .kanban{grid-template-columns:repeat(2,1fr)} }
.kb-col { background: var(--surface-3); border-radius: 12px; padding: 10px; min-height: 300px; }
.kb-col h4 { font-size: 12px; text-transform: uppercase; letter-spacing:.05em; color:#475569;
  padding: 4px 6px 10px; display:flex; justify-content:space-between; }
.kb-card { background: var(--card); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(15,23,42,.06); cursor:pointer; font-size: 12.5px; }
.kb-card:hover { border-color: var(--info); }
.kb-card b { display:block; color: var(--heading); font-size: 12.5px; }
.kb-card .meta { color: #64748b; font-size: 11.5px; margin-top: 4px; }

/* ---------- heat tiles ---------- */
.heat-grid { display:grid; grid-template-columns: repeat(5,1fr); gap: 10px; }
@media (max-width: 900px){ .heat-grid{grid-template-columns:repeat(2,1fr)} }
.heat-tile { border-radius: 12px; padding: 14px; color:#fff; }
.heat-tile b { font-size: 14px; display:block; }
.heat-tile .sc { font-size: 24px; font-weight: 800; margin-top: 4px; }
.heat-tile small { opacity:.9; font-size: 11px; }

/* ---------- rating bars ---------- */
.rate-row { display:flex; align-items:center; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.rate-row .lbl { width: 190px; color: var(--ink-2); }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: var(--line);
  transition: .2s; border-radius: 999px; }
.switch .slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; transition: .2s; border-radius: 50%; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.rate-bar { flex:1; height: 10px; background: var(--surface-3); border-radius: 999px; overflow:hidden; }
.rate-bar > div { height:100%; border-radius: 999px; }
.rate-val { width: 46px; text-align:right; font-weight: 700; color: var(--heading); }

/* ---------- live call ---------- */
.live-wrap { display:grid; grid-template-columns: 1.1fr .9fr; gap: 16px; }
@media (max-width: 1000px){ .live-wrap{grid-template-columns:1fr} }
.script-step { padding: 10px 12px; border-left: 3px solid var(--green); background: var(--surface-2);
  border-radius: 0 8px 8px 0; margin-bottom: 8px; font-size: 13px; }
