/* «Досрок» — сброс, каркас страницы, типографика. */

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

html { font-size: var(--text-base); }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--stamp); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--stamp);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--stamp-wash); }

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

/* ---- Каркас: сайдбар + шапка + содержимое ---------------------------- */

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

.aside {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper-aside);
  border-right: 1px solid var(--line);
  padding: 20px 12px 16px;
}

.brand {
  display: block;
  padding: 2px 14px 18px;
  font-family: var(--font-doc);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand .brand-dot { color: var(--stamp); }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--r-m);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-soft);
  white-space: nowrap;
}
button.nav-item {
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.nav-item svg { width: 20px; height: 20px; flex: none; color: var(--ink-faint); }
.nav-item:hover { background: rgba(255, 255, 255, 0.75); color: var(--ink); text-decoration: none; }
.nav-item:hover svg { color: var(--ink-soft); }
.nav-item.is-active {
  background: var(--surface);
  color: var(--stamp);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-card);
}
.nav-item.is-active svg { color: var(--stamp); }

.nav-badge {
  margin-left: auto;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--amber-wash);
  color: var(--amber);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}
.nav-item.is-active .nav-badge { background: var(--amber-wash); }

.aside-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }

.aside-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.avatar {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: var(--stamp-wash);
  color: var(--stamp);
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 600;
}
.aside-user-name { font-size: 0.88rem; font-weight: 500; line-height: 1.25; }
.aside-user-plan { font-size: 0.78rem; color: var(--ink-faint); }

/* ---- Шапка ------------------------------------------------------------ */

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

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 32px 10px;
}

.search {
  position: relative;
  width: 340px;
  max-width: 38vw;
}
.search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-m);
  background: var(--surface);
  font-size: 0.94rem;
}
.search input::placeholder { color: var(--ink-faint); }
.search > svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 18px;
  height: 18px;
  translate: 0 -50%;
  color: var(--ink-faint);
  pointer-events: none;
}

.sync-line {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  padding: 6px 10px;
  border-radius: var(--r-s);
  font-size: 0.84rem;
  color: var(--ink-soft);
  white-space: nowrap;
  cursor: pointer;
}
.sync-line:hover { background: rgba(255, 255, 255, 0.9); }
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex: none;
}

/* ---- Содержимое -------------------------------------------------------- */

.content {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  padding: 8px 32px 72px;
}

.page-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin: 14px 0 20px;
}
.page-title {
  margin: 0;
  font-family: var(--font-doc);
  font-weight: 700;
  font-size: 1.7rem;
  line-height: 1.2;
}
.page-sub { color: var(--ink-soft); font-size: 0.94rem; }
.page-head-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.section-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 28px 0 10px;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.section-title .count { color: var(--ink-faint); font-weight: 500; letter-spacing: 0; }

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---- Мобильная деградация (прототип показываем с ноутбука) ------------ */

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .aside {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand { padding: 0 10px 0 4px; font-size: 1.2rem; }
  .nav { flex-direction: row; }
  .nav-item { padding: 8px 10px; white-space: nowrap; }
  .aside-foot { display: none; }
  .topbar { flex-wrap: wrap; padding: 12px 16px 8px; }
  .search { width: 100%; max-width: none; order: 3; }
  .sync-line { display: none; }
  .content { padding: 4px 16px 56px; }
}

/* ---- Печать ------------------------------------------------------------ */

@media print {
  .aside, .topbar, .no-print { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
  .content { max-width: none; padding: 0; }
}
