/* ────────────────────────────────────────────────────────────
   Планёрки ПСБ — Component styles
   Depends on tokens.css being loaded first
   ──────────────────────────────────────────────────────────── */

/* ── App Shell ──────────────────────────────────────────────── */
.psb-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.psb-sidebar {
  width: 244px;
  flex: none;
  background: var(--bg-2);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
  gap: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.2s ease;
}

.psb-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
}

.psb-sidebar-logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  flex: none;
}

.psb-sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.psb-sidebar-brand-text strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.psb-sidebar-brand-text span {
  font-size: 11px;
  color: var(--muted);
}

/* Search */
.psb-sidebar-search {
  position: relative;
  padding: 0 4px;
}

.psb-sidebar-search .psb-input {
  padding-left: 32px;
  height: 30px;
  font-size: 12.5px;
  background: var(--surface);
}

.psb-sidebar-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.psb-sidebar-search .psb-kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

/* Nav groups */
.psb-nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.psb-nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.psb-nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 0 12px;
  margin-bottom: 2px;
}

.psb-nav-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Nav item */
.psb-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-2);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background 0.1s;
  letter-spacing: -0.005em;
  position: relative;
}

.psb-nav-item:hover {
  background: var(--bg-3);
  color: var(--ink);
}

.psb-nav-item.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  box-shadow: var(--shadow-1);
}

.psb-nav-item .nav-icon {
  color: var(--muted);
  flex: none;
  width: 16px;
}

.psb-nav-item.active .nav-icon {
  color: var(--ink-2);
}

.psb-nav-item .nav-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.psb-nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  background: var(--bg-3);
  color: var(--muted);
  flex: none;
}

.psb-nav-badge.accent {
  background: var(--accent);
  color: var(--accent-ink);
}

.psb-nav-badge.warn {
  background: var(--st-progress-bg);
  color: var(--st-progress);
}

/* Quick filters */
.psb-filters {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.psb-filter-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--ink-2);
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.1s;
  letter-spacing: -0.005em;
}

.psb-filter-btn:hover { background: var(--bg-3); }

.psb-filter-btn .filter-count {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.psb-filter-btn.danger .filter-count { color: var(--st-stuck); }
.psb-filter-btn.warn .filter-count { color: var(--st-progress); }

/* Sidebar bottom: user */
.psb-sidebar-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
}

.psb-sidebar-user:hover { background: var(--bg-3); }

.psb-sidebar-user .user-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.psb-sidebar-user .user-role {
  font-size: 11px;
  color: var(--muted);
}

/* ── Main area ───────────────────────────────────────────────── */
.psb-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── Page Header ─────────────────────────────────────────────── */
.psb-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--hairline);
  gap: 16px;
  flex: none;
}

.psb-page-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.psb-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.psb-page-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.psb-page-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.psb-page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

/* ── Toolbar ─────────────────────────────────────────────────── */
.psb-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 28px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
  flex: none;
}

.psb-toolbar .spacer { flex: 1; }

/* View switcher */
.psb-view-switcher {
  display: flex;
  align-items: center;
  background: var(--bg-2);
  border-radius: 8px;
  padding: 2px;
  gap: 1px;
}

.psb-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.psb-view-btn:hover { color: var(--ink-2); }
.psb-view-btn.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* Filter chips */
.psb-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--ink-2);
  background: var(--bg-2);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  white-space: nowrap;
  letter-spacing: -0.005em;
}

.psb-chip:hover { background: var(--bg-3); border-color: var(--line-strong); }

.psb-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 500;
}

.psb-chip .chip-count {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--muted);
}

.psb-chip.active .chip-count { color: var(--accent); }

/* ── Content area ────────────────────────────────────────────── */
.psb-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Two-panel layout */
.psb-two-panel {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.psb-panel-list {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  border-right: 1px solid var(--hairline);
}

.psb-panel-detail {
  width: 420px;
  flex: none;
  overflow-y: auto;
  background: var(--surface);
}

/* ── Group Header ────────────────────────────────────────────── */
.psb-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px 6px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}

.psb-group-header-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.psb-group-header-count {
  font-size: 11px;
  color: var(--muted-2);
  font-family: var(--font-mono);
}

.psb-group-header-line {
  flex: 1;
  height: 1px;
  background: var(--hairline);
}

