/* Inkbraid Key Manager — Material Design 3 styling, self-contained.
   No external fonts, icons or scripts: the hub's Content-Security-Policy is
   default-src 'self', and a hub must work on an isolated network. */

:root {
  --primary: #4b53bc; --on-primary: #fff;
  --primary-container: #e0e0ff; --on-primary-container: #0b0f66;
  --surface: #fbf8ff; --surface-1: #ffffff; --surface-2: #f2effa; --surface-3: #e9e6f2;
  --fg: #1b1b21; --muted: #5d5d69; --outline: #c7c5d0; --outline-strong: #777680;
  --ok: #256b34; --ok-container: #d5efd8;
  --warn: #8a5300; --warn-container: #ffe3bd;
  --bad: #b3261e; --bad-container: #f9dedc;
  --inverse: #303036; --on-inverse: #f3eff7;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .18), 0 1px 3px 1px rgb(0 0 0 / .10);
  --shadow-3: 0 4px 8px 3px rgb(0 0 0 / .14), 0 1px 3px rgb(0 0 0 / .22);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #bdc2ff; --on-primary: #1a2189;
    --primary-container: #333ba3; --on-primary-container: #e0e0ff;
    --surface: #131318; --surface-1: #1c1c22; --surface-2: #24242b; --surface-3: #2e2e36;
    --fg: #e5e1e9; --muted: #a6a4b0; --outline: #46464f; --outline-strong: #91909a;
    --ok: #8fd69a; --ok-container: #17381d;
    --warn: #f5bd6f; --warn-container: #4a3000;
    --bad: #f2b8b5; --bad-container: #5c1a16;
    --inverse: #e5e1e9; --on-inverse: #303036;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: 5rem; }
body { margin: 0; font: 15px/1.5 Roboto, "Segoe UI", system-ui, sans-serif; background: var(--surface); color: var(--fg); }
main { max-width: 1160px; margin: 1.5rem auto 5rem; padding: 0 1.25rem; }
main.narrow { max-width: 440px; margin-top: 8vh; }
h1 { font-size: 1.75rem; font-weight: 400; margin: .5rem 0 1rem; }
h2 { font-size: 1.25rem; font-weight: 500; margin: 0 0 .75rem; }
h3 { font-size: 1rem; font-weight: 500; margin: 1.25rem 0 .5rem; }
p { margin: .5rem 0; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.right { margin-left: auto; }
[hidden] { display: none !important; }

code { background: var(--surface-3); padding: .05em .35em; border-radius: 4px; font-size: .92em; }
code.big { font-size: 1.35em; padding: .15em .5em; letter-spacing: .04em; }

/* ---- top app bar ---- */
.nav { position: sticky; top: 0; z-index: 20; display: flex; gap: .25rem; align-items: center;
       padding: .5rem 1.25rem; background: var(--surface-2); box-shadow: var(--shadow-1); flex-wrap: wrap; }
.nav .brand { font-weight: 500; font-size: 1.1rem; margin-right: 1rem; }
.nav a.navlink { text-decoration: none; color: var(--fg); padding: .45rem .9rem; border-radius: 99px; font-weight: 500; font-size: .93rem; }
.nav a.navlink:hover { background: var(--surface-3); }
.nav a.navlink.on { background: var(--primary-container); color: var(--on-primary-container); }
.appfoot { text-align: center; padding: 1.5rem 0 1rem; }

/* ---- page header ---- */
.pagehead { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.pagehead h1 { margin: .5rem 0; }
.pagehead .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---- cards ---- */
.card { background: var(--surface-1); border: 1px solid var(--outline); border-radius: var(--radius); padding: 1.25rem; margin: 0 0 1.25rem; }
.card > h2:first-child, .card > .cardhead:first-child { margin-top: 0; }
.cardhead { display: flex; align-items: center; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.cardhead h2 { margin: 0; }
.cardhead .actions { margin-left: auto; display: flex; gap: .5rem; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
.cols > .card { margin-bottom: 0; }
.cols { margin-bottom: 1.25rem; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }

/* ---- tabs ---- */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--outline); margin: 0 0 1.25rem; overflow-x: auto; }
.tabs button, .tabs a { appearance: none; background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0;
       color: var(--muted); font: inherit; font-weight: 500; padding: .8rem 1.2rem; cursor: pointer; white-space: nowrap; text-decoration: none; box-shadow: none; }
.tabs button:hover, .tabs a:hover { background: var(--surface-2); filter: none; }
.tabs button[aria-selected="true"], .tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- tables ---- */
.tablewrap { overflow-x: auto; border: 1px solid var(--outline); border-radius: var(--radius); background: var(--surface-1); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .65rem .9rem; border-bottom: 1px solid var(--outline); vertical-align: middle; }
th { font-size: .85rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td, table tr:hover td { background: color-mix(in srgb, var(--primary) 4%, transparent); }
td.actions { white-space: nowrap; text-align: right; }

/* Access matrix: column headers at 45 degrees so long host names stay
   readable without widening the columns. */
.matrixwrap { overflow-x: auto; padding-right: 8rem; border: 1px solid var(--outline); border-radius: var(--radius); background: var(--surface-1); }
table.matrix { width: auto; }
table.matrix th, table.matrix td { padding: .4rem .5rem; }
table.matrix td.cellcol, table.matrix th.rot { text-align: center; width: 3rem; min-width: 3rem; max-width: 3rem; }
table.matrix th.rot { height: 10rem; padding: 0; vertical-align: bottom; position: relative; border-bottom: 1px solid var(--outline); }
table.matrix th.rot > div { position: absolute; left: 50%; bottom: .45rem; width: 13rem; transform-origin: left bottom;
       transform: rotate(-45deg); text-align: left; }
table.matrix th.rot > div > span { display: inline-block; max-width: 12.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
       font-size: .9rem; font-weight: 500; color: var(--fg); vertical-align: bottom; }
table.matrix th.rot.group > div > span { color: var(--primary); }
table.matrix th.rowhead, table.matrix td.rowhead { text-align: left; white-space: nowrap; padding: .4rem 1.25rem .4rem .9rem; }
table.matrix th.rowhead { vertical-align: bottom; padding-bottom: .6rem; }
.legend { display: flex; gap: 1.25rem; flex-wrap: wrap; margin: .75rem 0 0; }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }

/* ---- forms ---- */
form { margin: 0; }
form.inline { display: inline-block; margin: 0; }
form.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.field { display: block; margin: 0 0 1rem; }
.field > span { display: block; font-size: .85rem; font-weight: 500; color: var(--muted); margin-bottom: .3rem; }
.field > small { display: block; color: var(--muted); margin-top: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=search], input:not([type]), select, textarea {
  font: inherit; width: 100%; padding: .65rem .8rem; border: 1px solid var(--outline-strong); border-radius: 6px;
  background: var(--surface-1); color: var(--fg); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
form.row input, form.row select { width: auto; flex: 1 1 12rem; max-width: 22rem; }
input.small { width: 9rem; padding: .35rem .5rem; font-size: .9em; }
.field.narrow input { max-width: 10rem; }
/* A checkbox row: box and label on one line, aligned to the text baseline. */
.check { display: flex; gap: .75rem; align-items: flex-start; margin: 0 0 1rem; cursor: pointer; }
.check input { flex: none; width: 1.15rem; height: 1.15rem; margin: .18rem 0 0; accent-color: var(--primary); }
.check small { display: block; color: var(--muted); }
.formactions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: .5rem; }
fieldset { border: 1px solid var(--outline); border-radius: 8px; margin: 0 0 1rem; padding: .75rem 1rem; }

/* ---- buttons ---- */
button, .btn { font: inherit; font-weight: 500; font-size: .93rem; padding: .55rem 1.3rem; border: 0; border-radius: 99px; cursor: pointer;
       background: var(--primary); color: var(--on-primary); text-decoration: none; display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap; }
button:hover, .btn:hover { filter: brightness(1.08); box-shadow: var(--shadow-1); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button.tonal, .btn.tonal { background: var(--primary-container); color: var(--on-primary-container); }
button.text, .btn.text { background: none; color: var(--primary); padding: .55rem .8rem; }
button.text:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); box-shadow: none; filter: none; }
button.outlined, .btn.outlined { background: none; color: var(--primary); border: 1px solid var(--outline-strong); }
button.danger { background: var(--bad); color: var(--surface-1); }
button.text.danger, button.outlined.danger { background: none; color: var(--bad); }
button.linkish { background: none; border: none; color: var(--primary); padding: .3rem .5rem; border-radius: 6px; }
button.linkish:hover { box-shadow: none; background: color-mix(in srgb, var(--primary) 10%, transparent); }
button.linkish.danger { color: var(--bad); }
button.iconbtn { background: none; color: var(--muted); padding: .4rem; border-radius: 50%; width: 2.2rem; height: 2.2rem; justify-content: center; }
button.iconbtn:hover { background: var(--surface-3); box-shadow: none; filter: none; }
svg.icon { width: 1.2rem; height: 1.2rem; fill: currentColor; flex: none; }

/* Access cells */
button.cell { background: none; color: var(--muted); border: 1px solid var(--outline); border-radius: 8px; width: 2.2rem; height: 2.2rem; padding: 0; justify-content: center; font-size: 1rem; }
button.cell:hover { border-color: var(--primary); box-shadow: none; filter: none; }
button.cell.on { background: var(--ok-container); border-color: var(--ok); color: var(--ok); }
/* Access the person has without this box being ticked (through a group or
   as super user). Dashed so it reads as "already allowed, but not from here". */
button.cell.implied { background: color-mix(in srgb, var(--ok-container) 55%, transparent); border: 1px dashed var(--ok); color: var(--ok); }
.cellkey { display: inline-flex; width: 1.5rem; height: 1.5rem; border-radius: 6px; align-items: center; justify-content: center; font-size: .8rem; }
.cellkey.on { background: var(--ok-container); border: 1px solid var(--ok); color: var(--ok); }
.cellkey.implied { background: color-mix(in srgb, var(--ok-container) 55%, transparent); border: 1px dashed var(--ok); color: var(--ok); }
.cellkey.off { border: 1px solid var(--outline); color: var(--muted); }

/* Floating action button with a label that flies out on hover or focus. */
.fab { position: fixed; right: 1.75rem; bottom: 1.75rem; z-index: 15; height: 3.5rem; min-width: 3.5rem; padding: 0 1rem; border-radius: 16px;
       background: var(--primary-container); color: var(--on-primary-container); box-shadow: var(--shadow-3); gap: 0; }
.fab svg.icon { width: 1.5rem; height: 1.5rem; }
.fab .fablabel { max-width: 0; overflow: hidden; opacity: 0; transition: max-width .2s ease, opacity .2s ease, margin .2s ease; }
.fab:hover .fablabel, .fab:focus-visible .fablabel { max-width: 14rem; opacity: 1; margin-left: .6rem; }
.fab:hover { box-shadow: var(--shadow-3); }

/* ---- chips & badges ---- */
.badge, .chip { font-size: .78rem; padding: .2rem .65rem; border-radius: 8px; white-space: nowrap; font-weight: 500; display: inline-block; }
.chip { border: 1px solid var(--outline); color: var(--fg); margin: .1rem .15rem .1rem 0; }
.chip.via { border-style: dashed; color: var(--muted); }
.badge.s-current, .badge.s-active { background: var(--ok-container); color: var(--ok); }
.badge.s-needs-update, .badge.s-pending { background: var(--warn-container); color: var(--warn); }
.badge.s-stale, .badge.s-never-checked-in, .badge.s-revoked { background: var(--bad-container); color: var(--bad); }

/* ---- command boxes with a copy button ---- */
pre { background: var(--surface-2); border: 1px solid var(--outline); padding: .8rem 1rem; border-radius: 8px; overflow-x: auto; font-size: .87rem; margin: .5rem 0 1rem; }
.cmdbox { position: relative; margin: .5rem 0 1rem; }
.cmdbox pre { margin: 0; padding-right: 3.2rem; white-space: pre-wrap; word-break: break-all; }
.cmdbox .copybtn { position: absolute; top: .3rem; right: .3rem; }
.copybtn.done { color: var(--ok); }

/* ---- dialogs ---- */
dialog { border: 0; border-radius: 28px; padding: 1.5rem; background: var(--surface-1); color: var(--fg); box-shadow: var(--shadow-3);
         width: min(32rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow-y: auto; }
dialog.wide { width: min(52rem, calc(100vw - 2rem)); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog h2 { font-size: 1.4rem; font-weight: 400; margin: 0 0 1rem; }
dialog .formactions { justify-content: flex-end; margin-top: 1.25rem; }
.picklist { border: 1px solid var(--outline); border-radius: 8px; max-height: 14rem; overflow-y: auto; padding: .5rem .75rem; margin-bottom: 1rem; }
.picklist .check { margin: .35rem 0; }

/* ---- snackbars ---- */
.snackbars { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: .5rem;
             width: min(36rem, calc(100vw - 2rem)); pointer-events: none; }
.snackbar { pointer-events: auto; display: flex; align-items: center; gap: .75rem; background: var(--inverse); color: var(--on-inverse);
            padding: .75rem .75rem .75rem 1rem; border-radius: 8px; box-shadow: var(--shadow-3); transition: opacity .25s ease, transform .25s ease; }
.snackbar.err { background: var(--bad); color: #fff; }
.snackbar .msg { flex: 1; overflow-wrap: anywhere; }
.snackbar button { background: none; color: inherit; padding: .3rem .6rem; border-radius: 6px; opacity: .85; }
.snackbar button:hover { background: rgb(255 255 255 / .15); box-shadow: none; filter: none; }
.snackbar.leaving { opacity: 0; transform: translateY(.5rem); }

/* In-page notices (not transient) */
.notice { padding: .75rem 1rem; border-radius: 8px; margin: 0 0 1rem; background: var(--primary-container); color: var(--on-primary-container); }
.notice.err { background: var(--bad-container); color: var(--bad); }
.notice.ok { background: var(--ok-container); color: var(--ok); }

.empty { color: var(--muted); padding: 1.5rem; text-align: center; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: 0 0 1rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.ssobtn { display: inline-block; padding: .55rem 1.3rem; border: 1px solid var(--outline-strong); border-radius: 99px; text-decoration: none; font-weight: 500; }
