:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e4e7ec;
  --line2: #d4d9e0;
  --text: #1b2430;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #e8effd;
  --ok: #12805c;
  --ok-soft: #e2f3ec;
  --warn: #a05a00;
  --warn-soft: #fdf1df;
  --bad: #c62828;
  --bad-soft: #fdeaea;
  --code-bg: #f2f4f7;
  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-lift: 0 6px 24px rgba(16, 24, 40, 0.08);
}
html.dark {
  --bg: #0e1116;
  --panel: #171b22;
  --line: #262c36;
  --line2: #323a46;
  --text: #e7eaf0;
  --muted: #9aa3b2;
  --accent: #4c8dff;
  --accent-ink: #0b1220;
  --accent-soft: #17294a;
  --ok: #34c98f;
  --ok-soft: #123327;
  --warn: #f0a53a;
  --warn-soft: #35270f;
  --bad: #ff6b6b;
  --bad-soft: #3a1818;
  --code-bg: #12161d;
  --shadow: none;
  --shadow-lift: 0 6px 24px rgba(0, 0, 0, 0.45);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; font-weight: 650; letter-spacing: -0.01em; margin: 0 0 .15rem; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .25rem; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .12rem .35rem;
  font-size: .86em;
}
pre { font-family: ui-monospace, Menlo, monospace; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius-s); padding: .7rem; overflow: auto; font-size: .78rem; white-space: pre-wrap; word-break: break-word; }
button {
  font: inherit; font-weight: 550; color: var(--accent-ink);
  background: var(--accent); border: 0; border-radius: var(--radius-s);
  padding: .55rem .95rem; cursor: pointer; min-height: 40px;
}
button:hover { filter: brightness(1.06); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
button.ghost { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--line2); }
button.danger { background: var(--bad); }
button.plain { background: none; color: var(--bad); box-shadow: none; min-height: auto; padding: .2rem .3rem; font-weight: 500; }
button.sm { padding: .4rem .7rem; min-height: 34px; font-size: .88rem; }
button.plain.danger { color: var(--bad); }
a.btn-link { color: var(--accent); font-weight: 550; padding: .2rem .3rem; }
input, select, textarea {
  font: inherit; width: 100%; padding: .55rem .65rem;
  border-radius: var(--radius-s); border: 1.5px solid var(--line2);
  background: var(--panel); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly] { background: var(--code-bg); }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 550; margin: .8rem 0; }
.muted { color: var(--muted); font-size: .88rem; }
.bad { color: var(--bad); }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.05rem 1.15rem;
  box-shadow: var(--shadow);
}
.card.bad { border-color: var(--bad-soft); }
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  border-radius: 999px; padding: .14rem .6rem;
  font-size: .76rem; font-weight: 650; letter-spacing: .01em;
  background: var(--code-bg); color: var(--muted);
  border: 1px solid transparent; white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.mute { background: var(--code-bg); color: var(--muted); }

.chip { border-radius: 999px; padding: .2rem .7rem; font-size: .8rem; font-weight: 550; background: var(--code-bg); border: 1px solid var(--line); }
.hidden { display: none !important; }