.psb-group-header-toggle {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.psb-group-header-toggle:hover { background: var(--bg-3); color: var(--ink-2); }

.psb-group-header.overdue .psb-group-header-label { color: var(--st-stuck); }

/* ── Task Row ────────────────────────────────────────────────── */
.psb-task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--row-h);
  padding: 0 var(--row-pad-x);
  border-bottom: 1px solid var(--hairline);
  cursor: pointer;
  transition: background 0.08s;
  position: relative;
  user-select: none;
}

.psb-task-row:hover { background: var(--bg-3); }
.psb-task-row.selected { background: var(--accent-soft); }
.psb-task-row.overdue .task-title { color: var(--st-stuck); }
.psb-task-row.dropped .task-title { text-decoration: line-through; color: var(--muted); }

.psb-task-row .task-check {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--line-strong);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--st-done);
  background: none;
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
}

.psb-task-row .task-check:hover { border-color: var(--st-done); }
.psb-task-row .task-check.checked { background: var(--st-done); border-color: var(--st-done); color: white; }

.psb-task-row .task-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  flex: none;
  min-width: 48px;
}

.psb-task-row .task-src { flex: none; }

.psb-task-row .task-title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.005em;
}

.psb-task-row .task-overdue-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--st-stuck);
  flex: none;
}

.psb-task-row .task-deadline {
  font-size: 12px;
  color: var(--muted);
  flex: none;
  font-family: var(--font-mono);
}

.psb-task-row .task-deadline.overdue { color: var(--st-stuck); }

.psb-task-row .task-actions {
  display: none;
  align-items: center;
  gap: 4px;
  flex: none;
}

.psb-task-row:hover .task-actions { display: flex; }

/* ── Draft card (Moderation) ─────────────────────────────────── */
.psb-draft-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.12s, border-color 0.12s;
  cursor: pointer;
}

.psb-draft-card:hover { box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.psb-draft-card.accepted { border-color: var(--st-done); border-left: 3px solid var(--st-done); }
.psb-draft-card.rejected { opacity: 0.5; }

.psb-draft-card-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.psb-draft-card-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

.psb-draft-card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  flex: 1;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.psb-confidence {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  flex: none;
}
.psb-confidence.high { color: var(--st-done); }
.psb-confidence.mid  { color: var(--st-progress); }
.psb-confidence.low  { color: var(--st-stuck); }

.psb-draft-quote {
  font-size: 12.5px;
  color: var(--muted);
  border-left: 3px solid var(--accent-line);
  padding: 6px 10px;
  border-radius: 0 6px 6px 0;
  background: var(--bg-2);
  font-style: italic;
  line-height: 1.5;
}

.psb-draft-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.psb-draft-meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.psb-draft-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--hairline);
  padding-top: 10px;
  margin-top: 2px;
}

/* ── Stats bar ───────────────────────────────────────────────── */
.psb-stats-bar {
  display: flex;
  align-items: stretch;
  gap: 1px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
  flex: none;
}

.psb-stat-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 20px 0 0;
  min-width: 0;
}

.psb-stat-item + .psb-stat-item {
  border-left: 1px solid var(--hairline);
  padding-left: 20px;
}

.psb-stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.025em;
  line-height: 1;
}

.psb-stat-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}

.psb-stat-value.warn  { color: var(--st-progress); }
.psb-stat-value.danger { color: var(--st-stuck); }
.psb-stat-value.ok    { color: var(--st-done); }

/* ── Empty state ─────────────────────────────────────────────── */
.psb-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

.psb-empty-icon { color: var(--muted-2); }

.psb-empty-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
}

.psb-empty-text { font-size: 13px; max-width: 280px; }

/* ── Modal / Dialog ──────────────────────────────────────────── */
.psb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,15,10,0.4);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: psb-fade-in 0.15s ease;
}

.psb-dialog {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  width: 480px;
  max-width: calc(100vw - 32px);
  animation: psb-slide-in 0.15s ease;
  overflow: hidden;
}

.psb-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hairline);
}

.psb-dialog-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.psb-dialog-body { padding: 20px; }

.psb-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--hairline);
}

/* ── Datepicker ──────────────────────────────────────────────── */
.psb-dp-dialog { width: 360px; }

