/* ═══════════════════════════════════════════════════════════
   PORTBILL — DATA MANAGEMENT
   Rotation Registry, Saved Bills, Analytics, Dashboard.
   Enterprise tables: sticky header, right-aligned money,
   status badges, hover row — spec §19–22.
═══════════════════════════════════════════════════════════ */

.rotation-page { max-width: 1100px; }
.rotation-grid { display: grid; gap: var(--sp-4); }

/* Summary strip — "N rotations · N years · Latest CLD dd/mm/yyyy" */
.rot-reg-summary {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  font-size: 12px; color: var(--tx-1);
}
.rot-reg-summary-item strong { color: var(--accent-hi); font-family: 'DM Mono', monospace; }
.rot-reg-summary-sep { color: var(--tx-3); }

.rot-reg-form { display: flex; align-items: flex-end; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.rot-reg-form .fg { flex: 1; min-width: 140px; margin-bottom: 0; }
.rot-reg-form .rot-reg-input { width: 100%; }
.rot-reg-form .rot-reg-fg-cld { max-width: 200px; }
.rot-reg-input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.rot-reg-add-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 16px;
  border-radius: var(--r-sm); border: none;
  background: var(--accent); color: #060911;
  font-size: 12.5px; font-weight: 700; cursor: pointer;
  white-space: nowrap;
}
.rot-reg-add-btn:hover { background: var(--accent-hi); }

/* Search + expand/collapse toolbar, above the table */
.rot-reg-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.rot-reg-toolbar-actions { display: flex; gap: 6px; }
@media (max-width: 480px) {
  .rot-reg-toolbar { flex-direction: column; align-items: stretch; }
  .rot-reg-toolbar-actions { justify-content: flex-end; }
}

.rot-reg-table-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--bdr-1); }
table.rot-reg-table { width: 100%; border-collapse: collapse; min-width: 480px; }
.rot-reg-table thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; padding: 10px 14px;
  background: var(--bg-surface); color: var(--tx-2);
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  border-bottom: 1px solid var(--bdr-1);
}
.rot-reg-table td {
  padding: 10px 14px; font-size: 12.5px; color: var(--tx-1);
  border-bottom: 1px solid var(--bdr-0);
}
.rot-reg-table tbody tr:hover { background: var(--bg-hover); }
.rot-reg-table td:last-child, .rot-reg-table th:last-child { text-align: right; }
@media (pointer: fine) {
  .rot-reg-table tbody tr[data-year-row] { transition: box-shadow var(--t-fast); }
  .rot-reg-table tbody tr[data-year-row]:hover { box-shadow: inset 3px 0 0 var(--accent); }
}
.rot-num-chip {
  font-family: 'DM Mono', monospace; font-size: 12px; font-weight: 600;
  color: var(--tx-0); background: var(--bg-hover);
  padding: 2px 8px; border-radius: var(--r-xs);
}
.rot-cld-cell { display: inline-flex; align-items: center; gap: 6px; }
.rot-cld-ico {
  width: 11px; height: 11px; flex-shrink: 0;
  background: var(--tx-2);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 9h18M8 3v4M16 3v4' stroke='%23000' stroke-width='2' fill='none'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M3 9h18M8 3v4M16 3v4' stroke='%23000' stroke-width='2' fill='none'/%3E%3C/svg%3E") center/contain no-repeat;
}
.rot-del-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--r-xs);
  border: 1px solid var(--bdr-2); background: transparent; color: var(--tx-1); cursor: pointer; margin-left: 4px;
}
.rot-del-btn:hover { color: var(--red); border-color: var(--red-bdr); background: var(--red-bg); }


.rot-year-group td { background: var(--bg-surface); font-weight: 700; cursor: pointer; }
.rot-year-chevron {
  display: inline-block;
  width: 0; height: 0;
  margin-right: 8px;
  border-style: solid;
  border-width: 5px 4px 0 4px;
  border-color: var(--tx-2) transparent transparent transparent;
  transition: transform var(--t-fast);
  vertical-align: middle;
}
.rot-year-group.collapsed .rot-year-chevron { transform: rotate(-90deg); }
.rot-year-count {
  font-size: 10px; font-weight: 700; color: var(--tx-2); margin-left: 6px;
  background: var(--bg-hover); padding: 1px 7px; border-radius: 999px;
}
[data-year-row][style*="display: none"] { display: none; }

