@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Hanken+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --paper: #f3ede0;
  --paper-2: #fbf8f1;
  --card: #fffdf8;
  --ink: #1c1b18;
  --ink-soft: #6b675c;
  --green: #0f5b43;
  --green-deep: #0a3d2e;
  --amber: #c07a22;
  --rust: #a8472a;
  --line: rgba(28, 27, 24, 0.12);
  --line-2: rgba(28, 27, 24, 0.07);
  --shadow: 0 1px 2px rgba(28,27,24,.06), 0 12px 30px -12px rgba(10,61,46,.18);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }

body {
  font-family: 'Hanken Grotesk', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(15,91,67,.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(192,122,34,.10), transparent 55%),
    var(--paper);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
}
/* faint paper grain */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
}
#app, main, .topbar { position: relative; z-index: 1; }

h1, h2, h3 { font-family: 'Fraunces', serif; font-weight: 600; letter-spacing: -.01em; line-height: 1.1; }
.mono, .num { font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; }
a { color: var(--green); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 16px 28px; border-bottom: 1px solid var(--line);
  background: rgba(251,248,241,.7); backdrop-filter: blur(8px);
  position: sticky; top: 0;
}
.brand { font-family: 'Fraunces', serif; font-size: 22px; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.brand .mark { width: 26px; height: 26px; border-radius: 7px; background: var(--green); color: #fff; display: grid; place-items: center; font-size: 15px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.brand .mark::after { content: '₹'; }
.spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-soft); }
.role-badge { font-family: 'IBM Plex Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 4px 9px; border-radius: 999px; background: var(--green); color: #fff; }
.role-badge.partner { background: var(--amber); }
.role-badge.user { background: var(--ink); }

main { max-width: 1120px; margin: 0 auto; padding: 34px 28px 80px; }
.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: 34px; }
.page-head p { color: var(--ink-soft); margin-top: 6px; max-width: 60ch; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card h2 { font-size: 20px; margin-bottom: 4px; }
.card .sub { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 16px; }
.grid { display: grid; gap: 20px; }
.cols-2 { grid-template-columns: 360px 1fr; }
@media (max-width: 860px) { .cols-2 { grid-template-columns: 1fr; } }

/* ---------- stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; position: relative; overflow: hidden; }
.stat::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--green); }
.stat:nth-child(2)::after { background: var(--amber); }
.stat:nth-child(3)::after { background: var(--rust); }
.stat:nth-child(4)::after { background: var(--ink); }
.stat .k { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); }
.stat .v { font-family: 'IBM Plex Mono', monospace; font-size: 30px; font-weight: 600; margin-top: 6px; }

/* ---------- buttons + fields ---------- */
.btn { font-family: inherit; font-size: 14.5px; font-weight: 600; border: 1px solid var(--line); background: var(--paper-2); color: var(--ink); padding: 10px 16px; border-radius: 10px; cursor: pointer; transition: transform .08s, box-shadow .15s, background .15s; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--green); color: #fff; border-color: transparent; box-shadow: 0 8px 18px -8px rgba(15,91,67,.6); }
.btn-primary:hover { background: var(--green-deep); }
.btn-ghost { background: transparent; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
input, select { width: 100%; font-family: inherit; font-size: 15px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-2); color: var(--ink); }
input:focus, select:focus { outline: 2px solid rgba(15,91,67,.35); border-color: var(--green); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--line-2); }
tr:last-child td { border-bottom: none; }
.tag { font-family: 'IBM Plex Mono', monospace; font-size: 11px; padding: 3px 8px; border-radius: 6px; background: rgba(28,27,24,.06); }
.dot { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.dot::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-soft); }
/* One trust signal: colour always agrees with the plain-language line. Green ONLY means live right now. */
.dot.on::before,
.dot-live::before       { background: var(--green); box-shadow: 0 0 0 3px rgba(15,91,67,.18); animation: pulse 2s infinite; }
.dot-connecting::before { background: #2b6cb0; box-shadow: 0 0 0 3px rgba(43,108,176,.18); animation: pulse-blue 1.4s infinite; }
.dot-offline::before    { background: var(--amber); box-shadow: 0 0 0 3px rgba(192,122,34,.18); }
.dot-stale::before      { background: #c2410c; box-shadow: 0 0 0 3px rgba(194,65,12,.18); }
.dot-down::before       { background: var(--ink-soft); }
@keyframes pulse      { 0%,100% { box-shadow: 0 0 0 3px rgba(15,91,67,.18); } 50% { box-shadow: 0 0 0 5px rgba(15,91,67,.10); } }
@keyframes pulse-blue { 0%,100% { box-shadow: 0 0 0 3px rgba(43,108,176,.20); } 50% { box-shadow: 0 0 0 5px rgba(43,108,176,.08); } }
@media (prefers-reduced-motion: reduce) { .dot-live::before, .dot.on::before, .dot-connecting::before { animation: none; } }

/* ---------- connection card ---------- */
.conn .status { display: flex; align-items: flex-start; gap: 10px; font-weight: 600; margin-bottom: 16px; }
.conn .status > .dot { margin-top: 4px; }
.code { font-family: 'IBM Plex Mono', monospace; font-size: 30px; font-weight: 600; letter-spacing: .18em; text-align: center; padding: 16px; border: 1.5px dashed var(--green); border-radius: 12px; background: rgba(15,91,67,.05); color: var(--green-deep); margin: 10px 0 6px; }
.steps { list-style: none; counter-reset: s; margin-top: 8px; }
.steps li { counter-increment: s; position: relative; padding: 7px 0 7px 30px; font-size: 13.5px; color: var(--ink-soft); }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--green); color: #fff; font-family: 'IBM Plex Mono', monospace; font-size: 11px; display: grid; place-items: center; }
.conn .csub { display: block; color: var(--ink-soft); font-size: 13px; margin-top: 3px; font-weight: 400; }
/* first-run onboarding: outcome-first, the gateway prerequisite is emphasised (not muted) */
.onboard h3 { font-size: 17px; margin-bottom: 6px; }
.onboard .trust { font-size: 13px; color: var(--green); background: rgba(15,91,67,.07); border: 1px solid rgba(15,91,67,.18); border-radius: 9px; padding: 8px 11px; margin: 0 0 14px; }
.onboard .steps li { color: var(--ink); font-size: 14px; padding: 9px 0 9px 30px; }
.onboard .steps li b { font-weight: 600; }
.onboard .steps .gw-help { display: block; color: var(--ink-soft); font-size: 13px; margin-top: 6px; padding: 9px 11px; border-left: 2px solid var(--green); background: var(--paper-2); border-radius: 0 8px 8px 0; }
.onboard .steps .gw-help code { font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; background: rgba(28,27,24,.06); padding: 1px 5px; border-radius: 4px; }
.ok-line { font-size: 15px; color: var(--green-deep); font-weight: 600; margin-bottom: 8px; }
.callout { font-size: 13.5px; border-radius: 10px; padding: 11px 13px; margin-top: 12px; }
.callout.warn { background: rgba(192,122,34,.10); border: 1px solid rgba(192,122,34,.35); color: var(--ink); }

/* Connector update banner — prominent, dismissible, sits above the tabs so it's seen on every pane. */
.update-banner { display: flex; align-items: center; gap: 15px; margin: 0 0 20px; padding: 15px 18px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(192,122,34,.14), rgba(192,122,34,.06));
  border: 1px solid rgba(192,122,34,.40); box-shadow: 0 12px 26px -18px rgba(192,122,34,.75); }