.psb-dp-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.psb-dp-month {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.psb-dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.psb-dp-wd {
  text-align: center;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 0;
}
.psb-dp-day {
  font-family: var(--font-mono);
  font-size: 12.5px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.psb-dp-day:hover { background: var(--bg-3); }
.psb-dp-day.outside { color: var(--muted-2); }
.psb-dp-day.past { opacity: 0.45; }
.psb-dp-day.weekend { color: var(--st-stuck); }
.psb-dp-day.today {
  border-color: var(--accent);
  font-weight: 600;
}
.psb-dp-day.selected {
  background: var(--st-done);
  color: #fff;
  border-color: var(--st-done);
  font-weight: 600;
}
.psb-dp-day.selected:hover { filter: brightness(1.05); }

.psb-dp-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}
.psb-dp-chip {
  font-family: inherit;
  font-size: 12px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.psb-dp-chip:hover { background: var(--bg-3); border-color: var(--line-strong); }
.psb-dp-chip.active {
  background: var(--st-done-bg);
  border-color: var(--st-done);
  color: var(--st-done);
  font-weight: 500;
}

@media (max-width: 768px) {
  .psb-dp-dialog { width: calc(100vw - 24px); }
  .psb-dp-day { height: 40px; font-size: 13px; }
}

/* ── Toast / Hotkey hint ─────────────────────────────────────── */
.psb-toast-wrap {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

/* Боковой стек — для уведомлений действий */
.psb-toast-side {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  pointer-events: none;
}

.psb-toast {
  background: var(--ink);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-3);
  animation: psb-slide-in 0.15s ease;
}

/* Уведомления действий: success / warn / danger / info */
.psb-toast.action {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 280px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 400;
  line-height: 1.45;
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(20,17,13,.10), 0 2px 6px rgba(20,17,13,.06);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity .2s, transform .2s;
}
.psb-toast.action.show { opacity: 1; transform: translateX(0); }
.psb-toast.action .ic {
  width: 22px; height: 22px; border-radius: 999px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; margin-top: 1px;
}
.psb-toast.action.success { border-left: 3px solid var(--st-done); }
.psb-toast.action.success .ic { background: var(--ok-soft, #e6f3ec); color: var(--st-done); }
.psb-toast.action.warn    { border-left: 3px solid var(--st-progress); }
.psb-toast.action.warn .ic{ background: var(--warn-soft, #fdf3dc); color: var(--st-progress); }
.psb-toast.action.danger  { border-left: 3px solid var(--st-stuck); }
.psb-toast.action.danger .ic { background: var(--accent-soft); color: var(--st-stuck); }
.psb-toast.action.info    { border-left: 3px solid var(--info, #1f5fb2); }
.psb-toast.action.info .ic{ background: var(--info-soft, #e6eef9); color: var(--info, #1f5fb2); }
.psb-toast.action .body { flex: 1; min-width: 0; }
.psb-toast.action .title { font-size: 13.5px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.psb-toast.action .sub { font-size: 12px; color: var(--ink-3); }
.psb-toast.action .close {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 18px; line-height: 1; padding: 0; flex: none;
}
.psb-toast.action .close:hover { color: var(--ink); }

/* Hint-banner на странице модерации (persistent) */
.psb-mod-hint {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin: 0 28px 14px;
  background: var(--ok-soft, #e6f3ec);
  border: 1px solid var(--st-done, #2f7a4d);
  border-radius: 10px;
  font-size: 13px; color: var(--ink-2);
}
.psb-mod-hint .num { font-weight: 700; color: var(--st-done); }
.psb-mod-hint .arrow { margin-left: auto; color: var(--st-done); font-weight: 600; }

/* ── Hamburger (mobile) ──────────────────────────────────────── */
.psb-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-2);
  padding: 4px;
  border-radius: 6px;
}

.psb-hamburger:hover { background: var(--bg-3); }

/* ── Mobile breakpoint ───────────────────────────────────────── */
@media (max-width: 768px) {
  .psb-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    box-shadow: var(--shadow-3);
  }

  .psb-sidebar.open { transform: translateX(0); }

  .psb-hamburger { display: flex; }

  .psb-panel-detail { display: none; }
  .psb-panel-list { border-right: none; }

  .psb-page-header { padding: 16px 16px 14px; }
  .psb-toolbar { padding: 8px 16px; }
  .psb-content { padding: 0; }

  .psb-task-row { padding: 0 16px; }
  .psb-stats-bar { padding: 12px 16px; overflow-x: auto; }
}
