:root {
  --bg1: #0f172a;
  --bg2: #1e1b4b;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --danger-bg: #fee2e2;
  --danger-text: #b91c1c;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; }

body {
  min-height: 100vh;
  font-family: "Tajawal", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg1), var(--bg2));
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 3rem 1rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
.card.wide { max-width: 980px; }

.brand {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.subtitle { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }
.muted { color: var(--muted); }
h1 { font-size: 1.25rem; margin: 0.75rem 0; }

input, button { font: inherit; }

input {
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  background: #fff;
}

button {
  border: none;
  border-radius: 10px;
  padding: 0.6rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
button:active { transform: translateY(1px); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-block { width: 100%; margin-top: 1rem; padding: 0.75rem; }
.btn-ghost { background: #f1f5f9; color: #334155; }
.btn-ghost:hover { background: #e2e8f0; }
.btn-danger { background: var(--danger-bg); color: var(--danger-text); }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.83rem; border-radius: 8px; }

.field { display: block; margin-top: 1.25rem; }
.field span { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.4rem; }
.field input { width: 100%; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.error {
  background: #fef2f2;
  color: var(--danger-text);
  border: 1px solid #fecaca;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.success {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

form.create { display: flex; gap: 0.6rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
form.create input[name="url"] { flex: 2 1 260px; }
form.create input[name="slug"] { flex: 1 1 150px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: start;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
td { padding: 0.7rem 0.75rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.url { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; }
td.url a { color: var(--primary); text-decoration: none; }
td.url a:hover { text-decoration: underline; }

.slug-pill {
  font-family: ui-monospace, monospace;
  direction: ltr;
  unicode-bidi: embed;
  font-size: 0.85rem;
  background: #eef2ff;
  color: #4338ca;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  text-decoration: none;
}
.slug-pill:hover { background: #e0e7ff; }

.badge { font-size: 0.75rem; font-weight: 600; padding: 0.2rem 0.6rem; border-radius: 999px; }
.badge-on { background: #dcfce7; color: #15803d; }
.badge-off { background: #f1f5f9; color: var(--muted); }
.row-off td { opacity: 0.55; }
.row-off td:last-child { opacity: 1; }

.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 2rem 0; }

@media (max-width: 640px) {
  body { padding: 1.5rem 0.75rem; }
  .card { padding: 1.5rem; }
  .topbar { flex-direction: column; align-items: flex-start; }
  td.url { max-width: 130px; }
}
