:root {
  --black: #000; --orange: #fc6109; --orange-2: #ff9137; --volt: #e7ff54; --white: #fff;
  --bg: #f5f3ee; --surface: #fff; --ink: #111; --muted: #6a665e; --line: #e4e0d6;
  --tile-hover: #fffaf5; --focus: #fc6109; --danger: #c62d12;
  --font-display: "Unbounded", system-ui, sans-serif;
  --font-body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-accent: "Oswald", "Arial Narrow", sans-serif;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0b; --surface: #161616; --ink: #f3f1ec; --muted: #a39f96; --line: #2a2a2a;
    --tile-hover: #1d1812; --danger: #ff6a4d; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b0b; --surface: #161616; --ink: #f3f1ec; --muted: #a39f96; --line: #2a2a2a;
  --tile-hover: #1d1812; --danger: #ff6a4d; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font-body); min-height: 100vh; }
a { color: inherit; }
code { font: 0.85em/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* Top bar */
.topbar { background: var(--black); color: var(--white); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px max(16px, calc((100vw - 1120px) / 2)); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.brand img { height: 20px; width: auto; display: block; }
.brand-apps { font: 700 13px/1 var(--font-display); letter-spacing: .04em; color: var(--black); background: var(--volt); padding: 5px 8px; border-radius: 6px; }
.usernav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.usernav a { text-decoration: none; opacity: .85; }
.usernav a:hover, .usernav a.on { opacity: 1; color: var(--orange-2); }
.usernav form { margin: 0; }
.who { display: flex; align-items: center; gap: 8px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--orange); color: var(--black); font-weight: 700; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
.topbar .linkbtn { color: var(--white); opacity: .85; }
.linkbtn.danger { color: var(--danger); }

main.wrap { max-width: 1120px; margin: 0 auto; padding: 32px 16px 64px; }
main.center { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }

.flashes { margin: 0 0 20px; }
.flashes p { margin: 0 0 8px; padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, var(--volt) 55%, var(--surface)); color: #111; border: 1px solid color-mix(in srgb, var(--volt) 80%, #000 10%); }

/* Sign-in */
body.dark-page { background: var(--black); color: var(--white); }
body.dark-page .flashes p { background: #222; color: #fff; border-color: #333; }
.signin, .notice { width: 100%; max-width: 420px; text-align: center; }
.signin-logo { width: 260px; max-width: 80%; height: auto; margin-bottom: 36px; }
.signin h1, .notice h1 { font: 700 clamp(28px, 6vw, 38px)/1.1 var(--font-display); margin: 0 0 10px; letter-spacing: -.01em; }
.signin .lede, .notice p { color: #bdb9b0; margin: 0 0 28px; }
body:not(.dark-page) .notice p { color: var(--muted); }
.gbtn { display: inline-flex; align-items: center; justify-content: center; gap: 12px; min-width: 260px; padding: 13px 22px; background: #fff; color: #1f1f1f; border-radius: 999px; font-weight: 600; text-decoration: none; border: 2px solid transparent; transition: border-color .15s, transform .15s; }
.gbtn:hover { border-color: var(--orange); transform: translateY(-1px); }
.fine { font-size: 13px; color: #8f8b83; margin-top: 22px; }
.fine a { color: #d6d2c9; }
.devlogin { margin-top: 24px; color: var(--volt); font-size: 13px; }

/* Buttons */
.btn { display: inline-block; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 14px/1.2 var(--font-body); text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--orange); }
.btn-orange { background: var(--orange); border-color: var(--orange); color: var(--black); }
.btn-orange:hover { background: var(--orange-2); border-color: var(--orange-2); }
body.dark-page .btn { background: #fff; color: #111; }

/* Home */
.hero { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.greet { font: 700 clamp(26px, 5vw, 36px)/1.1 var(--font-display); margin: 0; letter-spacing: -.01em; }
.search { position: relative; flex: 0 1 320px; }
.search input { width: 100%; padding: 11px 40px 11px 14px; font: inherit; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.search input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px color-mix(in srgb, var(--orange) 25%, transparent); }
.search kbd { position: absolute; right: 10px; top: 50%; translate: 0 -50%; font: 12px ui-monospace, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.group { margin-top: 30px; }
.group h2 { font: 500 13px/1 var(--font-accent); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tile { display: flex; gap: 14px; align-items: flex-start; padding: 16px; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; transition: border-color .15s, transform .15s, background .15s; }
.tile:hover { border-color: var(--orange); background: var(--tile-hover); transform: translateY(-2px); }
.logo { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; background: #fff; border: 1px solid var(--line); overflow: hidden; }
.logo img { width: 30px; height: 30px; object-fit: contain; }
.logo-ph { font: 700 18px var(--font-display); color: var(--orange); }
.meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.name { font-weight: 700; font-size: 16px; }
.desc { color: var(--muted); font-size: 14px; line-height: 1.35; }
.badge { align-self: flex-start; margin-top: 8px; font-size: 11.5px; font-weight: 600; padding: 2px 8px 2px 18px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); position: relative; }
.badge::before { content: ""; position: absolute; left: 7px; top: 50%; width: 6px; height: 6px; border-radius: 50%; translate: 0 -50%; background: var(--muted); }
.badge-sso { color: var(--ink); border-color: color-mix(in srgb, var(--orange) 55%, var(--line)); }
.badge-sso::before { background: var(--orange); }
.badge-google::before { background: #4285f4; }
.badge-vault::before { background: #175ddc; }
.empty, .noresults { color: var(--muted); }

/* Admin */
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.subnav a { padding: 7px 12px; border-radius: 999px; text-decoration: none; font-size: 14px; font-weight: 600; color: var(--muted); border: 1px solid transparent; }
.subnav a.on { color: var(--ink); border-color: var(--line); background: var(--surface); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; }
.panel h2 { font: 700 18px/1.2 var(--font-display); margin: 0 0 8px; }
.help { color: var(--muted); font-size: 13.5px; font-weight: 400; }
.scroll-x { overflow-x: auto; margin: 16px 0; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font: 500 12px/1.2 var(--font-accent); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.matrix td { text-align: center; }
.matrix th[scope=row] { white-space: nowrap; font-weight: 600; }
.matrix .app-col span { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; text-transform: none; letter-spacing: 0; font: 600 12px var(--font-body); white-space: nowrap; }
.matrix input { width: 18px; height: 18px; accent-color: var(--orange); }
tr.muted { opacity: .55; }
tr.warn td { background: color-mix(in srgb, var(--orange) 8%, transparent); }
.list .url { max-width: 280px; }
.ua { max-width: 260px; color: var(--muted); font-size: 12.5px; }
.actions { white-space: nowrap; text-align: right; }
.actions form { display: inline; margin-left: 12px; }
.pill { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--volt); color: #111; }
.pill-off { background: var(--line); color: var(--muted); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
input:not([type=checkbox]), select, textarea { font: inherit; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); min-width: 0; }
textarea { width: 100%; font: 13px/1.4 ui-monospace, monospace; }
.inline-form input { flex: 1 1 220px; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 12px; }
.grid-form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 14px; }
.grid-form .wide { grid-column: 1 / -1; }
.grid-form .check { flex-direction: row; align-items: center; gap: 8px; align-self: end; }
.grid-form .row { display: flex; gap: 16px; align-items: center; }
.delete-form { margin-top: 16px; }
.client { border-top: 1px solid var(--line); padding: 16px 0; }
.client-head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.client-head form { margin-left: auto; }
.uris { display: flex; gap: 10px; align-items: end; margin-top: 10px; }
.uris label { flex: 1; display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 18px 0; }
.kv dt { font-weight: 600; }
.kv dd { margin: 0; }
.secret { background: var(--bg); padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); }

@media (max-width: 640px) {
  .who-name, .brand-apps { display: none; }
  .usernav { gap: 12px; }
  .brand img { height: 16px; }
  .search { flex-basis: 100%; }
  .grid-form { grid-template-columns: 1fr; }
  .uris { flex-direction: column; align-items: stretch; }
  .kv { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
