:root {
  --red: #d31212;
  --red-dark: #a90e0e;
  --ink: #1e1f21;
  --muted: #5f6368;
  --line: #e3e4e6;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ok: #1e7b34;
  --warn-bg: #fff4e5;
  --warn-ink: #8a4b00;
  --radius: 14px;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #eceef1; --muted: #a4a9b0; --line: #34373c; --bg: #17181b; --card: #222428;
    --warn-bg: #3a2a12; --warn-ink: #ffcf8a; --ok: #6fd18a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); }
[hidden] { display: none !important; }
a { color: var(--red); }
button { font: inherit; cursor: pointer; }

/* header */
.top { height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 16px;
       background: var(--card); border-bottom: 1px solid var(--line); }
.top img { width: 32px; height: 32px; }
.top .title { font-weight: 700; font-size: 1.05rem; }
.top .spacer { flex: 1; }
.top .who { color: var(--muted); font-size: .9rem; }
.top a.btn, .top button { white-space: nowrap; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card);
       color: var(--ink); padding: 7px 14px; border-radius: 8px; text-decoration: none; font-size: .9rem; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.danger.solid { background: var(--red); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.badge-count { background: var(--red); color: #fff; border-radius: 10px; padding: 0 7px; font-size: .75rem; }

/* sign-in */
.signin { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
          gap: 18px; padding: 16px; text-align: center; }
.signin img { width: 120px; height: 120px; }
.signin h1 { margin: 0; font-size: 2rem; }
.signin p { margin: 0; color: var(--muted); max-width: 26rem; }
.signin .btn { font-size: 1.1rem; padding: 12px 26px; }

/* launcher: the screen is split EQUALLY among the apps (MW D8) */
.launch { height: calc(100% - 56px); display: flex; flex-direction: column; padding: 16px; gap: 16px; }
.grid { flex: 1; display: grid; gap: 16px; min-height: 0;
        grid-template-columns: repeat(var(--cols, 1), 1fr); grid-template-rows: repeat(var(--rows, 1), 1fr); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
        padding: 20px; text-align: center; text-decoration: none; color: var(--ink);
        transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; min-height: 0; }
.card:hover, .card:focus-visible { transform: translateY(-3px); border-color: var(--red);
        box-shadow: 0 10px 28px rgba(0,0,0,.10); outline: none; }
.card img { width: clamp(64px, 14vmin, 150px); height: auto; border-radius: 22%; }
.card .name { font-size: clamp(1.2rem, 2.6vmin, 2rem); font-weight: 700; }
.card .role { font-size: .95rem; color: var(--red); font-weight: 600; }
.card .desc { font-size: .9rem; color: var(--muted); max-width: 28rem; }
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
         color: var(--muted); text-align: center; }
.request-bar { display: flex; justify-content: center; }
.request-bar .btn { font-size: 1.05rem; padding: 12px 28px; }

@media (max-width: 700px) {
  .launch { height: auto; }
  .grid { grid-template-columns: 1fr !important; grid-template-rows: none !important; }
  .card { min-height: 170px; }
}

/* dialog */
dialog { border: none; border-radius: var(--radius); padding: 0; width: min(560px, calc(100% - 32px));
         background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.dlg-head { padding: 18px 20px 6px; font-weight: 700; font-size: 1.15rem; }
.dlg-body { padding: 8px 20px; max-height: 65vh; overflow: auto; }
.dlg-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.req-row { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center;
           padding: 12px 0; border-bottom: 1px solid var(--line); }
.req-row img { width: 48px; height: 48px; border-radius: 22%; }
.req-row .desc { color: var(--muted); font-size: .85rem; }
.req-row textarea { grid-column: 2 / 4; width: 100%; font: inherit; padding: 8px; border-radius: 8px;
                    border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.pending { color: var(--warn-ink); background: var(--warn-bg); padding: 4px 10px; border-radius: 8px; font-size: .85rem; }

/* admin */
.admin { max-width: 1200px; margin: 0 auto; padding: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent;
          white-space: nowrap; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--red); font-weight: 600; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; overflow-x: auto; }
.panel h2 { margin: 0 0 12px; font-size: 1.1rem; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
input[type=search], input[type=text], select, textarea {
  font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
input[type=search] { flex: 1; min-width: 200px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { overflow-wrap: break-word; text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: .78rem; padding: 2px 8px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.chip.off { color: #fff; background: var(--red); border-color: var(--red); }
.chip.kind { color: var(--warn-ink); background: var(--warn-bg); border-color: transparent; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.warn { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 12px; border-radius: 8px; margin: 8px 0; }
.grant-row { display: grid; grid-template-columns: 40px 1fr minmax(160px, 240px); gap: 10px; align-items: center;
             padding: 10px 0; border-bottom: 1px solid var(--line); }
.grant-row img { width: 40px; height: 40px; border-radius: 22%; }
code.key { display: block; word-break: break-all; padding: 10px; background: var(--bg); border-radius: 8px; user-select: all; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
         padding: 10px 16px; border-radius: 8px; font-size: .9rem; z-index: 10; }
@media (max-width: 700px) {
  .grant-row { grid-template-columns: 40px 1fr; }
  .grant-row select, .grant-row .btn { grid-column: 2; }
  .hide-sm { display: none; }
  .top .who { display: none; }
}
