/* SaaS additions on top of base.css (the Eshaan control-tower design tokens) */
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--fs-body)/var(--lh-body) var(--font-ui); }
[hidden] { display: none !important; }
a { color: var(--accent); }
.small { font-size: 11.5px; }
.muted { color: var(--muted); }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 22px 24px; }
.auth-card .brand { align-items: flex-start; gap: 4px; margin-bottom: 14px; padding: 0 0 12px; background: none; }
.auth-card .brand-logo { height: 64px; }
/* auth + form controls → css/forms.css */

/* menu filter (the box above the sidebar; core/nav.js) and the sidebar's section headers */
.nav-search { padding: 4px 10px 6px; }
.nav-search input { width: 100%; height: 28px; border: 1px solid var(--line); border-radius: 7px; padding: 0 8px; background: var(--surface-2); color: var(--ink); font: inherit; }
.nav-group { font: 600 10.5px var(--font-head); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); cursor: pointer; user-select: none; display: flex; justify-content: space-between; }
.nav-group[aria-expanded="false"] + .nav-items { display: none; }
.nav-count { font: 500 10px var(--font-mono); color: var(--muted); }

/* list screen */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar input[type=search], .toolbar select, .toolbar input[type=date], .toolbar input[type=number] { height: 28px; border: 1px solid var(--line-2); border-radius: 7px; padding: 0 8px; background: var(--surface); color: var(--ink); font: inherit; }
.toolbar input[type=search] { width: 260px; max-width: 100%; }
.toolbar .spacer { flex: 1; }
.tbl th[data-sort] { cursor: pointer; user-select: none; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tbl tbody tr.clickable:hover td { background: var(--accent-soft); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 8px 2px; color: var(--muted); font-size: 11.5px; }

/* ref picker in list toolbar (not full record forms) */
.toolbar .ref-pick { flex-direction: row; align-items: center; gap: 6px; }
.toolbar .ref-pick .ref-q { width: 150px; height: 28px; min-height: 0; }
.toolbar input[type=number] { width: 110px; }

/* detail */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; }
.detail-grid dt { font-size: 10.5px; color: var(--muted); }
.detail-grid dd { margin: 0 0 6px; font-weight: 500; word-break: break-word; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(8, 12, 20, .45); display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal { width: min(980px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 12px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-h h3 { font: 600 14px var(--font-head); margin: 0; flex: 1; }
.modal-b { padding: 12px 14px 14px; }

/* home */
.module-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.module-tile { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-decoration: none; color: var(--ink); }
.module-tile:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.module-tile b { font-weight: 600; }
.module-tile span { font-size: 11px; color: var(--muted); }
@media (max-width: 720px) {
  .toolbar input[type=search] { width: 100%; }
  /* phone: a page's title and its buttons wrap instead of pushing the screen sideways */
  .page-h { flex-wrap: wrap; align-items: flex-start; }
  .page-h .actions { flex-wrap: wrap; margin-left: 0; }
}

/* WhatsApp bot */
.wa-shell { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; align-items: start; }
.wa-chat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 520px; }
.wa-bar, .wa-roles, .wa-suggest { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.wa-bar { justify-content: space-between; }
.wa-thread { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; max-height: 420px; background: var(--bg); }
.wa-msg { max-width: 85%; padding: 8px 10px; border-radius: 10px; white-space: pre-wrap; line-height: 1.4; }
.wa-msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.wa-msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); }
.wa-compose { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.wa-compose input[type=text] { flex: 1; height: 32px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px; background: var(--surface); color: var(--ink); }
.wa-hood .wa-trace { display: grid; grid-template-columns: 72px 1fr; gap: 4px 8px; margin: 0; }
.wa-hood .wa-trace dt { color: var(--muted); }
.wa-hood .wa-trace dd { margin: 0; }
.wa-apis { margin: 8px 0 0; padding-left: 16px; }
@media (max-width: 900px) { .wa-shell { grid-template-columns: 1fr; } }

/* forms as popups (app.js routeForm): the new / edit form of a module over the screen it was opened from */
.fpop-back { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; padding: 20px; background: rgba(8, 12, 20, .45); }
.fpop { display: flex; flex-direction: column; width: min(1080px, 100%); height: min(92vh, 100%); background: var(--bg, var(--surface)); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg, var(--shadow)); overflow: hidden; }
.fpop-h { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.fpop-h h3 { flex: 1; margin: 0; font: 600 15px var(--font-head); }
.fpop-b { flex: 1; min-height: 0; overflow: auto; padding: 16px 18px 0; }
.fpop-b > .sf, .fpop-b > form { max-width: none; }
body.fpop-on { overflow: hidden; }
@media (max-width: 767px) {
  .fpop-back { padding: 0; }
  .fpop { width: 100%; height: 100%; border-radius: 0; border: 0; }
  .fpop-b { padding: 12px 12px 0; }
}
