/* ===== alhijri — Umm al-Qura date tools. Mobile first, RTL first. ===== */

@font-face {
  font-family: 'JF Flat';
  src: url('font/JF-Flat-regular.woff') format('woff'),
       url('font/JF-Flat-regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

:root {
  --paper:   #f4f2ec;
  --card:    #ffffff;
  --ink:     #14201b;
  --ink-mid: #52605a;
  --ink-dim: #8a938e;
  --line:    #e2ded3;
  --accent:  #0d7a52;
  --accent-soft: #e6f2ec;
  --gold:    #9a7233;
  --gold-soft: #f6efe2;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20,32,27,.05), 0 8px 24px -12px rgba(20,32,27,.14);
  --sans: 'JF Flat', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans Arabic', Tahoma, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:   #0d1310;
    --card:    #161f1a;
    --ink:     #e9ece8;
    --ink-mid: #a3aea7;
    --ink-dim: #6e7a73;
    --line:    #273229;
    --accent:  #3fbd88;
    --accent-soft: #14281f;
    --gold:    #d2a85e;
    --gold-soft: #241e12;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --paper:   #0d1310;
  --card:    #161f1a;
  --ink:     #e9ece8;
  --ink-mid: #a3aea7;
  --ink-dim: #6e7a73;
  --line:    #273229;
  --accent:  #3fbd88;
  --accent-soft: #14281f;
  --gold:    #d2a85e;
  --gold-soft: #241e12;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
}

/* lets the native date picker and its icon follow the theme */
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  padding: 0 16px 48px;
  overflow-x: hidden;
}

.wrap { max-width: 640px; margin: 0 auto; }

/* ---------- header ---------- */

.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 18px 0 14px;
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: inherit; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 auto;
  background: var(--accent);
  display: grid; place-items: center;
}
.brand .mark svg { width: 19px; height: 19px; display: block; }
.brand b { font-size: 19px; font-weight: 400; letter-spacing: .2px; }
.brand span { color: var(--ink-dim); font-size: 13px; display: block; margin-top: -3px; }

.themebtn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-mid);
  width: 40px; height: 40px; border-radius: 12px; font-size: 17px;
  cursor: pointer; flex: 0 0 auto; display: grid; place-items: center;
}
.themebtn:active { transform: scale(.94); }

/* ---------- today card ---------- */

.today {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; text-align: center; margin-bottom: 18px;
  position: relative; overflow: hidden;
}
.today::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 0; bottom: 0;
  width: 4px; background: linear-gradient(var(--accent), var(--gold));
}
.today .lbl { font-size: 12px; color: var(--ink-dim); letter-spacing: .6px; }
.today .h {
  font-size: clamp(25px, 7.2vw, 34px); line-height: 1.25;
  margin: 6px 0 2px; color: var(--accent);
}
.today .g { font-size: 16px; color: var(--ink-mid); }
.today .wd {
  display: inline-block; margin-top: 10px; padding: 3px 12px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; font-size: 13px;
}

/* ---------- tabs ---------- */

