/* v1.0.9 — Cosmos Light, adaptive scaling and layout refinements */
:root {
  --ui-scale: 1;
  --font-scale: 1;
}

.brand-block { gap: calc(10px * var(--ui-scale)); }
.brand-mark {
  width: calc(42px * var(--ui-scale));
  height: calc(42px * var(--ui-scale));
  border-radius: calc(13px * var(--ui-scale));
  font-size: calc(20px * var(--font-scale));
}
.brand-title {
  color: var(--muted);
  font-size: calc(10.5px * var(--font-scale)) !important;
  font-weight: 720 !important;
  letter-spacing: 0 !important;
  line-height: 1.15;
}
.brand-subtitle {
  color: var(--text);
  margin-top: calc(3px * var(--ui-scale));
  font-size: calc(20px * var(--font-scale)) !important;
  font-weight: 820;
  letter-spacing: -.025em;
  line-height: 1.05;
}

.app-shell {
  min-height: 100dvh;
  padding: calc(16px * var(--ui-scale)) calc(22px * var(--ui-scale)) calc(12px * var(--ui-scale));
  grid-template-rows: calc(66px * var(--ui-scale)) minmax(0, 1fr) !important;
  gap: calc(10px * var(--ui-scale)) !important;
}
.topbar { gap: calc(18px * var(--ui-scale)); }
.period-block { gap: calc(4px * var(--ui-scale)); }
.period-block .eyebrow,
.section-kicker { font-size: calc(9.5px * var(--font-scale)); }
.period-block strong { font-size: calc(22px * var(--font-scale)) !important; }
.clock { font-size: calc(20px * var(--font-scale)); min-width: calc(55px * var(--ui-scale)); }
.icon-btn,
.drawer-toggle {
  width: calc(36px * var(--ui-scale));
  height: calc(36px * var(--ui-scale));
  min-width: calc(36px * var(--ui-scale));
  border-radius: calc(11px * var(--ui-scale));
  font-size: calc(17px * var(--font-scale));
}
.drawer-toggle { font-size: calc(24px * var(--font-scale)); }
.action-drawer-wrap.open .action-drawer { width: calc(120px * var(--ui-scale)); gap: calc(6px * var(--ui-scale)); }

.dashboard {
  grid-template-rows: calc(142px * var(--ui-scale)) minmax(0, 1fr) !important;
  gap: calc(12px * var(--ui-scale));
}
.kpi-grid { gap: calc(12px * var(--ui-scale)); }
.kpi-card {
  border-radius: calc(18px * var(--ui-scale));
  padding: calc(14px * var(--ui-scale)) calc(15px * var(--ui-scale)) calc(12px * var(--ui-scale));
  gap: calc(9px * var(--ui-scale));
}
.kpi-label { font-size: calc(12px * var(--font-scale)); }
.kpi-percent { font-size: calc(15px * var(--font-scale)) !important; }
.kpi-main { font-size: calc(30px * var(--font-scale)) !important; }
.kpi-plan { font-size: calc(11px * var(--font-scale)); }
.kpi-hint { font-size: calc(10px * var(--font-scale)); margin-top: calc(7px * var(--ui-scale)); }
.progress-track { height: max(4px, calc(5px * var(--ui-scale))); }

.lower-grid {
  grid-template-columns: minmax(0, 2.12fr) minmax(calc(420px * var(--ui-scale)), .88fr) !important;
  gap: calc(12px * var(--ui-scale));
}
.panel { border-radius: calc(18px * var(--ui-scale)); }
.panel-header { padding: calc(14px * var(--ui-scale)) calc(16px * var(--ui-scale)) calc(10px * var(--ui-scale)); }
.panel-header h2 { font-size: calc(17px * var(--font-scale)); }
.team-meta { font-size: calc(10px * var(--font-scale)); gap: calc(12px * var(--ui-scale)); }
.table-wrap { padding: 0 calc(9px * var(--ui-scale)) calc(10px * var(--ui-scale)); }
.team-table {
  border-spacing: 0 calc(4px * var(--ui-scale));
  font-size: calc(10.2px * var(--font-scale));
}
.team-table thead th {
  font-size: calc(8.5px * var(--font-scale));
  padding: 0 calc(5px * var(--ui-scale)) calc(4px * var(--ui-scale));
}
.team-table .rank-col { width: calc(31px * var(--ui-scale)); }
.team-table .name-col { width: clamp(142px, calc(174px * var(--ui-scale)), 250px); }
.team-table thead th:nth-child(3),
.team-table tbody td:nth-child(3) { width: clamp(96px, calc(118px * var(--ui-scale)), 185px); }
.team-table tbody td { padding: calc(6px * var(--ui-scale)) calc(5px * var(--ui-scale)); }
.pace-pill { min-width: calc(35px * var(--ui-scale)); padding: calc(3px * var(--ui-scale)) calc(6px * var(--ui-scale)); }

