/* pws-watch: admin page styles. */

:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #66727f;
  --line: #d9e0e5;
  --panel: rgba(255, 255, 255, 0.88);
  --accent: #0093a8;
  --danger: #d64531;
  --good: #16805d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(rgba(23, 32, 42, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 42, 0.055) 1px, transparent 1px),
    #eef4f4;
  background-size: 38px 38px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

main {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

header,
.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(23, 32, 42, 0.08);
}

header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 5vw, 54px);
  line-height: 0.95;
}

h2 {
  font-size: 16px;
}

.subtle {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.controls {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(180px, 280px) 132px 160px 96px;
  gap: 10px;
  align-items: end;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input,
select,
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

input,
select {
  width: 100%;
  padding: 0 12px;
}

button {
  cursor: pointer;
  background: var(--ink);
  color: white;
}

.assistant-icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border-color: var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
}

.assistant-icon-button svg {
  width: 21px;
  height: 21px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.metric-group {
  display: grid;
  gap: 12px;
  min-height: 188px;
  padding: 14px;
  align-content: start;
}

.metric-group-head,
.admin-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.admin-card-head {
  min-height: 30px;
}

.metric-group-head h2 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.metric-group-toggle,
.admin-card-toggle {
  display: inline-grid;
  place-items: center;
  width: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 8px;
  background: rgba(0, 147, 168, 0.1);
  color: var(--accent);
}

.metric-group-toggle svg,
.admin-card-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 140ms ease;
}

.metric-group.collapsed {
  min-height: 0;
}

.metric-group.collapsed .metric-list {
  display: none;
}

.metric-group.collapsed .metric-group-toggle svg,
.admin-card.collapsed .admin-card-toggle svg {
  transform: rotate(-90deg);
}

.admin-card.collapsed .admin-card-body {
  display: none;
}

.metric-lead {
  display: grid;
  gap: 5px;
}

.metric-lead span,
.metric-row span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.metric-lead strong {
  display: block;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1;
}

.metric-list {
  display: grid;
  gap: 7px;
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 7px;
}

.metric-row strong {
  font-size: 14px;
  white-space: nowrap;
}

.metric-group.ok {
  border-color: rgba(22, 128, 93, 0.22);
}

.metric-group.warning {
  border-color: rgba(214, 69, 49, 0.24);
}

.columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.billing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.panel {
  padding: 16px;
}

.billing-card {
  display: grid;
  gap: 12px;
}

.admin-card-body {
  min-width: 0;
}

.billing-card .admin-card-body {
  display: grid;
  gap: 12px;
}

.billing-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.billing-head strong {
  display: block;
  margin-top: 5px;
  font-size: 32px;
  line-height: 1;
}

.billing-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.billing-message {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.billing-lines {
  display: grid;
  gap: 7px;
}

.billing-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.billing-links,
.billing-footnotes {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.billing-links a {
  color: var(--accent);
  font-weight: 950;
  text-decoration: none;
}

.billing-footnotes {
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 6px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.number {
  text-align: right;
  white-space: nowrap;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding-bottom: 4px;
}

.recent-events-panel {
  overflow: hidden;
}

.recent-events-panel .admin-card-body {
  min-width: 0;
}

.recent-events-table {
  table-layout: fixed;
  min-width: 1180px;
}

.recent-events-table th,
.recent-events-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-events-table th:nth-child(1),
.recent-events-table td:nth-child(1) {
  width: 76px;
}

.recent-events-table th:nth-child(2),
.recent-events-table td:nth-child(2) {
  width: 112px;
}

.recent-events-table th:nth-child(3),
.recent-events-table td:nth-child(3) {
  width: 116px;
}

.recent-events-table th:nth-child(4),
.recent-events-table td:nth-child(4) {
  width: 72px;
}

.recent-events-table th:nth-child(5),
.recent-events-table td:nth-child(5),
.recent-events-table th:nth-child(6),
.recent-events-table td:nth-child(6),
.recent-events-table th:nth-child(9),
.recent-events-table td:nth-child(9) {
  width: 132px;
}

.recent-events-table th:nth-child(7),
.recent-events-table td:nth-child(7) {
  width: 118px;
}

.recent-events-table th:nth-child(8),
.recent-events-table td:nth-child(8) {
  width: 88px;
}

.recent-events-table th:nth-child(10),
.recent-events-table td:nth-child(10) {
  width: 82px;
}

.recent-events-table th:nth-child(11),
.recent-events-table td:nth-child(11) {
  width: 250px;
}

.event-time,
.event-tokens {
  line-height: 1.15;
}

.event-type,
.event-station,
.event-principal,
.event-credential,
.event-metric,
.event-client,
.event-route {
  overflow-wrap: normal;
  white-space: nowrap;
}

.event-route {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(0, 147, 168, 0.1);
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.pill.error {
  background: rgba(214, 69, 49, 0.1);
  color: var(--danger);
}

.pill.warning {
  background: rgba(217, 119, 6, 0.12);
  color: #9a5b07;
}

.status {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.page-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.page-footer a {
  color: inherit;
  font-weight: 950;
}

ai-conversation-panel {
  --ai-panel-top: 96px;
}

@media (max-width: 1180px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  header,
  .controls,
  .billing-grid,
  .columns {
    grid-template-columns: 1fr;
  }

  header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .metric-group {
    min-height: 0;
  }
}
