:root {
  --ink: #14211b;
  --muted: #5b6b63;
  --line: #d5ddd7;
  --paper: #f3f6f2;
  --panel: #ffffff;
  --accent: #0f6b4c;
  --accent-ink: #083d2c;
  --warn: #9a3412;
  --danger: #b42318;
  --ok: #0f6b4c;
  --shadow: 0 18px 50px rgba(20, 33, 27, 0.08);
  --radius: 18px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-body: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(15, 107, 76, 0.12), transparent 60%),
    radial-gradient(900px 420px at 100% 0%, rgba(20, 33, 27, 0.08), transparent 55%),
    linear-gradient(180deg, #eef3ee 0%, var(--paper) 45%, #e8eee9 100%);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

#app { min-height: 100vh; }

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.01em;
}
.brand span { color: var(--accent); font-weight: 600; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }

.hero-auth {
  min-height: calc(100vh - 40px);
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid rgba(20, 33, 27, 0.08);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  padding: 36px 32px 28px;
}
.auth-card .eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.auth-card h1 {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 10px;
}
.auth-card .lede {
  color: var(--muted);
  margin: 0 0 28px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: -1px;
}
.tabs button.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 0.86rem; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fbfcfb;
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(15, 107, 76, 0.25);
  border-color: var(--accent);
  background: #fff;
}
.row { display: flex; gap: 10px; align-items: end; }
.row .field { flex: 1; }
.form-error {
  color: var(--danger);
  background: #fff1f0;
  border: 1px solid #f3c1bc;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  background: #e8eee9;
  color: var(--ink);
  font-weight: 600;
}
.btn:hover { filter: brightness(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: #fff1f0; color: var(--danger); border-color: #f3c1bc; }
.btn.small { padding: 7px 12px; font-size: 0.86rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.card {
  background: var(--panel);
  border: 1px solid rgba(20, 33, 27, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card.clickable { cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.card.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 48px rgba(20, 33, 27, 0.12);
}
.card h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.25rem;
}
.card .meta { color: var(--muted); font-size: 0.88rem; }
.page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}
.page-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.9rem;
}
.back {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8eee9;
  font-size: 0.78rem;
  font-weight: 600;
}
.empty, .loading {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  background: rgba(255,255,255,0.55);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 33, 27, 0.42);
  display: grid; place-items: center;
  padding: 20px;
  z-index: 40;
}
.modal {
  width: min(480px, 100%);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.modal h3 { margin: 0 0 8px; font-family: var(--font-display); }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toasts {
  position: fixed; right: 16px; bottom: 16px;
  display: grid; gap: 8px; z-index: 50;
}
.toast {
  background: var(--ink); color: #fff;
  padding: 12px 14px; border-radius: 12px;
  box-shadow: var(--shadow); max-width: 360px;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
.toast.hide { opacity: 0; transition: opacity 0.25s ease; }

.secret-box {
  background: #14211b;
  color: #dff7ea;
  border-radius: 12px;
  padding: 12px;
  font-family: var(--font-mono);
  word-break: break-all;
  margin-top: 10px;
}

@media (max-width: 640px) {
  .auth-card { padding: 28px 20px; }
  .auth-card h1 { font-size: 1.7rem; }
  .page-header { flex-direction: column; align-items: stretch; }
}
