:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1c2230;
  --muted: #6b7385;
  --border: #dde1e8;
  --primary: #3355e0;
  --primary-hover: #2744c2;
  --danger: #c93b3b;
  --danger-bg: #fdecec;
  --warn: #8a5a00;
  --warn-bg: #fff6e0;
  --ok: #1e7a45;
  --ok-bg: #e5f6ec;
  --pending: #2c5bb8;
  --pending-bg: #e7eefc;
  --input-bg: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 50, .08), 0 4px 16px rgba(20, 30, 50, .05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c;
    --card: #1b1f29;
    --text: #e4e7ee;
    --muted: #979fb2;
    --border: #2d3342;
    --primary: #5b7cff;
    --primary-hover: #7593ff;
    --danger: #ff6b6b;
    --danger-bg: #3a1f22;
    --warn: #ffcb66;
    --warn-bg: #3a3020;
    --ok: #5fd08f;
    --ok-bg: #1d3528;
    --pending: #8fb0ff;
    --pending-bg: #1f2a44;
    --input-bg: #141820;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
[hidden] { display: none !important; }
h1 { font-size: 1.45rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 1rem; }
p { margin: .25rem 0 1rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 650; font-size: 1.05rem; }
.brand .icon { color: var(--primary); }
.nav-form { margin: 0; }

.container { max-width: 1100px; margin: 2rem auto; padding: 0 1rem; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem;
}
.card.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.center { text-align: center; }

.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm { display: flex; flex-direction: column; gap: .6rem; }
label { display: flex; flex-direction: column; gap: .35rem; font-weight: 550; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem 1rem; margin: 0; }
legend { font-weight: 600; padding: 0 .35rem; }
input[type=text], input[type=password], textarea, select {
  font: inherit; color: var(--text); background: var(--input-bg);
  border: 1px solid var(--border); border-radius: 8px; padding: .55rem .7rem; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 2.6rem; }
fieldset > .btn { margin-top: .6rem; }

.muted { color: var(--muted); font-weight: normal; }
.hint { color: var(--muted); font-size: .85rem; margin: 0; }
.tiny { font-size: .78rem; }
.mono { font-family: var(--mono); }
.warn-text { color: var(--danger); font-weight: 600; }
.ua { max-width: 360px; word-break: break-word; color: var(--muted); }

.icon { width: 1.05em; height: 1.05em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.15em; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 550; cursor: pointer; border-radius: 8px;
  padding: .55rem 1rem; border: 1px solid transparent; background: none; color: var(--text);
  white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.ghost { border-color: var(--border); }
.btn.ghost:hover { background: var(--bg); }
.btn.danger { color: var(--danger); border-color: var(--border); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.2rem; height: 2.2rem; flex: none; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text);
}
.icon-btn:hover { background: var(--bg); }
.icon-btn.done { color: var(--ok); border-color: var(--ok); }
.icon-btn.fail { color: var(--danger); border-color: var(--danger); }

.alert { padding: .65rem .9rem; border-radius: 8px; margin: 0; font-size: .92rem; }
.alert.error { background: var(--danger-bg); color: var(--danger); }
.alert.warn { background: var(--warn-bg); color: var(--warn); margin-bottom: 1rem; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge.pending { background: var(--pending-bg); color: var(--pending); }
.badge.accessed { background: var(--ok-bg); color: var(--ok); }
.badge.expired { background: var(--danger-bg); color: var(--danger); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; }
td.actions .btn { margin: 0 .2rem .25rem 0; }

.secret-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: .5rem; align-items: start; }
@media (max-width: 700px) { .secret-row { grid-template-columns: 1fr auto; } .secret-row .secret-value { grid-column: 1; } }

.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.file-list li { display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 8px; }
.file-list .name { flex: 1; word-break: break-all; }
.file-list .icon-btn { width: 1.8rem; height: 1.8rem; }

.copy-field { display: flex; gap: .4rem; font-weight: normal; }

dialog {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem;
  width: min(560px, 92vw); background: var(--card); color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(10, 15, 25, .55); }
dialog label { margin-bottom: 1rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

.reveal-item { border: 1px solid var(--border); border-radius: 8px; padding: .75rem; }
.reveal-name { font-weight: 600; margin-bottom: .35rem; word-break: break-all; }
.reveal-row { display: flex; gap: .4rem; align-items: flex-start; }
.reveal-value {
  flex: 1; margin: 0; padding: .5rem .7rem; background: var(--bg); border-radius: 6px;
  white-space: pre-wrap; word-break: break-all; min-height: 2.2rem; max-height: 22rem; overflow: auto;
}
.reveal-value.masked { letter-spacing: .15em; color: var(--muted); user-select: none; }
.reveal-item.file { display: flex; align-items: center; gap: .75rem; }
.reveal-item.file > .icon { width: 1.6rem; height: 1.6rem; color: var(--muted); }
.reveal-item.file .file-meta { flex: 1; min-width: 0; }
.reveal-item.file .reveal-name { margin-bottom: 0; }