.update-banner .ub-ic { flex: none; width: 42px; height: 42px; border-radius: 999px; display: grid; place-items: center;
  background: #c07a22; color: #fff; font-size: 21px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.28); }
.update-banner .ub-txt { flex: 1 1 auto; min-width: 0; }
.update-banner .ub-title { font-weight: 700; font-size: 15.5px; color: var(--ink); }
.update-banner .ub-sub { font-size: 13px; color: var(--ink-soft); margin-top: 3px; line-height: 1.45; }
.update-banner .ub-cta .btn { white-space: nowrap; }
.update-banner .ub-x { flex: none; align-self: flex-start; background: transparent; border: 0; color: var(--ink-soft);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 7px; border-radius: 8px; }
.update-banner .ub-x:hover { background: rgba(28,27,24,.08); color: var(--ink); }
@media (max-width: 580px) {
  .update-banner { flex-wrap: wrap; }
  .update-banner .ub-cta { flex: 1 1 100%; order: 3; }
  .update-banner .ub-cta .btn { width: 100%; }
}
.link-inline { background: none; border: none; padding: 0; font: inherit; color: var(--green); text-decoration: underline; cursor: pointer; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; height: min(620px, 70vh); }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 4px 2px 14px; }
.msg { max-width: 86%; padding: 12px 15px; border-radius: 14px; font-size: 14.5px; animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.msg.user { align-self: flex-end; background: var(--green); color: #fff; border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: var(--paper-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.bot.refusal { background: rgba(168,71,42,.06); border-color: rgba(168,71,42,.3); }
.msg .source { font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; color: var(--ink-soft); margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line); }
.msg .badge { font-family: 'IBM Plex Mono', monospace; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; padding: 2px 6px; border-radius: 5px; background: rgba(192,122,34,.16); color: var(--amber); margin-left: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.chip { font-size: 12.5px; padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper-2); cursor: pointer; transition: background .15s; }
.chip:hover { background: rgba(15,91,67,.08); border-color: var(--green); }
.composer { display: flex; gap: 10px; }
.composer input { flex: 1; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
@media (max-width: 880px) { .auth { grid-template-columns: 1fr; } .auth .hero { display: none; } }
.auth .hero { background: linear-gradient(160deg, var(--green-deep), var(--green)); color: #fbf8f1; padding: 56px 50px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth .hero::after { content: '₹'; position: absolute; right: -40px; bottom: -70px; font-family: 'Fraunces', serif; font-size: 380px; opacity: .07; }
.auth .hero h1 { font-size: 46px; color: #fff; max-width: 14ch; }
.auth .hero p { margin-top: 18px; max-width: 38ch; opacity: .9; font-size: 16px; }
.auth .hero .ex { font-family: 'IBM Plex Mono', monospace; font-size: 13px; opacity: .85; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); border-radius: 10px; padding: 12px 14px; margin-top: 10px; }
.auth .panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth .box { width: 100%; max-width: 380px; }
.tabs { display: flex; gap: 6px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-bottom: 22px; }
.tabs button { flex: 1; border: none; background: transparent; padding: 9px; border-radius: 7px; font-family: inherit; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--ink-soft); }
.tabs button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.demo-accts { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.demo-accts .t { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin-bottom: 10px; }
.demo-accts button { width: 100%; text-align: left; margin-bottom: 7px; font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; }
.err { color: var(--rust); font-size: 13.5px; margin-bottom: 12px; min-height: 18px; }
.muted { color: var(--ink-soft); font-size: 13px; }
.section-title { font-family: 'Fraunces', serif; font-size: 18px; margin: 28px 0 12px; }

/* password field with show/hide eye */
.pw { position: relative; }
.pw input { padding-right: 44px; }
.pw .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: transparent; border: none; cursor: pointer; font-size: 16px; line-height: 1; padding: 6px; opacity: .55; }
.pw .eye:hover { opacity: 1; }

/* modal (change password) */
.modal-bg { position: fixed; inset: 0; background: rgba(28,27,24,.45); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 60; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; width: min(380px, 92vw); }
.modal h2 { font-family: 'Fraunces', serif; font-size: 22px; margin-bottom: 16px; }
.modal .ok { color: var(--green); font-size: 13.5px; min-height: 18px; }
.modal-row { display: flex; gap: 10px; margin-top: 6px; }
.link-btn { background: transparent; border: none; color: var(--ink-soft); cursor: pointer; font-family: inherit; font-size: 13.5px; text-decoration: underline; padding: 0 4px; }
.link-btn:hover { color: var(--ink); }
.link-btn.danger { color: var(--rust); }

/* tabs */
.tabbar { display: flex; gap: 6px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px; padding: 5px; margin-bottom: 22px; max-width: 540px; }
.tabbar button { flex: 1; border: none; background: transparent; padding: 10px; border-radius: 8px; font-family: inherit; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--ink-soft); }
.tabbar button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* list rows */
.row-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.row-item:last-child { border-bottom: none; }
.add-row { display: flex; gap: 8px; margin-top: 12px; }
.add-row input { flex: 1; }
.tag.ok { background: rgba(15,91,67,.12); color: var(--green); }
.tag.warn { background: rgba(192,122,34,.16); color: var(--amber); }
.badge.live { background: rgba(15,91,67,.16); color: var(--green); }
.chk { display: block; padding: 5px 0; font-family: 'IBM Plex Mono', monospace; font-size: 13px; }
.dow { display: flex; gap: 6px; flex-wrap: wrap; }
.dow button { border: 1px solid var(--line); background: var(--paper-2); border-radius: 8px; padding: 7px 10px; cursor: pointer; font-family: inherit; font-size: 13px; }
.dow button.on { background: var(--green); color: #fff; border-color: transparent; }
select.mini { width: auto; padding: 5px 8px; font-size: 13px; }
.gate { background: rgba(192,122,34,.10); border: 1px solid rgba(192,122,34,.35); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; font-size: 14.5px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.gate .btn { margin-left: auto; }

/* in-chat reports: tables + bar charts */
.viz { margin-top: 12px; }
.ans-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--paper-2); border-radius: 8px; overflow: hidden; margin-top: 8px; }
.ans-table th { background: rgba(15,91,67,.08); text-align: left; padding: 7px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); border-bottom: 1px solid var(--line); }
.ans-table td { padding: 7px 10px; border-bottom: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
.ans-table tr:last-child td { border-bottom: none; }
.bars { display: flex; flex-direction: column; gap: 7px; margin: 4px 0 10px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr auto; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); }
.bar-track { background: rgba(28,27,24,.07); border-radius: 6px; height: 16px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #2e8b6b); border-radius: 6px; transition: width .5s ease; }
.bar-val { font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; font-size: 12px; }
@media (max-width: 520px) { .bar-row { grid-template-columns: 90px 1fr auto; } }

/* ---- natural-language cron: schedule proposal card (in chat) ---- */
.sched-card { border: 1px solid var(--green); border-radius: 12px; padding: 14px 16px; background: rgba(15,91,67,.04); }
.sched-h { font-weight: 700; color: var(--green-deep); margin-bottom: 8px; }
.sched-row { font-size: 14px; margin: 3px 0; }
.sched-row b { color: var(--ink-soft); font-weight: 600; }
.sched-actions { display: flex; gap: 8px; margin-top: 12px; }
.sched-note { margin-top: 8px; font-size: 13px; }

/* ---- voice note recording state ---- */
#mic.rec { background: var(--rust); color: #fff; border-color: var(--rust); animation: micpulse 1s ease-in-out infinite; }
@keyframes micpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(168,71,42,.5); } 50% { box-shadow: 0 0 0 6px rgba(168,71,42,0); } }

/* ---- export buttons under an answer ---- */
.export-bar { margin-top: 8px; font-size: 12.5px; }
.export-bar .link-btn { color: var(--green); }

/* The hidden attribute always wins (several blocks here set display:flex, which used to override it). */
[hidden] { display: none !important; }
/* Phone: the top bar wraps instead of running off the right edge. */
@media (max-width: 560px) {
  .topbar { padding: 12px 14px; gap: 8px 12px; flex-wrap: wrap; }
  .topbar .brand { font-size: 19px; }
  .who { flex-wrap: wrap; gap: 6px 10px; font-size: 13px; justify-content: flex-end; }
  .who .muted { display: none; }
  .who .btn { padding: 7px 12px; }
  .modal { box-sizing: border-box; width: calc(100vw - 28px); max-width: 380px; padding: 20px 18px; }
  .modal-row { flex-wrap: wrap; }
}
.ans-li { display: flex; gap: 8px; margin: 3px 0; }
.ans-li > span:first-child { flex: none; color: var(--ink-soft); }
