/* Overview: grouped summary cards, unit status donut, chart tabs and the alert bell. */

:root {
  --tone-success: #6fcf9b;
  --tone-waiting: #f2b866;
  --tone-danger: #ff8f88;
  --tone-muted: #7d8fa3;
  --bar-bill: #7590ab;
  --bar-saving: var(--accent);
  --bar-consumption: #8aa6c4;
  --bar-compensation: #5cc3b0;
}
@media (prefers-color-scheme: light) {
  :root {
    --tone-success: #1f8a55;
    --tone-waiting: #c27a12;
    --tone-danger: #c23a42;
    --tone-muted: #8496a8;
    --bar-bill: #8ea3b8;
    --bar-consumption: #5f7fa0;
    --bar-compensation: #1f9a84;
  }
}

/* Summary cards */
.summary-groups {
  display: grid;
  grid-template-columns: 1fr 1fr 1.25fr;
  gap: 14px;
  margin-bottom: 18px;
}
.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.summary-card header { display: flex; align-items: center; gap: 10px; }
.summary-card h2 { font-size: 15px; }
.summary-when { margin-left: auto; color: var(--muted); font-size: 12px; }
.summary-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--raised); flex: none;
}
.summary-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.summary-icon.energy { color: var(--tone-waiting); }
.summary-icon.energy svg { fill: currentColor; stroke: none; }
.summary-icon.money { color: var(--accent); }
.summary-icon.status { color: var(--tone-success); }
.summary-list { margin: 0; display: grid; gap: 8px; }
.summary-list div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.summary-highlight {
  display: grid; gap: 2px;
  padding: 12px 14px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
}
.summary-highlight span { color: var(--muted); font-size: 12px; }
.summary-highlight strong { font-size: 24px; letter-spacing: -.02em; color: var(--accent); font-variant-numeric: tabular-nums; }
.summary-highlight em { font-style: normal; font-size: 12px; color: var(--muted); }
.summary-foot { margin: auto 0 0; padding-top: 10px; border-top: 1px solid var(--soft-line); font-size: 13px; color: var(--muted); }
.summary-foot strong { color: var(--text); }

