/* System screens: announcements, admins and roles, audit log, app config. Uses the tokens from styles.css. */

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
input[type='datetime-local'], input[type='date'] {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: inherit; min-height: 42px; color-scheme: dark;
}
input[type='datetime-local']:focus-visible, input[type='date']:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

/* ---------- chips and avatars ---------- */
.sys-chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 600; background: #202020; color: var(--muted); white-space: nowrap; }
.sys-chip-success { background: var(--success-soft); color: var(--success); }
.sys-chip-warn { background: var(--warn-soft); color: var(--warn); }
.sys-chip-danger { background: var(--danger-soft); color: var(--danger); }
.sys-chip-info { background: var(--info-soft); color: var(--info); }
.sys-chip-accent { background: var(--accent-soft); color: var(--accent); }
.avatar.sys-av-sm { width: 26px; height: 26px; font-size: 0.66rem; }
.sys-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sys-cell > div { min-width: 0; }
.sys-cell small { display: block; overflow-wrap: anywhere; }

/* hidden labels inside a scrolling table must be clipped by it, or they widen the whole page */
.table-wrap:has(.sys-matrix), .table-wrap:has(.sys-audit), .table-wrap:has(.sys-admins) { position: relative; }

/* ---------- tabs ---------- */
.sys-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.sys-tab { border: 0; background: none; padding: 10px 14px; min-height: 42px; color: var(--muted); font: inherit; font-weight: 550; border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer; }
.sys-tab:hover { color: var(--text); }
.sys-tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
.sys-tab:focus-visible { outline-offset: -3px; }
.sys-count { font-size: 0.7rem; background: #202020; border-radius: 999px; padding: 0 7px; margin-left: 6px; color: var(--muted); }

/* ---------- announcements ---------- */
.sys-live { margin-bottom: 16px; }
.sys-live-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--accent); }
.sys-live-head h2 { color: var(--text); }
.sys-live-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.sys-live-title { overflow-wrap: anywhere; }
.sys-live-actions { margin-top: 10px; }
.sys-slot-note { margin-top: 10px; }
.sys-compose-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.sys-compose-grid > * { min-width: 0; }
.sys-compose, .sys-side .card { margin-bottom: 14px; }
.sys-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.sys-window-line { margin: 2px 0 6px; }
.sys-side { position: sticky; top: 72px; }
.sys-reach { text-align: center; margin-top: 10px; }
.sys-phone { width: min(270px, 100%); margin: 0 auto; border: 7px solid #232323; border-radius: 32px; background: #070707; padding: 14px 12px 16px; box-shadow: 0 0 0 1px #3a3a3a; }
.sys-notch { width: 70px; height: 5px; background: #222; border-radius: 9px; margin: -4px auto 12px; }
.sys-phone-body { display: flex; flex-direction: column; gap: 12px; }
.sys-phone-empty { text-align: center; padding: 14px 0; }
.sys-banner { display: flex; align-items: flex-start; gap: 10px; padding: 10px 6px 10px 10px; border-radius: 10px; border: 1px solid; }
.sys-banner > .icon { margin-top: 1px; }
.sys-banner-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; overflow-wrap: anywhere; font-size: 0.86rem; }
.sys-banner-text p { color: var(--muted); font-size: 0.8rem; }
.sys-banner-link { font-weight: 700; margin-top: 4px; }
.sys-banner-x { color: var(--muted); flex: none; }
.sys-banner-info { background: var(--accent-soft); border-color: rgba(255, 74, 10, 0.4); }
.sys-banner-info > .icon, .sys-banner-info .sys-banner-link { color: var(--accent); }
.sys-banner-warning { background: var(--warn-soft); border-color: rgba(232, 163, 23, 0.45); }
.sys-banner-warning > .icon, .sys-banner-warning .sys-banner-link { color: var(--warn); }
.sys-skel { display: flex; flex-direction: column; gap: 8px; }
.sys-skel i { display: block; height: 62px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.sys-skel i:nth-child(2) { height: 44px; }
.sys-items { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.sys-item { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.sys-item-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.sys-item-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sys-item-title { overflow-wrap: anywhere; }
.sys-item-msg { color: var(--muted); overflow-wrap: anywhere; }
.sys-item-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
.sys-sev { font-size: 0.72rem; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 0 6px; }
.sys-sev-warning { color: var(--warn); border-color: rgba(232, 163, 23, 0.45); }
.sys-item .icon { vertical-align: -2px; }

/* ---------- admins ---------- */
.sys-row-off td { opacity: 0.75; }
.sys-row-off td.td-actions { opacity: 1; }
.sys-row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.sys-row-note { margin-top: 6px; text-align: right; white-space: normal; max-width: 280px; margin-left: auto; }
.sys-blurb { margin: -6px 0 14px; }
.sys-gen { margin: -6px 0 14px; }
.sys-matrix th, .sys-matrix td { text-align: center; }
.sys-matrix th:first-child, .sys-matrix td:first-child { text-align: left; }
.sys-matrix tbody th { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 0.92rem; color: var(--text); white-space: normal; }
.sys-matrix td { padding: 8px 10px; }
.sys-yes { color: var(--success); }
.sys-no { color: #4b4b4b; }
.sys-roles-dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 18px; margin: 14px 0 0; }
.sys-roles-dl dt { font-weight: 600; }
.sys-roles-dl dd { margin: 0; }

/* ---------- audit ---------- */
.sys-readonly { margin-bottom: 12px; }
.sys-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 8px; }
.sys-filter-search { flex: 1 1 240px; min-width: 0; }
.sys-filter { flex: 0 1 170px; min-width: 130px; display: flex; flex-direction: column; gap: 4px; }
.sys-filter label:not(.sr-only) { font-size: 0.76rem; color: var(--muted); }
.sys-filters .btn { min-height: 42px; }
.sys-results { margin-top: 8px; }
.sys-audit td { vertical-align: top; }
.sys-when { white-space: nowrap; }
.sys-when small, .sys-audit small { display: block; }
.sys-target { overflow-wrap: anywhere; font-weight: 550; }
.sys-change { color: var(--muted); overflow-wrap: anywhere; max-width: 360px; }
.sys-audit-row.is-open td { background: var(--surface-2); }
.sys-audit-row td:first-child { border-left: 3px solid transparent; }
.sys-audit-row.is-open td:first-child { border-left-color: var(--accent); }
.sys-detail td { background: var(--surface-2); padding: 12px 16px 16px; border-left: 3px solid var(--accent); }
.sys-detail-summary { overflow-wrap: anywhere; margin-bottom: 4px; }
.sys-json-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 6px; }
.sys-json { min-width: 0; }
.sys-json .json { max-height: 260px; margin-top: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- config ---------- */
.sys-meta { margin: -8px 0 14px; }
.sys-config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; align-items: start; }
.sys-config-grid > .card { margin-bottom: 0; }
.sys-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.sys-warn-card { border-color: rgba(232, 163, 23, 0.28); }
.sys-effect { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: 0.86rem; margin-bottom: 14px; }
.sys-effect .icon { margin-top: 3px; color: var(--info); }
.sys-link-card .btn { margin-top: 12px; }
.sys-sticky { position: sticky; bottom: 12px; z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-top: 18px; background: rgba(24, 24, 24, 0.97); border: 1px solid #333; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); }
.sys-sticky .sys-actions { margin-top: 0; }

@media (max-width: 960px) {
  .sys-compose-grid { grid-template-columns: minmax(0, 1fr); }
  .sys-side { position: static; }
}
@media (max-width: 600px) {
  .sys-item { flex-direction: column; }
  .sys-item-actions { justify-content: flex-start; }
  .sys-filter { flex: 1 1 130px; }
  .sys-actions .btn { flex: 1 1 auto; }
  .sys-row-note { text-align: left; margin-left: 0; }
  .sys-row-actions { justify-content: flex-start; }
  .sys-sticky { bottom: 0; border-radius: 12px 12px 0 0; }
  /* tables become stacked cards on a phone, so every action stays visible without sideways scrolling */
  .sys-admins thead, .sys-audit thead { display: none; }
  .sys-admins, .sys-audit, .sys-admins tbody, .sys-audit tbody { display: block; min-width: 0; }
  .sys-admins tr { display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; padding: 12px; border-bottom: 1px solid var(--border); }
  .sys-admins tr:last-child { border-bottom: 0; }
  .sys-admins td { display: block; padding: 0; border: 0; }
  .sys-admins td:first-child, .sys-admins td.td-actions { grid-column: 1 / -1; }
  .sys-admins td.td-actions { text-align: left; white-space: normal; }
  .sys-audit-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 12px; border-bottom: 1px solid var(--border); }
  .sys-audit-row td { display: block; padding: 0; border: 0; background: none; }
  .sys-audit-row td:nth-child(1) { grid-column: 1; }
  .sys-audit-row td:nth-child(3) { grid-column: 2; grid-row: 1; }
  .sys-audit-row td:nth-child(2), .sys-audit-row td:nth-child(4) { grid-column: 1 / -1; }
  .sys-audit-row td:nth-child(5) { grid-column: 1 / -1; max-width: none; }
  .sys-audit-row.is-open { background: var(--surface-2); }
  .sys-audit-row td:first-child, .sys-audit-row.is-open td:first-child { border-left: 0; }
  .sys-detail { display: block; }
  .sys-detail td { display: block; }
}
