/* ============================================================
   PM-учёт · SHARED PATCH
   Общие компоненты, которые подключаются ПОВЕРХ темы:
   - Мобильное меню-гамбургер
   - Новые экраны: Reports, Roadmap, Calendar, Profile, Login
   Все стили используют CSS-переменные темы — выглядят как тема.
   ============================================================ */

/* ============ MOBILE TOP BAR + HAMBURGER ============ */
.mobile-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-elev-1, var(--bg-sidebar, var(--bg)));
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  height: 56px;
}
.hamburger {
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--line-strong, var(--line));
  border-radius: var(--r-sm, 6px);
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  box-shadow: none;
}
.hamburger:hover { transform: none; background: var(--bg-elev-2, transparent); }
.hamburger span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--fg);
  border-radius: 0;
  transition: transform .2s, opacity .2s;
}
.hamburger.open span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }
.mobile-logo {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display, var(--font-sans));
  font-size: 16px;
  font-weight: 600;
  color: var(--fg-bright);
  letter-spacing: -0.01em;
}
.mobile-search {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--line-strong, var(--line));
  border-radius: var(--r-sm, 6px);
  color: var(--fg-muted);
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  cursor: pointer;
  box-shadow: none;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 90;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}

/* ============ REPORTS ============ */
.chart-mock.chart-tall { height: 200px; }

.report-projects { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.report-projects li {
  display: grid;
  grid-template-columns: 1fr 100px 50px;
  gap: 14px;
  align-items: center;
}
.rp-info { min-width: 0; }
.rp-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--fg-bright);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rp-meta {
  font-size: 11.5px;
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.rp-bar {
  height: 8px;
  background: var(--bg-elev-3, var(--bg-elev-2));
  border-radius: var(--r-full);
  overflow: hidden;
}
.rp-bar span { display: block; height: 100%; border-radius: var(--r-full); }
.rp-val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ============ ROADMAP ============ */
.roadmap {
  display: grid;
  grid-template-columns: 180px repeat(6, 1fr);
  gap: 0;
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 0;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  overflow-x: auto;
}
.rm-header {
  display: contents;
}
.rm-header .rm-quarter {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: var(--bg-elev-2);
}
.rm-header .rm-track-label {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev-2);
}
.rm-q-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-bright);
  margin-bottom: 3px;
  letter-spacing: -0.005em;
}
.rm-q-meta {
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rm-track { display: contents; }
.rm-track > .rm-track-label {
  padding: 16px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev-1);
}
.rm-track-label b {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg-bright);
  letter-spacing: -0.005em;
  margin-bottom: 2px;
}
.rm-track-label .muted {
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rm-row {
  grid-column: 2 / span 6;
  position: relative;
  height: 90px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / calc(100%/6) 100%;
}

.rm-item {
  position: absolute;
  top: 8px;
  height: 40px;
  left: calc(var(--start) * 100% / 6);
  width: calc(var(--span) * 100% / 6);
  background: color-mix(in srgb, var(--c) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  border-left: 3px solid var(--c);
  border-radius: var(--r-sm, 6px);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  cursor: grab;
  overflow: hidden;
  transition: transform .12s, box-shadow .12s;
  min-width: 60px;
}
.rm-item:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.rm-item.active {
  background: var(--c);
  color: white;
  border-color: var(--c);
}
.rm-item.active .rm-item-title,
.rm-item.active .rm-item-meta { color: white; }
.rm-item-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-bright);
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rm-item-meta {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rm-item-prog {
  margin-top: 4px;
  height: 2px;
  background: color-mix(in srgb, var(--c) 30%, transparent);
  border-radius: var(--r-full);
  overflow: hidden;
}
.rm-item-prog span { display: block; height: 100%; background: var(--c); }
.rm-item.active .rm-item-prog { background: rgba(255,255,255,0.3); }
.rm-item.active .rm-item-prog span { background: white; }

/* "Now" line — vertical, spans all tracks */
.rm-now {
  position: absolute;
  top: 50px;
  bottom: 0;
  /* Position based on --now-col: the index of the current month column (0-based in the 6-col grid) */
  left: calc(180px + var(--now-col, -1) * (100% - 180px) / 6 + (100% - 180px) / 12);
  width: 2px;
  background: var(--accent, var(--accent-berry, var(--accent-lime, var(--p-urgent))));
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 0 0 0.5px var(--bg-elev-1);
  display: var(--now-col, -1) < 0 ? none : block;
}
.rm-now::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  width: 10px;
  height: 10px;
  background: var(--accent, var(--accent-berry, var(--p-urgent)));
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg-elev-1);
}

