/* annonERP prototype — admin module styles (shell extras, overview, reports, approvals, users, settings, organisation).
   Use tokens from tokens.css only. */

/* ---------- Sign-in / signed-out screen ---------- */
.auth-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-4); padding: var(--space-6) var(--space-4); background: var(--canvas); }
.auth-card { width: 100%; max-width: 420px; padding: var(--space-8); }
.auth-card h1 { font-family: var(--font-display); font-size: var(--fs-section); margin: var(--space-6) 0 var(--space-2); letter-spacing: var(--tracking-tight); }
.auth-brand { display: flex; align-items: center; gap: var(--space-3); }
.auth-brand svg { width: 32px; height: 32px; }
.auth-code { font-variant-numeric: tabular-nums; letter-spacing: 0.3em; font-size: 1.25rem; text-align: center; }
code.auth-code { display: inline-block; font-size: 0.95rem; letter-spacing: 0.15em; padding: 2px 8px; background: var(--fill); border-radius: var(--radius-sm); }
.auth-foot { text-align: center; max-width: 420px; }
@media (max-width: 640px) { .auth-card { padding: var(--space-6) var(--space-5); } }

/* ---------- Notifications drawer groups ---------- */
h3.notif-group { font-size: var(--fs-label); font-weight: 600; color: var(--text-secondary); text-transform: none; margin: var(--space-4) 0 var(--space-2); }
h3.notif-group:first-child { margin-top: 0; }

/* ---------- List view extras ---------- */
.lv-range { display: inline-flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.lv-range .input { width: auto; min-width: 140px; }
.lv-view-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Overview ---------- */
.ov-period { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-5); }
.ov-period .tabs { margin: 0; overflow-x: auto; max-width: 100%; }
.kpi { position: relative; }
.kpi-hint { display: inline-flex; margin-left: 2px; color: var(--text-muted); cursor: help; border-radius: var(--radius-full); }
.kpi-hint:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.kpi .kpi-hint svg { width: 13px; height: 13px; color: var(--text-muted); }
.kpi-link { display: inline-block; margin-top: var(--space-2); font-weight: 500; color: var(--accent-700); }
.kpi-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.kpi-link:focus-visible { outline: none; }
.kpi:has(.kpi-link:focus-visible) { box-shadow: var(--focus-ring); }
.kpi .kpi-hint { position: relative; z-index: 1; }
.ov-pos .card-body { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); padding: var(--space-8); }
.ov-pos h2 { font-family: var(--font-display); font-size: var(--fs-section); margin: 0; }
.ov-pos-icon { width: 52px; height: 52px; border-radius: var(--radius-lg); background: var(--accent-tint); color: var(--accent-700); display: grid; place-items: center; }
.ov-pos-icon svg { width: 26px; height: 26px; }
.neg { color: var(--danger); }

/* ---------- Reports ---------- */
.rep-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.rep-nav { position: sticky; top: var(--space-4); overflow: hidden; }
.rep-nav .list { margin: 0; padding: 0; list-style: none; }
.rep-nav .list-item { align-items: flex-start; padding: var(--space-3) var(--space-4); }
.rep-nav .list-item > svg { margin-top: 2px; }
.rep-nav .list-item > span { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.rep-nav .meta { font-weight: 400; }
.rep-group { font-size: var(--fs-label); font-weight: 600; color: var(--text-secondary); padding: var(--space-4) var(--space-4) var(--space-1); }
.rep-title { font-weight: 500; }
.rep-pick { display: none; margin-bottom: var(--space-4); }
.rep-head h2 { margin: 0; }
.rep-chart { border-bottom: 1px solid var(--hairline); }
.rep-bars .bar-row { grid-template-columns: minmax(120px, 200px) 1fr auto; }
.rep-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-label); }
.rep-note { display: flex; gap: var(--space-2); align-items: flex-start; padding: var(--space-3) var(--space-5) var(--space-4); margin: 0; }
.rep-note svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }
.table tfoot td { border-top: 2px solid var(--border); background: var(--fill); }
@media (max-width: 960px) {
  .rep-grid { grid-template-columns: minmax(0, 1fr); }
  .rep-nav { display: none; }
  .rep-pick { display: block; }
}
@media (max-width: 640px) { .rep-bars .bar-row { grid-template-columns: 90px 1fr auto; } }

