/* ---------------------------------------------------------------
   base.css — reset, app shell, sidebar, topbar, typography
   --------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--dur) var(--ease),
              color var(--dur) var(--ease);
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 21px; letter-spacing: -0.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p  { margin: 0 0 var(--space-3); }
a  { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

/* visible focus for keyboard users only */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--accent-soft); color: var(--text); }

/* thin, unobtrusive scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: var(--radius-pill);
}

.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;
}

/* ---------------- app shell ---------------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-4);
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-2);
}
.brand__mark {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
}
.brand__name { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
.brand__sub  { font-size: 11px; color: var(--text-faint); margin-top: -2px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: var(--space-3) var(--space-2) var(--space-1);
}
.nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 7px var(--space-2);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav__item:hover { background: var(--surface-hover); color: var(--text); }
.nav__item.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.nav__item svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.nav__count {
  margin-left: auto;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0 6px;
  border-radius: var(--radius-pill);
}
.nav__item.is-active .nav__count {
  background: var(--surface); color: var(--accent-text); border-color: var(--accent-line);
}
.nav__count.is-alert { color: var(--urgent); border-color: var(--urgent); }

.sidebar__foot { margin-top: auto; display: grid; gap: var(--space-3); }

/* ---------------- main column ---------------- */

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__title { display: grid; gap: 1px; margin-right: auto; min-width: 0; }
.topbar__title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__sub { font-size: 12px; color: var(--text-faint); }

.view {
  padding: var(--space-5);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

.section { margin-bottom: var(--space-6); }
.section__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.section__head h2 { display: flex; align-items: center; gap: var(--space-2); }
.section__rule { flex: 1; height: 1px; background: var(--border); }

.grid { display: grid; gap: var(--space-4); }
.grid--2 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
/* fixed two-up — auto-fill would collapse to one column in narrow panes */
.grid--pair { grid-template-columns: 1fr 1fr; gap: var(--space-3); }
@media (max-width: 420px) { .grid--pair { grid-template-columns: 1fr; } }

.row { display: flex; align-items: center; gap: var(--space-2); }
.row--wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* responsive: collapse the sidebar into a top bar of icons */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .brand { width: 100%; padding: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: var(--space-1); }
  .nav__label, .nav__count { display: none; }
  .nav__item { width: auto; padding: 7px 10px; }
  .sidebar__foot { display: none; }
  .view { padding: var(--space-4); }
  .topbar { padding: var(--space-3) var(--space-4); flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
