/* ==========================================================================
   Layout — page grid, content column, panes
   docs/02 §8
   ========================================================================== */

.page {
  min-height: 100%;
  padding-bottom: var(--dock-clearance);
}

.content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---- Page header (docs/02 §4) ------------------------------------------ */

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 64px;
  padding: var(--sp-32) 0 var(--sp-24);
  gap: var(--sp-24);
}

.page-header__titles {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.page-header__context {
  color: var(--ink-500);
  font-size: var(--t-body-size);
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  flex-shrink: 0;
}

/* ---- Dashboard grid (12 columns) ---------------------------------------- */

.grid-12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--sp-24);
}

.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-5  { grid-column: span 5; }
.col-6  { grid-column: span 6; }
.col-7  { grid-column: span 7; }
.col-8  { grid-column: span 8; }
.col-9  { grid-column: span 9; }
.col-12 { grid-column: span 12; }

@media (max-width: 1727px) {
  .col-7, .col-5 { grid-column: span 12; }
}

/* ---- Three-pane split (KhataBook customer screen), docs/02 §8 ---------- */

.pane-split {
  display: grid;
  grid-template-columns: 300px minmax(560px, 1fr) 360px;
  height: 100vh;
  overflow: hidden;
}

.pane-split.is-right-collapsed {
  grid-template-columns: 300px minmax(560px, 1fr) 0px;
}

@media (max-width: 1599px) {
  .pane-split { grid-template-columns: 300px minmax(560px, 1fr) 320px; }
  .pane-split.is-right-collapsed { grid-template-columns: 300px minmax(560px, 1fr) 0px; }
}

.pane {
  min-height: 0;
  overflow-y: auto;
  /* Each pane scrolls internally, not the window, so the dock's auto-hide
     (which tracks window scroll) never engages here. Reserve real space
     instead of relying on it — docs/02 §3's dock still floats above this
     padding, but content is never permanently hidden beneath it. */
  padding-bottom: var(--dock-clearance);
}

.pane--left,
.pane--right {
  border-left: var(--border-hairline);
  /* Three-value form deliberately: bottom stays the dock-clearance value
     set on .pane above — a plain `padding: … var(--sp-20)` shorthand would
     reset it to var(--sp-20) since these rules share .pane's specificity
     and come later in the cascade. */
  padding: var(--sp-24) var(--sp-20) var(--dock-clearance);
}

.pane--left {
  border-left: none;
  border-right: var(--border-hairline);
}

.pane--center {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pane--right {
  transition: width var(--dur-slow) var(--ease-out), opacity var(--dur-slow) var(--ease-out);
}

.pane-split.is-right-collapsed .pane--right {
  width: 0;
  opacity: 0;
  padding: 0;
  overflow: hidden;
  border-left: none;
}

/* ---- Segmented layout helpers ------------------------------------------- */

.stack {
  display: flex;
  flex-direction: column;
}

.row {
  display: flex;
  align-items: center;
}

.spacer { flex: 1 1 auto; }

.hairline {
  height: 1px;
  background: var(--ink-100);
  border: none;
}

/* ---- Settings two-column layout (docs/05 §7) ---------------------------- */

.settings-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 720px);
  gap: var(--sp-48);
  align-items: start;
}

.settings-rail {
  position: sticky;
  top: var(--sp-32);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
