:root {
  --bg: #f3f0e8;
  --bg-accent: #e7e0d2;
  --ink: #1c1914;
  --muted: #6b6458;
  --line: #d4cdc0;
  --panel: #fffdf8;
  --accent: #1f5c4d;
  --accent-soft: #d8ebe4;
  --warn: #8a5a12;
  --warn-soft: #f3e4c4;
  --danger: #8b2e2e;
  --danger-soft: #f3d6d6;
  --ok: #1f5c4d;
  --ok-soft: #d8ebe4;
  --shadow: 0 12px 40px rgba(28, 25, 20, 0.08);
  --radius: 14px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, #efe7d7 0, transparent 40%),
    radial-gradient(circle at bottom right, #dce8e2 0, transparent 35%),
    var(--bg);
}

body {
  padding: 24px;
}

a {
  color: var(--accent);
}

.shell {
  max-width: 960px;
  margin: 0 auto;
}

.auth-shell {
  max-width: 420px;
  margin: 8vh auto 0;
}

.brand {
  margin: 0 0 8px;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.lead {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.45;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel + .panel {
  margin-top: 20px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

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

.btn,
button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
}

.btn:hover,
button:hover {
  filter: brightness(0.96);
}

.btn.secondary,
button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn.danger,
button.danger {
  background: var(--danger);
}

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

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.92rem;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
}

.field {
  margin-bottom: 14px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.row > * {
  min-width: 0;
}

.row input {
  flex: 1;
}

.msg {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  display: none;
}

.msg.visible {
  display: block;
}

.msg.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.list li:first-child {
  border-top: 0;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}

.badge.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.search-wrap {
  position: relative;
}

.dropdown {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow: auto;
  display: none;
}

.dropdown.open {
  display: block;
}

.dropdown button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: 0;
  padding: 10px 12px;
}

.dropdown button:hover {
  background: var(--bg-accent);
  filter: none;
}

.preview {
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg-accent);
  display: none;
}

.preview.visible {
  display: block;
}

.preview h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 20, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(420px, 100%);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.modal p {
  margin: 0 0 16px;
  line-height: 1.45;
}

.modal .actions {
  justify-content: flex-end;
}

.empty {
  color: var(--muted);
  padding: 8px 0;
}

@media (max-width: 640px) {
  body {
    padding: 16px;
  }

  .topbar,
  .list li,
  .row {
    flex-direction: column;
    align-items: stretch;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
  }
}
