:root {
  --bg: #f5efdf;
  --surface: rgba(255, 252, 244, 0.95);
  --surface-strong: #fffdf7;
  --text: #18150f;
  --muted: #6d665a;
  --line: rgba(78, 69, 50, 0.12);
  --green: #2d7b63;
  --green-deep: #184d3d;
  --gold: #d4a532;
  --gold-soft: #f3db92;
  --danger: #ad493e;
  --shadow: 0 20px 50px rgba(47, 38, 20, 0.12);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --font-ui: "IBM Plex Sans Arabic", "Cairo", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-ui);
  background:
    radial-gradient(circle at top right, rgba(212, 165, 50, 0.18), transparent 24%),
    radial-gradient(circle at top left, rgba(45, 123, 99, 0.18), transparent 22%),
    linear-gradient(180deg, #fbf6eb 0%, #f5efdf 100%);
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.flash-stack {
  position: fixed;
  inset: 18px 18px auto;
  z-index: 10;
  display: grid;
  gap: 10px;
}

.flash {
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.flash-success { border-color: rgba(45, 123, 99, 0.28); }
.flash-error { border-color: rgba(173, 73, 62, 0.28); }

.login-shell,
.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 22px;
  align-items: center;
}

.login-hero,
.login-card,
.hero-card,
.panel,
.topbar {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.login-hero {
  padding: 30px;
  background:
    linear-gradient(140deg, rgba(19, 19, 16, 0.95), rgba(24, 77, 61, 0.93) 62%, rgba(45, 123, 99, 0.88)),
    var(--surface);
  color: #fff9ef;
}

.login-card,
.hero-card,
.panel,
.topbar {
  padding: 24px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.brand-lockup img {
  width: 132px;
  height: 96px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 16px;
  padding: 6px;
}

.brand-lockup strong {
  display: block;
  font-size: 1rem;
}

.brand-lockup span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.login-hero .brand-lockup span { color: rgba(255, 249, 239, 0.78); }
.login-hero h1,
.hero-card h1 {
  margin: 22px 0 10px;
  font-size: clamp(2rem, 3vw, 3.4rem);
  line-height: 1.2;
}

.hero-title-box,
.register-box {
  margin-top: 26px;
  padding: 22px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 249, 239, 0.12);
}

.hero-title-box {
  background: rgba(255, 249, 239, 0.08);
}

.hero-title-box h2,
.register-box h3 {
  margin: 0 0 10px;
}

.hero-title-box p,
.register-box p {
  margin: 0;
  line-height: 1.9;
}

.login-hero p,
.hero-card p,
.section-head p,
.empty-state {
  line-height: 1.9;
  color: var(--muted);
}

.login-hero p { color: rgba(255, 249, 239, 0.86); }

.demo-accounts h2,
.login-card h2,
.section-head h2 {
  margin: 0 0 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.92rem;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(78, 69, 50, 0.16);
  background: #fffdf8;
  color: var(--text);
}

.password-control {
  position: relative;
  display: block;
}

.field .password-control input {
  width: 100%;
  padding-right: 48px;
}

/* زر العين داخل الخانة (الخانة من اليسار لليمين، فالزر في طرفها الأيمن) */
.toggle-password {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--green-deep);
  cursor: pointer;
}

.toggle-password:hover,
.toggle-password:focus-visible { background: rgba(45, 123, 99, 0.1); outline: none; }
.toggle-password .icon-eye-off { display: none; }
.toggle-password.is-visible .icon-eye { display: none; }
.toggle-password.is-visible .icon-eye-off { display: inline; }

.btn,
.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.btn:hover,
.mini-btn:hover { transform: translateY(-1px); }

.btn {
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 999px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), #efc868);
  color: #34260b;
}

.btn-outline {
  background: transparent;
  color: var(--green-deep);
  border: 1px solid rgba(45, 123, 99, 0.22);
}

.btn.wide { width: 100%; }

.form-divider {
  position: relative;
  margin: 22px 0;
  text-align: center;
}

