/* ================= نظام التصميم: فاتح دافئ RTL ================= */
:root {
  --bg: #F6F2E9;
  --bg-grad-1: #FBF8F1;
  --bg-grad-2: #F1ECE0;
  --surface: #FFFFFF;
  --surface-2: #F5F1E8;
  --surface-3: #EFE9DC;
  --border: #E6DECE;
  --border-soft: #EDE7DA;
  --text: #2C2A24;
  --text-muted: #746E60;
  --text-dim: #9A9382;

  --amber: #C28A1A;
  --amber-bright: #E0A82E;
  --amber-soft: #FBF0D6;
  --emerald: #168B79;
  --emerald-soft: #DCF1ED;
  --rose: #C0455B;
  --rose-soft: #FBE3E7;
  --blue: #3D6FD0;
  --blue-soft: #E2EAFB;
  --glowA: #FCEFD2;
  --glowB: #DCF1ED;

  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 18px 40px -22px rgba(91,72,30,.35);
  --shadow-soft: 0 8px 22px -14px rgba(91,72,30,.28);
  --font: 'IBM Plex Sans Arabic', 'Cairo', system-ui, sans-serif;
  --font-display: 'Cairo', 'IBM Plex Sans Arabic', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1100px 560px at 100% -8%, var(--glowA) 0%, transparent 55%),
    radial-gradient(820px 460px at -8% 108%, var(--glowB) 0%, transparent 52%),
    linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}
h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 700; margin: 0; letter-spacing: -.2px; color: var(--text); }
a { color: inherit; text-decoration: none; }

