/* Github Code Review.
 *
 * Greys do the structure, color only ever means status.  Dark mode follows the
 * system rather than asking.
 */

:root {
    --bg: #ffffff;
    --bg-soft: #f6f6f6;
    --bg-sunk: #efefef;
    --border: #e0e0e0;
    --border-strong: #c8c8c8;

    --text: #141414;
    --text-soft: #5c5c5c;
    --text-faint: #8a8a8a;
    --text-invert: #ffffff;

    --header: #141414;
    --sidebar: #fafafa;

    --ok: #1a7f37;
    --ok-bg: #eaf4ec;
    --warn: #9a6700;
    --warn-bg: #fdf6e3;
    --bad: #b42318;
    --bad-bg: #fdeceb;
    --info: #1f4f82;
    --info-bg: #eaf1f8;

    --radius: 6px;
    --nav-width: 232px;
    --topbar-height: 56px;

    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
            "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #161616;
        --bg-soft: #1e1e1e;
        --bg-sunk: #242424;
        --border: #333333;
        --border-strong: #454545;

        --text: #ededed;
        --text-soft: #a8a8a8;
        --text-faint: #7a7a7a;

        --header: #0d0d0d;
        --sidebar: #1a1a1a;

        --ok: #4ac26b;
        --ok-bg: #16261a;
        --warn: #d4a72c;
        --warn-bg: #2a2413;
        --bad: #f28b82;
        --bad-bg: #2d1a19;
        --info: #6ea8de;
        --info-bg: #16212e;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

a { color: inherit; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
code, .mono { font-family: var(--mono); font-size: .85em; }

/* ---- shell ------------------------------------------------------------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar-height);
    background: var(--header);
    color: var(--text-invert);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1rem; gap: 1rem; flex: none;
}
.topbar .flex, .topbar .right { display: flex; align-items: center; gap: .85rem; }
.topbar a { color: var(--text-invert); text-decoration: none; opacity: .85; }
.topbar a:hover { opacity: 1; }
.topbar .faint { color: rgba(255,255,255,.55); }

.brand {
    display: flex; align-items: center; gap: .5rem;
    font-weight: 600; font-size: 1rem; text-decoration: none;
}
.brand svg { width: 20px; height: 20px; flex: none; }

.layout { display: flex; flex: 1; min-height: 0; }

.sidebar {
    width: var(--nav-width); flex: none;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    padding: .75rem 0; overflow-y: auto;
}
.sidebar a {
    display: flex; align-items: center; gap: .6rem;
    padding: .45rem 1rem; color: var(--text-soft);
    text-decoration: none; font-size: .9rem;
}
.sidebar a svg { width: 15px; height: 15px; flex: none; opacity: .8; }
.sidebar a:hover { background: var(--bg-sunk); color: var(--text); }
.sidebar a.active {
    color: var(--text); font-weight: 600;
    box-shadow: inset 3px 0 0 var(--text);
    background: var(--bg-sunk);
}

.nav-group { margin-bottom: .35rem; }
.group-label {
    width: 100%; display: flex; align-items: center; gap: .6rem;
    padding: .4rem 1rem; background: none; border: 0; cursor: pointer;
    color: var(--text-faint); font: inherit; font-size: .72rem;
    text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
.group-label .group-icon { width: 13px; height: 13px; }
.group-label .chev { width: 13px; height: 13px; margin-left: auto;
                     transition: transform .15s; }
.group-label[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.group-label[aria-expanded="false"] + .group-links { display: none; }

.content { flex: 1; min-width: 0; padding: 1.25rem 1.5rem 3rem; overflow-y: auto; }
.wrap { max-width: 1180px; }

.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.page-actions { display: flex; gap: .5rem; align-items: center; }

/* ---- bits -------------------------------------------------------------- */
.card {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 1rem;
}
.card-head {
    padding: .7rem 1rem; border-bottom: 1px solid var(--border);
    font-weight: 600; display: flex; align-items: center;
    justify-content: space-between; gap: .75rem;
}
.card-body { padding: 1rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
         gap: .75rem; margin-bottom: 1.25rem; }
.stat {
    background: var(--bg-soft); border: 1px solid var(--border);
    border-radius: var(--radius); padding: .8rem .9rem;
}
.stat .n { font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.stat .l { color: var(--text-faint); font-size: .78rem; text-transform: uppercase;
           letter-spacing: .05em; margin-top: .15rem; }
.stat.bad .n  { color: var(--bad); }
.stat.warn .n { color: var(--warn); }
.stat.ok .n   { color: var(--ok); }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--border);
         vertical-align: top; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
     color: var(--text-faint); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--bg-soft); }
.table-scroll { overflow-x: auto; }
.nowrap { white-space: nowrap; }

