:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #15201d;
  --muted: #63706b;
  --line: #d9e0dc;
  --brand: #286c58;
  --brand-dark: #1f5647;
  --warn: #8a4b11;
  --warn-bg: #fff3dc;
  --danger: #9f2a2a;
  --soft: #eaf1ee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 720;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  color: var(--brand-dark);
  background: var(--soft);
  font-size: 12px;
  font-weight: 800;
  vertical-align: middle;
}

h2 {
  font-size: 16px;
  font-weight: 700;
}

.topbar p,
.hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 16px;
  padding: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.home-panel,
.import-panel,
.manage-panel,
.vault-panel,
.totp-panel {
  min-width: 0;
}

.home-panel,
.manage-panel,
.vault-panel,
.totp-panel {
  grid-column: 2;
}

.unlock-panel {
  grid-row: span 3;
  align-self: start;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.dialog-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

label {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input[type="password"],
input[type="text"],
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  font: inherit;
  outline: none;
  resize: vertical;
}

input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(40, 108, 88, 0.14);
}

.copyable-field {
  cursor: copy;
  background: #fbfcfb;
}

.copyable-field:hover {
  border-color: var(--brand);
}

button,
.file-picker {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
.file-picker:hover {
  background: var(--brand-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary:hover {
  background: var(--soft);
}

.icon-button {
  width: auto;
}

.file-picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0;
}

.file-picker input {
  display: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  min-height: 28px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 750;
}

.preview,
.items-list,
.totp-list {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 12px;
}

.empty {
  color: var(--muted);
  font-size: 13px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(96px, 1fr));
  gap: 10px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fff;
}

.stat strong {
  display: block;
  font-size: 24px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  align-items: end;
}

.item-form {
  margin: 0;
}

.search-field {
  flex: 1 1 360px;
  margin-top: 0;
}

.secondary-panel {
  grid-column: 2;
  padding: 0;
}

.secondary-panel details {
  padding: 16px 18px;
}

.secondary-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.item-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(820px, calc(100dvh - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  color: var(--ink);
}

.item-dialog::backdrop {
  background: rgba(21, 32, 29, 0.32);
}

.warning {
  margin-top: 12px;
  border: 1px solid #f0d6a7;
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 13px;
  line-height: 1.5;
}

.item-row,
.totp-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.item-result {
  background: transparent;
}

.item-result.selected {
  background: #dfece6;
}

.item-button {
  width: 100%;
  min-height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 400;
}

.item-button:hover {
  background: var(--soft);
}

.item-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.compact-button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.item-row:last-child,
.totp-row:last-child {
  border-bottom: 0;
}

.item-limit {
  padding: 12px 0 2px;
  color: var(--muted);
  font-size: 12px;
}

.item-title,
.totp-title {
  font-weight: 750;
}

.item-meta,
.totp-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.code {
  min-width: 98px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 12px 32px rgba(20, 32, 29, 0.24);
}

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

  .unlock-panel,
  .home-panel,
  .secondary-panel,
  .manage-panel,
  .vault-panel,
  .totp-panel {
    grid-column: 1;
    grid-row: auto;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 18px 16px;
  }

  .icon-button {
    width: 100%;
  }

  .panel {
    padding: 16px;
  }

  .actions {
    align-items: stretch;
  }

  .actions > button,
  .actions > .file-picker {
    flex: 1 1 160px;
  }

  .search-field {
    flex-basis: 100%;
  }

  .item-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    padding: 16px;
  }

  .item-row {
    grid-template-columns: 1fr auto;
    gap: 8px;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
    max-width: none;
  }
}