.rm-legend-card { background: transparent; box-shadow: none; border: 1px dashed var(--line-strong, var(--line)); padding: 14px 16px; }
.rm-legend-row { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--fg-muted); }
.rm-leg-item { display: inline-flex; align-items: center; gap: 6px; }
.rm-leg-bar { width: 24px; height: 8px; background: var(--accent-indigo, var(--c-progress)); border-radius: 2px; display: inline-block; }
.rm-leg-bar.muted { opacity: 0.4; }
.rm-leg-line { width: 2px; height: 14px; background: var(--accent, var(--accent-berry, var(--p-urgent))); display: inline-block; border-radius: 1px; }

/* Task bars inside roadmap rows */
.rm-task-bar {
  position: absolute;
  bottom: 6px;
  height: 18px;
  left: calc(var(--start) * 100% / 6);
  width: calc(var(--span) * 100% / 6);
  background: color-mix(in srgb, var(--c) 22%, transparent);
  border-left: 2px solid var(--c);
  border-radius: 0 3px 3px 0;
  padding: 0 6px;
  display: flex;
  align-items: center;
  font-size: 10px;
  color: var(--c);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.85;
}
.rm-task-bar a { color: inherit; }

/* Milestone diamond markers */
.rm-milestone {
  position: absolute;
  bottom: 26px;
  left: calc(var(--col) * 100% / 6 + 100% / 12);
  transform: translateX(-50%);
  font-size: 14px;
  color: var(--accent);
  z-index: 4;
  cursor: default;
  line-height: 1;
  text-shadow: 0 0 6px rgba(124,125,240,0.5);
}

/* Today column highlight */
.rm-today-col {
  background: rgba(124,125,240,0.04);
}

/* ============ CALENDAR ============ */
.calendar-card { padding: 0; overflow: hidden; }
.cal-month {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--line);
  gap: 1px;
}
.cal-wkday {
  padding: 12px 14px;
  background: var(--bg-elev-2);
  font-family: var(--font-mono, monospace);
  font-size: 10.5px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.cal-day {
  background: var(--bg-elev-1);
  min-height: 110px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
.cal-day.weekend { background: color-mix(in srgb, var(--bg-elev-2) 60%, var(--bg-elev-1)); }
.cal-day.cal-other { opacity: 0.45; }
.cal-day.cal-today {
  background: color-mix(in srgb, var(--accent, var(--accent-lime, var(--accent-berry))) 8%, var(--bg-elev-1));
  box-shadow: inset 0 0 0 2px var(--accent, var(--accent-berry));
}
.cal-num {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}
.cal-day.cal-today .cal-num {
  color: var(--accent, var(--accent-berry, var(--p-urgent)));
  font-weight: 700;
}
.cal-evt {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--c) 18%, transparent);
  color: color-mix(in srgb, var(--c) 75%, var(--fg-bright));
  border-left: 2px solid var(--c);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  letter-spacing: -0.005em;
}
.cal-evt:hover { filter: brightness(1.05); }
.cal-evt.deadline {
  background: color-mix(in srgb, var(--p-urgent) 14%, transparent);
  color: var(--p-urgent);
  border-left-color: var(--p-urgent);
  font-weight: 600;
}

