:root {
  --bg: #11131a;
  --panel: #191d27;
  --panel-2: #202634;
  --text: #f6f7fb;
  --muted: #aab1c2;
  --line: rgba(255,255,255,.09);
  --primary: #8fd3ff;
  --primary-dark: #3da3df;
  --warn: #ffcf70;
  --danger: #ff8d8d;
  --ok: #8dffb2;
  --shadow: 0 22px 70px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(143, 211, 255, .16), transparent 32rem),
    radial-gradient(circle at 85% 10%, rgba(255, 207, 112, .12), transparent 28rem),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button, input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  border-radius: 14px;
  padding: .75rem 1rem;
  font-weight: 800;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
}

button:hover { transform: translateY(-1px); }
button:disabled { opacity: .55; cursor: wait; transform: none; }

.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #07101a;
}

.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.danger {
  background: rgba(255, 141, 141, .13);
  color: var(--danger);
  border: 1px solid rgba(255, 141, 141, .25);
}

.full { width: 100%; }

.app-shell {
  width: min(1400px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 20px;
  padding: 30px;
  background: rgba(25, 29, 39, .76);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: .96;
  margin: 4px 0 14px;
  letter-spacing: -0.06em;
}

.subtitle {
  max-width: 820px;
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0;
}

.eyebrow {
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .76rem;
  font-weight: 900;
  margin: 0 0 6px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.stat-card, .panel {
  background: rgba(25, 29, 39, .84);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.stat-card {
  padding: 18px;
}

.stat-card span, .stat-card small {
  color: var(--muted);
  display: block;
}

.stat-card strong {
  font-size: 2.2rem;
  line-height: 1.1;
  display: block;
  margin: 6px 0;
}

.warn-card strong { color: var(--warn); }

.main-grid {
  display: grid;
  grid-template-columns: 1.3fr .9fr;
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  padding: 22px;
}

.panel-header {
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -.03em;
}

.split {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.form-stack {
  display: grid;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
  font-size: .92rem;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.055);
  color: var(--text);
  border-radius: 14px;
  padding: .82rem .92rem;
  outline: none;
}

input:focus {
  border-color: rgba(143,211,255,.65);
  box-shadow: 0 0 0 4px rgba(143,211,255,.10);
}

input[readonly] { color: var(--muted); }

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-template-columns: none;
}

.checkbox-line input {
  width: auto;
}

.muted {
  color: var(--muted);
  font-weight: 500;
}

.webhook-box {
  display: grid;
  gap: 6px;
  border: 1px dashed rgba(143,211,255,.25);
  background: rgba(143,211,255,.06);
  padding: 12px;
  border-radius: 16px;
  color: var(--muted);
  overflow: hidden;
}

code {
  display: block;
  color: var(--primary);
  word-break: break-all;
}

.table-panel { overflow: hidden; }
.table-wrap { overflow-x: auto; }

.search {
  max-width: 300px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1040px;
}

th, td {
  text-align: left;
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.title-cell {
  min-width: 340px;
}

.title-stack {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.title-meta {
  min-width: 0;
}

.cover-frame {
  width: 54px;
  height: 72px;
  flex: 0 0 54px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--primary);
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(0,0,0,.22);
}

.cover-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.cover-empty {
  font-size: 1.1rem;
}

.title-name {
  font-weight: 900;
  display: block;
  margin-bottom: 3px;
}

.source-link {
  color: var(--primary);
  text-decoration: none;
  word-break: break-all;
  font-size: .86rem;
}

.inline-input {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-input input {
  width: 92px;
  padding: .55rem .65rem;
}

.inline-input button, .row-actions button {
  padding: .55rem .7rem;
  border-radius: 10px;
  font-size: .86rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: .38rem .6rem;
  font-size: .82rem;
  font-weight: 900;
  white-space: nowrap;
}

.badge.ok { background: rgba(141,255,178,.12); color: var(--ok); }
.badge.warn { background: rgba(255,207,112,.12); color: var(--warn); }
.badge.error { background: rgba(255,141,141,.12); color: var(--danger); }
.badge.off { background: rgba(255,255,255,.08); color: var(--muted); }

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.small-note {
  color: var(--muted);
  font-size: .78rem;
  margin-top: 5px;
  max-width: 260px;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 32px;
}

.logs-list {
  display: grid;
  gap: 10px;
}

.log-item {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line);
}

.log-title {
  font-weight: 900;
}

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(520px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 18px;
  background: #f6f7fb;
  color: #11131a;
  box-shadow: var(--shadow);
  font-weight: 800;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 960px) {
  .hero, .split { align-items: flex-start; flex-direction: column; }
  .hero-actions { justify-content: flex-start; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .main-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .app-shell { width: min(100% - 20px, 1400px); padding-top: 10px; }
  .hero, .panel { border-radius: 20px; padding: 18px; }
  .stats-grid, .form-row { grid-template-columns: 1fr; }
  .hero-actions button { width: 100%; }
}