/* ===== التخطيط الرئيسي ===== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 268px; flex-shrink: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(250,247,240,.86));
  border-inline-start: 1px solid var(--border-soft);
  backdrop-filter: blur(8px);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  box-shadow: var(--shadow-soft);
}
.brand { padding: 22px 22px 14px; display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 13px;
  background: linear-gradient(135deg, var(--amber-bright), var(--amber));
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 8px 18px -6px rgba(224,168,46,.6);
}
.brand-text .t1 { font-family: var(--font-display); font-weight: 800; font-size: 16px; }
.brand-text .t2 { font-size: 11.5px; color: var(--text-muted); }

.nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav-group-label {
  font-size: 11px; color: var(--text-dim); font-weight: 700;
  padding: 14px 12px 6px; letter-spacing: .4px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 600; font-size: 14px;
  transition: all .16s ease; cursor: pointer; position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); transform: translateX(-2px); }
.nav-item.active { background: var(--amber-soft); color: var(--amber); }
.nav-item.active::before {
  content: ''; position: absolute; inset-inline-start: -12px; top: 18%; bottom: 18%;
  width: 3px; border-radius: 3px; background: var(--amber-bright);
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }

.sidebar-foot { margin-top: auto; padding: 14px; border-top: 1px solid var(--border-soft); }

/* ===== المحتوى ===== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; border-bottom: 1px solid var(--border-soft);
  background: rgba(251,248,241,.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 26px; flex: 1; max-width: 1240px; width: 100%; margin: 0 auto; }

/* ===== أزرار ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-family: var(--font);
  font-weight: 600; font-size: 14px; cursor: pointer; transition: all .15s ease;
}
.btn:hover { border-color: var(--amber); transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.btn svg { width: 17px; height: 17px; }
.btn-primary {
  background: linear-gradient(135deg, var(--amber-bright), var(--amber));
  color: #fff; border: none; box-shadow: 0 8px 18px -8px rgba(224,168,46,.7);
}
.btn-primary:hover { filter: brightness(1.05); color: #fff; }
.btn-ghost { background: transparent; }
.btn-emerald { background: linear-gradient(135deg, var(--emerald), #0f7567); color: #fff; border: none; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.chip-toggle { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.chip-toggle a { padding: 5px 13px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--text-muted); cursor: pointer; transition: all .15s; }
.chip-toggle a:hover { color: var(--text); }
.chip-toggle a.on { background: var(--amber-bright); color: #fff; }

/* ===== بطاقات ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}
.card-pad { padding: 22px; }
.card-title { font-size: 15px; font-weight: 800; margin-bottom: 16px; display:flex; align-items:center; gap:9px; }
.card-title .ic { color: var(--amber); display:inline-flex; }

/* ===== بطاقات الإحصائيات ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px,1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 18px 20px;
  position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s;
  box-shadow: var(--shadow-soft);
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat::after { content:''; position:absolute; inset-inline-end:-28px; top:-28px; width:88px; height:88px; border-radius:50%; opacity:.10; background: var(--accent, var(--amber-bright)); }
.stat .ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 14px; }
.stat .label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.stat .value { font-family: var(--font-display); font-weight: 800; font-size: 25px; margin-top: 4px; letter-spacing:-.5px; }
.stat .cur { font-size: 13px; font-weight: 700; color: var(--text-dim); margin-inline-start: 3px; }
.ico-amber { background: var(--amber-soft); color: var(--amber); }
.ico-emerald { background: var(--emerald-soft); color: var(--emerald); }
.ico-rose { background: var(--rose-soft); color: var(--rose); }
.ico-blue { background: var(--blue-soft); color: var(--blue); }
.val-pos { color: var(--emerald); } .val-neg { color: var(--rose); }

/* ===== جداول ===== */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: start; color: var(--text-muted); font-weight: 700; font-size: 12.5px; padding: 11px 12px; border-bottom: 2px solid var(--border); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--border-soft); }
.tbl tr:hover td { background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: none; }
.tag { display:inline-flex; align-items:center; gap:5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.tag-cash { background: var(--emerald-soft); color: var(--emerald); }
.tag-visa { background: var(--blue-soft); color: var(--blue); }
.tag-exp { background: var(--rose-soft); color: var(--rose); }
.tag-warn { background: #FCEFD2; color: #9A6B12; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ===== نماذج ===== */
.form-grid { display: grid; gap: 18px; max-width: 520px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.field .opt { color: var(--text-dim); font-weight: 400; }
.input, .select, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-family: var(--font); font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft);
}
.input.big { font-size: 22px; font-weight: 700; font-family: var(--font-display); padding: 14px 16px; }
.input-cur { position: relative; }
.input-cur .suffix { position: absolute; inset-inline-end: 14px; top: 50%; transform: translateY(-50%); color: var(--text-dim); font-weight: 700; pointer-events: none; }

.calc-box {
  background: linear-gradient(135deg, var(--amber-soft), #fff); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px; display: flex; flex-direction: column; gap: 9px;
}
.calc-row { display: flex; justify-content: space-between; font-size: 14px; }
.calc-row .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.calc-row.commission .v { color: var(--rose); }
.calc-row.net { padding-top: 9px; border-top: 1px solid var(--border); }
.calc-row.net .l { color: var(--text); font-weight: 800; }
.calc-row.net .v { color: var(--emerald); font-size: 19px; font-family: var(--font-display); }

.hint { font-size: 12.5px; color: var(--text-dim); display:flex; align-items:center; gap:7px; }
.alert-ok { background: var(--emerald-soft); border: 1px solid rgba(22,139,121,.3); color: var(--emerald); padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 700; display:flex; align-items:center; gap:9px; }
.alert-err { background: var(--rose-soft); border: 1px solid rgba(192,69,91,.3); color: var(--rose); padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 700; }

/* ===== رفع الملفات ===== */
.upload-zone {
  border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 28px;
  text-align: center; background: var(--surface-2); transition: all .15s; cursor: pointer;
}
.upload-zone:hover { border-color: var(--amber); background: var(--amber-soft); }
.upload-zone .big-ic { color: var(--amber); margin-bottom: 8px; }
.doc-type-pick { display: flex; gap: 10px; flex-wrap: wrap; }
.doc-type-pick .opt {
  display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 13px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; min-width: 96px;
  color: var(--text-muted); transition: all .15s; background: var(--surface);
}
.doc-type-pick .opt:hover { border-color: var(--amber); color: var(--text); transform: translateY(-2px); }
.doc-type-pick .opt.sel { border-color: var(--amber); background: var(--amber-soft); color: var(--amber); }
.doc-type-pick .opt svg { width: 24px; height: 24px; }

/* ===== صفحة الدخول ===== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 410px; }
.login-head { text-align: center; margin-bottom: 26px; }
.login-head .lg { width: 62px; height: 62px; border-radius: 18px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--amber-bright), var(--amber)); display: grid; place-items: center; color:#fff;
  box-shadow: 0 12px 26px -8px rgba(224,168,46,.6); }
.login-head h1 { font-size: 22px; }
.login-head p { color: var(--text-muted); font-size: 13.5px; margin-top: 6px; }
.cred-hint { margin-top: 18px; font-size: 12px; color: var(--text-muted); background: var(--surface-2);
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 11px 13px; line-height: 1.8; }
.cred-hint code { color: var(--amber); font-weight: 700; }

.user-pill { display:flex; align-items:center; gap:10px; padding: 5px 6px 5px 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg,var(--emerald),#0f7567);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; }
.user-pill .nm { font-size: 13.5px; font-weight: 700; }
.user-pill .rl { font-size: 11px; color: var(--text-muted); }

.section-head { display:flex; align-items:center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--text-muted); }
.empty { text-align:center; padding: 40px; color: var(--text-dim); }
.bars { display:flex; flex-direction:column; gap: 12px; }
.bar-row .bar-top { display:flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.bar-track { height: 10px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--amber-bright), var(--emerald)); }

.page-loading { padding: 60px; text-align:center; color: var(--text-muted); }

#blazor-error-ui { display:none; position: fixed; bottom: 0; inset-inline: 0; background: var(--rose);
  color:#fff; padding: 12px 20px; z-index: 1000; }
#blazor-error-ui .reload, #blazor-error-ui .dismiss { color:#fff; margin-inline-start: 12px; cursor:pointer; text-decoration: underline; }

@media (max-width: 860px) {
  .sidebar { position: fixed; inset-inline-start: 0; z-index: 50; width: 234px; box-shadow: var(--shadow); }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
}

/* ===== أزرار الأيقونات وإجراءات الصفوف ===== */
.row-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); display: inline-grid; place-items: center; cursor: pointer;
  color: var(--text-muted); transition: all .14s;
}
.icon-btn:hover { border-color: var(--amber); color: var(--amber); transform: translateY(-1px); }
.icon-btn.danger:hover { border-color: var(--rose); color: var(--rose); }
.icon-btn svg { width: 16px; height: 16px; }