.team-table thead th:not(.name-col):not(.rank-col),
.team-table tbody td:nth-child(n+3) { text-align: center !important; }
.team-table thead th.rank-col,
.team-table tbody td:first-child { text-align: center !important; }
.team-table .rev-cell {
  overflow: visible !important;
  text-overflow: clip !important;
  font-variant-numeric: tabular-nums;
}
.team-table .rev-cell strong,
.team-table .rev-cell .plan { white-space: nowrap; }
.team-table .rev-cell .plan { font-size: .92em; }

.side-panel-grid {
  grid-template-rows: minmax(0, 1fr) calc(150px * var(--ui-scale)) calc(150px * var(--ui-scale)) !important;
  gap: calc(12px * var(--ui-scale));
}
.events-list { padding: calc(6px * var(--ui-scale)) calc(14px * var(--ui-scale)) calc(14px * var(--ui-scale)); gap: calc(7px * var(--ui-scale)); }
.event-item {
  grid-template-columns: auto calc(64px * var(--ui-scale)) minmax(0, 1fr) !important;
  gap: calc(10px * var(--ui-scale));
  padding: calc(9px * var(--ui-scale)) calc(10px * var(--ui-scale));
  border-radius: calc(12px * var(--ui-scale));
}
.event-item > .event-day {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}
.event-item > .event-time {
  grid-column: 2;
  grid-row: 1;
}
.event-item > div:nth-child(2) {
  grid-column: 3;
  grid-row: 1;
}
.event-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: calc(54px * var(--ui-scale));
  padding: calc(5px * var(--ui-scale)) calc(10px * var(--ui-scale)) !important;
  border-radius: 999px !important;
  border: 1px solid color-mix(in srgb, var(--brand) 72%, #ffffff 12%) !important;
  background: color-mix(in srgb, var(--brand) 74%, #173b63 26%) !important;
  color: #fff !important;
  font-size: calc(9.5px * var(--font-scale)) !important;
  font-weight: 820;
  letter-spacing: .02em;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--brand) 18%, transparent);
}
.event-time { font-size: calc(11px * var(--font-scale)); }
.event-title { font-size: calc(11px * var(--font-scale)); }
.event-note { font-size: calc(9px * var(--font-scale)); }

.accent-panel,
.birthday-card,
.previous-leader-card { padding: calc(14px * var(--ui-scale)) calc(15px * var(--ui-scale)); }
.accent-panel h3 { font-size: calc(15px * var(--font-scale)); margin: calc(7px * var(--ui-scale)) 0 calc(6px * var(--ui-scale)); }
.focus-card p,
.goal-card p {
  color: var(--text) !important;
  font-size: calc(16px * var(--font-scale)) !important;
  font-weight: 800 !important;
  line-height: 1.28 !important;
  letter-spacing: -.02em;
}
.birthday-name,
.previous-leader-name { font-size: calc(16px * var(--font-scale)) !important; }
.previous-leader-value { font-size: calc(24px * var(--font-scale)) !important; }
.birthday-date { font-size: calc(12px * var(--font-scale)); }
.birthday-countdown,
.previous-leader-percent { font-size: calc(10.5px * var(--font-scale)); }

.branding-fields { margin-top: 8px; }
.branding-fields label { min-width: 0; }

