:root {
  --bg: #f3efe6;
  --bg-2: #fffdf8;
  --ink: #1c1915;
  --muted: #6b6458;
  --line: #ddd4c4;
  --brand: #1f3d34;
  --brand-2: #2f5d4e;
  --accent: #b8591e;
  --good: #1f7a45;
  --bad: #b42318;
  --warn: #9a6b12;
  --shadow: 0 10px 30px rgba(28, 25, 21, 0.08);
  --radius: 16px;
  font-family: "Figtree", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100%; }
body { font-size: 16px; line-height: 1.45; }
a { color: var(--brand-2); }
button, input, select, textarea { font: inherit; }
h1, h2, h3 { font-family: "Fraunces", Georgia, serif; font-weight: 600; margin: 0; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1000px 400px at 10% -10%, #e8d9b8 0, transparent 55%),
    var(--bg);
}
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-card { width: min(420px, 100%); padding: 32px 28px 28px; }
.login-card h1 { font-size: 1.8rem; color: var(--brand); }
.login-card p.lede { color: var(--muted); margin: 8px 0 22px; }
label { display: block; font-weight: 600; font-size: 0.9rem; margin: 14px 0 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 52px; }
.eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px 8px; font-weight: 600;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 11px 16px; cursor: pointer; font-weight: 700;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-brand { background: var(--brand); color: #fff; width: 100%; margin-top: 18px; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-danger { background: #b42318; color: #fff; }
.err { color: var(--bad); font-size: 0.92rem; min-height: 1.2em; }
.ok { color: var(--good); }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px;
  background: color-mix(in srgb, var(--bg) 88%, white);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 1.25rem; color: var(--brand); flex: 1; }
.top .who { color: var(--muted); font-size: 0.85rem; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.filters input, .filters select { width: auto; flex: 1; min-width: 160px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; padding: 0 18px; margin-top: 14px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; min-width: 110px; }
.stat b { display: block; font-size: 1.25rem; font-family: "Fraunces", Georgia, serif; }
.stat span { color: var(--muted); font-size: 0.8rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
  padding: 16px 18px 80px;
}
.site {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.site:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.thumb {
  height: 140px;
  background: #ece4d4 center/cover no-repeat;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.badge {
  position: absolute; top: 10px; left: 10px;
  background: #fff; border-radius: 999px; padding: 3px 8px;
  font-size: 0.72rem; font-weight: 700; border: 1px solid var(--line);
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; background: #b0a894; }
.dot.up { background: var(--good); }
.dot.down { background: var(--bad); }
.body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.body h2 { font-size: 1.15rem; }
.title-row { display: flex; align-items: center; gap: 10px; }
.title-row h2 { flex: 1; min-width: 0; }
.title-row > div { min-width: 0; }
.title-row > div h2 { margin: 0; }
.title-row > div .meta { margin: 4px 0 0; }
.logo-wrap {
  position: relative;
  width: 48px; height: 48px;
  border-radius: 12px;
  flex: none;
  overflow: hidden;
  background: hsl(var(--logo-hue), 38%, 32%);
  color: #fff;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
}
.logo-wrap.lg { width: 64px; height: 64px; border-radius: 14px; }
.logo-fallback {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 650;
  font-size: 1.25rem;
  line-height: 1;
}
.logo-wrap.lg .logo-fallback { font-size: 1.6rem; }
.logo-wrap img.logo-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #fff;
}
.logo-wrap.no-img img { display: none; }
.meta { color: var(--muted); font-size: 0.85rem; word-break: break-word; }
.row-actions { display: flex; gap: 8px; margin-top: 8px; }
.row-actions .btn { flex: 1; padding: 8px 10px; font-size: 0.88rem; }

.sheet-back {
  position: fixed; inset: 0; background: rgba(28,25,21,.45); z-index: 40;
  display: none; justify-content: flex-end;
}
.sheet-back.open { display: flex; }
.sheet {
  width: min(560px, 100%);
  height: 100%;
  background: var(--bg-2);
  overflow: auto;
  padding: 18px 18px 48px;
  box-shadow: var(--shadow);
}
.sheet .preview {
  width: 100%; height: 200px; border: 1px solid var(--line); border-radius: 12px;
  background: #ece4d4 center/cover no-repeat; margin: 10px 0 8px;
}
.sheet iframe {
  width: 100%; height: 280px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; font-size: 0.92rem; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 0.8rem; background: #f6f1e7; padding: 8px; border-radius: 8px; overflow-wrap: anywhere; }
.form-grid { display: grid; gap: 4px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

@media (max-width: 700px) {
  .top { padding: 12px; }
  .grid { padding: 12px 12px 80px; }
  .sheet { width: 100%; }
  .kv { grid-template-columns: 1fr; }
}
