/* The admin panel under the site header: a dense table tool (ported from the admin console's
   style.css and screens.css) with the site's tokens and controls from base.css. */

body.admin { display: flex; flex-direction: column; height: 100vh; height: 100dvh; font-size: 13.5px; }
.admin .site-header { flex: none; }
.admin .btn { height: 30px; padding: 0 12px; font-size: 13px; }
.admin .btn-sm { height: 26px; padding: 0 9px; font-size: 12.5px; }
.admin input[type="text"], .admin input[type="search"], .admin input[type="number"],
.admin input[type="datetime-local"] { height: 30px; font-size: 13px; }
.admin code, .admin .mono { font-size: 12.5px; }
.admin .dialog-body h2 { font-size: 18px; }

.gate-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* minmax(0, 1fr): a wide table scrolls inside its own box instead of widening the page. */
.admin-app {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
}

.admin-bar {
  display: flex;
  align-items: stretch;
  gap: 16px;
  height: 44px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}
.tabs { display: flex; }
.tabs a {
  display: flex;
  align-items: center;
  padding: 0 12px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  font-weight: 500;
  text-decoration: none;
  transition: color 120ms, border-color 120ms;
}
.tabs a:first-child { margin-left: -12px; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs a:focus-visible { outline-offset: -4px; }
.target {
  display: flex;
  align-items: center;
  min-width: 0;
  margin-left: auto;
  overflow: hidden;
  color: var(--text-3);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A column, not a grid: the hidden banners must not take a row from the table. */
.screen { display: flex; flex-direction: column; min-height: 0; }

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.toolbar-gap { flex: 1; }
.search { width: 300px; }
.summary { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.link-text {
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  user-select: all;
}

.message.banner { padding: 8px 20px; border-bottom: 1px solid color-mix(in oklab, currentColor 30%, transparent); background: color-mix(in oklab, currentColor 8%, transparent); }

.footnote {
  padding: 8px 20px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-3);
  font-size: 12.5px;
}

/* Fields the dialogs use -------------------------------------------------------------------- */

.inline-field { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); }
.input-days { width: 80px; }
.input-wide { width: min(360px, 100%); }

.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }

.field-row { display: grid; grid-template-columns: 1fr 1.2fr 0.9fr 0.8fr; gap: 10px; }
.field-row input { width: 100%; min-width: 0; }

.segmented {
  display: flex;
  flex-wrap: wrap;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.segmented label { position: relative; }
.segmented input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.segmented span {
  display: block;
  padding: 5px 11px;
  border-right: 1px solid var(--line);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  transition: background-color 120ms, color 120ms;
}
.segmented label:last-child span { border-right: 0; }
.segmented label:hover span { background: var(--raised); color: var(--text); }
.segmented input:checked + span { background: color-mix(in oklab, var(--accent) 20%, var(--surface)); color: var(--text); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.dialog-wide { width: min(520px, calc(100vw - 32px)); }

.new-key-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.new-key-box code { flex: 1; color: var(--text); font-size: 17px; letter-spacing: 0.03em; user-select: all; }

/* Tables ------------------------------------------------------------------------------------ */

/* relative: screen-reader-only text in the cells stays inside the scroll box. */
.admin .table-wrap { position: relative; flex: 1; min-height: 0; overflow: auto; border: 0; border-radius: 0; }

.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.grid td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
}
.grid th:first-child, .grid td:first-child { padding-left: 20px; }
.grid th:last-child, .grid td:last-child { padding-right: 20px; }
.grid .num { text-align: right; }

.grid tbody tr:hover > td { background: color-mix(in oklab, var(--raised) 55%, transparent); }
.grid tr.is-inactive > td { color: var(--text-3); }

.row { cursor: pointer; }
.grid tr.is-open > td, .grid tr.is-open:hover > td { background: var(--surface); border-bottom-color: transparent; }
.row.is-new > td { animation: arrived 2.4s var(--ease-out); }
@keyframes arrived { from { background: color-mix(in oklab, var(--accent) 22%, transparent); } }

.cell-key { color: var(--text); letter-spacing: 0.01em; }
.cell-note { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.cell-notes { min-width: 220px; max-width: 460px; white-space: normal !important; color: var(--text-2); }
.cell-actions { text-align: right; width: 1%; }
.cell-actions .btn + .btn { margin-left: 4px; }

.seen { white-space: nowrap; }

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--good);
  vertical-align: 1px;
}

/* Few, short columns: they keep their content width and the last one takes what is left. */
.grid-compact th:last-child { width: 100%; }
.grid-compact td { padding-right: 28px; }

.grid .panel-row > td, .grid .panel-row:hover > td {
  padding: 2px 20px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  white-space: normal;
  cursor: default;
}

.panel { display: grid; gap: 12px; }
.panel-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.panel-actions .spacer { flex: 1; }
.action-slot:empty { display: none; }
.action-slot { display: grid; gap: 8px; }

.action-form, .confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.action-form { padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 6px; background: var(--bg); }
.action-form .hint { flex-basis: 100%; color: var(--text-3); font-size: 12.5px; }
.confirm { justify-content: flex-end; padding-top: 2px; }
.confirm-text { color: var(--text-2); max-width: 70ch; }
.confirm-error { margin-top: 6px; text-align: right; }

.facts { display: flex; flex-wrap: wrap; gap: 10px 36px; margin: 0; }
.facts dt { color: var(--text-3); font-size: 12px; }
.facts dd { margin: 1px 0 0; overflow-wrap: anywhere; }
.facts .btn-copy { height: 22px; margin-left: 2px; vertical-align: 0; }

.grid .empty td, .grid .empty:hover td {
  padding: 28px 20px;
  background: none;
  color: var(--text-2);
  white-space: normal;
}
.empty strong { color: var(--text); font-weight: 600; }

.skeleton td { padding-top: 12px; padding-bottom: 12px; }
.skeleton .bar { width: 70%; height: 9px; }

button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
button.link:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--text-3); }

/* Narrow windows: drop the secondary columns before anything wraps. ----------------------------- */

@media (max-width: 900px) {
  .col-opt { display: none; }
  .target { display: none; }
}

@media (max-width: 720px) {
  .admin-bar { padding: 0 12px; }
  .toolbar { padding: 10px 12px; }
  .search { width: 100%; }
  .toolbar-gap { display: none; }
  .field-row { grid-template-columns: 1fr 1fr; }
}