body[data-theme-preset="cosmos-light"] {
  --bg: #eef3f7;
  --bg-soft: #f6f9fc;
  --panel: rgba(255,255,255,.96);
  --panel-2: rgba(255,255,255,.995);
  --panel-border: rgba(35,82,122,.115);
  --text: #102033;
  --muted: #6c8298;
  --muted-2: #7890a7;
  background:
    radial-gradient(circle at 94% 0%, rgba(70,146,216,.15), transparent 33%),
    radial-gradient(circle at 7% 100%, rgba(74,139,195,.055), transparent 34%),
    linear-gradient(145deg, #f5f8fb 0%, #eef3f7 52%, #e7f0f7 100%) !important;
}
body[data-theme-preset="cosmos-light"] .app-shell { background: transparent; }
body[data-theme-preset="cosmos-light"] .topbar { position: relative; }
body[data-theme-preset="cosmos-light"] .topbar:after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: calc(-6px * var(--ui-scale)); height: 1px;
  background: linear-gradient(90deg, transparent, rgba(55,111,158,.12), transparent);
}
body[data-theme-preset="cosmos-light"] .brand-mark {
  color: #fff !important;
  background: linear-gradient(145deg, #4aa2ff, #2f80e7) !important;
  border-color: rgba(47,128,231,.18) !important;
  box-shadow: 0 8px 22px rgba(47,128,231,.16) !important;
}
body[data-theme-preset="cosmos-light"] .brand-title { color: #59738d !important; }
body[data-theme-preset="cosmos-light"] .brand-subtitle,
body[data-theme-preset="cosmos-light"] .period-block strong,
body[data-theme-preset="cosmos-light"] .clock,
body[data-theme-preset="cosmos-light"] .panel-header h2,
body[data-theme-preset="cosmos-light"] .kpi-main,
body[data-theme-preset="cosmos-light"] .name-cell,
body[data-theme-preset="cosmos-light"] .team-table tbody td,
body[data-theme-preset="cosmos-light"] .ratio,
body[data-theme-preset="cosmos-light"] .ratio strong,
body[data-theme-preset="cosmos-light"] .rev-cell strong,
body[data-theme-preset="cosmos-light"] .event-title,
body[data-theme-preset="cosmos-light"] .birthday-name,
body[data-theme-preset="cosmos-light"] .previous-leader-name,
body[data-theme-preset="cosmos-light"] .focus-card p,
body[data-theme-preset="cosmos-light"] .goal-card p,
body[data-theme-preset="cosmos-light"] .settings-head h2,
body[data-theme-preset="cosmos-light"] .settings-card h3,
body[data-theme-preset="cosmos-light"] .service-item strong,
body[data-theme-preset="cosmos-light"] .history-table td,
body[data-theme-preset="cosmos-light"] .history-summary-card strong,
body[data-theme-preset="cosmos-light"] .code-modal h2 { color: #102033 !important; }
body[data-theme-preset="cosmos-light"] .brand-subtitle { color: #102033 !important; }
body[data-theme-preset="cosmos-light"] .team-meta,
body[data-theme-preset="cosmos-light"] .kpi-plan,
body[data-theme-preset="cosmos-light"] .kpi-hint,
body[data-theme-preset="cosmos-light"] .ratio .plan,
body[data-theme-preset="cosmos-light"] .event-note,
body[data-theme-preset="cosmos-light"] .field-note,
body[data-theme-preset="cosmos-light"] .field-label,
body[data-theme-preset="cosmos-light"] .birthday-countdown,
body[data-theme-preset="cosmos-light"] .previous-leader-percent,
body[data-theme-preset="cosmos-light"] .history-status,
body[data-theme-preset="cosmos-light"] .history-note,
body[data-theme-preset="cosmos-light"] .history-month-label { color: #6c8298 !important; }
body[data-theme-preset="cosmos-light"] .section-kicker,
body[data-theme-preset="cosmos-light"] .eyebrow,
body[data-theme-preset="cosmos-light"] .team-table thead th { color: #66839d; }
body[data-theme-preset="cosmos-light"] .kpi-card,
body[data-theme-preset="cosmos-light"] .panel {
  background: linear-gradient(160deg, rgba(255,255,255,.995), rgba(250,252,254,.98)) !important;
  border-color: rgba(31,77,117,.115) !important;
  box-shadow: 0 10px 28px rgba(28,70,108,.075) !important;
}
body[data-theme-preset="cosmos-light"] .kpi-card::after,
body[data-theme-preset="cosmos-light"] .panel::after { opacity: .45; }
body[data-theme-preset="cosmos-light"] .team-table tbody tr {
  background: rgba(246,249,252,.88) !important;
}
body[data-theme-preset="cosmos-light"] .team-table tbody tr:hover {
  background: #fff !important;
}
body[data-theme-preset="cosmos-light"] .leader-row {
  background: linear-gradient(90deg, rgba(47,128,231,.065), rgba(255,255,255,.72)) !important;
}
body[data-theme-preset="cosmos-light"] .event-item,
body[data-theme-preset="cosmos-light"] .service-item,
body[data-theme-preset="cosmos-light"] .history-summary-card {
  background: rgba(248,251,253,.94) !important;
  border-color: rgba(31,77,117,.09) !important;
}
body[data-theme-preset="cosmos-light"] .progress-track { background: rgba(31,77,117,.10) !important; }
body[data-theme-preset="cosmos-light"] .settings-modal,
body[data-theme-preset="cosmos-light"] .code-modal {
  background: #f7fafc !important;
  color: #102033 !important;
  border-color: rgba(31,77,117,.12) !important;
  box-shadow: 0 28px 70px rgba(28,70,108,.15) !important;
}
body[data-theme-preset="cosmos-light"] .settings-card {
  background: rgba(255,255,255,.82) !important;
  border-color: rgba(31,77,117,.09) !important;
}
body[data-theme-preset="cosmos-light"] .settings-head,
body[data-theme-preset="cosmos-light"] .settings-footer { border-color: rgba(31,77,117,.08) !important; }
body[data-theme-preset="cosmos-light"] .text-input,
body[data-theme-preset="cosmos-light"] .text-area,
body[data-theme-preset="cosmos-light"] .theme-select {
  background: #fff !important;
  color: #102033 !important;
  border-color: rgba(31,77,117,.14) !important;
}
body[data-theme-preset="cosmos-light"] .small-btn,
body[data-theme-preset="cosmos-light"] .secondary-btn,
body[data-theme-preset="cosmos-light"] .icon-btn,
body[data-theme-preset="cosmos-light"] .drawer-toggle {
  background: rgba(255,255,255,.90) !important;
  color: #18314a !important;
  border-color: rgba(31,77,117,.13) !important;
  box-shadow: 0 4px 12px rgba(28,70,108,.055);
}
body[data-theme-preset="cosmos-light"] .history-table thead { background: #edf4fa !important; }
body[data-theme-preset="cosmos-light"] .access-backdrop {
  background: radial-gradient(circle at top, rgba(47,128,231,.12), transparent 38%), rgba(238,243,247,.93) !important;
}

body[data-theme-preset="graphite"] .focus-card p,
body[data-theme-preset="graphite"] .goal-card p { color: var(--text) !important; }

@media (max-width: 1180px) {
  .lower-grid { grid-template-columns: minmax(0, 1fr) minmax(300px, .72fr) !important; }
  .team-meta span:last-child { display: none; }
  .team-table .name-col { width: 132px; }
}

@media (max-width: 920px) {
  body { overflow: auto; }
  .app-shell { min-width: 900px; }
}


/* Контрастные плашки дней недели в светлых темах */
body[data-theme-preset="light"] .event-day,
body[data-theme-preset="cosmos-light"] .event-day {
  background: #2376e8 !important;
  border-color: #1667d7 !important;
  color: #ffffff !important;
  opacity: 1 !important;
  font-weight: 850 !important;
  text-shadow: 0 1px 1px rgba(0,0,0,.18) !important;
  box-shadow: 0 3px 9px rgba(35,118,232,.22) !important;
}


/* Более заметная цель команды */
.goal-card h3 {
  font-size: calc(21px * var(--font-scale)) !important;
  font-weight: 860 !important;
  line-height: 1.08 !important;
  letter-spacing: -.035em !important;
  margin: calc(8px * var(--ui-scale)) 0 calc(7px * var(--ui-scale)) !important;
}
.goal-card p {
  color: var(--text) !important;
  font-size: calc(20px * var(--font-scale)) !important;
  font-weight: 860 !important;
  line-height: 1.14 !important;
  letter-spacing: -.03em !important;
  overflow-wrap: anywhere;
}


/* Global data activity status */
.global-sync-status[hidden] { display:none !important; }
.global-sync-status {
  max-width:240px;
  min-height:30px;
  display:inline-flex;
  align-items:center;
  gap:7px;
  padding:6px 10px;
  border:1px solid color-mix(in srgb,var(--brand) 28%,var(--panel-border));
  border-radius:999px;
  background:color-mix(in srgb,var(--brand) 8%,var(--panel-2));
  color:var(--text);
  font-size:calc(10px * var(--font-scale));
  font-weight:780;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.global-sync-status i {
  width:8px;
  height:8px;
  flex:0 0 8px;
  border-radius:50%;
  background:var(--brand);
}
.global-sync-status.is-loading i {
  width:10px;
  height:10px;
  flex-basis:10px;
  border:2px solid color-mix(in srgb,var(--brand) 25%,transparent);
  border-top-color:var(--brand);
  background:transparent;
  animation:globalSyncSpin .72s linear infinite;
}
.global-sync-status.is-ok {
  color:var(--green);
  border-color:color-mix(in srgb,var(--green) 30%,var(--panel-border));
  background:color-mix(in srgb,var(--green) 7%,var(--panel-2));
}
.global-sync-status.is-ok i { background:var(--green); }
.global-sync-status.is-error {
  color:var(--orange);
  border-color:color-mix(in srgb,var(--orange) 34%,var(--panel-border));
  background:color-mix(in srgb,var(--orange) 8%,var(--panel-2));
}
.global-sync-status.is-error i { background:var(--orange); }
@keyframes globalSyncSpin { to { transform:rotate(360deg); } }

@media (max-width:1100px) {
  .global-sync-status { max-width:160px; }
}


.global-sync-status.is-stale {
  color:var(--orange);
  border-color:color-mix(in srgb,var(--orange) 34%,var(--panel-border));
  background:color-mix(in srgb,var(--orange) 8%,var(--panel-2));
}
.global-sync-status.is-stale i {
  background:var(--orange);
}
.global-sync-status.is-critical {
  color:var(--red);
  border-color:color-mix(in srgb,var(--red) 38%,var(--panel-border));
  background:color-mix(in srgb,var(--red) 9%,var(--panel-2));
}
.global-sync-status.is-critical i {
  background:var(--red);
}


/* Final TV / desktop fit pass */
@media (min-width:921px) {
  html,
  body {
    height:100%;
    overflow:hidden !important;
  }
  .app-shell {
    height:100dvh;
    min-height:0 !important;
    overflow:hidden;
  }
  .dashboard {
    min-height:0;
    overflow:hidden;
  }
}

/* Large 16:9 displays: keep the same composition, improve viewing-distance legibility */
html[data-viewport-class="tv"] .topbar {
  column-gap:calc(22px * var(--ui-scale));
}
html[data-viewport-class="tv"] .section-kicker,
html[data-viewport-class="tv"] .eyebrow {
  font-weight:850;
}
html[data-viewport-class="tv"] .team-table tbody td {
  font-weight:650;
}
html[data-viewport-class="tv"] .kpi-card,
html[data-viewport-class="tv"] .panel {
  box-shadow:0 14px 34px rgba(0,0,0,.09);
}
html[data-viewport-class="tv"] body[data-theme-preset="light"] .kpi-card,
html[data-viewport-class="tv"] body[data-theme-preset="light"] .panel,
html[data-viewport-class="tv"] body[data-theme-preset="cosmos-light"] .kpi-card,
html[data-viewport-class="tv"] body[data-theme-preset="cosmos-light"] .panel {
  box-shadow:0 14px 34px rgba(28,70,108,.07);
}
