/* cdn-admin console styles — components built from otg-tokens.css var(--ds-*)
   only, composed the way examples/office-hub-reskin.html's `.after` layer
   does. No hex literals here except where a token has none.

   ponytail: font-family is intentionally NOT set here — otg-tokens.css maps
   --ds-font-ui to "Geist" and --ds-font-brand to "Space Mono", both
   self-hosted via /static/fonts.css (linked before this file in layout.tmpl),
   so `body { font-family: var(--ds-font-ui) }` below is the only place a
   family is referenced. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--ds-bg-page);
  color: var(--ds-text-primary);
  font-family: var(--ds-font-ui);
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--ds-link);
}

h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--ds-text-primary);
  margin: 0 0 4px;
}

.sub {
  font-size: 13px;
  color: var(--ds-text-muted);
  margin: 0;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 28px 64px;
}

/* ─── Topbar ──────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 28px;
  background: var(--ds-bg-sidebar);
  border-bottom: 1px solid var(--ds-border);
}

.brand-mark {
  font-family: var(--ds-font-brand);
  font-weight: 700;
  font-size: 15px;
  color: var(--ds-text-primary);
  letter-spacing: -0.3px;
}

.topnav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: var(--ds-radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--ds-text-secondary);
  text-decoration: none;
}

.topnav a:hover {
  background: var(--ds-bg-hover);
  color: var(--ds-text-primary);
}

.logout-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.userchip {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ds-text-secondary);
}

/* ─── Page head ───────────────────────────────────────────────────────── */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.range-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ds-text-muted);
}

.range-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.range-form input,
.range-form select {
  border: 1px solid var(--ds-border-input, var(--ds-border));
  border-radius: var(--ds-radius-sm);
  padding: var(--ds-field-pad-y-sm) var(--ds-field-pad-x-sm);
  font-size: var(--ds-field-font-sm);
  font-family: inherit;
  background: var(--ds-bg-card);
  color: var(--ds-text-primary);
}

/* ─── KPI strip ───────────────────────────────────────────────────────── */

.signal {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: var(--ds-bg-card);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-card);
  margin-bottom: 22px;
  overflow: hidden;
}

.kpi {
  padding: 14px 16px;
  border-right: 1px solid var(--ds-border-light);
}

.kpi:last-child {
  border-right: none;
}

.kpi .lab {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ds-text-muted);
}

.kpi .val {
  font-size: 22px;
  font-weight: 600;
  margin-top: 6px;
  color: var(--ds-text-primary);
  font-variant-numeric: tabular-nums;
  font-family: var(--ds-font-brand);
}

/* ─── Cards / tables ──────────────────────────────────────────────────── */

.card {
  background: var(--ds-bg-card);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-card);
  margin-bottom: 22px;
}

.card-head {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ds-text-primary);
  padding: 13px 16px;
  border-bottom: 1px solid var(--ds-border-light);
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--ds-text-muted);
  font-weight: 600;
  padding: 10px 16px;
  border-bottom: 1px solid var(--ds-border-light);
  white-space: nowrap;
}

.table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--ds-border-light);
  vertical-align: middle;
  color: var(--ds-text-secondary);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: var(--ds-bg-hover);
}

.table td.mono {
  font-family: var(--ds-font-brand);
  font-size: 12px;
  color: var(--ds-text-primary);
}

.table td.empty {
  text-align: center;
  color: var(--ds-text-muted);
  padding: 24px 16px;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: inherit;
  text-decoration: none;
}

.sort-link:hover {
  color: var(--ds-text-primary);
}