/* ── SAVED BILLS ── */
.saved-sub-tabs { display: flex; gap: 4px; margin-bottom: var(--sp-4); border-bottom: 1px solid var(--bdr-1); }
.saved-sub-tab {
  padding: 9px 16px; border: none; background: transparent; color: var(--tx-2);
  font-size: 12.5px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent;
}
.saved-sub-tab:hover { color: var(--tx-0); }
.saved-sub-tab.active { color: var(--accent-hi); border-bottom-color: var(--accent); }
.sb-panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.sb-panel-head-search { display: flex; align-items: center; gap: var(--sp-3); }
table.saved-bills-table td:nth-child(6) { text-align: right; font-family: 'DM Mono', monospace; } table.saved-bills-table td:last-child { white-space: nowrap; } .sb-actions { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; } .sb-action-btn { display: inline-flex; align-items: center; justify-content: center; height: 30px; padding: 0 12px; border-radius: var(--r-xs); border: 1px solid var(--bdr-2); background: transparent; color: var(--tx-1); font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast); } .sb-action-btn:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 1px; } .sb-edit-btn:hover { color: var(--accent-hi); border-color: var(--accent-bdr); background: var(--accent-bg); } .sb-print-btn:hover { color: var(--tx-0); border-color: var(--bdr-3); background: var(--bg-hover); } .sb-del-btn:hover { color: var(--red); border-color: var(--red-bdr); background: var(--red-bg); }
@media (max-width: 480px) {
  .sb-panel-head { flex-direction: column; align-items: stretch; }
  .sb-panel-head-search { flex-direction: column; align-items: stretch; }
  .pb-search-wrap { max-width: none; }
}

/* ── ADMIN PASSWORD PANEL uses .rot-reg-* already styled in 04-components ── */

/* ── ANALYTICS ── */
.stats-msg { padding: var(--sp-4); text-align: center; color: var(--tx-2); font-size: 12.5px; }
.stats-head-right { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-left: auto; }
.stats-live-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
}
.stats-live-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.stats-live-live { color: var(--green); background: var(--green-bg); }
.stats-live-live::before { background: var(--green); animation: livePulse 1.6s ease-in-out infinite; }
.stats-live-offline { color: var(--amber); background: var(--amber-bg); }
.stats-live-offline::before { background: var(--amber); }
.stats-live-error { color: var(--red); background: var(--red-bg); }
.stats-live-error::before { background: var(--red); }
.stats-updated { font-size: 10.5px; color: var(--tx-2); font-family: 'DM Mono', monospace; white-space: nowrap; }
.stats-refresh-icon { width: 13px; height: 13px; vertical-align: -2px; }
.stats-refresh-icon.spinning { animation: statsSpin 0.8s linear infinite; }
@keyframes statsSpin { to { transform: rotate(360deg); } }
@media (max-width: 480px) { .stats-head-right { width: 100%; justify-content: space-between; } }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-3); margin-bottom: var(--sp-5); }
@media (max-width: 720px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 360px) { .stats-grid { grid-template-columns: 1fr; } }
.stat-card { background: var(--bg-surface); border: 1px solid var(--bdr-1); border-radius: var(--r); padding: var(--sp-4); }
.stats-grid.stats-loading .stat-num, .stats-grid.stats-loading .stat-sub {
  color: transparent;
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--bg-elevated) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: statsShimmer 1.4s ease-in-out infinite;
}
@keyframes statsShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.stat-lbl { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--tx-2); }
.stat-num { font-family: 'DM Mono', monospace; font-size: 26px; font-weight: 700; color: var(--purple-a-hi); margin: 6px 0 2px; }
.stat-sub { font-size: 10.5px; color: var(--tx-2); }
.stats-legend { display: flex; gap: var(--sp-4); font-size: 11px; color: var(--tx-2); margin-bottom: var(--sp-3); }
.stats-chart-wrap { background: var(--bg-surface); border: 1px solid var(--bdr-1); border-radius: var(--r); padding: var(--sp-4); }
.stats-chart-title { font-size: 12px; font-weight: 700; color: var(--tx-1); margin-bottom: var(--sp-3); }
.stats-chart { width: 100%; height: auto; }
.sbar { fill: var(--purple-a); }
.sbar-axis { stroke: var(--bdr-2); }
.sbar-grid { stroke: var(--bdr-1); stroke-dasharray: 3 3; }
.sbar-max { fill: var(--tx-3); font-size: 9px; font-family: 'DM Mono', monospace; }
.sbar-x { fill: var(--tx-2); font-size: 9px; font-family: 'DM Mono', monospace; }
.stats-privacy { margin-top: var(--sp-4); font-size: 10.5px; color: var(--tx-3); text-align: center; }