.form-divider::before {
  content: "";
  position: absolute;
  inset: 50% 0 auto;
  border-top: 1px solid rgba(78, 69, 50, 0.14);
}

.form-divider span {
  position: relative;
  display: inline-block;
  padding: 0 12px;
  background: var(--surface);
  color: var(--muted);
}

.success-box {
  margin: 16px 0 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(45, 123, 99, 0.12), rgba(212, 165, 50, 0.14));
  border: 1px solid rgba(45, 123, 99, 0.18);
  color: var(--green-deep);
  line-height: 1.8;
  font-weight: 600;
}

.inline-messages {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.inline-flash {
  position: static;
  width: 100%;
}

.text-link {
  margin-top: 12px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--green-deep);
  cursor: pointer;
  font-weight: 600;
}

.hidden-panel {
  display: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.user-badge {
  display: grid;
  gap: 4px;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(45, 123, 99, 0.08);
}

.hero-card {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stat-card,
.payslip-card,
.table-form,
.filter-row {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(78, 69, 50, 0.08);
  border-radius: var(--radius-md);
}

.stat-card {
  padding: 16px;
}

.stat-card strong {
  display: block;
  color: var(--green-deep);
  font-size: 1.8rem;
  margin-bottom: 4px;
}

.content-grid {
  margin-top: 18px;
  display: grid;
  gap: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.section-head h2 { margin: 0; }
.section-head p { margin: 6px 0 0; }

.table-wrap {
  overflow: auto;
  margin-top: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: right;
  padding: 12px 10px;
  border-bottom: 1px solid rgba(78, 69, 50, 0.08);
  vertical-align: top;
}

th { color: var(--green-deep); }

.pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.pill.in {
  background: rgba(45, 123, 99, 0.12);
  color: var(--green-deep);
}

.pill.out {
  background: rgba(212, 165, 50, 0.18);
  color: #775204;
}

.table-form {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.table-form select,
.table-form input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(78, 69, 50, 0.12);
}

.mini-btn {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(45, 123, 99, 0.1);
  color: var(--green-deep);
}

.mini-btn.delete {
  background: rgba(173, 73, 62, 0.11);
  color: var(--danger);
}

.filter-row {
  padding: 14px;
  margin-bottom: 14px;
}

.payslip-card {
  padding: 18px;
}

.payslip-head,
.payslip-total {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.payslip-head h3,
.payslip-total strong {
  margin: 0;
}

.slip-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.slip-grid div {
  padding: 14px;
  border-radius: 16px;
  background: var(--surface-strong);
  border: 1px solid rgba(78, 69, 50, 0.08);
}

.slip-grid span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.payslip-total {
  margin-top: 14px;
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(45, 123, 99, 0.12), rgba(212, 165, 50, 0.2));
}

.compact { margin-top: 16px; }

@media (max-width: 900px) {
  .login-shell,
  .hero-card {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .stats-grid,
  .slip-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head,
  .payslip-head,
  .payslip-total {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* تلميح شروط كلمة المرور */
.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  color: #6b6b6b;
  line-height: 1.5;
}
.field-hint-error { color: #ad493e; font-weight: 600; }
.password-control input[dir="ltr"] { text-align: left; }

/* ملف الموظف */
.profile-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.profile-grid strong { word-break: break-word; }
.next-day { color: #8a6d1f; }

/* الإجازات */
.badge {
  display: inline-block;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #ad493e;
  color: #fff;
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
}
.filter-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-tabs .mini-btn { text-decoration: none; }
.filter-tabs .mini-btn.active { background: #2d7b63; color: #fff; }
.status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  white-space: nowrap;
}
.status-pending { background: #fbf0d3; color: #8a6d1f; }
.status-approved { background: #dcefe7; color: #2d7b63; }
.status-rejected { background: #f6e1de; color: #ad493e; }
.status-cancelled { background: #ececec; color: #6b6b6b; }
.decision-form { display: grid; gap: 6px; min-width: 200px; }
.decision-form input { padding: 6px 8px; border-radius: 8px; border: 1px solid #d9d4c7; font: inherit; }
.decision-actions { display: flex; gap: 6px; }
.mini-btn.approve { background: #dcefe7; color: #2d7b63; }

/* تصفية مسيرات الرواتب */
.payroll-filter { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 14px 0 6px; }
.payroll-filter .field { min-width: 140px; }
.total-row td { font-weight: 700; background: #f4f1e9; }

/* الخطابات */
.setting-preview { max-width: 180px; max-height: 120px; border: 1px solid #ddd8cc; border-radius: 10px; padding: 6px; background: #fff; }
.checkbox-line { display: flex; gap: 6px; align-items: center; font-size: 0.85rem; }
.mini-btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* سجل الحركات وكلمة المرور المؤقتة */
.audit-warning td { background: #fbefed; }
.pager { align-items: center; margin-top: 12px; }
.temp-password-panel { max-width: 640px; margin: 40px auto; }
.temp-password { display: flex; gap: 12px; align-items: center; margin: 18px 0; }
.temp-password code { font-size: 1.6rem; letter-spacing: 2px; padding: 10px 16px; border-radius: 10px; background: #f4f1e9; border: 1px dashed #2d7b63; }

/* تقرير الحضور */
.cell-bad { color: #ad493e; font-weight: 700; }
.cell-warn { color: #8a6d1f; font-weight: 700; }
.report-summary { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 6px 0 14px; color: #555; }
tr.day-absent td { background: #f6e1de; }
tr.day-weekend td, tr.day-holiday td, tr.day-not_counted td { color: #9a9a9a; background: #f7f6f2; }
tr.day-leave td { background: #e8f1ed; }
tr.day-weekend_work td { background: #eef0fb; }
.weekday-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.field textarea { width: 100%; border-radius: 12px; border: 1px solid #ddd8cc; padding: 10px; font: inherit; }
/* النسخ الاحتياطي */
.backup-reminder { background: #fbf0d3; border: 1px solid #e8d49a; }
.backup-reminder p { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin: 0; }
.backup-notes { margin: 14px 0; }
.danger-panel { border: 1px solid #e7c4be; }
.btn.danger { color: #ad493e; border-color: #ad493e; }

/* الجوال: أزرار الشريط العلوي تلتف، ولا يوجد تمرير أفقي */
html, body { max-width: 100%; overflow-x: hidden; }
.hero-kicker { display: block; color: #6b6b6b; font-size: 0.9rem; margin-bottom: 4px; }

/* التسجيل السريع للموظف */
.quick-attendance { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; border: 1px solid rgba(45, 123, 99, 0.25); }
.quick-attendance-status { display: grid; gap: 4px; }
.quick-attendance-status span { color: #555; }
.quick-attendance-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.quick-btn { min-width: 150px; min-height: 52px; font-size: 1.05rem; }
.quick-btn[disabled] { opacity: 0.45; cursor: not-allowed; }

@media (max-width: 900px) {
  .topbar-actions { width: 100%; justify-content: flex-start; }
  .topbar-actions > * { flex: 1 1 calc(50% - 10px); }
  .topbar-actions .btn, .topbar-actions form .btn { width: 100%; justify-content: center; }
  .topbar-actions .user-badge { flex-basis: 100%; }
  .quick-attendance-actions { width: 100%; }
  .quick-attendance-actions form { flex: 1 1 0; }
  .quick-btn { width: 100%; min-width: 0; }
  .table-wrap { overflow-x: auto; }
}

/* تنبيه إيقاف الدخول */
.lock-alert { display: grid; gap: 8px; padding: 14px 16px; margin-bottom: 14px; border-radius: 14px; background: #fbefed; border: 1px solid #e7c4be; color: #7d342c; }
.lock-alert form { justify-self: start; }

/* إخفاء الرسائل تلقائيًا */
.flash { transition: opacity 0.4s ease, transform 0.4s ease; cursor: pointer; }
.flash.flash-hide { opacity: 0; transform: translateY(-8px); }

.muted { color: var(--muted, #6b7280); font-size: 0.85em; }
