/*
 * base.css — reset + app shell (sidebar, topbar, content) + data tables.
 * The shell is described verbatim in roadmap/design-system.md §"App shell".
 */

/* ---- reset ---- */
*,
*::before,
*::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--text); }
ul { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.mono { font-family: var(--font-mono); font-feature-settings: 'tnum' 1; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

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

/* ---- sidebar ---- */
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 16px;
}
.sidebar__brand .logo { width: 28px; height: 28px; flex: none; }
.sidebar__wordmark { line-height: 1.1; }
.sidebar__wordmark strong { color: #fff; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.sidebar__wordmark span {
  display: block;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 1px;
}
.nav { flex: 1; padding: 6px 12px; }
.nav__section { margin-top: 16px; }
.nav__label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #64748B;
  padding: 6px 12px;
}
.nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  margin-left: -3px;
  cursor: pointer;
  white-space: nowrap;
}
.nav__item:hover { background: #1E293B99; color: #E2E8F0; text-decoration: none; }
.nav__item.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  border-left-color: var(--accent-2);
}
.nav__item .icon { width: 17px; height: 17px; flex: none; opacity: 0.9; }
.nav__pinned {
  border-top: 1px solid #1E293B;
  padding: 10px 12px 16px;
  margin: 6px 0 0;
}

/* ---- topbar ---- */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; overflow: hidden; }
.topbar {
  height: var(--topbar-h);
  flex: none;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
}
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.breadcrumb .sep { color: var(--muted); }
.breadcrumb a { color: var(--text-secondary); font-weight: 500; }
.breadcrumb .current { color: var(--text); font-weight: 600; }
.topbar__search {
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}
.topbar__search input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 0 40px 0 38px;
  font-size: 13px;
  color: var(--text);
}
.topbar__search input::placeholder { color: var(--muted); }
.topbar__search .magnifier { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar__search .kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; background: #fff;
}
.topbar__right { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: var(--radius); border: none; background: transparent; color: var(--text-secondary); }
.iconbtn:hover { background: var(--row-hover); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--indigo-bg); color: var(--indigo-text);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}

/* ---- content ---- */
.content { flex: 1; overflow-y: auto; padding: 28px 32px 48px; }
.content--wide { max-width: none; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: var(--fs-h1); letter-spacing: -0.02em; }
.page-head .subtitle { color: var(--muted); font-size: 13px; margin-top: 4px; }
.page-head__actions { display: flex; align-items: center; gap: 12px; }

/* ---- tables ---- */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-table); }
table.data thead th {
  text-align: left;
  font-size: var(--fs-label);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data thead th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data thead th.sortable { cursor: pointer; }
table.data thead th.sortable::after { content: '⌄'; margin-left: 4px; color: var(--muted); font-size: 11px; }
table.data thead th.sort-asc::after { content: '⌃'; color: var(--text-secondary); }
table.data thead th.sort-desc::after { content: '⌄'; color: var(--text-secondary); }
table.data tbody td {
  padding: 0 14px;
  height: 44px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
  white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--row-hover); }
table.data tbody tr.clickable { cursor: pointer; }
table.data td.wrap { white-space: normal; }
table.data td.dim, table.data tr.dim td { color: var(--muted); }
.cell-primary { font-weight: 500; color: var(--text); }
.cell-sub { color: var(--muted); font-size: 11px; }

.empty-state { padding: 48px 24px; text-align: center; color: var(--muted); }
.error-state { padding: 16px; border: 1px solid var(--red-bg); background: #FEF2F2; color: var(--red-text); border-radius: var(--radius); font-size: 13px; }

/* ---- loading skeleton ---- */
.skeleton { background: linear-gradient(90deg, #EEF2F6 25%, #E2E8F0 50%, #EEF2F6 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 4px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