/* ── DASHBOARD (new, spec §8) — reads only existing saved-bill/rotation data ── */
.dash-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.dash-date { font-family: 'DM Mono', monospace; font-size: 11.5px; color: var(--tx-2); white-space: nowrap; padding-bottom: 4px; }

.dash-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); margin-bottom: var(--sp-5); }
@media (max-width: 960px) { .dash-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0) 45%), var(--bg-card);
  border: 1px solid var(--bdr-1); border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-4);
  border-top: 3px solid var(--dash-color, var(--accent));
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--t-base), transform var(--t-base);
}
@media (pointer: fine) {
  .dash-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-1px); }
}
.dash-card-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.dash-card-lbl { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: var(--tx-2); text-transform: uppercase; letter-spacing: 0.03em; }
.dash-card-icon { width: 16px; height: 16px; color: var(--dash-color, var(--accent)); flex-shrink: 0; opacity: 0.85; }
.dash-card-num { font-family: 'DM Mono', monospace; font-size: 30px; font-weight: 700; color: var(--tx-0); margin: 8px 0 2px; }
.dash-card-sub { font-size: 11px; color: var(--tx-2); }
.dash-card-delta { display: inline-block; margin-top: 6px; font-size: 10.5px; font-weight: 700; color: var(--green); }

.dash-section { margin-bottom: var(--sp-5); }
.dash-section-head { display: flex; align-items: center; gap: 8px; margin-bottom: var(--sp-3); }
.dash-section-icon { width: 14px; height: 14px; color: var(--accent); flex-shrink: 0; }
.dash-section-title { font-size: 13px; font-weight: 700; color: var(--tx-0); }
.dash-section-action { margin-left: auto; }
.dash-view-all {
  border: none; background: transparent; cursor: pointer;
  font-size: 11.5px; font-weight: 600; color: var(--accent-hi);
}
.dash-view-all:hover { text-decoration: underline; }

.dash-activity-chart { width: 100%; height: auto; }
.dash-bar { fill: var(--accent); }
.dash-bar-axis { stroke: var(--bdr-2); }
.dash-bar-x { fill: var(--tx-2); font-size: 9px; font-family: 'DM Mono', monospace; }

.dash-quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
@media (max-width: 640px) { .dash-quick { grid-template-columns: 1fr; } }
.dash-quick-btn {
  display: flex; align-items: center; gap: 10px;
  padding: var(--sp-4); border-radius: var(--r); border: 1px solid var(--bdr-1);
  background: var(--bg-card); color: var(--tx-0);
  border-left: 3px solid var(--dash-color, var(--accent));
  font-size: 12.5px; font-weight: 600; text-align: left; cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.dash-quick-btn:hover { background: var(--bg-hover); border-color: var(--bdr-2); }
.dash-quick-icon { width: 17px; height: 17px; color: var(--dash-color, var(--accent)); flex-shrink: 0; }

.dash-recent-list { display: flex; flex-direction: column; gap: 1px; }
.dash-recent-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: 10px var(--sp-3); border-radius: var(--r-xs); font-size: 12.5px;
}
.dash-recent-row:hover { background: var(--bg-hover); }
.dash-recent-meta { color: var(--tx-2); font-size: 11px; }
.dash-recent-amt { font-family: 'DM Mono', monospace; font-weight: 600; color: var(--tx-0); }
.dash-status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--sp-3); }
.dash-status-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-3); background: var(--bg-surface); border-radius: var(--r-sm); font-size: 12px; color: var(--tx-1); }
.dash-status-checked { margin-top: var(--sp-3); font-size: 10.5px; color: var(--tx-3); text-align: right; }
