/* Zidos · W2C (Wave 2 Stream C) — Устройства и Расходы */

/* ===== W2C: Устройства ===== */
.section-screen .section-devices .section-heading {
  display: flex;
  justify-content: space-between;
  flex-wrap: nowrap;
  align-items: center;
}

.section-screen .section-devices .section-heading > div {
  margin-bottom: 0;
}

.section-screen .section-devices .section-heading > .primary {
  width: auto;
  flex: 0 0 auto;
}

.devices-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-12);
  padding: var(--sp-16) var(--pad-card);
  background: var(--panel);
  border-radius: var(--radius-card);
  margin-bottom: var(--sp-20);
}

.devices-topbar-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.devices-topbar-copy strong {
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--ink);
}

.device-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-12);
  margin-bottom: var(--sp-8);
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: var(--pad-row);
}

.device-row .device-title {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-8);
  font-size: var(--fs-h3);
  font-weight: 600;
  color: var(--ink);
}

.device-pill-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--panel);
  color: var(--muted);
  font-size: var(--fs-micro);
  font-weight: 500;
}

.device-row .row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.device-row small {
  display: block;
  font-size: var(--fs-small);
  color: var(--muted);
  line-height: 1.35;
}

.device-row-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  flex: none;
  align-self: center;
}

/* телефон: действия устройства второй строкой под текстом — текст не сжимается до столбика букв */
@media (max-width: 760px) {
  .device-row.w2c-device-row { flex-wrap: wrap; }
  .device-row.w2c-device-row > .section-row-copy { flex: 1 1 calc(100% - 56px); }
  .device-row.w2c-device-row > .device-row-actions { flex: 1 1 100%; justify-content: flex-start; padding-left: 52px; }
}

.device-current-label {
  font-size: var(--fs-small);
  color: var(--muted);
  font-weight: 500;
  padding: 0 var(--sp-8);
}

.device-list--special {
  margin-top: var(--sp-24);
}

.device-perms-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.device-perms-label {
  font-size: var(--fs-micro);
  color: var(--muted);
  font-weight: 500;
}

.device-perms-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.device-perm-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--panel);
  color: var(--ink);
  font-family: var(--z-font-code);
  font-size: 11px;
}

/* Модальные окна и подтверждения (sheets) */
.device-sheet {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  display: none;
  place-items: center;
  z-index: 1000;
}

.device-sheet[open] {
  display: grid;
}

.device-sheet::backdrop {
  background: var(--scrim);
}

.device-sheet .sheet-container {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  background: var(--frame);
  color: var(--ink);
  padding: var(--pad-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: var(--sp-16);
}

.device-sheet .sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.device-sheet .sheet-header h2 {
  font-size: var(--fs-h2);
  font-weight: var(--fw-h2);
  margin: 0;
}

.device-sheet .sheet-body {
  font-size: var(--fs-body);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: var(--sp-12);
}

.device-sheet .sheet-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-8);
}

.device-history-heading {
  font-size: var(--fs-h4);
  font-weight: var(--fw-h4);
  color: var(--ink);
  margin-top: var(--sp-8);
}

.device-history-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}

.device-history-item {
  display: flex;
  flex-direction: column;
  padding: var(--sp-8) var(--sp-12);
  background: var(--panel);
  border-radius: var(--radius-inner);
  gap: 2px;
}

.device-history-item strong {
  font-size: var(--fs-small);
  color: var(--ink);
}

.device-history-item small {
  font-size: var(--fs-micro);
  color: var(--muted);
}

/* ===== W2C: Расходы ===== */
.spend-overview-card {
  margin-bottom: var(--sp-20);
}

.spend-period-nav {
  display: flex;
  flex-direction: column;
  gap: var(--sp-12);
  margin-bottom: var(--sp-16);
}

.spend-period-segment, .spend-sort-segment {
  display: inline-flex; align-self: flex-start; gap: 2px; padding: 4px; border-radius: 99px;
  background: var(--panel); max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.spend-period-segment::-webkit-scrollbar, .spend-sort-segment::-webkit-scrollbar { display: none; }
.spend-period-segment .segment__btn, .spend-sort-segment .segment__btn {
  background: transparent; color: var(--muted); border: 0; box-shadow: none; cursor: pointer;
}
.spend-period-segment .segment__btn.is-active, .spend-sort-segment .segment__btn.is-active {
  background: var(--clio-segment-ink); color: var(--clio-segment-text); font-weight: 550;
}

.spend-custom-range {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  flex-wrap: wrap;
  padding: var(--sp-12);
  background: var(--panel);
  border-radius: var(--radius-inner);
}

.spend-custom-range[hidden] {
  display: none;
}

.custom-range-label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-8);
  font-size: var(--fs-small);
  color: var(--muted);
}

.custom-range-label input[type="date"] {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--panel);
  border-radius: var(--radius-inner);
  padding: 4px 8px;
  font-family: inherit;
  font-size: var(--fs-small);
}

.spend-total-block {
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}

