/* Пространства: switcher at the top of the graphite sidebar, the owner page «Пространства», the token dialogs.
   Tokens from app.css; the tile tones are the only colour per space (DESIGN.md: colour only in a compact sign). */

/* ---- switcher (sidebar slot data-slot="space-switcher") ------------------------------------------ */
.side-space { position: relative; margin-top: 14px; }
.side :focus-visible { outline-color: #8cd3ae; }
.sp-btn { width: 100%; min-height: 56px; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 9px; color: #eef3f0; background: #2a3431; border: 1px solid #3c4844; border-radius: 8px; text-align: left; transition: background-color .14s ease, border-color .14s ease; }
.sp-btn:hover { background: #303c38; border-color: #4d5b56; }
.sp-btn[aria-expanded="true"] { background: #34443d; border-color: #5f7a6d; }
.sp-btn-empty { border-style: dashed; }
.sp-btn-empty .sp-btn-name { font-size: 14px; white-space: normal; }
.sp-btn-text { min-width: 0; flex: 1; display: grid; justify-items: start; gap: 3px; }
.sp-btn-name { max-width: 100%; overflow: hidden; font-size: 15px; font-weight: 700; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.sp-btn-meta { max-width: 100%; overflow: hidden; padding: 0 6px; color: #b3bdb9; border: 1px solid #4a5652; border-radius: 4px; font-size: 12px; line-height: 18px; text-overflow: ellipsis; white-space: nowrap; }
.sp-chev { color: #a4afaa; }
.sp-tile { width: 34px; height: 34px; display: inline-grid; flex: none; place-items: center; color: #34413d; background: #d9e0dd; border-radius: 7px; }
.sp-tile svg.lucide { width: 18px; height: 18px; }
.sp-tile-none { color: #a4afaa; background: transparent; border: 1px dashed #6d7a75; }
.sp-tile-none svg.lucide { width: 16px; height: 16px; }
.sp-tile-xs { width: 20px; height: 20px; border-radius: 5px; }
.sp-tile-xs svg.lucide { width: 12px; height: 12px; }
.sp-tile-lg { width: 42px; height: 42px; border-radius: 8px; }
.sp-tile-lg svg.lucide { width: 20px; height: 20px; }
.sp-tile-xl { width: 60px; height: 60px; border-radius: 12px; }
.sp-tile-xl svg.lucide { width: 28px; height: 28px; }
.sp-menu { margin-top: 6px; padding: 6px; background: #27312e; border: 1px solid #45514d; border-radius: 8px; }
.sp-menu-label { padding: 6px 8px 4px; color: #a4afaa; font-size: 12px; font-weight: 600; }
.sp-list { display: grid; gap: 2px; }
.sp-item { width: 100%; min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 6px 8px; color: #e4ebe7; background: none; border: 0; border-radius: 6px; font-size: 14px; text-align: left; }
.sp-item:hover { background: #34403c; }
.sp-item.is-current { background: #303c38; }
.sp-item .sp-tile { width: 28px; height: 28px; border-radius: 6px; }
.sp-item .sp-tile svg.lucide { width: 16px; height: 16px; }
.sp-item-text { min-width: 0; flex: 1; display: grid; }
.sp-item-name, .sp-item-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-item-name { font-weight: 650; }
.sp-item-meta { color: #a9b4af; font-size: 12px; }
.sp-check { color: #7fcca3; }
.sp-menu-foot { display: grid; gap: 2px; margin-top: 6px; padding-top: 6px; border-top: 1px solid #3c4844; }
.sp-item-quiet { min-height: 40px; gap: 10px; color: #c7d0cc; font-size: 13.5px; font-weight: 600; }
.sp-item-quiet svg.lucide { width: 16px; height: 16px; margin: 0 6px; color: #a4afaa; }
.sp-none { display: flex; align-items: center; gap: 8px; padding: 10px 9px; color: #b3bdb9; border: 1px dashed #4a5652; border-radius: 8px; font-size: 13px; }
.crumb-space { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-weight: 600; }

/* ---- page «Пространства» ------------------------------------------------------------------------ */
.sp-rows { display: grid; gap: 14px; }
.sp-row { padding: 18px 20px 0; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.sp-row.is-off { background: var(--tint); }
.sp-row.is-off .sp-tile { opacity: .55; }
.sp-row .sp-row-id > .sp-tile { width: 22px; height: 22px; color: var(--muted); background: none; border-radius: 0; }
.sp-row .sp-row-id > .sp-tile svg.lucide { width: 22px; height: 22px; }
.sp-row-id { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; }
.sp-row-title { min-width: 0; flex: 1 1 200px; }
.sp-row-name { font-size: 18px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.sp-row-host { margin-top: 1px; color: var(--muted); font-size: 13.5px; }
.sp-row-marks { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sp-rename { order: 9; }
.sp-open { min-height: 24px; display: inline-flex; align-items: center; padding: 1px 8px; color: var(--ink-2); background: #e7ece9; border-radius: 4px; font-size: 13px; font-weight: 650; }
.sp-facts { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, .9fr) minmax(0, 1.5fr) minmax(0, .9fr); gap: 16px 28px; margin-top: 16px; padding: 14px 0 16px; border-top: 1px solid var(--line-2); }
.sp-fact dt { margin-bottom: 6px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.sp-fact dd { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; font-size: 14px; }
.sp-fact-note { color: var(--ink-2); font-size: 13px; line-height: 1.45; }
.sp-num { font-size: 22px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.sp-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 0 14px; border-top: 1px solid var(--line-2); }
.sp-acts-main, .sp-acts-danger { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sp-acts-danger { margin-left: 8px; padding-left: 16px; border-left: 1px solid var(--line); }
.sp-hint { display: inline-block; padding: 2px 8px; color: var(--ink); background: #eef1f0; border: 1px solid var(--line); border-radius: 4px; font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1.4; font-variant-numeric: tabular-nums; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: #f0f4f1; border-color: var(--line); }
.perm-space { margin-top: 8px; }

/* ---- «Сегодня»: one calm line before the first space -------------------------------------------- */
.sp-first { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: -6px 0 18px; padding: 12px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.sp-first p svg.lucide { margin-right: 8px; color: var(--green); vertical-align: -3px; }
.sp-first p { min-width: 0; flex: 1 1 320px; font-size: 14px; }
.sp-first p span { color: var(--ink-2); }

/* ---- dialogs ------------------------------------------------------------------------------------ */
.sp-form { margin-top: 0; }
.sp-form .prose { margin-top: 0; font-size: 14px; }
.form-error > span { min-width: 0; flex: 1; }
.form-error.is-amber { color: #5e4209; background: var(--amber-soft); border-color: var(--amber-line); }
.form-error.is-amber svg.lucide { color: var(--amber); }
.form-error .btn { margin-top: 8px; display: flex; }
.form-error .spin { border-color: #c9d4cf; border-top-color: var(--green); }
.btn-primary .spin { border-color: rgba(255,255,255,.4); border-top-color: #fff; }
.sp-done { display: flex; align-items: center; gap: 16px; }
.sp-done-name { margin-top: 6px; font-size: 22px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.sp-done-lead { font-size: 15px; }
.sp-done-count { font-weight: 650; }
.sp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-chip { min-height: 28px; display: inline-flex; align-items: center; padding: 2px 10px; color: var(--ink-2); background: var(--tint); border: 1px solid var(--line); border-radius: 14px; font-size: 13px; }

@media (min-width: 768px) { .sp-acts-main { flex-wrap: nowrap; } }
@media (min-width: 768px) and (max-width: 1279px) {
  .sp-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .sp-row { padding: 16px 16px 0; }
  .sp-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
  .sp-fact-check { grid-column: 1 / -1; }
  .crumb-space { flex: none; }
  .crumb-space + svg.lucide { display: inline-block; flex: none; }
  .sp-acts { display: grid; gap: 10px; }
  .sp-acts-main { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .sp-acts-danger { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-left: 0; padding: 10px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  /* every secondary action at this width is the same full-width outline button */
  .sp-acts .btn { width: 100%; min-height: 44px; white-space: normal; color: var(--ink-2); background: transparent; border-color: var(--field); }
  .sp-acts .btn.btn-primary { color: #fff; background: var(--green-btn); border-color: var(--green-btn); }
  .sp-acts .btn-quiet-red { color: var(--red); }
  .sp-rename { width: 44px; height: 44px; }
  .sp-item, .sp-btn { min-height: 48px; }
}
@media (forced-colors: active) {
  .sp-tile, .sp-btn, .sp-row { border: 1px solid CanvasText; }
}

/* ---- «Обновить данные из CRM» (dashboard/refresh.mjs): button, progress, result, data age --------- */
.head-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rf-btn { min-width: 262px; }
.rf-btn[aria-disabled="true"] { cursor: progress; color: var(--ink-2); background: var(--tint); }
.sp-row .rf-btn { min-width: min(232px, 100%); max-width: 100%; }
.rf { display: grid; gap: 8px; margin: -10px 0 20px; }
.sp-row .rf { margin: 0; padding: 12px 0 14px; border-top: 1px solid var(--line-2); }
/* Inside a space card the result is flat: no card in a card. */
.sp-row .rf-result, .sp-row .rf-status:not(.rf-error) { background: transparent; border: 0; border-radius: 0; }
.sp-row .rf-result > summary, .sp-row .rf-status:not(.rf-error), .sp-row .rf-plan { padding-left: 0; padding-right: 0; }
.rf-age, .rf-note { display: flex; align-items: flex-start; gap: 8px; color: var(--ink-2); font-size: 13.5px; }
.rf-age svg.lucide, .rf-note svg.lucide { width: 15px; height: 15px; margin-top: 2px; flex: none; color: var(--muted); }
.rf-age.is-stale { color: #5e4209; }
.rf-age.is-stale svg.lucide { color: var(--amber); }
.rf-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; }
.rf-status > span:not(.mark):not(.spin) { min-width: 0; flex: 1 1 240px; }
.rf-error { background: var(--red-soft); border-color: var(--red-line); color: #7c2e2a; }
.rf-result { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.rf-result > summary { min-height: 44px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 8px 12px; cursor: pointer; list-style: none; font-size: 14px; }
.rf-result > summary::-webkit-details-marker { display: none; }
.rf-sum { min-width: 0; flex: 1 1 260px; display: flex; align-items: flex-start; gap: 8px; }
.rf-sum svg.lucide { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--green); }
.rf-sum-amber svg.lucide { color: var(--amber); }
.rf-more { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.rf-more svg.lucide { width: 15px; height: 15px; transition: transform .14s ease; }
.rf-result[open] .rf-more svg.lucide { transform: rotate(180deg); }
.rf-plans { display: grid; border-top: 1px solid var(--line-2); }
.rf-plan { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(0, 2fr); gap: 6px 16px; padding: 10px 12px; font-size: 14px; }
.rf-plan + .rf-plan { border-top: 1px solid var(--line-2); }
.rf-plan-name { font-weight: 650; overflow-wrap: anywhere; }
.rf-plan-state { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 8px; color: var(--ink-2); }
.rf-plan-state > span:not(.mark) { min-width: 0; flex: 1 1 220px; }
@media (max-width: 767px) {
  .head-acts { width: 100%; }
  .head-acts .btn { flex: 1 1 auto; min-height: 44px; }
  .rf-plan { grid-template-columns: 1fr; }
  .rf .btn { min-height: 44px; }
}
.rf-plan-name a { display: inline-block; padding: 4px 0; }
