/* ClosingGrid — base.css
 * Reset, typography, layout shell, primitives. Mobile-first.
 */

@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/ibm-plex-sans-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/ibm-plex-sans-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("/static/fonts/ibm-plex-sans-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/static/fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--cg-font-sans);
  font-size: var(--cg-t-base);
  line-height: var(--cg-lh-normal);
  color: var(--cg-text);
  background: var(--cg-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: var(--cg-fw-semibold); line-height: var(--cg-lh-tight); }
h1 { font-size: var(--cg-t-2xl); }
h2 { font-size: var(--cg-t-xl); }
h3 { font-size: var(--cg-t-lg); }
h4 { font-size: var(--cg-t-md); }
p  { margin: 0 0 var(--cg-s-3); }
a  { color: var(--cg-brand-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: var(--cg-t-sm); color: var(--cg-text-muted); }
code, pre, kbd { font-family: var(--cg-font-mono); font-size: 0.92em; }
hr { border: 0; border-top: 1px solid var(--cg-border); margin: var(--cg-s-4) 0; }

/* App shell layout */
.cg-app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: var(--cg-topbar-h) 1fr;
  grid-template-columns: 1fr;
}
.cg-app__topbar { grid-row: 1; grid-column: 1; }
.cg-app__body {
  grid-row: 2;
  grid-column: 1;
  display: grid;
  grid-template-columns: 1fr;
}
.cg-app__sidebar { display: none; }
.cg-app__main {
  min-width: 0;
  padding: var(--cg-s-6);
  background: var(--cg-bg);
}

@media (min-width: 900px) {
  .cg-app__body {
    grid-template-columns: var(--cg-sidebar-w) 1fr;
  }
  .cg-app__sidebar {
    display: block;
    border-right: 1px solid var(--cg-border);
    background: var(--cg-sidebar-bg);
    min-height: calc(100vh - var(--cg-topbar-h));
    position: sticky;
    top: var(--cg-topbar-h);
    height: calc(100vh - var(--cg-topbar-h));
    overflow-y: auto;
  }
}

/* Mobile sidebar drawer */
.cg-drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: var(--cg-z-sidebar);
  display: none;
}
.cg-drawer-backdrop[data-open="true"] { display: block; }
@media (max-width: 899px) {
  .cg-app__sidebar[data-open="true"] {
    display: block;
    position: fixed;
    top: var(--cg-topbar-h);
    left: 0;
    bottom: 0;
    width: var(--cg-sidebar-w);
    z-index: calc(var(--cg-z-sidebar) + 1);
    background: var(--cg-sidebar-bg);
    border-right: 1px solid var(--cg-border);
    box-shadow: var(--cg-shadow-lg);
  }
}

/* Form primitives */
.cg-field { display: block; margin-bottom: var(--cg-s-4); }
.cg-label { display: block; font-size: var(--cg-t-sm); color: var(--cg-text-muted); margin-bottom: var(--cg-s-1); font-weight: var(--cg-fw-medium); }
.cg-input, .cg-select, .cg-textarea {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font-family: inherit;
  font-size: var(--cg-t-base);
  line-height: var(--cg-lh-normal);
  color: var(--cg-text);
  background: var(--cg-surface);
  border: 1px solid var(--cg-border-strong);
  border-radius: var(--cg-r-md);
  transition: border-color .15s, box-shadow .15s;
}
.cg-input:focus, .cg-select:focus, .cg-textarea:focus {
  outline: 0;
  border-color: var(--cg-brand-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cg-brand-primary) 18%, transparent);
}
.cg-textarea { min-height: 88px; resize: vertical; }
.cg-help { font-size: var(--cg-t-xs); color: var(--cg-text-subtle); margin-top: var(--cg-s-1); }

/* Buttons */
.cg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--cg-s-2);
  padding: 8px 14px;
  font-family: inherit;
  font-size: var(--cg-t-base);
  font-weight: var(--cg-fw-medium);
  line-height: 1.2;
  color: var(--cg-text);
  background: var(--cg-surface);
  border: 1px solid var(--cg-border-strong);
  border-radius: var(--cg-r-md);
  cursor: pointer;
  transition: background-color .12s, border-color .12s, color .12s;
}
.cg-btn:hover { background: var(--cg-surface-hover); }
.cg-btn:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cg-brand-primary) 25%, transparent);
}
.cg-btn--primary {
  color: var(--cg-text-on-brand);
  background: var(--cg-brand-primary);
  border-color: var(--cg-brand-primary);
}
.cg-btn--primary:hover {
  background: var(--cg-brand-primary-hover);
  border-color: var(--cg-brand-primary-hover);
}
.cg-btn--danger {
  color: var(--cg-danger-text);
  background: var(--cg-danger-bg);
  border-color: color-mix(in srgb, var(--cg-danger) 30%, transparent);
}
.cg-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--cg-text-muted);
}
.cg-btn--ghost:hover { background: var(--cg-surface-hover); color: var(--cg-text); }
.cg-btn--sm { padding: 5px 10px; font-size: var(--cg-t-sm); }
.cg-btn--icon { padding: 6px; }

/* Tables */
.cg-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--cg-surface);
}
.cg-table th, .cg-table td {
  text-align: left;
  padding: var(--cg-s-3) var(--cg-s-4);
  border-bottom: 1px solid var(--cg-border);
  font-size: var(--cg-t-sm);
}
.cg-table th {
  font-weight: var(--cg-fw-medium);
  color: var(--cg-text-muted);
  background: var(--cg-surface-2);
  border-bottom: 1px solid var(--cg-border-strong);
}
.cg-table tbody tr:hover { background: var(--cg-surface-2); }

/* Utility */
.cg-stack > * + * { margin-top: var(--cg-s-3); }
.cg-row { display: flex; align-items: center; gap: var(--cg-s-3); }
.cg-row--between { justify-content: space-between; }
.cg-mt-4 { margin-top: var(--cg-s-4); }
.cg-mt-6 { margin-top: var(--cg-s-6); }
.cg-mt-8 { margin-top: var(--cg-s-8); }
.cg-muted { color: var(--cg-text-muted); }
.cg-subtle { color: var(--cg-text-subtle); }
.cg-mono { font-family: var(--cg-font-mono); }
.cg-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.cg-hide-mobile { display: none; }
@media (min-width: 700px) { .cg-hide-mobile { display: revert; } }
.cg-show-mobile { display: revert; }
@media (min-width: 700px) { .cg-show-mobile { display: none; } }

/* Page header */
.cg-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--cg-s-4);
  margin-bottom: var(--cg-s-6);
  flex-wrap: wrap;
}
.cg-page-header__title { font-size: var(--cg-t-2xl); margin: 0; }
.cg-page-header__sub { color: var(--cg-text-muted); margin: 4px 0 0; font-size: var(--cg-t-sm); }
