:root {
  --navy: #0b1f3a;
  --navy-2: #132a4a;
  --teal: #0e7488;
  --teal-2: #0a5c6b;
  --accent: #1aa3b8;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #152033;
  --muted: #5b6780;
  --line: #d8dee8;
  --danger: #b42318;
  --warn: #b45309;
  --ok: #067647;
  --shadow: 0 1px 2px rgba(11, 31, 58, 0.06), 0 8px 24px rgba(11, 31, 58, 0.06);
  --radius: 12px;
  font-family: "Segoe UI", "SF Pro Text", "Helvetica Neue", ui-sans-serif, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; min-height: 100%; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--teal); }

.app-header {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  min-height: 56px;
  flex-shrink: 0;
}
.app-header img.logo { width: 32px; height: 32px; border-radius: 8px; background: #fff; }
.app-header h1 { font-size: 17px; font-weight: 650; margin: 0; letter-spacing: 0.01em; }
.app-header .grow { flex: 1; }
#search {
  width: min(420px, 46vw);
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: #1c3356;
  color: #fff;
  outline: none;
}
#search::placeholder { color: #9db0c9; }
#search:focus { background: #24406a; }
.icon-btn, .btn {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--teal);
  color: #fff;
  font-weight: 600;
}
.btn:hover, .icon-btn:hover { background: var(--teal-2); }
.btn.secondary { background: #e8eef5; color: var(--navy); }
.btn.secondary:hover { background: #d5deea; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #911a12; }
.btn.ghost, .icon-btn.ghost { background: transparent; color: inherit; }
.icon-btn.ghost:hover { background: rgba(255,255,255,0.1); }
.btn:disabled { opacity: 0.55; cursor: default; }

.layout { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 320px;
  max-width: 40vw;
  border-right: 1px solid var(--line);
  background: var(--card);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-tools { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.list { overflow: auto; flex: 1; }
.item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.item:hover { background: #f4f7fb; }
.item.active { background: #e7f4f7; box-shadow: inset 3px 0 0 var(--teal); }
.item .name { font-weight: 600; }
.item .meta { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .tag { display: inline-block; background: #e8eef5; color: var(--navy-2); border-radius: 999px; padding: 1px 8px; font-size: 11px; margin-right: 4px; }
.item.conflict .name::after { content: " conflict"; color: var(--warn); font-weight: 500; font-size: 11px; }
.empty { color: var(--muted); padding: 32px 16px; text-align: center; }

.detail { flex: 1; overflow: auto; padding: 24px 28px; }
.detail-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 720px;
}
.detail h2 { margin: 0 0 4px; font-size: 22px; }
.detail .url a { word-break: break-all; }
.row { display: flex; align-items: center; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.row .label { width: 110px; color: var(--muted); font-size: 13px; flex-shrink: 0; }
.row .value { font-weight: 500; }
.secret-dots { letter-spacing: 2px; color: var(--muted); user-select: none; }
.copy-flash { color: var(--ok); font-size: 13px; font-weight: 600; }
.notes { white-space: pre-wrap; background: #f6f8fb; padding: 12px; border-radius: 8px; }
.countdown { font-variant-numeric: tabular-nums; color: var(--teal); font-weight: 600; font-size: 13px; }
.totp { font-size: 28px; font-weight: 700; letter-spacing: 4px; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }

/* Forms / gates */
.gate {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.gate-card {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  width: min(440px, 100%);
}
.gate-card h2 { margin: 8px 0 6px; }
.gate-card p { color: var(--muted); margin: 0 0 20px; line-height: 1.45; }
.gate-card img { width: 56px; height: 56px; border-radius: 12px; }
label.field { display: block; margin: 0 0 14px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
label.field input, label.field textarea, label.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}
label.field textarea { min-height: 90px; resize: vertical; }
label.field input:focus, label.field textarea:focus { outline: 2px solid #bfe3ea; border-color: var(--teal); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.error { background: #fef3f2; color: var(--danger); border-radius: 8px; padding: 10px 12px; margin: 0 0 14px; font-size: 14px; }
.okbox { background: #ecfdf3; color: var(--ok); border-radius: 8px; padding: 10px 12px; margin: 0 0 14px; }

.modal-back {
  position: fixed; inset: 0;
  background: rgba(11, 31, 58, 0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 20;
}
.modal {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 24px;
  width: min(560px, 100%);
  max-height: 92vh;
  overflow: auto;
}
.modal h2 { margin: 0 0 16px; }
.hidden { display: none !important; }

.clip-bar {
  position: sticky; bottom: 0;
  background: var(--navy);
  color: #fff;
  padding: 8px 16px;
  font-size: 13px;
  display: flex; align-items: center; gap: 12px;
}
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff;
  padding: 10px 16px; border-radius: 999px;
  font-size: 13px; z-index: 30;
  box-shadow: var(--shadow);
}

footer.fine {
  font-size: 12px; color: var(--muted);
  padding: 8px 16px;
  border-top: 1px solid var(--line);
}

@media (max-width: 720px) {
  .sidebar { max-width: 100%; width: 100%; }
  .layout.mobile-detail .sidebar { display: none; }
  .layout.mobile-list .detail { display: none; }
  #search { width: 100%; }
  .app-header { flex-wrap: wrap; }
  .detail { padding: 12px; }
}