/* ===== نافذة منبثقة ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(54,44,20,.32); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 120; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  animation: pop .16s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { font-size: 16px; }
.modal-x { width: 30px; height: 30px; border-radius: 8px; border: none; background: var(--surface-2); cursor: pointer; color: var(--text-muted); font-size: 16px; }
.modal-x:hover { background: var(--rose-soft); color: var(--rose); }
.modal-body { padding: 22px; }
.modal-foot { display: flex; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border-soft); }

/* ===== لوحة إدخالات الموظف ===== */
.daily-panel { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 16px; margin-top: 10px; }
.daily-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 14px; }
.daily-stat { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 12px 14px; }
.daily-stat .l { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.daily-stat .v { font-family: var(--font-display); font-weight: 800; font-size: 18px; margin-top: 3px; }

/* زر إجراء نصّي للحذف */
.btn-danger { color: var(--rose); }
.btn-danger:hover { border-color: var(--rose); background: var(--rose-soft); color: var(--rose); }
.row-actions .btn { padding: 6px 12px; }

/* ================= السمات اللونية (Themes) ================= */
/* الافتراضي = الذهبي الدافئ (في :root) */

[data-theme="ocean"] {
  --amber: #1C6E97; --amber-bright: #2C9AD0; --amber-soft: #E0F1FA;
  --emerald: #168B79; --emerald-soft: #DCF1ED;
  --glowA: #D7EEFB; --glowB: #DDF2EE;
}
[data-theme="emerald"] {
  --amber: #157A5E; --amber-bright: #20A87E; --amber-soft: #DDF4EC;
  --emerald: #2C7BD0; --emerald-soft: #E2EAFB;
  --glowA: #D8F3E8; --glowB: #E4EEFB;
}
[data-theme="violet"] {
  --amber: #6A3FB0; --amber-bright: #8B5CD6; --amber-soft: #EEE6FA;
  --emerald: #168B79; --emerald-soft: #DCF1ED;
  --glowA: #ECE2FB; --glowB: #DCF1ED;
}
[data-theme="rose"] {
  --amber: #B53A63; --amber-bright: #DB5C86; --amber-soft: #FBE3EC;
  --emerald: #168B79; --emerald-soft: #DCF1ED;
  --glowA: #FBE0EA; --glowB: #DCF1ED;
}

/* الوضع الداكن */
[data-theme="dark"] {
  --bg: #0E1116; --bg-grad-1: #11151c; --bg-grad-2: #0b0e13;
  --surface: #161A22; --surface-2: #1C2230; --surface-3: #232b3b;
  --border: #2A3243; --border-soft: #222a39;
  --text: #E7EAF0; --text-muted: #9AA6B8; --text-dim: #6B7689;
  --amber: #B9821B; --amber-bright: #E0A82E; --amber-soft: rgba(224,168,46,.14);
  --emerald: #2FB6A0; --emerald-soft: rgba(47,182,160,.14);
  --rose: #E0556B; --rose-soft: rgba(224,85,107,.14);
  --blue: #5B8DEF; --blue-soft: rgba(91,141,239,.14);
  --glowA: #182033; --glowB: #15201d;
}
[data-theme="dark"] .btn-primary, [data-theme="dark"] .brand-logo, [data-theme="dark"] .login-head .lg { color: #1a130a; }
[data-theme="dark"] .avatar { color: #06231e; }

/* ===== شبكة السمات في الإعدادات ===== */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 14px; }
.theme-card {
  border: 1.5px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer;
  background: var(--surface); transition: all .15s; text-align: center; text-decoration: none; color: var(--text);
}
.theme-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-soft); border-color: var(--text-dim); }
.theme-card.sel { border-color: var(--amber-bright); box-shadow: 0 0 0 3px var(--amber-soft); }
.theme-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.theme-dot { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,.08); }
.theme-name { font-weight: 700; font-size: 13.5px; }
