@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Space+Grotesk:wght@500;600;700&display=swap");

:root {
  --bg: #f3efe6;
  --bg-deep: #e7e0d2;
  --ink: #1c1917;
  --muted: #78716c;
  --line: rgba(28, 25, 23, 0.12);
  --card: rgba(255, 252, 247, 0.86);
  --accent: #d9480f;
  --accent-soft: #fff1e6;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --shadow: 0 18px 50px rgba(28, 25, 23, 0.08);
  --radius: 18px;
  --font: "DM Sans", "Segoe UI", sans-serif;
  --display: "Space Grotesk", "DM Sans", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(217, 72, 15, 0.16), transparent 36%),
    radial-gradient(circle at 88% 8%, rgba(15, 118, 110, 0.12), transparent 28%),
    linear-gradient(160deg, var(--bg), var(--bg-deep));
  background-attachment: fixed;
}
button, input, textarea, select { font: inherit; }
a { color: inherit; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  backdrop-filter: blur(10px);
}
.install-card { width: min(560px, 100%); }
.brand-mark {
  width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(145deg, #fb923c, #d9480f); color: #fff7ed;
  font-family: var(--display); font-weight: 700; font-size: 22px; margin-bottom: 18px;
  box-shadow: 0 10px 24px rgba(217, 72, 15, 0.28);
}
.auth-card h1 { margin: 0; font-family: var(--display); font-size: 28px; letter-spacing: -0.03em; }
.auth-card p { margin: 8px 0 0; color: var(--muted); line-height: 1.5; }
.form { display: grid; gap: 14px; margin-top: 28px; }
.form-section { margin: 10px 0 0; font-family: var(--display); font-size: 15px; letter-spacing: -0.02em; }
label { display: grid; gap: 8px; font-size: 13px; font-weight: 600; color: #44403c; }
input, textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  background: #fff; color: var(--ink); outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input:focus, textarea:focus {
  border-color: rgba(217, 72, 15, 0.55);
  box-shadow: 0 0 0 3px rgba(217, 72, 15, 0.12);
}
textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
input[readonly] { background: #f5f0e8; color: var(--muted); }

.btn {
  appearance: none; border: none; border-radius: 12px; padding: 12px 16px;
  font-weight: 650; cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: #fff7ed; }
.btn-secondary { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }

.msg { min-height: 20px; margin-top: 10px; font-size: 13px; color: var(--danger); }
.msg-ok { color: var(--ok); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar {
  padding: 28px 20px; border-right: 1px solid var(--line);
  background: rgba(255, 252, 247, 0.72); backdrop-filter: blur(12px);
  display: flex; flex-direction: column; gap: 28px;
}
.sidebar-brand { display: flex; gap: 12px; align-items: center; }
.sidebar-brand strong { display: block; font-family: var(--display); font-size: 18px; }
.sidebar-brand span { color: var(--muted); font-size: 12px; }
.nav { display: grid; gap: 8px; }
.nav-btn {
  text-align: left; border: 1px solid transparent; background: transparent;
  border-radius: 12px; padding: 12px 14px; cursor: pointer; color: #44403c; font-weight: 600;
}
.nav-btn:hover, .nav-btn.active {
  background: var(--accent-soft); border-color: rgba(217, 72, 15, 0.18); color: #9a3412;
}
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; }
.main { padding: 28px; }
.topbar { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 22px; }
.topbar h2 { margin: 0; font-family: var(--display); font-size: 30px; letter-spacing: -0.03em; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 13px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.status-pill.ok .status-dot { background: var(--ok); }
.status-pill.bad .status-dot { background: var(--danger); }

.panel { display: none; }
.panel.active { display: block; animation: rise 0.28s ease; }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .panel.active, .btn { animation: none; transition: none; }
}

.grid-2 { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 18px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card h3 { margin: 0 0 14px; font-family: var(--display); font-size: 18px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0 0 14px; }
.settings-help p { margin: 0 0 12px; }
.group-list { display: grid; gap: 8px; max-height: 360px; overflow: auto; }
.group-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.group-item input { width: auto; margin-top: 3px; }
.group-item strong { display: block; margin-bottom: 2px; }
.group-item small { color: var(--muted); word-break: break-all; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.result-box { margin-top: 14px; font-size: 13px; line-height: 1.6; }
.result-ok { color: var(--ok); }
.result-bad { color: var(--danger); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-bad { background: var(--danger-soft); color: var(--danger); }
.placeholder { min-height: 320px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.placeholder strong { display: block; color: var(--ink); font-family: var(--display); font-size: 22px; margin-bottom: 8px; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(28, 25, 23, 0.35);
  display: none; place-items: center; padding: 20px; z-index: 40;
}
.modal-backdrop.open { display: grid; }
.modal {
  width: min(480px, 100%); background: #fffaf3; border-radius: 20px;
  border: 1px solid var(--line); padding: 22px; box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 8px; font-family: var(--display); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.msg-extra {
  display: grid;
  gap: 10px;
  margin: 10px 0 4px;
  padding: 12px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.4);
}
.msg-extra[hidden] { display: none !important; }
.db-report {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
  color: var(--ink);
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
}