.app { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem 1rem; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.brand { font-weight: 750; letter-spacing: .01em; font-size: 1.02rem; }
.topbar-spacer { flex: 1; }
.topbar .chipwrap { display: flex; gap: .4rem; align-items: center; }
.icon-btn { background: none; color: var(--text); box-shadow: none; min-height: 40px; min-width: 40px; font-size: 1.05rem; }
.icon-btn:hover { background: var(--code-bg); filter: none; }

.layout { display: flex; flex: 1; width: 100%; max-width: 1060px; margin: 0 auto; }
.menu {
  width: 190px; flex-shrink: 0; padding: .9rem .55rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.menu a {
  color: var(--text); padding: .55rem .8rem; border-radius: var(--radius-s);
  font-weight: 520; display: flex; align-items: center; gap: .5rem;
}
.menu a:hover { background: var(--code-bg); text-decoration: none; }
.menu a.active { background: var(--accent); color: var(--accent-ink); }
.menu a.active:hover { background: var(--accent); }
.view { flex: 1; padding: 1.4rem 1.2rem 3rem; min-width: 0; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.page-head p { margin: .15rem 0 0; max-width: 46ch; }
.head-act { display: flex; gap: .5rem; align-items: center; }
.stack { display: flex; flex-direction: column; gap: .85rem; }

.mail { font-weight: 620; }
.mail.big { font-size: 1.06rem; letter-spacing: -0.01em; }
.meta { color: var(--muted); font-size: .84rem; margin: .2rem 0 .6rem; }

.lrow { display: flex; flex-direction: column; gap: .7rem; }
.lrow-title { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.linkbar { display: flex; gap: .5rem; align-items: center; }
.linkbar input { font-family: ui-monospace, Menlo, monospace; font-size: .84rem; }
.linkbar button { flex-shrink: 0; min-width: 74px; }
.row-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

.rrow-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; flex-wrap: wrap; }
.creds { margin: .85rem 0 .3rem; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; }
.creds-row { display: grid; grid-template-columns: 92px 1fr auto; gap: .6rem; align-items: center; padding: .5rem .7rem; }
.creds-row + .creds-row { border-top: 1px solid var(--line); }
.creds-row .muted { font-size: .8rem; font-weight: 600; }
.creds-row code { word-break: break-all; }

.how { margin-top: .9rem; border-top: 1px dashed var(--line2); padding-top: .55rem; }
.how summary { cursor: pointer; color: var(--muted); font-size: .84rem; font-weight: 550; }
.how ol { margin: .5rem 0 0 1.1rem; padding: 0; }
.how li { margin: .3rem 0; font-size: .9rem; }

.empty { text-align: center; padding: 2.4rem 1.4rem; }
.empty h3 { margin-bottom: .3rem; }
.empty p { color: var(--muted); max-width: 40ch; margin: 0 auto; }
.empty-act { margin-top: 1.1rem; }
.attrib { margin-top: 1.4rem; }

.svc { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.svc:last-child { border: 0; }
table { width: 100%; border-collapse: collapse; margin: .4rem 0 .8rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 650; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
td .pill { margin-right: .2rem; }

.spinner { display: inline-block; width: 16px; height: 16px; border: 2.5px solid var(--line2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; margin-right: .5rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { max-width: 360px; width: 100%; padding: 1.6rem; }
.login-logo { font-size: 1.25rem; font-weight: 800; letter-spacing: .01em; margin-bottom: .15rem; }
.login-sub { margin: 0 0 1rem; }
.login-card button { width: 100%; margin-top: .6rem; }
.error-text { color: var(--bad); margin: .6rem 0 0; font-size: .88rem; }

.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 60; }
.toast {
  background: var(--panel); border: 1px solid var(--line);
  border-left: 4px solid var(--accent); border-radius: 10px;
  padding: .65rem .95rem; box-shadow: var(--shadow-lift);
  max-width: 340px; font-size: .9rem;
}
.toast.err { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .menu {
    width: 100%; flex-direction: row; flex-wrap: wrap;
    gap: .3rem; padding: .4rem .6rem; display: none;
    border-bottom: 1px solid var(--line);
  }
  .menu.open { display: flex; }
  .menu a { min-height: 38px; }
  .view { padding: 1rem .8rem 3rem; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  table, thead, tbody, th, td, tr { display: block; width: 100%; }
  thead { display: none; }
  tr { border: 1px solid var(--line); border-radius: 10px; margin: .5rem 0; padding: .35rem .2rem; }
  td { border: 0; padding: .3rem .6rem; }
  td::before { content: attr(data-label); display: block; font-size: .72rem; color: var(--muted); text-transform: uppercase; font-weight: 600; letter-spacing: .03em; }
  .topbar { padding: .4rem .6rem; }
  .brand { font-size: .95rem; }
  .creds-row { grid-template-columns: 1fr auto; }
  .creds-row .muted { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