.spend-total-label {
  font-size: var(--fs-small);
  color: var(--muted);
}

.spend-odometer {
  display: inline-flex;
  align-items: center;
  font-variant-numeric: tabular-nums;
  font-size: 38px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
  height: 44px;
  overflow: hidden;
}

.odometer-prefix {
  font-size: 32px;
  font-weight: 700;
  color: var(--muted);
  margin-right: 2px;
}

.odometer-separator {
  font-size: 32px;
  font-weight: 700;
  color: var(--ink);
}

.odometer-digit {
  display: inline-block;
  width: 0.65em;
  height: 44px;
  overflow: hidden;
  position: relative;
  vertical-align: top;
}

.odometer-wheel {
  display: flex;
  flex-direction: column;
  transition: transform 0.5s var(--ease);
}

.odometer-wheel > span {
  display: block;
  height: 44px;
  line-height: 44px;
  text-align: center;
}

.spend-metrics-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-24);
  margin-top: var(--sp-8);
}

.spend-metrics-row > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.spend-metrics-row strong {
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--ink);
}

.spend-metrics-row small {
  font-size: var(--fs-micro);
}

/* График по дням */
.spend-chart-card {
  margin-bottom: var(--sp-20);
}

.spend-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--sp-16);
}

.spend-card-header h2 {
  margin: 0;
}

.spend-chart-wrap {
  position: relative;
  width: 100%;
}

.spend-chart {
  width: 100%;
  height: auto;
  max-height: 240px;
  display: block;
}

.chart-bar {
  transition: fill 0.15s var(--ease);
}

.chart-bar-group:hover .chart-bar,
.chart-bar-group:focus .chart-bar {
  fill: color-mix(in srgb, var(--action) 80%, white 20%);
  outline: none;
}

.chart-axis-label {
  font-size: 11px;
  font-family: inherit;
  user-select: none;
}

.spend-chart-tooltip {
  position: absolute;
  pointer-events: none;
  padding: 6px 10px;
  background: var(--frame);
  color: var(--ink);
  border-radius: var(--radius-inner);
  box-shadow: var(--shadow);
  font-size: var(--fs-micro);
  z-index: 20;
  border: 1px solid var(--panel);
  white-space: nowrap;
  transform: translate(-50%, -100%);
  margin-top: -8px;
}

.spend-chart-tooltip[hidden] {
  display: none;
}

/* Разбивка по агентам и моделям */
.spend-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-16);
  margin-bottom: var(--sp-20);
}

.spend-breakdown-card {
  padding: var(--pad-card);
}

.spend-breakdown-card h2 {
  margin-top: 0;
  margin-bottom: var(--sp-16);
}

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-12);
}

.breakdown-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.breakdown-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--fs-small);
}

.breakdown-title {
  font-weight: 500;
  color: var(--ink);
}

.breakdown-val {
  color: var(--muted);
  font-size: var(--fs-micro);
  font-variant-numeric: tabular-nums;
}

.breakdown-bar-track {
  height: 8px;
  background: var(--panel);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.breakdown-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width 0.4s var(--ease);
}

/* Квоты провайдеров */
.spend-quotas-card {
  margin-bottom: var(--sp-20);
}

.spend-quotas-card h2 {
  margin-top: 0;
  margin-bottom: var(--sp-16);
}

.quotas-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-16);
}

.quota-card {
  background: var(--panel);
  border-radius: var(--radius-inner);
  padding: var(--sp-16);
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}

.quota-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.quota-head strong {
  font-size: var(--fs-body);
  color: var(--ink);
}

.quota-tier {
  font-size: var(--fs-micro);
  font-weight: normal;
}

.quota-status-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--ok-bg);
  color: var(--ok);
}

.quota-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: var(--fs-micro);
  line-height: 1.4;
}

.quota-bar-track {
  height: 6px;
  background: var(--surface);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: 4px;
}

.quota-bar-fill {
  height: 100%;
  background: var(--ok);
  border-radius: var(--radius-pill);
}

/* Бюджеты расходов */
.spend-budgets-card {
  margin-bottom: var(--sp-20);
}

.spend-budgets-card h2 {
  margin-top: 0;
  margin-bottom: var(--sp-16);
}

.budgets-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-16);
}

.budget-card {
  background: var(--panel);
  border-radius: var(--radius-inner);
  padding: var(--sp-16);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.budget-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-body);
}

.budget-head strong {
  font-weight: 600;
  color: var(--ink);
}

.budget-values {
  font-size: var(--fs-small);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.budget-meta {
  font-size: var(--fs-micro);
  margin-bottom: 4px;
}

.budget-bar-track {
  height: 6px;
  background: var(--surface);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.budget-bar-fill {
  height: 100%;
  background: var(--action);
  border-radius: var(--radius-pill);
}

/* Сортировка таблицы расходов */
.spend-history-block {
  position: relative;
}

.spend-sort-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-8);
  margin-bottom: var(--sp-12);
}

.spend-sort-label {
  font-size: var(--fs-micro);
}



.spend-history-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
