/* Jood interface. Colours are the owner's brand ("ألوان جود"); every colour is a token below,
   redefined for dark mode. Mobile first, right to left, buttons at least 44px. */

@font-face { font-family: Cairo; font-style: normal; font-display: swap; font-weight: 200 1000;
  src: url(../fonts/cairo-arabic-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: Cairo; font-style: normal; font-display: swap; font-weight: 200 1000;
  src: url(../fonts/cairo-latin-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Vazirmatn; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(../fonts/vazirmatn-arabic-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: Vazirmatn; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(../fonts/vazirmatn-latin-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  color-scheme: light;
  --bg: #F6F7EF; --card: #FFFFFF; --text: #1F2A1C; --muted: #5E7152;
  --primary: #3F5736; --on-primary: #FFFFFF; --brand: #D9DCC7; --decor: #95A786;
  --wordmark: #3F5736; --accent: #8A6A1F; --status: #3F5736; --danger: #A3443B;
  --line: #DFE2D2; --soft: #EEF0E4; --overlay: rgba(23, 27, 20, .45);
  --radius: 14px; --shadow: 0 1px 2px rgba(31, 42, 28, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #171B14; --card: #20261C; --text: #E8EBDD; --muted: #A9B49C;
    --primary: #D9DCC7; --on-primary: #171B14; --brand: #D9DCC7; --decor: #95A786;
    --wordmark: #D9DCC7; --accent: #D4B36A; --status: #B7CCA3; --danger: #E09A93;
    --line: #343C2E; --soft: #2A3125; --overlay: rgba(0, 0, 0, .55); --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171B14; --card: #20261C; --text: #E8EBDD; --muted: #A9B49C;
  --primary: #D9DCC7; --on-primary: #171B14; --brand: #D9DCC7; --decor: #95A786;
  --wordmark: #D9DCC7; --accent: #D4B36A; --status: #B7CCA3; --danger: #E09A93;
  --line: #343C2E; --soft: #2A3125; --overlay: rgba(0, 0, 0, .55); --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 17px/1.6 Cairo, system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  font-variant-numeric: tabular-nums; min-height: 100vh;
}
h1, h2, h3 { line-height: 1.3; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--decor); outline-offset: 2px; }
.ltr { direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- logo ---- */
.logo { display: inline-flex; align-items: center; gap: .55em; text-decoration: none; }
.logo .mark { width: 1.9em; height: 1.9em; flex: none; }
.logo .mark .petal { fill: var(--brand); }
.logo .mark .dot { fill: var(--decor); }
.logo .word { font-family: Vazirmatn, Cairo, sans-serif; font-weight: 900; color: var(--wordmark); font-size: 1.7em; line-height: 1; }

/* ---- controls ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 44px; padding: 0 1.1em; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.block { width: 100%; }
.btn.icon { padding: 0; width: 44px; position: relative; }
.btn[disabled] { opacity: .6; cursor: progress; }
.field { display: grid; gap: .3em; }
.field label { font-weight: 700; font-size: .95rem; }
.input {
  min-height: 48px; padding: .4em .8em; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); width: 100%;
}
.input:focus { border-color: var(--decor); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--decor) 35%, transparent); }
.error { color: var(--danger); font-weight: 700; }
.chip {
  display: inline-flex; align-items: center; min-height: 30px; padding: 0 .85em; border-radius: 999px;
  border: 1px solid var(--status); color: var(--status); font-size: .9rem; font-weight: 700; white-space: nowrap;
}
.chip.done { border-color: var(--text); color: var(--text); }
.chip.cancelled, .chip.danger { border-color: var(--danger); color: var(--danger); }
.chip.gold { border-color: var(--accent); color: var(--accent); }
.badge {
  position: absolute; top: 4px; inset-inline-end: 2px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--accent); color: var(--on-primary); font-size: .75rem; font-weight: 800;
  display: grid; place-items: center; line-height: 1;
}

/* ---- cards and lists ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stack { display: grid; gap: 12px; }
.section { display: grid; gap: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.event-title { font-size: 1.1rem; font-weight: 800; }
.meta { color: var(--muted); font-size: .95rem; }
.empty { color: var(--muted); padding: 8px 0; }
.check {
  width: 28px; height: 28px; flex: none; border-radius: 8px; border: 2px solid var(--decor);
  background: transparent; cursor: pointer; display: grid; place-items: center;
}
.check.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-row { display: flex; gap: 12px; align-items: flex-start; }
.task-row .grow { flex: 1; min-width: 0; }
.alert-row { display: grid; gap: 6px; justify-items: start; }
.alert-row + .alert-row { border-top: 1px solid var(--line); padding-top: 12px; }
.alert-card { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.alert-card .grow { flex: 1; display: grid; gap: 6px; justify-items: start; }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 72px 16px 24px; position: relative; }
.login-tools { position: absolute; top: max(12px, env(safe-area-inset-top)); inset-inline-end: 12px; display: flex; gap: 8px; }
.login .card { width: min(420px, 100%); padding: 28px 22px; display: grid; gap: 18px; }
.login .logo { font-size: 1.5rem; justify-content: center; }
.login h1 { text-align: center; font-size: 1.3rem; }

/* ---- shell ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .logo { font-size: .95rem; margin-inline-end: auto; }
.topbar { gap: 6px; }
.lang-btn { width: auto; min-width: 44px; padding: 0 10px; }
.lang-btn span { font-weight: 800; font-size: .95rem; }
.refresh-btn { padding: 0 10px; gap: 6px; min-width: 64px; }
.refresh-btn[hidden] { display: none; }
.refresh-btn .count { min-width: 2ch; font-weight: 800; text-align: center; }
.refresh-btn.paused { color: var(--muted); }
.refresh-btn svg { width: 20px; height: 20px; }
/* Narrow phones: slightly smaller top bar buttons so all of them fit beside the logo. */
@media (max-width: 400px) {
  .topbar { gap: 4px; padding-inline: 8px; }
  .topbar .btn.icon { width: 40px; min-height: 40px; }
  .topbar .lang-btn { min-width: 40px; padding: 0 8px; }
  .refresh-btn { min-height: 40px; min-width: 58px; padding: 0 8px; }
  .topbar .logo { font-size: .85rem; }
  .seg button { padding: 0 6px; font-size: .9rem; }
}
.layout { display: grid; grid-template-columns: 1fr; }
.content { padding: 16px; padding-bottom: 48px; width: 100%; max-width: 980px; margin: 0 auto; display: grid; gap: 22px; }
.nav {
  position: fixed; inset-block: 0; inset-inline-start: 0; width: min(300px, 86vw); z-index: 40;
  background: var(--card); border-inline-end: 1px solid var(--line); padding: 16px 12px;
  transform: translateX(100%); transition: transform .2s ease; display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.nav.open { transform: none; }
[dir="ltr"] .nav:not(.open) { transform: translateX(-100%); }
.nav .logo { font-size: 1rem; padding: 4px 8px 14px; }
.nav a {
  display: flex; align-items: center; min-height: 46px; padding: 0 14px; border-radius: 10px;
  text-decoration: none; font-weight: 700; color: var(--text);
}
.nav a:hover { background: var(--soft); }
.nav a[aria-current="page"] { background: var(--primary); color: var(--on-primary); }
.nav .spacer { flex: 1; }
.nav .who { padding: 10px 14px; border-top: 1px solid var(--line); margin-top: 8px; }
.scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 30; }
.menu-btn { display: inline-flex; }
@media (min-width: 900px) {
  .layout { grid-template-columns: 260px 1fr; }
  .nav, [dir="ltr"] .nav:not(.open) { position: sticky; top: 0; height: 100vh; transform: none; width: auto; z-index: 10; }
  .scrim, .menu-btn { display: none; }
  .topbar .logo { visibility: hidden; }
  .content { padding: 24px 28px 48px; }
}
@media (prefers-reduced-motion: reduce) { .nav { transition: none; } }

.page-head { display: grid; gap: 4px; }
.toast {
  position: fixed; inset-inline: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 50;
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 12px 16px; font-weight: 700; text-align: center;
}
.seg { display: flex; width: 100%; max-width: 420px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; min-height: 44px; padding: 0 12px; border: 0; background: var(--card); cursor: pointer; font-weight: 700; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

/* ---- dialogs, action messages, forms ---- */
.dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); padding: 20px; width: min(440px, calc(100vw - 32px)); }
.dialog::backdrop { background: var(--overlay); }
.dialog-actions { justify-content: flex-start; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--card); }
.toast-action { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: start; }
.toast-btn { min-height: 38px; background: transparent; color: inherit; border-color: currentColor; }
.form-grid { display: grid; gap: 14px; }
@media (min-width: 700px) { .form-grid.two { grid-template-columns: 1fr 1fr; } .form-grid .wide { grid-column: 1 / -1; } }
.input.invalid { border-color: var(--danger); }
textarea.input { min-height: 96px; resize: vertical; }
.search { position: relative; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-decoration: none; color: inherit; }
.list-item:hover { border-color: var(--decor); }
.list-item .grow { min-width: 0; flex: 1; display: grid; gap: 2px; }
.list-item .name { font-weight: 800; font-size: 1.05rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.chip.vip { border-color: var(--accent); color: var(--accent); }
.back { text-decoration: none; color: var(--muted); font-weight: 700; display: inline-flex; min-height: 44px; align-items: center; }

.card.soft { background: var(--soft); box-shadow: none; }
.card-link { cursor: pointer; border-radius: var(--radius); }
.card-link:hover .card { border-color: var(--decor); }
.card-link:focus-within .card { border-color: var(--decor); }
.list-pick { justify-content: flex-start; width: 100%; font-weight: 600; }
.dialog p { white-space: pre-line; }
.seg + .seg { margin-top: -4px; }
input[type="date"].input, input[type="time"].input { min-height: 48px; }

/* ---- receipt, and printing ---- */
.receipt { max-width: 640px; }
.receipt-head { align-items: flex-start; border-bottom: 2px solid var(--text); padding-bottom: 12px; }
.receipt-head p { margin: 0; }
@media print {
  :root, :root[data-theme="dark"] { --bg: #fff; --card: #fff; --text: #000; --muted: #444; --line: #ccc; --shadow: none; color-scheme: light; }
  .topbar, .nav, .scrim, .no-print, .toast { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
  body { background: #fff; }
}

/* ---- calendar ---- */
.cal { padding: 12px; }
.cal-head { flex-wrap: nowrap; }
.cal-title { text-align: center; }
.cal-title h2 { font-size: 1.15rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-wd { text-align: center; font-size: .72rem; color: var(--muted); font-weight: 700; padding-bottom: 4px; overflow: hidden; white-space: nowrap; text-overflow: clip; }
.cal-cell {
  position: relative; aspect-ratio: 1 / 1; min-height: 44px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.cal-cell.empty { cursor: default; }
.cal-cell .num { font-weight: 700; font-size: .95rem; }
.cal-cell.busy { background: var(--soft); }
.cal-cell.today { border-color: var(--decor); }
.cal-cell.today .num { color: var(--status); font-weight: 900; }
.cal-cell.selected { background: var(--primary); }
.cal-cell.selected .num, .cal-cell.selected.today .num { color: var(--on-primary); }
.cal-cell .count {
  position: absolute; bottom: 3px; inset-inline-end: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
  background: var(--accent); color: var(--card); font-size: .68rem; font-weight: 800; display: grid; place-items: center; line-height: 1;
}
.cal-cell .count.all-done { background: var(--muted); }
@media (min-width: 700px) { .cal-wd { font-size: .85rem; } .cal-cell { aspect-ratio: 4 / 3; } }

/* ---- printed documents: quotes, contracts, invoices ---- */
.doc-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.doc-table th, .doc-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: start; }
.doc-table th { color: var(--muted); font-weight: 700; font-size: .9rem; }
.doc-totals { margin-inline-start: auto; min-width: min(280px, 100%); }
.doc-totals dd { text-align: end; }
.doc-notes { white-space: pre-wrap; color: var(--muted); }
.signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 24px; }
.sign-line { border-bottom: 1px solid var(--text); height: 48px; }
.line-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.line-row .line-item { grid-column: 1 / -1; }
@media (min-width: 700px) { .line-row { grid-template-columns: 3fr 1fr 1.4fr auto; } .line-row .line-item { grid-column: auto; } }

/* ---- report tables ---- */
.table-wrap { overflow-x: auto; padding: 0; }
.report { min-width: 520px; }
.report th, .report td { white-space: nowrap; padding: 10px 12px; }
.report td.num { text-align: end; }
.report tfoot td { font-weight: 800; border-top: 2px solid var(--text); border-bottom: 0; }

.checkbox { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
label.row { cursor: pointer; }

/* Password fields: the eye button sits on the right, where an LTR password ends. */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 52px; }
.reveal {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px;
  display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 8px;
}
.reveal:hover { color: var(--text); }