/* ---------- Approvals ---------- */
.ap-list { margin: 0; padding: 0; list-style: none; }
.ap-item { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--hairline); }
.ap-item:last-child { border-bottom: 0; }
.ap-item > input[type="checkbox"] { width: 18px; height: 18px; margin: 10px 0 0; accent-color: var(--accent-600); flex: none; }
.ap-nosel { width: 18px; flex: none; }
.ap-item .li-main { flex: 1; min-width: 0; }
.ap-kind { font-size: var(--fs-meta); padding: 1px 8px; min-height: 0; cursor: default; }
.ap-actions { display: flex; gap: var(--space-2); flex: none; align-self: center; }
.ap-lock { display: flex; gap: 6px; align-items: flex-start; margin-top: var(--space-2); font-size: var(--fs-meta); color: var(--danger); }
.ap-lock svg { width: 14px; height: 14px; flex: none; margin-top: 2px; }
.ap-all { font-size: var(--fs-label); }
.ap-confirm { margin: var(--space-3) 0 0; padding-left: var(--space-5); max-height: 220px; overflow: auto; font-size: var(--fs-label); }
.ap-hist { padding: var(--space-4) var(--space-5) 0; }
.ap-hist .badge { vertical-align: middle; }
@media (max-width: 640px) {
  .ap-item { flex-wrap: wrap; padding: var(--space-4); }
  .ap-actions { width: 100%; justify-content: flex-end; }
  .ap-actions .btn { flex: 1; }
}

/* ---------- Profile ---------- */
.pf-static { margin: 0; min-height: var(--control-h); display: flex; align-items: center; color: var(--text-secondary); }
.pf-steps { margin: 0 0 var(--space-4); padding-left: var(--space-5); display: grid; gap: var(--space-2); }

/* ---------- Users: permission matrix ---------- */
.pm-table th[scope="row"] { font-weight: 400; text-align: left; white-space: normal; min-width: 200px; }
.pm-table .pm-col { text-align: center; white-space: nowrap; }
.pm-table thead .pm-col { font-size: var(--fs-label); }
.pm-group th { background: var(--fill); font-weight: 600 !important; font-size: var(--fs-label); color: var(--text-secondary); }
.pm-yes { display: inline-flex; color: var(--success); }
.pm-yes svg { width: 16px; height: 16px; }
.pm-no { color: var(--text-muted); }
.pm-table thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.pm-table th[scope="row"]:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.pm-group th[scope="rowgroup"] { position: sticky; left: 0; }

/* ---------- Settings ---------- */
.field-check { align-self: end; min-height: var(--control-h); }
.ar-table .input-group { max-width: 200px; }
.ar-table .field { margin: 0; }
.ar-table th[scope="row"] { font-weight: 500; text-align: left; }
.ar-note { padding: var(--space-3) var(--space-5) 0; margin: 0; }

/* ---------- Organisation ---------- */
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.plain-list code { font-size: var(--fs-meta); background: var(--fill); padding: 1px 6px; border-radius: var(--radius-sm); }

/* ---------- Help ---------- */
.help-qa details { border-bottom: 1px solid var(--hairline); padding-bottom: var(--space-3); }
.help-qa details:last-child { border-bottom: 0; }
.help-qa summary { cursor: pointer; font-weight: 500; min-height: 32px; display: flex; align-items: center; }
.help-qa summary:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.help-qa p { margin: var(--space-2) 0 0; color: var(--text-secondary); }

/* ---------- Mobile (390px) ---------- */
@media (max-width: 640px) {
  .pm-table th[scope="row"] { min-width: 150px; }
  .lv-range .input { min-width: 0; flex: 1; }
  .ov-period { align-items: flex-start; }
  .ov-pos .card-body { padding: var(--space-6) var(--space-5); }
}
/* grid items must be able to shrink below their table's width (tables scroll inside .table-wrap) */
.grid-main-side > *, .grid-2 > *, .rep-grid > * { min-width: 0; }
/* screen-reader-only text inside a scrolling table must not widen the page (its absolute box escapes the scroller otherwise) */
.table-wrap { position: relative; }
.ov-row { align-items: start; }
/* "Submitted by you": on phones the status badge drops under the text instead of squeezing it */
@media (max-width: 640px) {
  .ap-mine li { flex-wrap: wrap; align-items: flex-start; }
  .ap-mine li .li-main { flex: 1 1 calc(100% - 34px - var(--space-3)); }
  .ap-mine li > .badge { margin-left: calc(34px + var(--space-3)); }
}
/* Long forms on phones: the sticky footer stays one row tall (it used to grow 64px to clear the demo button and hid
   ~120px of the form). The demo button shrinks to an icon under the top bar instead, so it never sits on the footer's buttons. */
@media (max-width: 640px) {
  body:has(.demo-fab) .form-footer { padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); flex-wrap: wrap; }
  body:has(.form-footer) .demo-fab { bottom: auto; top: 72px; }
  body:has(.form-footer) .demo-fab .demo-fab-label { display: none; }
  body:has(.form-footer) .demo-fab > button { width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: var(--radius-full); }
  .form-footer .btn { flex: 1 1 auto; }
  .form-footer .left { flex-basis: 100%; }
}
