:root {
  --ink: #1a2230;
  --ink-light: #232e40;
  --ink-lighter: #2d3a4f;
  --gold: #c9a227;
  --gold-soft: #e0c568;
  --cream: #ece7da;
  --muted: #9aa4b5;
  --success: #4caf7d;
  --danger: #d96a5f;
  --border: #37455a;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; letter-spacing: 0.2px; }

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

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #151c28;
  border-right: 1px solid var(--border);
  padding: 24px 0;
}

.brand {
  padding: 0 20px 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.brand .qalam { color: var(--gold); font-size: 22px; }
.brand .ai { color: var(--cream); }
.brand .tag { color: var(--muted); font-size: 12px; margin-top: 2px; }

.nav a {
  display: block;
  padding: 10px 20px;
  color: var(--muted);
  border-left: 3px solid transparent;
}
.nav a:hover { color: var(--cream); text-decoration: none; background: var(--ink-light); }
.nav a.active { color: var(--gold-soft); border-left-color: var(--gold); background: var(--ink-light); }

.main { flex: 1; padding: 32px 40px; max-width: 1100px; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.topbar .logout { font-size: 13px; color: var(--muted); }

.card {
  background: var(--ink-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--ink-light); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .num { font-family: Georgia, serif; font-size: 28px; color: var(--gold-soft); }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 2px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
tr:hover td { background: rgba(255,255,255,0.02); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; }
.badge.active { background: rgba(76,175,125,0.15); color: var(--success); }
.badge.inactive { background: rgba(154,164,181,0.15); color: var(--muted); }
.badge.error { background: rgba(217,106,95,0.15); color: var(--danger); }
.badge.success { background: rgba(76,175,125,0.15); color: var(--success); }
.badge.info { background: rgba(201,162,39,0.15); color: var(--gold-soft); }

.btn {
  display: inline-block;
  background: var(--gold);
  color: #1a2230;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: var(--gold-soft); text-decoration: none; }
.btn.secondary { background: transparent; color: var(--cream); border: 1px solid var(--border); }
.btn.secondary:hover { border-color: var(--gold); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 5px 12px; font-size: 12px; }

form label { display: block; margin: 14px 0 6px 0; font-size: 13px; color: var(--muted); }
form .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=time], textarea, select {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--cream);
  font-size: 14px;
  font-family: inherit;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 1px solid var(--gold); border-color: var(--gold); }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.checkbox-row input { width: auto; }

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

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { width: 340px; }

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

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink-lighter); border: 1px solid var(--gold); padding: 12px 18px; border-radius: var(--radius); font-size: 14px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } .app-shell { flex-direction: column; } .sidebar { width: 100%; } }
