:root {
  --background: #f7f8f6;
  --surface: #ffffff;
  --foreground: #1a231d;
  --muted: #667066;
  --border: #e2e6e1;
  --brand: #009e8f;
  --brand-hover: #007e72;
  --brand-soft: #e7f3f1;
  --accent: #62c3b6;
  --accent-soft: #e2f1ef;
  --danger: #b3432f;
  --danger-soft: #fbe9e5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: 'Cairo', Arial, Helvetica, sans-serif;
}

a { color: inherit; text-decoration: none; }

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

.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.app-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.app-brand-icon {
  width: 52px; height: 40px; border-radius: 8px; background: #fff; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; padding: 4px; flex-shrink: 0;
}
.app-brand-icon img { max-width: 100%; max-height: 100%; object-fit: contain; }
.app-brand-title { font-size: 14px; font-weight: 700; }
.app-brand-sub { font-size: 12px; color: var(--muted); }

.app-nav { display: flex; flex-direction: column; gap: 4px; }
.app-nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 500;
  color: var(--muted);
}
.app-nav-link:hover { background: rgba(14,124,120,0.08); color: var(--foreground); }
.app-nav-link.active { background: var(--brand-soft); color: var(--brand); }

.app-sidebar-footer { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.app-user-card { background: var(--background); border-radius: 10px; padding: 10px 12px; }
.app-user-name { font-size: 14px; font-weight: 600; }
.app-user-role { font-size: 12px; color: var(--muted); }

.app-main { flex: 1; padding: 28px 32px; overflow-x: hidden; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header h1 { font-size: 20px; font-weight: 700; margin: 0; }
.page-header p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.back-link { font-size: 13px; color: var(--muted); }
.back-link:hover { color: var(--brand); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }

.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.stat-tile .label { font-size: 12px; color: var(--muted); }
.stat-tile .value { font-size: 22px; font-weight: 700; margin-top: 6px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
th { text-align: right; padding: 12px 16px; color: var(--muted); font-weight: 500; background: rgba(0,0,0,0.02); border-bottom: 1px solid var(--border); }
td { padding: 10px 16px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.badge-muted { background: var(--background); color: var(--muted); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; background: var(--brand); color: #fff;
}
.btn:hover { background: var(--brand-hover); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--foreground); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-link { background: none; border: none; color: var(--brand); font-weight: 600; padding: 0; font-size: 14px; }
.btn-link:hover { text-decoration: underline; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

form.form-card { max-width: 640px; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--background); font-family: inherit; font-size: 14px; color: var(--foreground);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,124,120,0.15);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--brand-soft); color: var(--brand); }

.empty-state { text-align: center; padding: 40px 16px; color: var(--muted); font-size: 14px; }

/* شاشة الدخول */
.login-shell { display: flex; min-height: 100vh; flex-wrap: wrap; }
.login-panel { flex: 1; min-width: 320px; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-panel form { width: 100%; max-width: 360px; }
.login-brand-panel {
  flex: 1; min-width: 320px; position: relative; color: #fff; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 32px; background: linear-gradient(135deg, var(--brand), var(--brand), var(--accent));
}
.login-brand-icon {
  width: 160px; height: 80px; border-radius: 16px; background: #fff;
  display: flex; align-items: center; justify-content: center; padding: 10px; margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.login-brand-icon img { max-width: 100%; max-height: 100%; object-fit: contain; }
.login-badge { background: rgba(255,255,255,0.15); border-radius: 999px; padding: 4px 14px; font-size: 12px; margin-bottom: 8px; }
.login-brand-panel h2 { font-size: 24px; font-weight: 800; margin: 0; }
.login-brand-panel .en { font-size: 13px; opacity: 0.85; margin: 2px 0 0; }
.login-brand-panel .desc { max-width: 320px; margin: 16px auto 0; font-size: 14px; line-height: 1.7; opacity: 0.85; }
.login-features { margin-top: 28px; width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 10px; }
.login-feature { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.1); border-radius: 12px; padding: 10px 14px; text-align: right; backdrop-filter: blur(4px); }
.login-feature .icon { font-size: 18px; }
.login-feature .title { font-size: 13px; font-weight: 700; }
.login-feature .desc { font-size: 11px; opacity: 0.75; }
.login-credit { position: absolute; bottom: 16px; font-size: 11px; opacity: 0.7; }

@media print {
  .app-sidebar, .no-print { display: none !important; }
  .app-main { padding: 0; }
  .app-shell { display: block; }
}
