:root {
  --bg: #0f1115;
  --bg-card: #171a21;
  --bg-card-hover: #1c2029;
  --border: #2a2e38;
  --border-light: #353a47;
  --text: #e8e9ec;
  --text-muted: #9aa0ad;
  --text-dim: #6b7280;
  --accent: #5b7fff;
  --accent-dark: #3d5fd9;
  --danger: #ff5b6e;
  --danger-bg: #2a1418;
  --success: #3ecf8e;
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

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

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* Topbar */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.logo {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.logo span { color: var(--accent); }
.nav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-size: 0.92rem;
}
.nav a { color: var(--text-muted); }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav-user {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.btn-primary-sm, .btn-ghost {
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  border: 1px solid var(--border-light);
}
.btn-primary-sm {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary-sm:hover { background: var(--accent-dark); text-decoration: none; }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); text-decoration: none; border-color: var(--text-dim); }

/* Page heading */
h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 0.4rem; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 0.75rem; }
.subtitle { color: var(--text-muted); margin: 0 0 1.75rem; font-size: 0.95rem; }

/* Search */
.search-box {
  position: relative;
  margin-bottom: 1.25rem;
}
.search-box input[type="text"] {
  width: 100%;
  padding: 0.85rem 1rem 0.85rem 2.6rem;
  font-size: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
}
.search-box input::placeholder { color: var(--text-dim); }
.search-box input:focus {
  outline: none;
  border-color: var(--accent);
}
.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}
.chip {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { background: var(--accent); color: white; border-color: var(--accent); }

.result-count {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.85rem;
}

/* Rule card */
.rule-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}
.rule-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}
.rule-number {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--text-dim);
  background: var(--bg);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.rule-category {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(91,127,255,0.12);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.rule-text { font-size: 0.93rem; margin: 0; color: var(--text); }
.rule-sanction {
  margin-top: 0.65rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: var(--danger-bg);
  border: 1px solid rgba(255,91,110,0.25);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--danger);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
  font-size: 0.92rem;
}

/* Forms */
.form-card {
  max-width: 380px;
  margin: 2rem auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.form-card h1 { text-align: center; margin-bottom: 1.5rem; font-size: 1.3rem; }
.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.field input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
}
.field input:focus { outline: none; border-color: var(--accent); }
.btn-full {
  width: 100%;
  padding: 0.7rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
}
.btn-full:hover { background: var(--accent-dark); }
.form-footer {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.alert {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(255,91,110,0.25);
}
.alert-success {
  background: rgba(62,207,142,0.1);
  color: var(--success);
  border: 1px solid rgba(62,207,142,0.25);
}

/* Tables (admin) */
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; }
tr:hover td { background: var(--bg-card-hover); }

.btn-sm {
  font-size: 0.78rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
}
.btn-sm:hover { color: var(--text); border-color: var(--accent); }
.btn-sm.danger:hover { color: var(--danger); border-color: var(--danger); }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.history-item {
  display: flex;
  justify-content: space-between;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.history-item:last-child { border-bottom: none; }
.history-date { color: var(--text-dim); font-size: 0.8rem; }

.footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 2rem 1rem;
}

textarea, select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}
textarea:focus, select:focus { outline: none; border-color: var(--accent); }