/* Unit status donut */
.status-donut-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 16px; align-items: center; }
.status-donut {
  width: 112px; aspect-ratio: 1; border-radius: 50%;
  background: var(--status-gradient, var(--line));
  display: grid; place-items: center;
}
.status-donut > div {
  width: 76px; aspect-ratio: 1; border-radius: 50%;
  background: var(--panel);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.status-donut strong { font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
.status-donut span { font-size: 11px; color: var(--muted); }
.status-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 13px; }
.status-legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 38px; gap: 8px; align-items: center; }
.status-legend li.is-empty { opacity: .55; }
.status-legend strong { font-variant-numeric: tabular-nums; }
.status-legend em { font-style: normal; color: var(--muted); font-size: 12px; text-align: right; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.tone-success { background: var(--tone-success); }
.tone-waiting { background: var(--tone-waiting); }
.tone-danger { background: var(--tone-danger); }
.tone-muted { background: var(--tone-muted); }

/* Chart tabs */
.customer-chart .panel-head { flex-wrap: wrap; }
.chart-tabs,
.chart-panel .panel-head > .chart-tabs {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--raised); border: 1px solid var(--line); border-radius: 9px;
}
.chart-tabs button {
  border: 0; background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 700; padding: 6px 11px; border-radius: 6px; cursor: pointer;
}
.chart-tabs button:hover { color: var(--text); }
.chart-tabs button[aria-selected="true"] { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px var(--shadow); }
.chart-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chart-legend { display: flex; gap: 16px; padding: 12px 18px 0; font-size: 12px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch.bill { background: var(--bar-bill); }
.swatch.saving { background: var(--bar-saving); }

/* Bars: stacked bill + saving, and the single-series variants */
.chart-bar-fill.stacked {
  display: flex; flex-direction: column; overflow: hidden;
  background: none; box-shadow: none;
}
.chart-bar-fill.stacked .segment { display: block; width: 100%; flex: none; }
.chart-bar-fill.stacked .segment.saving { background: var(--bar-saving); border-radius: 6px 6px 0 0; }
.chart-bar-fill.stacked .segment.bill { background: var(--bar-bill); border-radius: 0 0 2px 2px; }
.chart-bar-fill.stacked.is-missing,
.chart-bar-fill.is-missing { height: 4px; background: repeating-linear-gradient(45deg, #52677d 0 4px, #31465c 4px 8px); }
.chart-bar-fill.consumption { background: var(--bar-consumption); box-shadow: none; }
.chart-bar-fill.compensation { background: var(--bar-compensation); box-shadow: none; }
.chart-tooltip { white-space: pre-line; line-height: 1.5; }

/* Alert bell */
.attention { position: relative; }
.attention summary {
  list-style: none; cursor: pointer; position: relative;
  width: 38px; height: 38px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); border: 1px solid transparent;
}
.attention summary::-webkit-details-marker { display: none; }
.attention summary:hover, .attention[open] summary { color: var(--text); background: var(--raised); border-color: var(--line); }
.attention summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.attention summary svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.attention-count {
  position: absolute; top: 2px; right: 1px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--tone-danger); color: #1b0d0d;
  font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
}
.attention-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50;
  width: min(360px, calc(100vw - 28px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 45px var(--shadow); padding: 8px; color: var(--text);
}
.attention-title { display: block; padding: 8px 10px; font-size: 13px; }
.attention-panel ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.attention-panel a {
  display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 9px 10px; border-radius: 8px;
}
.attention-panel a:hover { background: var(--raised); text-decoration: none; }
.attention-panel .status-dot { margin-top: 4px; }
.attention-panel a strong { display: block; font-size: 13px; }
.attention-panel a span span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.attention-empty, .attention-more { margin: 0; padding: 6px 10px 10px; color: var(--muted); font-size: 13px; }

@media (max-width: 1000px) {
  .summary-groups { grid-template-columns: 1fr 1fr; }
  .summary-groups .summary-card:last-child { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .summary-groups { grid-template-columns: 1fr; }
  .chart-tabs,
  .chart-panel .panel-head > .chart-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
  .chart-tabs button { padding: 7px 2px; font-size: 11px; }
  .status-donut-row { grid-template-columns: 96px minmax(0, 1fr); gap: 12px; }
  .status-donut { width: 96px; }
  .status-donut > div { width: 66px; }
}
@media (prefers-reduced-motion: reduce) {
  .chart-tabs button { transition: none; }
}

/* Top bar: the bell now comes first, so hide the label by class, not position. */
.account .user { white-space: nowrap; }
@media (max-width: 640px) {
  .account .account-label { display: none; }
  .account { gap: 8px; }
}

/* A month in which the bill with ID Solar exceeded the bill without it. */
.chart-bar-fill.stacked.is-negative .segment.bill { background: var(--tone-danger); border-radius: 6px 6px 2px 2px; }

/* Invoice coverage progress used by the client and UG summaries. */
.summary-progress { display: grid; gap: 8px; }
.summary-progress-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.summary-progress-head span { color: var(--muted); }
.summary-progress-head strong { font-variant-numeric: tabular-nums; }
.summary-progress-track { height: 8px; border-radius: 4px; background: var(--raised); overflow: hidden; }
.summary-progress-track span { display: block; height: 100%; border-radius: 4px; background: var(--tone-success); }
.summary-progress-note { margin: 0; font-size: 12px; color: var(--muted); }

/* Friendly empty states: what is missing and how to get there. */
.empty-state { padding: 26px 22px; display: grid; gap: 6px; }
.empty-state strong { font-size: 15px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; max-width: 62ch; }
.empty-state a { color: var(--accent); }

/* Plain-language status with the technical text tucked away. */
.status-title { display: block; font-size: 14px; color: var(--text); }
.inline-action { display: inline-flex; margin: 8px 0 0; }
.tech-details { margin-top: 6px; font-size: 12px; color: var(--muted); }
.tech-details summary { cursor: pointer; width: fit-content; }
.tech-details code { display: block; margin-top: 4px; white-space: pre-wrap; word-break: break-word; font-size: 11px; color: var(--muted); }
.button.ghost { background: transparent; }

/* Unit rows: field names only above the first row of each group. */
.catalog-unit-row .field-label {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.catalog-group-head + .catalog-unit-row .field-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
.catalog-unit-row + .catalog-unit-row { padding-top: 6px; }
@media (max-width: 640px) {
  .catalog-unit-row .field-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
}

/* Tables that become stacked cards on phones (labels come from the header). */
@media (max-width: 640px) {
  table.stack-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack-table, table.stack-table tbody, table.stack-table tr, table.stack-table td { display: block; width: 100%; }
  table.stack-table tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.stack-table tbody tr:last-child { border-bottom: 0; }
  table.stack-table td { padding: 5px 0; border: 0; }
  table.stack-table td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 2px;
    color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  }
  table.stack-table td:empty, table.stack-table td[data-label=""]::before { display: none; }
}

/* Reason why each invoice is missing in the Coleta table. */
.missing-reasons { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; max-width: 62ch; }
.missing-reasons a { color: var(--accent); text-decoration: underline; }
