:root { --ink: #0f2a3d; --muted: #38566a; --line: #69b4d3; --bg: #87ceeb; --panel: var(--bg); --accent: #075985; --bar: #0369a1;
  --teal: #0d9488; --indigo: #4f46e5; --bad: #b91c1c; --soft: var(--bg); --dr: #0f2a3d;
  --body-font: "Inter", system-ui, "Segoe UI", sans-serif; --head-font: "Poppins", "Inter", system-ui, sans-serif; }
* { box-sizing: border-box; }
html { font-size: 16px; }
html, body { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; font: .9375rem/1.4 var(--body-font); color: var(--ink); }
h1, h2, h3, h4, .brand, .bar nav, .gw-menu li a { font-family: var(--head-font); }
a { color: var(--accent); }
.bar { display: flex; gap: .75rem; align-items: center; padding: .5rem 1rem; background: var(--bg); color: var(--ink); flex-wrap: wrap;
  box-shadow: 0 2px 8px #0369a133; }
.bar a { color: var(--ink); text-decoration: none; }
.bar nav { display: flex; gap: .5rem; flex-wrap: wrap; }
.bar nav a { display: flex; align-items: center; min-height: 36px; padding: .35rem .6rem; font-size: .9rem; border: 1px solid var(--line); border-radius: 8px; }
.bar nav a:hover, .bar nav a:focus-visible { background: #fcd34d; }
.bar .back { display: flex; align-items: center; gap: .35rem; min-height: 36px; padding: .35rem .7rem; font-weight: 600; font-size: .9rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.bar .back:hover, .bar .back:focus-visible { background: #fcd34d; }
.bar .back kbd { font: inherit; font-size: .7rem; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 .25rem; }
.brand { display: flex; align-items: center; gap: .45rem; font-weight: 700; font-size: 1.15rem; letter-spacing: .01em; color: #0b3b5c; }
.brand img { display: block; border-radius: 7px; }
.brand .company { font-weight: 500; font-size: .95rem; color: var(--muted); padding-left: .5rem; border-left: 1px solid var(--line); }
.login-brand { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; font: 700 1.9rem/1 var(--head-font); color: #0b3b5c; }
.login-brand img { border-radius: 14px; }
.fy { display: flex; align-items: center; gap: .4rem; }
.fy select { width: auto; min-height: 34px; padding: .2rem .4rem; font-weight: 600; }
.who { margin-left: auto; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.role { background: #ffffff22; padding: 0 .5rem; border-radius: 3px; font-size: .85em; }
main { width: 100%; flex: 1; min-width: 0; margin: .75rem 0; padding: 0 clamp(12px, 1.25vw, 24px); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .85rem 1rem; margin-bottom: .75rem;
  box-shadow: 0 1px 3px #0369a114; }
.narrow { max-width: 460px; margin: 2rem auto; }
h1 { font-size: 1.4rem; font-weight: 600; margin: 0 0 .75rem; color: var(--bar); } h2 { font-size: 1.1rem; font-weight: 600; margin: .5rem 0; }
label { display: block; margin: .4rem 0; font-size: .92em; color: var(--muted); }
[hidden] { display: none !important; }  /* a hidden label or div stays hidden whatever its display */
input, select, textarea { display: block; width: 100%; min-width: 0; min-height: 38px; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 6px; font: inherit;
  color: var(--ink); background: var(--bg); }
input[type="checkbox"] { display: inline-block; width: auto; min-height: 0; margin: 0 .4rem 0 0; vertical-align: middle; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
button, a.button, label.button { margin-top: .6rem; min-height: 38px; padding: .45rem 1rem; border: 0; border-radius: 8px; background: var(--accent); color: #fff;
  font: 500 .9375rem var(--head-font); cursor: pointer; box-shadow: 0 1px 2px #0f2a3d26; transition: filter .15s, transform .15s; }
a.button, label.button { display: inline-flex; align-items: center; text-decoration: none; }
button:hover, a.button:hover, label.button:hover { filter: brightness(1.08); transform: translateY(-1px); }
button:active { transform: none; }
button:focus-visible { outline: 3px solid #fcd34d; outline-offset: 2px; }
button.secondary { background: var(--teal); }
button.danger { background: var(--bad); }
button.alt { background: var(--indigo); }
button.link { background: none; color: var(--ink); padding: 0; margin: 0; text-decoration: underline; box-shadow: none; font: inherit; }
button.link:hover { transform: none; }
form.inline { display: inline; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: .5rem 1rem; align-items: end; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 1rem; }
.list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: .75rem; list-style: none; padding: 0; margin: 0; }
.list li { padding: .4rem .65rem; border: 1px solid var(--line); border-radius: 8px; overflow-wrap: anywhere; }
.list li a { display: inline-block; padding: .35rem 0; font-weight: 600; }
.muted { color: var(--muted); } .error { color: var(--bad); font-weight: 600; } .ok { color: #11743b; font-weight: 600; }
table { width: 100%; border-collapse: collapse; } th, td { padding: .35rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); } tr.cancelled td { color: var(--muted); text-decoration: line-through; }
.scroll { overflow-x: auto; }
.keys { width: 100%; margin: 0 0 1rem; padding: 0 clamp(12px, 2vw, 40px); color: var(--muted); font-size: .85em; }
.period { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; } .period label { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.lines td input, .lines td select { min-width: 6rem; }
.bills { margin: .2rem 0 .4rem 1.5rem; font-size: .9em; }
.tally .ledger-col { display: none; }
#tally-head .bill-holder { max-width: 40rem; }
.bank-holder { display: flex; flex-wrap: wrap; gap: .4rem; max-width: 40rem; }
.bank-holder > * { flex: 1 1 9rem; width: auto; }
.tally-field { display: flex; flex-wrap: wrap; align-items: end; gap: .3rem 1rem; margin: .4rem 0; }
.tally-field label { flex: 0 1 26rem; }
.cur-bal { color: var(--muted); font-size: .9em; white-space: nowrap; }
.tally-total { font-weight: 700; font-size: 1.05rem; text-align: right; border-top: 2px solid var(--ink); padding: .4rem .5rem; }
.print-only { display: none; }
/* Gateway: TallyPrime-style dashboard */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.card { display: flex; flex-direction: column; gap: .15rem; padding: .55rem .75rem; background: var(--panel); border: 1px solid var(--line);
  border-top: 4px solid var(--accent); border-radius: 10px; color: var(--ink); text-decoration: none; }
.card span { font-size: .78em; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.card b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.card:hover { border-color: var(--accent); } .card.profit { border-top-color: #11743b; } .card.loss { border-top-color: var(--bad); }
.gateway { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr) minmax(180px, .8fr); gap: .75rem; align-items: start; }
.gateway > * { min-width: 0; }
.gw-info { background: var(--soft); border: 1px solid var(--line); border-radius: 6px; padding: .6rem .9rem; font-size: .92em; }
.gw-info h3 { margin: .7rem 0 .1rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--bar); }
.gw-info h3:first-child { margin-top: 0; } .gw-info p { margin: 0; }
.gw-menu { width: 100%; background: var(--panel); border: 1px solid var(--bar); border-radius: 10px; overflow: hidden; }
.gw-menu h1 { margin: 0; padding: .55rem .9rem; background: var(--bg); color: var(--ink); border-bottom: 1px solid var(--line); font-size: 1rem; text-align: center; }
.gw-menu h4 { margin: .7rem 0 .2rem; padding: 0 1.2rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.gw-menu ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: .4rem; list-style: none; margin: 0; padding: 0 .75rem; }
.gw-menu li a { display: block; min-height: 36px; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.gw-menu li a u { color: var(--bad); font-weight: 700; text-decoration: none; }
.gw-menu li a.active, .gw-menu li a:focus { background: #fcd34d; outline: none; font-weight: 600; }
.gw-hint { margin: .7rem 0 0; padding: .4rem .9rem; border-top: 1px solid var(--line); font-size: .78em; text-align: center; }
.fkeys { display: flex; flex-direction: column; gap: .5rem; }
.fkeys a { display: flex; align-items: center; gap: .4rem; min-height: 38px; padding: .45rem .6rem; background: var(--soft); border: 1px solid var(--line); border-radius: 6px; color: var(--ink); text-decoration: none; font-size: .9375rem; }
.fkeys a:hover { background: #fcd34d; } .fkeys kbd { display: inline-block; min-width: 3.4em; font: 600 .85em ui-monospace, monospace; color: var(--bar); }
/* Distinct colours for action buttons and navigation choices. */
a.button[data-tone="blue"], button[data-tone="blue"] { background: #075985; }
a.button[data-tone="green"], button[data-tone="green"] { background: #166534; }
label.button[data-tone="teal"], button[data-tone="teal"] { background: #0f766e; }
button[data-tone="purple"] { background: #7e22ce; }
button[data-tone="indigo"] { background: #4338ca; }
button[data-tone="orange"] { background: #9a3412; }
button[data-tone="pink"] { background: #9d174d; }
button[data-tone="red"] { background: #b91c1c; }
button.link[data-tone] { color: #fff; padding: .35rem .65rem; text-decoration: none; }
.bar nav a, .fkeys a, .gw-menu li a, .list li { --menu-color: #dbeafe; background: var(--menu-color); border-color: #0f2a3d40; }
.bar nav a:nth-child(8n+2), .fkeys a:nth-child(8n+2), .gw-menu li:nth-child(8n+2) a, .list li:nth-child(8n+2) { --menu-color: #dcfce7; }
.bar nav a:nth-child(8n+3), .fkeys a:nth-child(8n+3), .gw-menu li:nth-child(8n+3) a, .list li:nth-child(8n+3) { --menu-color: #f3e8ff; }
.bar nav a:nth-child(8n+4), .fkeys a:nth-child(8n+4), .gw-menu li:nth-child(8n+4) a, .list li:nth-child(8n+4) { --menu-color: #ffedd5; }
.bar nav a:nth-child(8n+5), .fkeys a:nth-child(8n+5), .gw-menu li:nth-child(8n+5) a, .list li:nth-child(8n+5) { --menu-color: #fce7f3; }
.bar nav a:nth-child(8n+6), .fkeys a:nth-child(8n+6), .gw-menu li:nth-child(8n+6) a, .list li:nth-child(8n+6) { --menu-color: #ccfbf1; }
.bar nav a:nth-child(8n+7), .fkeys a:nth-child(8n+7), .gw-menu li:nth-child(8n+7) a, .list li:nth-child(8n+7) { --menu-color: #fef9c3; }
.bar nav a:nth-child(8n+8), .fkeys a:nth-child(8n+8), .gw-menu li:nth-child(8n+8) a, .list li:nth-child(8n+8) { --menu-color: #e0e7ff; }
.bar nav a:hover, .fkeys a:hover, .gw-menu li a:hover, .list li:hover { filter: brightness(.96); }
.gw-menu li a.active, .gw-menu li a:focus-visible, .bar nav a:focus-visible, .fkeys a:focus-visible { background: #fcd34d; outline: 2px solid var(--ink); outline-offset: -2px; }
@media (max-width: 860px) {
  .gateway { grid-template-columns: 1fr; } .gw-menu { max-width: none; order: -1; }
  .fkeys { flex-direction: row; flex-wrap: wrap; } .fkeys a { flex: 1 1 140px; }
}
@media (max-width: 600px) {
  .bar { gap: .75rem; padding: .6rem .75rem; } .bar nav { width: 100%; } .bar nav a { flex: 1 1 140px; }
  .who { width: 100%; margin-left: 0; } .panel { padding: .85rem; } .period label { flex: 1 1 180px; }
  input, select, textarea { font-size: 16px; }
  button, .bar nav a, .gw-menu li a, .fkeys a { min-height: 44px; }
}
@media print { :root { --bg: #fff; } html { font-size: 12px; } body { display: block; min-height: 0; } main { padding: 0; margin: 0; } .print-only { display: block; } .bar, .keys, .period, .actions, button { display: none !important; } .panel { border: 0; } }

/* AI Accountant */
.ai-wrap { display: grid; grid-template-columns: 14rem 1fr; gap: 1rem; align-items: start; }
.ai-side .ai-chats { list-style: none; padding: 0; margin: .6rem 0 0; font-size: .9em; }
.ai-side .ai-chats li { margin: .25rem 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-side .ai-chats a[aria-current] { font-weight: 700; }
.ai-log { display: flex; flex-direction: column; gap: .6rem; max-height: 62vh; overflow-y: auto; padding: .3rem; }
.ai-msg { max-width: 46rem; padding: .55rem .8rem; border-radius: 12px; white-space: pre-wrap; line-height: 1.45; }
.ai-msg.user { align-self: flex-end; background: #0f766e; color: #fff; }
.ai-msg.user .muted { color: #d1fae5; }
.ai-msg.pending { opacity: .7; }
.ai-msg.assistant { align-self: flex-start; background: #ffffffcc; color: var(--ink); }
.ai-hello { white-space: normal; }
.ai-hello ul { margin: .3rem 0; }
.ai-card { align-self: flex-start; width: min(46rem, 100%); background: #fff; border: 2px solid #4338ca; border-radius: 12px; padding: .6rem .8rem; }
.ai-card h3 { margin: 0 0 .4rem; font-size: 1rem; }
.ai-form textarea { width: 100%; }
.bar nav a.ai-link { background: #4338ca; color: #fff; border-color: #4338ca; font-weight: 600; }
@media (max-width: 720px) { .ai-wrap { grid-template-columns: 1fr; } .ai-side { order: 2; } }
.ai-batch { width: 100%; max-width: 60rem; }
.ai-batch tr.row-already_entered td, .ai-batch tr.row-error td { background: #f1f5f9; }
.ai-batch td input[type=checkbox] { width: 1.1rem; height: 1.1rem; min-width: 0; }
.ai-batch .ai-stmt { display: block; font-size: .8em; overflow-wrap: anywhere; }
/* GSTR-2B Reconcile */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.chips a { padding: .3rem .65rem; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; text-decoration: none; color: var(--ink); }
.chips a[aria-current] { background: #0b3b5c; color: #fff; border-color: #0b3b5c; }
.recon tr[data-result="mismatch"] td:first-child { color: #b42318; font-weight: 600; }
.recon tr[data-result="probable"] td:first-child { color: #b54708; font-weight: 600; }
.recon tr[data-result="only_2b"] td:first-child, .recon tr[data-result="only_books"] td:first-child { color: #6941c6; font-weight: 600; }
.recon tr[data-result="matched"] td:first-child { color: #027a48; }
.recon small { color: var(--muted); }
/* Phone app: ☰ Menu, quick actions on the Gateway, Dues cards */
.menu-toggle, .quick, .bar nav a.phone-only { display: none; }
.dues { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: .6rem; }
.due { display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; padding: .7rem .8rem; background: #ffffffa6; border: 1px solid var(--line);
  border-left: 5px solid var(--accent); border-radius: 10px; }
.due.late { border-left-color: var(--bad); }
.due-name { font-weight: 600; overflow-wrap: anywhere; } .due-amt { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.due > .muted { grid-column: 1 / -1; font-size: .85em; }
.due-actions { grid-column: 1 / -1; display: flex; gap: .5rem; flex-wrap: wrap; }
.due-actions .button { margin-top: .3rem; flex: 1 1 8rem; justify-content: center; }
@media (pointer: coarse) { .keys, .gw-hint, .bar .back kbd { display: none; } }
@media (max-width: 600px) {
  .menu-toggle { display: inline-flex; align-items: center; margin: 0; min-height: 40px; padding: .3rem .7rem; background: var(--bar); }
  .bar nav a.phone-only { display: flex; }
  .js .bar:not(.open) nav, .js .bar:not(.open) .who, .js .bar:not(.open) .fy { display: none; }
  .brand .company { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .keys, .fkeys, .gw-hint { display: none; }
  .cards { grid-template-columns: 1fr 1fr; }
  .quick { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .9rem; }
  .quick a { display: flex; align-items: center; justify-content: center; min-height: 48px; padding: .4rem; text-align: center; border-radius: 10px;
    background: #fff; border: 1px solid var(--line); color: var(--ink); font: 600 .95rem var(--head-font); text-decoration: none; }
  .quick a.main { background: var(--bar); color: #fff; border-color: var(--bar); }
}
