:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0d9488;
  --brand-dark: #0f766e;
  --brand-soft: #ccfbf1;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --sidebar: #0f172a;
  --sidebar-ink: #cbd5e1;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .05);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Cairo', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid #1e293b; }
.brand-icon { font-size: 28px; }
.brand-name { font-weight: 800; color: #fff; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: #64748b; }
.sidebar nav { flex: 1; padding: 10px 8px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; margin-bottom: 2px;
  color: var(--sidebar-ink); font-weight: 600; font-size: 13.5px;
}
.sidebar nav a:hover { background: #1e293b; text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.nav-ic { width: 22px; text-align: center; }
.sidebar-foot { padding: 12px; border-top: 1px solid #1e293b; display: flex; gap: 8px; }
.lang-btn, .logout-btn {
  flex: 1; text-align: center; padding: 8px; border-radius: 10px;
  background: #1e293b; color: #e2e8f0; font-weight: 700; font-size: 13px;
}
.lang-btn:hover, .logout-btn:hover { background: #334155; text-decoration: none; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 14px 24px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 19px; font-weight: 800; flex: 1; }
.burger { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--ink); }
.user-chip { background: var(--bg); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.user-chip small { color: var(--muted); }
.content { padding: 24px; max-width: 1300px; width: 100%; margin: 0 auto; }

/* ---------- flash ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-weight: 600; }
.flash-success { background: var(--ok-soft); color: #166534; }
.flash-error { background: var(--danger-soft); color: #991b1b; }

/* ---------- cards & grids ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card h2 { font-size: 16px; font-weight: 800; margin-bottom: 14px; }
.card h2 .h2-link { font-size: 12px; font-weight: 700; float: inline-end; }
.grid { display: grid; gap: 16px; margin-bottom: 20px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1000px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 520px)  { .grid-4 { grid-template-columns: 1fr; } }

.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stat .stat-label { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.stat .stat-value { font-size: 24px; font-weight: 800; margin-top: 4px; }
.stat .stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.stat-danger .stat-value { color: var(--danger); }
.stat.stat-ok .stat-value { color: var(--ok); }

/* ---------- progress bars ---------- */
.bar { background: var(--line); border-radius: 999px; height: 10px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); transition: width .3s; }
.bar > span.bar-over { background: var(--danger); }
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar-row .bar { flex: 1; }
.bar-label { min-width: 160px; font-weight: 600; font-size: 13.5px; }
.bar-num { min-width: 110px; text-align: end; font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; padding: 10px 12px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: #f8fafc; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 800; border-top: 2px solid var(--line); }

/* ---------- badges & chips ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-gray { background: var(--bg); color: var(--muted); }
.badge-green { background: var(--ok-soft); color: #166534; }
.badge-amber { background: var(--warn-soft); color: #92400e; }
.badge-red { background: var(--danger-soft); color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.cat-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; color: #fff; white-space: nowrap; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=file], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 14px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--ink); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: none; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 700;
  background: var(--brand); color: #fff;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-outline { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.page-actions .spacer { flex: 1; }

/* ---------- filter bar ---------- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filter-bar > div { min-width: 130px; }
.filter-bar .grow { flex: 1; min-width: 180px; }

/* ---------- modal ---------- */
.modal-back {
  display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  z-index: 100; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal-back.open { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h3 { font-size: 17px; font-weight: 800; margin-bottom: 16px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---------- gallery ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.photo-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.photo-card img { width: 100%; height: 150px; object-fit: cover; display: block; }
.photo-card .photo-meta { padding: 8px 10px; font-size: 12.5px; }
.photo-card .photo-meta .cap { font-weight: 700; }
.photo-card .photo-meta .sub { color: var(--muted); }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mb0 { margin-bottom: 0; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); font-weight: 600; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
canvas { max-width: 100%; }
.chart-box { position: relative; height: 300px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a, #134e4a); padding: 16px; }
.login-card { background: #fff; border-radius: 20px; padding: 36px; width: 100%; max-width: 400px; box-shadow: 0 25px 60px rgba(0,0,0,.4); }
.login-card .login-logo { font-size: 44px; text-align: center; }
.login-card h1 { text-align: center; font-size: 22px; font-weight: 800; margin: 6px 0 2px; }
.login-card .login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card form > div { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; }
.login-lang { text-align: center; margin-top: 16px; }

/* ---------- print ---------- */
@media print {
  .sidebar, .topbar, .page-actions, .btn, .filter-bar, .flash { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid var(--line); page-break-inside: avoid; }
  body { background: #fff; }
}

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; inset-inline-start: 0; top: 0; z-index: 90;
    transform: translateX(-100%); transition: transform .25s;
  }
  [dir=rtl] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0) !important; }
  .burger { display: block; }
  .content { padding: 16px; }
  .bar-label { min-width: 110px; font-size: 12.5px; }
  .topbar h1 { font-size: 16px; }
  .user-chip small { display: none; }
}