.ics-card { display: flex; flex-direction: column; gap: 12px; }
.ics-card p { font-size: 13px; color: var(--fg-muted); line-height: 1.5; }
.ics-url {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elev-2);
  border-radius: var(--r-sm, 6px);
  border: 1px solid var(--line);
  flex-wrap: wrap;
}
.ics-url code {
  flex: 1;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: var(--fg);
  background: transparent;
  padding: 0;
  border: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ============ PROFILE ============ */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.profile-card-hero {
  grid-column: 1 / -1;
  background: var(--bg-elev-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.avatar.avatar-xl {
  width: 80px;
  height: 80px;
  font-size: 30px;
  font-family: var(--font-display, var(--font-sans));
}
.profile-hero-info { flex: 1; min-width: 240px; }
.profile-name {
  font-family: var(--font-display, var(--font-sans));
  font-size: 24px;
  font-weight: 600;
  color: var(--fg-bright);
  margin-bottom: 2px;
  letter-spacing: -0.01em;
}
.profile-meta {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--fg-muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--fg-muted);
  font-weight: 500;
}
.form-grid input, .form-grid select { width: 100%; }
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.toggle-list { list-style: none; display: flex; flex-direction: column; gap: 0; }
.toggle-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  gap: 16px;
}
.toggle-list li:last-child { border-bottom: none; }
.toggle-list li > div { display: flex; flex-direction: column; }
.toggle-list b { font-size: 13.5px; color: var(--fg-bright); font-weight: 500; margin-bottom: 2px; }
.toggle-list .muted { font-size: 12px; }

.switch {
  display: inline-block;
  width: 36px;
  height: 20px;
  background: var(--bg-elev-3, var(--bg-elev-2));
  border-radius: var(--r-full);
  position: relative;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
  border: 1px solid var(--line-strong, var(--line));
}
.switch::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  background: var(--bg-elev-1);
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch.on {
  background: var(--accent, var(--c-done));
  border-color: var(--accent, var(--c-done));
}
.switch.on::after { transform: translateX(16px); }

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--fg-muted);
  cursor: pointer;
}
.checkbox-label input { width: 14px; height: 14px; margin: 0; padding: 0; }

.danger-zone {
  grid-column: 1 / -1;
  border-color: color-mix(in srgb, var(--p-urgent) 30%, var(--line)) !important;
  background: color-mix(in srgb, var(--p-urgent) 4%, var(--bg-elev-1)) !important;
}
.danger-zone h3 { color: var(--p-urgent) !important; }

/* ============ LOGIN ============ */
.screen-fullbleed {
  margin: calc(var(--content-pad-y, 28px) * -1) calc(var(--content-pad-x, 36px) * -1);
  min-height: calc(100vh - 0px);
}

.authpage {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
  padding: 0;
  margin: 0;
  align-items: stretch;
}
.auth-side {
  background: var(--bg-sidebar);
  color: var(--fg-on-ink, var(--fg-bright));
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  gap: 36px;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-side::before {
  content: '';
  position: absolute;
  top: 60%;
  right: -100px;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent, var(--accent-lime, var(--accent-berry))) 30%, transparent), transparent 70%);
  pointer-events: none;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display, var(--font-sans));
  font-size: 22px;
  font-weight: 600;
  color: var(--fg-on-ink, var(--fg-bright));
  letter-spacing: -0.01em;
  z-index: 1;
}
.auth-quote { z-index: 1; }
.auth-quote p {
  font-family: var(--font-serif, var(--font-display, var(--font-sans)));
  font-size: 26px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--fg-on-ink, var(--fg-bright));
  margin-bottom: 14px;
  letter-spacing: -0.015em;
}
.auth-quote-meta {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--fg-muted-on-ink, var(--fg-muted));
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.auth-feats {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1;
}
.auth-feats li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 13.5px;
  color: var(--fg-muted-on-ink, var(--fg-muted));
  line-height: 1.4;
}
.auth-feat-bullet {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent, var(--accent-lime, var(--accent-berry)));
  color: var(--bg-sidebar);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.authcard {
  background: var(--bg);
  padding: 56px 64px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  justify-content: center;
  width: 100%;
  border-radius: 0;
  box-shadow: none;
}
.authcard h1 {
  font-size: 36px;
  margin-bottom: 4px;
}
.authcard > .muted { margin-bottom: 16px; }
.authcard label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--fg-muted);
  font-weight: 500;
}
.authcard input { width: 100%; padding: 12px 14px; font-size: 14px; }
.authcard button.auth-submit { width: 100%; justify-content: center; padding: 13px; font-size: 14px; margin-top: 6px; }

