/* Navigation, color preferences, data grids and permission matrix. */
:root {
  --brand-ink: #fff;
  --tag-bg: #e9f0f6;
  --tag-ink: #405b70;
  --group-bg: #21364a;
  --group-active: #2b4b61;
  --group-line: #48627a;
  --matrix-section: #e8f1f5;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #101b26;
  --surface: #182632;
  --surface-subtle: #1e303f;
  --text: #ecf4f9;
  --muted: #bacbd8;
  --line: #354b5d;
  --input-line: #526c81;
  --nav: #0c1723;
  --nav-hover: #223a4e;
  --nav-text: #c6d8e7;
  --brand: #8ce8dc;
  --brand-ink: #10242d;
  --brand-hover: #b5f7eb;
  --brand-soft: #183f41;
  --ok: #a0e8bd;
  --ok-soft: #1e4137;
  --warn: #ffe0a0;
  --warn-soft: #48391f;
  --danger: #ffb4ba;
  --danger-soft: #4b2735;
  --info: #b5d8ff;
  --info-soft: #213b56;
  --ring: #87e8db;
  --tag-bg: #263b4c;
  --tag-ink: #c5d8e5;
  --group-bg: #182939;
  --group-active: #24435a;
  --group-line: #3b566f;
  --matrix-section: #233648;
  --shadow: 0 2px 6px rgb(0 0 0 / 18%);
}

.btn-primary { color: var(--brand-ink); }
.tag, .pill { background-color: var(--tag-bg); color: var(--tag-ink); }
.data tbody > tr:hover > td { background: var(--surface-subtle); }
.alert.error { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.alert.success { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.alert.info { border-color: color-mix(in srgb, var(--info) 35%, var(--line)); }
.alert.warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.btn-danger { border-color: color-mix(in srgb, var(--danger) 42%, var(--line)); }
:root[data-theme="dark"] .btn-danger-solid { background: #a82933; border-color: #a82933; color: #fff; }
:root[data-theme="dark"] .btn-danger-solid:hover { background: #be3945; border-color: #be3945; }
:root[data-theme="dark"] .dialog::backdrop { background: rgb(0 8 16 / 73%); }
.topbar .theme-toggle { margin-left: auto; }
.topbar .account-menu { margin-left: 0; }
.auth > .theme-toggle { position: absolute; top: 16px; right: 16px; }
.theme-toggle { font-size: 19px; }

.app.nav-enhanced .nav-toggle { display: inline-flex !important; flex: none; }
.menu-glyph { display: block; width: 16px; height: 2px; background: currentColor; box-shadow: 0 5px currentColor, 0 -5px currentColor; }
@media (min-width: 901px) {
  :root[data-sidebar="hidden"] .app.nav-enhanced { grid-template-columns: minmax(0, 1fr); }
  :root[data-sidebar="hidden"] .app.nav-enhanced > .sidebar { display: none; }
}

.sidebar-nav { padding: 6px 12px 18px; }
.nav-group + .nav-group { margin-top: 12px; }
.nav-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: 0;
  padding: 9px 10px;
  background: var(--group-bg);
  color: #e1edf6;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 750;
  line-height: 1.3;
  list-style: none;
  cursor: pointer;
}
.nav-title::-webkit-details-marker { display: none; }
.nav-title:hover { border-color: var(--group-line); }
.nav-title:focus-visible { outline-color: #9aebdd; }
.nav-title::after { content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); }
.nav-group[open] > .nav-title::after { transform: rotate(45deg) translateY(-2px); }
.nav-group:has(.nav-link.active) > .nav-title { background: var(--group-active); color: #fff; border-color: var(--group-line); }
.nav-items { margin: 5px 0 0 9px; padding-left: 7px; border-left: 1px solid var(--group-line); }
.nav-items .nav-link { min-height: 34px; padding: 7px 9px; font-size: 13px; }
.nav-items .nav-link.active { background: #295261; box-shadow: inset 3px 0 #a1f6de; color: #fff; }
.nav-items .nav-link.active::after { content: ""; margin-left: auto; width: 5px; height: 5px; flex: none; border-radius: 50%; background: #a1f6de; }

.data-tools {
  position: relative;
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px;
  border-block: 1px solid var(--line);
}
.data-tools > label:first-child { flex: 1 1 190px; max-width: 340px; }
.data-tools > label:last-child { margin-left: auto; width: 95px; }
.table-filters { position: relative; }
.table-filters summary { list-style: none; }
.table-filters summary::-webkit-details-marker { display: none; }
.table-filters[open] summary { background: var(--brand-soft); }
.table-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  align-items: end;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
@media (min-width: 591px) {
  .table-filter-grid { position: absolute; z-index: 5; inset: calc(100% + 6px) auto auto 0; width: min(435px, 46vw); }
}
@media (max-width: 590px) {
  .table-filters[open] { flex: 1 1 100%; }
  .table-filter-grid { margin-top: 6px; }
}

.table-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.table-sort:hover, th[aria-sort="ascending"], th[aria-sort="descending"] { color: var(--brand); }
.sort-arrow::before { content: "↕"; opacity: .7; }
[aria-sort="ascending"] .sort-arrow::before { content: "↑"; opacity: 1; }
[aria-sort="descending"] .sort-arrow::before { content: "↓"; opacity: 1; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 9px; flex-wrap: wrap; }
.table-pages { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.table-pages [aria-current="page"] { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
.card:not(.data-card) > .table-footer { padding-inline: 0; }
.data-card > .table-wrap:has(+ .table-footer) { border-radius: 0; }
.table-wrap > .data.account-table { min-width: 740px; }
.table-wrap > .data.app-account-table { min-width: 1140px; }
.account-table .cell-name { min-width: 145px; }
.account-table time, .account-table .pill { white-space: nowrap; }
.account-table time { font-variant-numeric: tabular-nums; }
.account-email { max-width: 23ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.matrix-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; width: min(100%, 490px); }
.matrix-tools .label { width: auto; margin-top: 0; }
.matrix-scroll { max-height: 60vh; overflow: auto; }
.matrix-table { min-width: 100%; border-collapse: separate; border-spacing: 0; }
.matrix-table thead th { position: sticky; top: 0; z-index: 2; min-width: 120px; text-align: center; }
.matrix-table thead th:first-child { left: 0; z-index: 3; min-width: min(240px, 60vw); text-align: left; }
.matrix-table tbody th[scope="row"] { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.matrix-table tbody td { text-align: center; }
.matrix-table td { padding: 7px; }
.matrix-table .matrix-section th { background: var(--matrix-section); color: var(--text); font-size: 13px; }
.matrix-group { font-size: 13px; font-weight: 700; }
.matrix-code { display: block; overflow-wrap: anywhere; font-size: 11px; }
.matrix-table input { width: 17px; height: 17px; accent-color: var(--brand); }
.matrix-table input:disabled { opacity: .68; }