/* ─── Pagination ──────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 16px;
  border-top: 1px solid var(--ds-border-light);
  font-size: 12.5px;
  color: var(--ds-text-muted);
}

.pagination .btn-disabled {
  opacity: .4;
  pointer-events: none;
}

.row-actions {
  white-space: nowrap;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
}

.reason-input {
  width: 110px;
  border: 1px solid var(--ds-border-input, var(--ds-border));
  border-radius: var(--ds-radius-sm);
  padding: 4px 7px;
  font-size: 12px;
  font-family: inherit;
  background: var(--ds-bg-card);
  color: var(--ds-text-primary);
}

/* ─── Badges ──────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ds-text-secondary);
}

.badge-muted {
  color: var(--ds-text-muted);
  font-style: italic;
}

.badge-danger {
  color: var(--ds-error-text);
  background: var(--ds-error-light);
  padding: 2px 8px;
  border-radius: var(--ds-radius-sm);
}

.badge-success {
  color: var(--ds-success-text);
  background: var(--ds-success-light);
  padding: 2px 8px;
  border-radius: var(--ds-radius-sm);
}

/* ─── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: var(--ds-control-font-md);
  font-weight: 600;
  padding: var(--ds-control-pad-y-md) var(--ds-control-pad-x-md);
  border-radius: var(--ds-radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.btn-sm {
  font-size: var(--ds-control-font-sm);
  padding: var(--ds-control-pad-y-sm) var(--ds-control-pad-x-sm);
}

.btn-primary {
  background: var(--ds-primary);
  color: var(--ds-on-primary);
}

.btn-primary:hover {
  background: var(--ds-primary-hover);
}

.btn-secondary {
  background: var(--ds-bg-section);
  color: var(--ds-text-primary);
  border-color: var(--ds-border);
}

.btn-secondary:hover {
  background: var(--ds-bg-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--ds-text-secondary);
  border-color: var(--ds-border);
}

.btn-ghost:hover {
  background: var(--ds-bg-hover);
  color: var(--ds-text-primary);
}

.btn-danger {
  background: var(--ds-error);
  color: #ffffff;
}

.btn-danger:hover {
  background: var(--ds-error-hover);
}

/* ─── Forms (login / upload) ──────────────────────────────────────────── */

.login-card,
.upload-card {
  max-width: 420px;
  padding: 28px;
  margin: 40px auto 0;
}

.login-card form,
.upload-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ds-text-secondary);
}

.field input {
  border: 1px solid var(--ds-border-input, var(--ds-border));
  border-radius: var(--ds-radius-sm);
  padding: var(--ds-field-pad-y-md) var(--ds-field-pad-x-md);
  font-size: var(--ds-field-font-md);
  font-family: inherit;
  background: var(--ds-bg-card);
  color: var(--ds-text-primary);
}

.field input:focus {
  outline: 2px solid var(--ds-primary-subtle);
  outline-offset: 1px;
  border-color: var(--ds-primary);
}

.alert {
  border-radius: var(--ds-radius-md);
  padding: 9px 12px;
  font-size: 12.5px;
  margin: 14px 0 0;
}

.alert-error {
  background: var(--ds-error-light);
  color: var(--ds-error-text);
  box-shadow: inset 0 0 0 1px var(--ds-error);
}

/* ─── File preview modal ──────────────────────────────────────────────── */

.key-link {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-family: var(--ds-font-brand);
  font-size: 12px;
  color: var(--ds-link);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.key-link:hover {
  color: var(--ds-primary-hover);
}

.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--ds-z-modal, 100);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.preview-overlay[hidden] {
  display: none;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 16, 0.55);
}

.preview-box {
  position: relative;
  max-width: min(90vw, 960px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--ds-bg-card);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-modal);
  overflow: hidden;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--ds-border-light);
}

.preview-title {
  font-size: 12.5px;
  color: var(--ds-text-primary);
  word-break: break-all;
}

.preview-close {
  flex: none;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
  color: var(--ds-text-muted);
  cursor: pointer;
  border-radius: var(--ds-radius-sm);
}

.preview-close:hover {
  background: var(--ds-bg-hover);
  color: var(--ds-text-primary);
}

.preview-body {
  padding: 14px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-media {
  display: block;
  max-width: 100%;
  max-height: calc(90vh - 90px);
  border-radius: var(--ds-radius-sm);
}

.preview-nomedia {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px;
  color: var(--ds-text-muted);
  font-size: 13px;
}

/* ─── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .container {
    padding: 16px;
  }
  .signal {
    grid-template-columns: repeat(2, 1fr);
  }
  .kpi:nth-child(2n) {
    border-right: none;
  }
  .kpi {
    border-bottom: 1px solid var(--ds-border-light);
  }
}
