:root {
  --bg: #f6f4ef;
  --ink: #1c1b19;
  --muted: #847d72;
  --line: #e7e2d8;
  --card: #ffffff;
  --accent: #0f6e5e;
  --accent2: #d98a2b;
  --danger: #c0492f;
  --shadow: 0 1px 2px rgba(28,27,25,.04), 0 8px 24px rgba(28,27,25,.06);
}

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

body {
  font-family: 'Tajawal', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ===== شاشة الدخول ===== */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 20%, rgba(15,110,94,.10), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(217,138,43,.10), transparent 40%),
    var(--bg);
}
.login-card {
  background: var(--card);
  width: 100%; max-width: 380px;
  padding: 40px 32px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--line);
}
.login-mark {
  font-size: 40px; color: var(--accent);
  width: 72px; height: 72px; line-height: 72px;
  margin: 0 auto 16px;
  background: rgba(15,110,94,.08); border-radius: 18px;
}
.login-card h1 { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.login-card input {
  width: 100%; padding: 14px 16px; font-size: 16px; font-family: inherit;
  border: 1.5px solid var(--line); border-radius: 12px; margin-bottom: 14px;
  text-align: center; background: #fcfbf8;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card button {
  width: 100%; padding: 14px; font-size: 16px; font-weight: 700; font-family: inherit;
  background: var(--accent); color: #fff; border: none; border-radius: 12px; cursor: pointer;
  transition: transform .1s, background .2s;
}
.login-card button:hover { background: #0c5b4d; }
.login-card button:active { transform: scale(.98); }
.login-error { color: var(--danger); font-size: 14px; margin-top: 12px; min-height: 18px; }

/* ===== اللوحة ===== */
.dashboard { max-width: 1140px; margin: 0 auto; padding: 0 16px 40px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 4px; margin-bottom: 8px;
}
.brand { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.brand-mark { color: var(--accent); }
.topbar-actions { display: flex; gap: 8px; }
.ghost-btn {
  font-family: inherit; font-size: 14px; font-weight: 500;
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; transition: background .2s;
}
.ghost-btn:hover { background: #efece5; }

/* الفلاتر */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; flex-wrap: wrap; }
.seg button {
  font-family: inherit; font-size: 13px; font-weight: 500;
  border: none; background: none; color: var(--muted);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; transition: all .15s;
}
.seg button.active { background: var(--accent); color: #fff; }
.filter-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.custom-range { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.custom-range input, .branch-select {
  font-family: inherit; font-size: 13px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--ink);
}

.loading-bar {
  height: 3px; border-radius: 3px; overflow: hidden; margin-bottom: 16px;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--accent));
  background-size: 200% 100%; animation: slide 1s linear infinite;
}
@keyframes slide { to { background-position: -200% 0; } }

/* البطاقات */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi {
  padding: 18px 20px; display: flex; flex-direction: column; gap: 6px;
  animation: rise .4s ease both;
}
.kpi-big { grid-column: span 1; background: var(--accent); border-color: var(--accent); }
.kpi-big .kpi-label, .kpi-big .kpi-value { color: #fff; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* الرسوم */
.charts { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 22px; }
.chart-card { padding: 20px; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card h3, .table-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.chart-card canvas { max-height: 300px; }

/* الجدول */
.table-card { padding: 20px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 10px; text-align: right; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 700; font-size: 13px; }
td.strong { font-weight: 700; }
td.empty { text-align: center; color: var(--muted); padding: 28px; }
tbody tr:hover { background: #faf8f4; }

.foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 28px; }

/* الموبايل */
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
  .chart-card.wide { grid-column: auto; }
  .kpi-value { font-size: 20px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filter-right { justify-content: space-between; }
}
