:root {
  --bg: #f3efe6;
  --bg-2: #ebe4d6;
  --ink: #1c1914;
  --muted: #6b6358;
  --panel: rgba(255, 252, 246, 0.88);
  --line: rgba(28, 25, 20, 0.12);
  --accent: #0f766e;
  --accent-2: #c2410c;
  --ok: #15803d;
  --warn: #a16207;
  --err: #b91c1c;
  --shadow: 0 18px 50px rgba(28, 25, 20, 0.08);
  --radius: 18px;
  --font: "Manrope", sans-serif;
  --display: "Space Grotesk", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(15, 118, 110, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(194, 65, 12, 0.12), transparent 50%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255,252,246,0.7);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--ink); color: #f8f4ec;
  font-family: var(--display); font-weight: 700; font-size: 1.2rem;
}
.brand-name { font-family: var(--display); font-weight: 700; letter-spacing: 0.04em; }
.brand-sub { color: var(--muted); font-size: 0.82rem; }

.sidebar nav { display: flex; flex-direction: column; gap: 6px; }
.sidebar nav a {
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
}
.sidebar nav a.active,
.sidebar nav a:hover {
  background: rgba(15, 118, 110, 0.12);
  text-decoration: none;
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; font-size: 0.9rem; }

.content { padding: 32px 36px 48px; }

h1, h2, h3 { font-family: var(--display); margin: 0 0 12px; letter-spacing: -0.02em; }
h1 { font-size: 1.9rem; }
.lead { color: var(--muted); margin: 0 0 24px; }

.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 24px; }
.grid.two { grid-template-columns: 1.2fr 0.8fr; gap: 20px; }

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

.stat-value { font-family: var(--display); font-size: 2rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 0.9rem; }

.badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600;
  background: rgba(15,118,110,0.12); color: var(--accent);
}
.badge.warn { background: rgba(161,98,7,0.14); color: var(--warn); }
.badge.err { background: rgba(185,28,28,0.12); color: var(--err); }
.badge.ok { background: rgba(21,128,61,0.12); color: var(--ok); }
.badge.muted { background: rgba(28,25,20,0.08); color: var(--muted); }

.btn, button, input[type=submit] {
  appearance: none; border: 0; cursor: pointer;
  background: var(--ink); color: #f8f4ec;
  padding: 10px 14px; border-radius: 12px;
  font: inherit; font-weight: 600;
}
.btn.secondary, button.secondary {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line);
}
.btn.danger { background: var(--err); }
.btn.accent { background: var(--accent); }
.btn.small { padding: 7px 10px; font-size: 0.85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.table th, .table td {
  text-align: left; padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  word-break: break-word;
}
.table th { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.table td.actions { width: 220px; white-space: normal; }

.source-list { display: flex; flex-direction: column; gap: 12px; }
.source-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.source-item:last-child { border-bottom: 0; padding-bottom: 0; }
.source-main { min-width: 0; flex: 1; }
.source-title-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.source-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  margin-bottom: 4px;
}
.source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}
.test-result { margin-bottom: 16px; }
.test-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.test-result-head h2 { margin: 0; }
.test-sample { margin: 0; padding-left: 18px; }
.test-sample li { margin-bottom: 6px; }
.test-sample-title { overflow-wrap: anywhere; }

@media (max-width: 720px) {
  .source-item { flex-direction: column; }
  .source-actions { width: 100%; }
}

label { display: block; font-weight: 600; margin: 0 0 6px; }
input[type=text], input[type=password], input[type=number], input[type=url],
input[type=datetime-local], textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  color: var(--ink);
}
textarea { min-height: 160px; resize: vertical; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: auto; }

.flash {
  padding: 12px 14px; border-radius: 12px; margin-bottom: 16px;
  background: rgba(15,118,110,0.12); color: var(--accent);
}
.flash.err { background: rgba(185,28,28,0.12); color: var(--err); }

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 32px;
}
.login-card h1 { margin-bottom: 8px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.86rem; }
.clamp { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview {
  white-space: pre-wrap; line-height: 1.5;
  background: #fffdf8; border: 1px solid var(--line);
  border-radius: 14px; padding: 14px;
}
.status-dot {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px;
  background: var(--err);
}
.status-dot.on { background: var(--ok); }

@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .content { padding: 20px; }
  .grid.two, .row { grid-template-columns: 1fr; }
}
