/* App frame and screen layout. Components come from components.css; only layout lives here. */
html { background: var(--surface); }
body { min-height: 100vh; }
a { color: var(--link); }
:where(a, button, select, input, textarea, summary):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.jm-header-home { display: inline-flex; }
/* The DS renders steps and buttons as <button>; as links they need the same box and no underline. */
a.jm-step, a.jm-btn { text-decoration: none; box-sizing: border-box; }
.jm-progress-head b { white-space: nowrap; }
.jm-header .menu { display: flex; align-items: center; gap: var(--space-3); }
.jm-header .menu form { margin: 0; }

.app-frame { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: calc(100vh - 57px); }
.app-frame.no-sidebar { grid-template-columns: minmax(0, 1fr); }
.app-sidebar { background: var(--surface-raised); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.app-sidebar .jm-steps { border-right: 0; width: auto; }
.app-sidebar-back { display: block; padding: var(--space-3) var(--space-4); font-size: 13px; line-height: 18px; font-weight: 700; color: var(--link); text-decoration: none; border-bottom: 1px solid var(--line); }
.app-sidebar-back:hover { text-decoration: underline; }
.app-muni { padding: var(--space-4); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--space-1); }
.app-muni b { font-size: 16px; line-height: 24px; }
.app-warnings { margin-top: auto; padding: var(--space-4); border-top: 1px solid var(--line); font-size: 13px; line-height: 18px; color: var(--ink-muted); display: flex; justify-content: space-between; align-items: center; }
.app-counter { min-width: 24px; height: 24px; padding: 0 var(--space-2); border-radius: var(--radius-pill); background: var(--neutral-soft); color: var(--ink); font-weight: 700; font-size: 12px; display: inline-grid; place-items: center; box-sizing: border-box; }
.app-counter.warn { background: var(--warn-soft); color: var(--warn); }

.app-content { padding: var(--space-8) var(--space-6); }
.app-content-inner { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-6); }
.app-content.full .app-content-inner { max-width: none; }

.step-head { display: flex; flex-direction: column; gap: var(--space-1); }
.step-head h1, .page-title { margin: 0; font-size: 26px; line-height: 32px; font-weight: 700; }
.step-head p { margin: 0; color: var(--ink-muted); font-size: 15px; line-height: 22px; max-width: 80ch; }
.display { margin: 0; font-size: 32px; line-height: 40px; font-weight: 700; letter-spacing: -.01em; }

.step-pager { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); padding-top: var(--space-2); }
.step-pager .pos { font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.step-pager > :first-child:empty, .step-pager > :last-child:empty { min-width: 1px; }

.step-select { display: none; padding: var(--space-3) var(--space-4); background: var(--surface-raised); border-bottom: 1px solid var(--line); }

.flash-stack { position: fixed; right: var(--space-6); bottom: var(--space-6); display: flex; flex-direction: column; gap: var(--space-2); z-index: 20; }

.stub-note { margin: 0; color: var(--ink-muted); }

/* Login (S0) */
.auth-frame { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-frame .jm-brand { min-height: 100vh; box-sizing: border-box; justify-content: flex-end; }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: var(--space-12); background: var(--surface-raised); }
.auth-form form, .auth-form .auth-inner { display: flex; flex-direction: column; gap: var(--space-4); max-width: 400px; width: 100%; }
.auth-form .jm-btn { justify-content: center; }

/* Styleguide */
.sg-grid { display: grid; gap: var(--space-6); }
.sg-card { display: flex; flex-direction: column; gap: var(--space-2); }
.sg-card > h3 { margin: 0; font-size: 12px; line-height: 16px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.sg-canvas { background: var(--surface); border: 1px solid var(--line); }
.sg-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; max-width: 760px; }

@media (max-width: 1023px) {
  .app-frame { grid-template-columns: minmax(0, 1fr); }
  .app-sidebar { display: none; }
  .step-select { display: block; }
  .app-content { padding: var(--space-6) var(--space-4); }
  .jm-header { gap: var(--space-3); padding: 0 var(--space-4); }
  .jm-header .prod { display: none; }
  .auth-frame { grid-template-columns: minmax(0, 1fr); }
  .auth-frame .jm-brand { min-height: 0; padding: 88px var(--space-6) var(--space-6); }
  .auth-form { padding: var(--space-6) var(--space-4); }
}

/* S6b invoice review: PDF and fields side by side (the only full-width screen) */
.invoice-review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-6); align-items: start; }
@media (max-width: 1023px) { .invoice-review { grid-template-columns: minmax(0, 1fr); } }

/* S13 history drawer */
.app-drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(920px, 100vw); box-sizing: border-box; padding: 0; border: 0; border-left: 1px solid var(--line); background: var(--surface-raised); color: var(--ink); box-shadow: var(--shadow-overlay); }
.app-drawer::backdrop { background: rgba(20, 0, 41, .35); }
.app-drawer-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface-raised); }
.app-drawer-head h2 { margin: 0; font-size: 20px; line-height: 28px; }
.app-drawer-body { padding: var(--space-4) var(--space-6); }
.step-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); flex-wrap: wrap; }
.app-drawer-body .jm-tablewrap { overflow-x: auto; }
