:root {
  --bg: #0f1117;
  --surface: #181c26;
  --surface-2: #222736;
  --border: #2e3447;
  --text: #eef1f7;
  --muted: #9aa3b8;
  --primary: #4f7cff;
  --primary-hover: #3b68eb;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 28px;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
}

.subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.status-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
}

.badge-local {
  border-color: rgba(34, 197, 94, 0.4);
  color: #86efac;
  background: rgba(34, 197, 94, 0.1);
}

.badge-external {
  border-color: rgba(245, 158, 11, 0.4);
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.1);
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 860px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.card-header h2 {
  margin: 0;
  font-size: 18px;
}

.password-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

#password-output {
  width: 100%;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
  letter-spacing: 0.5px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.password-actions {
  display: flex;
  gap: 10px;
}

.password-actions .btn {
  flex: 1;
}

.strength-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.strength-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.strength-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.2s ease, background-color 0.2s ease;
}

.strength-text {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.control-group {
  margin-bottom: 16px;
}

.length-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.length-header input[type="number"] {
  width: 72px;
  padding: 6px 8px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.checkbox-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}

.checkbox-card.full-span {
  grid-column: 1 / -1;
}

.checkbox-card code {
  color: var(--muted);
  font-size: 12px;
}

.save-panel {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.save-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

input[type="text"],
input[type="password"],
input[type="search"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.autosave-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.btn {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: #2b3145;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.tabs {
  display: flex;
  gap: 6px;
}

.tab {
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
}

.tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.muted {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.notice {
  padding: 14px;
  border-radius: 10px;
  font-size: 14px;
}

.notice-warn {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
}

.totp-box {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.qr-container {
  background: #fff;
  padding: 12px;
  border-radius: 10px;
  width: fit-content;
}

.qr-container svg {
  width: 180px;
  height: 180px;
  display: block;
}

.inline-form {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.inline-form input {
  flex: 1;
}

.search-input {
  margin-bottom: 12px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 520px;
  overflow-y: auto;
}

.history-item {
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.history-label {
  font-weight: 600;
  font-size: 14px;
}

.history-meta {
  font-size: 12px;
  color: var(--muted);
}

.history-pass-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-pass {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  background: var(--bg);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow-x: auto;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
  font-size: 14px;
}

.hidden {
  display: none !important;
}