.badge {
    display: inline-block; padding: .1rem .45rem; border-radius: 10px;
    font-size: .72rem; font-weight: 600; white-space: nowrap;
    border: 1px solid transparent;
}
.badge.critical { background: var(--bad-bg);  color: var(--bad);  border-color: var(--bad); }
.badge.high     { background: var(--bad-bg);  color: var(--bad); }
.badge.medium   { background: var(--warn-bg); color: var(--warn); }
.badge.low      { background: var(--info-bg); color: var(--info); }
.badge.info,
.badge.unknown  { background: var(--bg-sunk); color: var(--text-soft); }
.badge.ok       { background: var(--ok-bg);   color: var(--ok); }
.badge.waived   { background: var(--bg-sunk); color: var(--text-faint); }
.badge.pending  { background: var(--warn-bg); color: var(--warn); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.neutral { background: var(--text-faint); }

.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .4rem .75rem; border: 1px solid var(--border-strong);
    border-radius: var(--radius); background: var(--bg);
    color: var(--text); font: inherit; font-size: .85rem;
    cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--bg-soft); }
.btn svg { width: 14px; height: 14px; }
.btn.primary { background: var(--header); color: var(--text-invert);
               border-color: var(--header); }
.btn.primary:hover { opacity: .9; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.sm { padding: .2rem .5rem; font-size: .78rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.notice {
    display: flex; gap: .6rem; align-items: flex-start;
    padding: .7rem .85rem; border-radius: var(--radius);
    border: 1px solid var(--border); margin-bottom: 1rem;
}
.notice svg { width: 16px; height: 16px; flex: none; margin-top: .1rem; }
.notice.bad  { background: var(--bad-bg);  border-color: var(--bad);  color: var(--bad); }
.notice.warn { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.notice.ok   { background: var(--ok-bg);   border-color: var(--ok);   color: var(--ok); }
.notice.info { background: var(--info-bg); border-color: var(--info); color: var(--info); }

.field { margin-bottom: .9rem; }
.field label { display: block; font-size: .82rem; font-weight: 600;
               margin-bottom: .25rem; }
.field .help { font-size: .8rem; color: var(--text-faint); margin-top: .2rem; }
input[type=text], input[type=password], input[type=email], input[type=date],
input[type=number], select, textarea {
    width: 100%; padding: .45rem .6rem; font: inherit; font-size: .875rem;
    color: var(--text); background: var(--bg);
    border: 1px solid var(--border-strong); border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--info); outline-offset: -1px;
}
textarea { min-height: 5rem; resize: vertical; }

.muted, .faint { color: var(--text-faint); }
.small { font-size: .8rem; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.flex { display: flex; gap: .6rem; align-items: center; }
.flex-between { display: flex; gap: .6rem; align-items: center;
                justify-content: space-between; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--text-faint); }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end;
           margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 150px; }

/* ---- sign in ----------------------------------------------------------- */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center;
    justify-content: center; background: var(--bg-soft); padding: 1rem;
}
.login-box {
    width: 100%; max-width: 380px; background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.75rem;
}
.login-box .brand { justify-content: center; margin-bottom: .25rem;
                    font-size: 1.05rem; color: var(--text); }
.login-box .sub { text-align: center; color: var(--text-faint);
                  font-size: .82rem; margin-bottom: 1.25rem; }
.login-divider {
    display: flex; align-items: center; gap: .6rem; margin: 1.1rem 0;
    color: var(--text-faint); font-size: .78rem;
}
.login-divider::before, .login-divider::after {
    content: ""; flex: 1; height: 1px; background: var(--border);
}
.qr { display: flex; justify-content: center; padding: .75rem;
      background: var(--bg-soft); border-radius: var(--radius);
      margin-bottom: .75rem; color: var(--text); }
.qr svg { width: 180px; height: 180px; }
.codes {
    font-family: var(--mono); font-size: .85rem; background: var(--bg-sunk);
    padding: .75rem; border-radius: var(--radius); line-height: 1.9;
    columns: 2; margin-bottom: .75rem;
}

/* ---- modal ------------------------------------------------------------- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem; z-index: 50;
}
.modal {
    background: var(--bg); border-radius: var(--radius);
    width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
    border: 1px solid var(--border);
}
.modal-head { padding: .85rem 1rem; border-bottom: 1px solid var(--border);
              font-weight: 600; display: flex; justify-content: space-between; }
.modal-body { padding: 1rem; }
.modal-foot { padding: .85rem 1rem; border-top: 1px solid var(--border);
              display: flex; justify-content: flex-end; gap: .5rem; }
.modal-close { background: none; border: 0; cursor: pointer; font-size: 1.2rem;
               color: var(--text-faint); line-height: 1; }
[hidden] { display: none !important; }

.menu-toggle { display: none; }
@media (max-width: 820px) {
    .sidebar { position: fixed; top: var(--topbar-height); bottom: 0; left: 0;
               z-index: 40; transform: translateX(-100%); transition: transform .18s; }
    .sidebar.open { transform: none; }
    .menu-toggle { display: inline-flex; }
    .content { padding: 1rem; }
}

/* The Advanced block on Settings.  Cards inside a card look like a stack of
   boxes, so the inner ones lose their frame and keep only the spacing. */
details.card > summary { list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "\25B8"; display: inline-block;
  margin-right: .5rem; transition: transform .12s ease; }
details.card[open] > summary::before { transform: rotate(90deg); }
details.card > .card { border: 0; box-shadow: none; padding: .4rem 0 1rem;
  margin: 0; border-radius: 0; }
details.card > .card + .card { border-top: 1px solid var(--line, #e5e7eb); }