.tabs {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 18px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; position: sticky; top: 8px; z-index: 20;
  box-shadow: var(--shadow);
}
.tabs button {
  flex: 1 1 0; min-width: 0; padding: 10px 4px;
  border: 0; background: transparent; color: var(--ink-mid);
  font-family: inherit; font-size: 15px; border-radius: 10px;
  cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { background: var(--accent); color: #fff; }

/* ---------- panels & cards ---------- */

.panel[hidden] { display: none; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card > h2 {
  margin: 0 0 14px; font-size: 17px; font-weight: 400; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.card > h2 i { color: var(--accent); font-style: normal; }
.hint { font-size: 13px; color: var(--ink-dim); margin: 0 0 12px; }

/* ---------- form controls ---------- */

label.fl { display: block; font-size: 13px; color: var(--ink-mid); margin-bottom: 6px; }

input[type="date"], input[type="number"], select {
  width: 100%; padding: 12px 12px; font-family: inherit; font-size: 16px;
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 12px;
  min-height: 48px; appearance: none;
}
input[type="date"] { text-align: start; }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-mid) 50%),
                    linear-gradient(135deg, var(--ink-mid) 50%, transparent 50%);
  background-position: left 14px center, left 19px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  /* the arrow is drawn at the physical left, which is the inline END in RTL,
     so the text needs its breathing room on that side or digits collide with it */
  padding-inline-end: 32px;
}
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.trio { display: grid; grid-template-columns: 1fr 1.5fr 1fr; gap: 8px; }
.duo  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg { display: flex; gap: 4px; padding: 3px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 11px; margin-bottom: 14px; }
.seg button {
  flex: 1; padding: 9px 6px; border: 0; background: transparent;
  color: var(--ink-mid); font-family: inherit; font-size: 14px;
  border-radius: 8px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; min-height: 46px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--paper); color: var(--ink-mid);
  font-family: inherit; font-size: 15px; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn.wide { width: 100%; }

/* ---------- results ---------- */

.out {
  margin-top: 14px; padding: 16px; border-radius: 13px;
  background: var(--accent-soft); text-align: center;
}
/* nothing entered yet -> no empty coloured bar */
.out:empty { display: none; }
.out .big {
  font-size: clamp(21px, 6vw, 27px); color: var(--accent); line-height: 1.3;
}
.out .sub { font-size: 14px; color: var(--ink-mid); margin-top: 5px; }
.out.bad { background: var(--gold-soft); }
.out.bad .big { font-size: 16px; color: var(--gold); }

.rows { margin-top: 14px; border-top: 1px solid var(--line); }
.rows:empty { display: none; }
.rows div {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.rows div span:first-child { color: var(--ink-mid); }
.rows div span:last-child { color: var(--ink); text-align: end; }
.rows div b { font-weight: 400; color: var(--accent); }

/* ---------- salary ---------- */

.pay { display: grid; gap: 12px; }
.paycard {
  border: 1px solid var(--line); border-radius: 13px; padding: 15px;
  background: var(--paper);
}
.paycard .who { font-size: 14px; color: var(--ink-mid); }
.paycard .when { font-size: 20px; color: var(--accent); margin: 4px 0 2px; }
.paycard .cd { font-size: 14px; color: var(--gold); }
.paycard .hij { font-size: 13px; color: var(--ink-dim); }

table.sched { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 14px; }
table.sched th, table.sched td {
  padding: 9px 6px; border-bottom: 1px solid var(--line); text-align: start;
}
table.sched th { color: var(--ink-dim); font-weight: 400; font-size: 12px; }
table.sched td.n { color: var(--ink-mid); }
table.sched tr.past td { color: var(--ink-dim); }
table.sched tr.past .tag { opacity: .45; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.tag.off { background: var(--accent-soft); color: var(--accent); }
.tag.exp { background: var(--gold-soft); color: var(--gold); }

/* ---------- footer ---------- */

footer {
  margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--ink-dim); line-height: 1.8;
}
footer a { color: var(--accent); }
footer p { margin: 0 0 9px; }

.months { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px;
  font-size: 14px; color: var(--ink-mid); }
.months div { padding: 6px 0; border-bottom: 1px solid var(--line); }
.months div b { color: var(--ink-dim); font-weight: 400; font-size: 12px; }

@media (min-width: 560px) {
  .trio { grid-template-columns: 1fr 1.8fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- ads ---------- */
/* reserve height so a loading ad cannot shove content around (layout shift) */
/* no min-height on purpose: an unfilled AdSense unit collapses to zero, and
   reserving space for it would leave a permanent blank band on the page */
.adwrap { margin: 18px 0; }
.adwrap:empty { display: none; margin: 0; }
.adsbygoogle { display: block; }

/* ---------- prose / FAQ ---------- */
.prose { margin-top: 26px; }
.prose h2 {
  font-size: 18px; font-weight: 400; color: var(--ink);
  margin: 22px 0 10px;
}
.prose p { font-size: 15px; color: var(--ink-mid); margin: 0 0 12px; }
.prose details {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 14px; margin-bottom: 8px;
}
.prose details[open] { padding-bottom: 4px; }
.prose summary {
  cursor: pointer; padding: 13px 0; font-size: 15px; color: var(--ink);
  list-style: none; display: flex; justify-content: space-between; align-items: center;
  gap: 10px; min-height: 46px;
}
.prose summary::-webkit-details-marker { display: none; }
.prose summary::after {
  content: '+'; color: var(--accent); font-size: 19px; flex: 0 0 auto;
}
.prose details[open] summary::after { content: '−'; }
.prose details p { font-size: 14.5px; margin: 0 0 12px; }