.auth-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2px 0;
}
.auth-link { color: var(--accent, var(--accent-berry, var(--accent-indigo))); font-size: 13px; font-weight: 500; }
.auth-link:hover { text-decoration: underline; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
  font-size: 11px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.auth-bottom { text-align: center; font-size: 13px; }

/* navicon for calendar2 */
.navicon[data-icon="cal2"] { mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="black" stroke-width="1.5"><rect x="2" y="3" width="12" height="11" rx="1.5"/><path d="M2 6.5h12M5 1.5v3M11 1.5v3"/><circle cx="11" cy="10" r="1.2" fill="black" stroke="none"/></svg>'); }

/* ============ RESPONSIVE — Hamburger / mobile sidebar ============ */
@media (max-width: 900px) {
  .mobile-bar { display: flex; }
  .app {
    grid-template-columns: 1fr !important;
    grid-template-rows: 56px 1fr;
  }
  .mobile-bar { grid-column: 1; }
  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px !important;
    height: 100vh !important;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-open .sidebar-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
  /* override: show full sidebar text on mobile (when open) */
  .sidebar .logo-text,
  .sidebar .qs-text,
  .sidebar .qs-kbd,
  .sidebar .nav-count,
  .sidebar .nav-badge,
  .sidebar .nav-primary a span:not(.navicon),
  .sidebar .nav-projects a span:not(.proj-dot),
  .sidebar .nav-section-label,
  .sidebar .timer-info,
  .sidebar .timer-stop,
  .sidebar .userbox-info,
  .sidebar .userbox-menu { display: flex !important; }
  .sidebar .nav-primary a span:not(.navicon),
  .sidebar .nav-projects a span:not(.proj-dot) { display: inline !important; }
  .sidebar .nav-primary a, .sidebar .nav-projects a {
    justify-content: flex-start !important;
    padding: 9px 12px !important;
  }
  .sidebar .quick-search { justify-content: flex-start !important; padding: 10px 14px !important; }
  .sidebar .timer-mini { justify-content: flex-start !important; padding: 10px 12px !important; }
  .sidebar .userbox { justify-content: flex-start !important; }
  .sidebar .userbox-link { flex: 1; display: flex; align-items: center; gap: 10px; color: inherit; }

  /* Responsive new screens */
  .profile-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .authpage { grid-template-columns: 1fr; }
  .auth-side { padding: 32px 28px; }
  .authcard { padding: 32px 28px; }
  .roadmap { grid-template-columns: 140px repeat(4, minmax(160px, 1fr)); overflow-x: auto; }
  .cal-day { min-height: 80px; padding: 6px; }
  .cal-evt { font-size: 10px; padding: 1px 5px; }
  .report-projects li { grid-template-columns: 1fr 60px 36px; }
}

@media (min-width: 901px) {
  .mobile-bar { display: none !important; }
  .sidebar-backdrop { display: none !important; }
}

@media (max-width: 600px) {
  /* Roadmap: force horizontal scroll with fixed-width columns so month labels stay readable */
  .roadmap {
    grid-template-columns: 110px repeat(6, minmax(110px, 1fr));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .cal-month { font-size: 10px; }
  .cal-day { min-height: 60px; padding: 4px; }
  .cal-wkday { padding: 8px; font-size: 9.5px; }
  .auth-side { display: none; }
  .authpage { grid-template-columns: 1fr; min-height: 100vh; }
}

/* ============ USERBOX-LINK (for sidebar profile click) ============ */
.userbox-link {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.userbox-link:hover { color: inherit; }
