/* Compact working layout for the owner cabinet. Loads after glass.css: keeps its material and tokens,
   changes structure and density. Spacing steps: 4 8 12 16 20 24. */
:root {
  --side-panel: min(460px, 38vw);
  --hit: 32px;
  color-scheme: dark;
  accent-color: var(--accent);
}
::selection { background: rgba(184, 220, 231, 0.32); color: #fff; }
input, textarea { caret-color: var(--accent); }
* { scrollbar-color: rgba(169, 198, 212, 0.28) transparent; scrollbar-width: thin; }
td, .summary strong, .category-stats-grid strong, #page-info, #page-number, time { font-variant-numeric: tabular-nums; }
.icon { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ── App bar: brand, sections and owner in one 56px row ─────────────────────────── */
.topbar {
  position: sticky; top: 8px; z-index: 20;
  height: 56px; margin: 8px auto 0; padding: 0 12px 0 16px; gap: 20px;
  border-radius: 16px; justify-content: flex-start;
}
.brand { font-size: 17px; gap: 10px; flex: none; }
.brand svg { width: 22px; height: 30px; }
.brand small { font-size: 10px; }
.topbar .tabs { margin: 0; padding: 3px; gap: 2px; border-radius: 12px; background: rgba(8, 20, 27, 0.35); }
.topbar .tabs button { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.owner-menu { margin-left: auto; gap: 8px; font-size: 12px; }
.owner-menu button { padding: 6px 12px; font-size: 12px; min-height: var(--hit); }
#owner-name { margin-right: 4px; }
body:has(#workspace[hidden]) .topbar .tabs { display: none; }
main { padding-bottom: 8px; }

/* ── Page heading: one line, actions on the right ───────────────────────────────── */
.page-heading { margin: 16px 0 12px; min-height: 0; align-items: center; }
.page-heading > div:first-child { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex-wrap: wrap; }
.page-heading h1 { font-size: 20px; letter-spacing: -0.4px; margin: 0; }
.page-heading p { margin: 0; font-size: 12px; }
.heading-actions { gap: 8px; }
.heading-actions button, .download-loader { padding: 7px 14px; font-size: 13px; min-height: var(--hit); }
.heading-actions .primary { display: inline-flex; align-items: center; gap: 6px; }

/* ── Keys toolbar: search and filters share a row ───────────────────────────────── */
#panel-keys:not([hidden]) { display: grid; grid-template-columns: minmax(280px, 1fr) auto; column-gap: 12px; align-items: center; }
#panel-keys > .registry { grid-column: 1 / -1; }
#panel-keys .searchbar { margin: 0 0 12px; gap: 8px; }
#panel-keys .search-field input { padding: 8px 12px 8px 36px; font-size: 13px; border-radius: 10px; }
#panel-keys .search-field svg { left: 12px; width: 16px; height: 16px; }
#panel-keys .searchbar > button { width: auto; padding: 7px 14px; font-size: 13px; border-radius: 10px; }
#panel-keys .filterbar { margin: 0 0 12px; gap: 8px; flex-wrap: nowrap; align-items: center; }
.filter-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#panel-keys .filterbar select { min-width: 0; padding: 7px 28px 7px 10px; font-size: 13px; margin: 0; }
#panel-keys .filterbar .check-label { height: auto; gap: 6px; font-size: 12px; white-space: nowrap; }
#panel-keys .filterbar > .text-button { height: auto; font-size: 12px; }
@media (max-width: 1280px) {
  #panel-keys:not([hidden]) { grid-template-columns: 1fr; }
  #panel-keys .filterbar { flex-wrap: wrap; }
}

/* ── Registry table: two-line key cell, 48px rows ───────────────────────────────── */
.surface { border-radius: 16px; }
.table-caption { padding: 10px 16px; align-items: center; }
.table-caption .muted { font-size: 11px; }
.table-wrap { max-height: calc(100dvh - 248px); min-height: 240px; overflow: auto; }
.registry thead th { position: sticky; top: 0; z-index: 1; background: rgba(20, 35, 44, 0.96); }
th { padding: 8px 12px; white-space: nowrap; }
td { padding: 7px 12px; font-size: 12.5px; }
#rows td:not(.key) { white-space: nowrap; }
td small { margin-top: 2px; font-size: 11px; }
#rows tr { cursor: pointer; transition: background-color 0.12s; }
#rows tr.selected { background: rgba(184, 220, 231, 0.1); }
#rows tr.selected:hover { background: rgba(184, 220, 231, 0.13); }
td.key { min-width: 220px; max-width: 360px; }
.key-title { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; color: var(--text); }
.key-title.muted { font-weight: 400; color: #8ea7b4; }
.order-ref { display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 400; color: #a9bec9; padding: 0 6px; border: 1px solid var(--line); border-radius: 5px; }
.key-line { display: flex; align-items: center; gap: 4px; min-width: 0; margin-top: 1px; }
.key .link {
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 11.5px/1.5 ui-monospace, 'Cascadia Mono', Consolas, monospace; color: #9fbecc; font-weight: 400;
}
.key .link:hover, .key .link:focus-visible { color: #e6f6fc; text-decoration: underline; text-underline-offset: 3px; }
.copy-key {
  display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0; flex: none;
  border: 0; border-radius: 6px; background: none; box-shadow: none; color: #9fbecc; opacity: 0.45;
}
#rows tr:hover .copy-key, .copy-key:focus-visible { opacity: 1; }
.copy-key:hover { background: rgba(184, 220, 231, 0.12); color: #fff; }
mark { background: rgba(228, 200, 149, 0.3); color: inherit; border-radius: 2px; padding: 0 1px; }
.badge { padding: 2px 7px; font-size: 11px; }
.hwid { font-size: 11.5px; }
.online-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #7fd1a8; vertical-align: 1px; }
.row-actions { width: var(--hit); height: var(--hit); padding: 0; font-size: 18px; line-height: 1; }
.pagination { padding: 8px 16px; gap: 16px; }
.pagination .page-size { display: flex; align-items: center; gap: 8px; margin: 0 auto 0 16px; font-size: 12px; }
.pagination .page-size select { width: auto; min-width: 0; margin: 0; padding: 4px 24px 4px 8px; font-size: 12px; }
.empty { padding: 40px 20px; }

/* ── Key card: side panel on wide screens, full-screen sheet on narrow ───────────── */
#key-details {
  position: fixed; inset: 72px 12px 12px auto; margin: 0;
  width: var(--side-panel); max-width: none; height: auto; max-height: none;
  padding: 16px 20px 20px; border-radius: 16px; overflow: auto; z-index: 30;
}
@media (min-width: 1100px) {
  body:has(#key-details[open]) main { padding-right: calc(var(--side-panel) + 12px); }
  /* With the card open the panel already shows type and dates: the registry keeps who, status, term, expiry, device. */
  body:has(#key-details[open]) #table :is(th, td):is(:nth-child(2), :nth-child(5), :nth-child(6)) { display: none; }
}
#key-details .dialog-heading { margin-bottom: 8px; }
#key-details h2 { font-size: 17px; }
#details-key {
  margin: 0 0 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(6, 18, 26, 0.4);
  font: 12.5px/1.6 ui-monospace, 'Cascadia Mono', Consolas, monospace; overflow-wrap: anywhere; user-select: all;
}
#details-fields { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; margin: 0 0 12px; }
#details-fields div { padding: 7px 0; }
#details-fields dd { font-size: 12.5px; }
.details-actions { gap: 6px; }
.details-actions button { padding: 8px; font-size: 12px; min-height: var(--hit); }
.details-history { margin-top: 16px; }
#details-history-list { max-height: none; }
@media (max-width: 1099px) {
  #key-details { inset: 0; width: 100%; height: 100dvh; border-radius: 0; }
}

/* ── Dialogs: tighter forms ─────────────────────────────────────────────────────── */
dialog { padding: 20px 24px; border-radius: 18px; }
dialog .dialog-heading { margin-bottom: 12px; }
dialog h2 { font-size: 19px; }
dialog label { margin-top: 8px; }
dialog input, dialog textarea, dialog select { margin: 4px 0 8px; padding: 8px 10px; font-size: 13px; }
dialog .hint { margin: 0 0 8px; }
#issue-dialog { width: min(560px, calc(100% - 24px)); }
#issue .presets { margin-top: 4px; }

/* ── History and devices: single-line rows ──────────────────────────────────────── */
#audit td { padding-top: 7px; padding-bottom: 7px; }
#audit td.audit-key { max-width: 420px; }
#audit td.audit-key { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.audit-who { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
#audit td.audit-key .link { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 11.5px/1.5 ui-monospace, 'Cascadia Mono', Consolas, monospace; color: #9fbecc; }
#blocked-rows td { padding-top: 8px; padding-bottom: 8px; }
#blocked-rows button { padding: 5px 12px; font-size: 12px; }

/* ── Statistics: smaller tiles, same reading order ──────────────────────────────── */
.summary { gap: 8px; margin-bottom: 12px; }
.summary > div { padding: 12px 14px; border-radius: 12px; }
.summary strong { font-size: 24px; margin-top: 4px; letter-spacing: -0.6px; }
.category-stats { padding: 16px; margin-bottom: 12px; }
/* Figures inside a panel are a row of values, not cards inside a card. */
.category-stats-grid { gap: 0; }
.category-stats-grid > div { padding: 2px 16px; border: 0; border-left: 1px solid var(--line); border-radius: 0; background: none; }
.category-stats-grid > div:first-child { border-left: 0; padding-left: 0; }
.category-stats-grid strong { font-size: 20px; }
/* History filters match the registry toolbar. */
.history-filters { margin-bottom: 12px; gap: 8px; align-items: end; }
.history-filters select { padding: 7px 28px 7px 10px; font-size: 13px; margin-top: 4px; }
.activity, .distribution { padding: 18px; }
.stats-layout { gap: 12px; }
.activity-chart { height: 170px; margin-top: 16px; }

footer { padding: 12px 2px; }

/* ── Narrow screens ─────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .topbar { height: auto; flex-wrap: wrap; row-gap: 8px; padding: 8px 12px; top: 6px; }
  .topbar .tabs { order: 3; flex: 1 0 100%; display: flex; overflow-x: auto; justify-content: space-between; }
  body:has(#workspace[hidden]) .topbar .tabs { display: none; }
  .topbar .tabs button { flex: 1 0 auto; padding: 7px 8px; font-size: 12px; }
  .owner-menu { gap: 6px; }
  #owner-name { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
  #owner-name::before { display: none; }
  .page-heading { display: block; margin: 12px 0 8px; }
  .brand small { display: none; }
  #panel-keys .filterbar { flex-wrap: wrap; }
  #panel-keys .filterbar > label:not(.check-label) { flex: 1 1 45%; min-width: 140px; }
  #audit td.audit-key { display: block; max-width: none; }
  #panel-keys .filterbar select { width: 100%; }
  .category-stats-grid > div { border-left: 0; padding: 8px 0; }
  .heading-actions { margin-top: 8px; }
  .table-wrap { max-height: none; min-height: 0; overflow: visible; }
  .registry thead th { position: static; }
  tr { padding: 10px 12px; }
  td.key { max-width: none; padding: 0 40px 6px 0; }
  .key .link { max-width: 62vw; }
  .copy-key { opacity: 1; }
  .pagination { flex-wrap: wrap; }
  .pagination .page-size { margin: 0; order: 3; flex-basis: 100%; justify-content: space-between; }
  #details-fields { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { #rows tr { transition: none; } }
.hwid-prefix { color: #7f98a6; font-size: 10.5px; }
.health-panel { padding: 18px; margin-top: 12px; }
.health-panel .section-heading { margin-bottom: 8px; }
#health-table td:nth-child(6) { white-space: normal; min-width: 220px; }
#details-reports-list { list-style: none; margin: 0; padding: 0; }
#details-reports-list li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
#details-reports-list time { color: var(--muted); margin-right: 6px; }
#details-reports-list a { color: var(--accent); text-underline-offset: 3px; }

/* Suspicious activity */
.alerts-panel { padding: 18px; margin-bottom: 12px; }
.alerts-panel .section-heading { margin-bottom: 8px; align-items: flex-start; }
.alerts-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.alert-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; grid-template-areas: "level key label when" "msg msg msg msg"; gap: 4px 10px; align-items: baseline; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.03); border-left: 3px solid #c9a24a; }
.alert-row.high { border-left-color: #d9735c; }
.alert-level { grid-area: level; font-size: 12px; font-weight: 600; color: #e2c47a; }
.alert-row.high .alert-level { color: #f0a08c; }
.alert-row .link { grid-area: key; min-width: 0; overflow-wrap: anywhere; text-align: left; }
.alert-row > .muted:nth-of-type(3) { grid-area: label; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-message { grid-area: msg; }
.alert-row > .muted:last-child { grid-area: when; font-size: 12px; }
.copy-result:empty { display: none; }
.copy-result { margin: 0 0 10px; }
.alert-badge { margin-left: 6px; padding: 0 6px; border-radius: 999px; font-size: 11px; background: #c9a24a; color: #1a1408; }
.alert-badge.high { background: #d9735c; color: #fff; }
@media (max-width: 640px) {
  .alerts-panel .section-heading { flex-direction: column; }
  .alert-row { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "level key" "label label" "msg msg" "when when"; }
}
/* Activation stopped for the owner's review and the "User info" card in the key details. */
.badge.review { background: #4a3f22; color: #f0d58f; }
.alert-row > button { justify-self: start; padding: 4px 10px; font-size: 12px; }
.user-info-fields { margin: 8px 0; }
.user-info-fields div { padding: 6px 0; border-bottom: 1px solid var(--line); }
.ban-history small { display: block; color: var(--muted); overflow-wrap: anywhere; }
