:root {
  --primary: #2952a3;
  --primary-dark: #1d3b78;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dfe4ea;
  --text: #1f2937;
  --text-muted: #6b7280;
  --danger: #c0392b;
  --success: #1e8449;
  --warning: #b7791f;
}

* { box-sizing: border-box; }

html[dir="rtl"] body { font-family: "Segoe UI", Tahoma, Arial, sans-serif; }
html[dir="rtl"] .app-shell { flex-direction: row-reverse; }
html[dir="rtl"] th, html[dir="rtl"] td, html[dir="rtl"] label { text-align: right; }
html[dir="rtl"] .page-header { flex-direction: row-reverse; }
html[dir="rtl"] .sidebar a { text-align: right; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.sidebar {
  width: 230px;
  background: var(--primary-dark);
  color: #fff;
  padding: 1.25rem 0;
  flex-shrink: 0;
}

.sidebar .brand {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  margin-bottom: 0.75rem;
}

.sidebar a {
  display: block;
  color: #dce4f5;
  text-decoration: none;
  padding: 0.6rem 1.25rem;
  font-size: 0.92rem;
}

.sidebar a:hover, .sidebar a.active {
  background: var(--primary);
  color: #fff;
}

.sidebar .user-box {
  margin-top: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-size: 0.85rem;
}

.sidebar form { margin-top: 0.5rem; }

.sidebar button.logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.main {
  flex: 1;
  padding: 1.5rem 2rem;
  max-width: 1200px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  font-size: 1.4rem;
  margin: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th, td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 0.92rem;
}

th { background: #eef1f6; font-weight: 600; }

tr:hover td { background: #f8fafc; }

.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 5px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-size: 0.88rem;
  cursor: pointer;
}

.btn:hover { background: var(--primary-dark); }

.btn.secondary {
  background: #fff;
  color: var(--primary);
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
}

.btn.small { padding: 0.25rem 0.55rem; font-size: 0.8rem; }

form.inline { display: inline; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-muted);
}

input, select, textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 0.92rem;
  margin-bottom: 0.9rem;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 1rem; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.success { background: #eafaf1; color: var(--success); }
.badge.danger { background: #fdecea; color: var(--danger); }
.badge.warning { background: #fdf3e3; color: var(--warning); }

.alert {
  padding: 0.7rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert.success { background: #eafaf1; color: var(--success); border: 1px solid #b7e4c7; }
.alert.error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c0; }
.alert.warning { background: #fdf3e3; color: var(--warning); border: 1px solid #f5e0a3; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.stat-card .value { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 0.85rem; color: var(--text-muted); }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.login-box {
  background: #fff;
  padding: 2rem 2.25rem;
  border-radius: 10px;
  width: 320px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.login-box h1 {
  font-size: 1.3rem;
  margin-top: 0;
  text-align: center;
  color: var(--primary-dark);
}

.text-muted { color: var(--text-muted); font-size: 0.85rem; }
