/* Flovent — shared design tokens and components (RTL, light + dark) */
:root {
  --bg: #F3F5F2; --surface: #FFFFFF; --surface-2: #E9EEE9; --line: #D5DCD5; --ink: #17201B; --muted: #5B6A61;
  --accent: #1C6A54; --accent-ink: #FFFFFF; --accent-soft: #DBEDE5; --gold: #9A6C17; --gold-soft: #F5ECD9;
  --ok: #2B7A4B; --ok-soft: #E0F1E5; --warn: #A15C00; --warn-soft: #FBEAD1; --bad: #B13434; --bad-soft: #F8E0DF;
  --info: #2F5D9E; --info-soft: #E2EAF6;
  --f-display: "Readex Pro", "IBM Plex Sans Arabic", Tahoma, sans-serif;
  --f-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --r: 12px; --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 6px 24px rgba(20, 30, 25, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1513; --surface: #17201C; --surface-2: #1F2A25; --line: #2D3A34; --ink: #E8EFEA; --muted: #9AABA1;
    --accent: #5CC6A3; --accent-ink: #0A1712; --accent-soft: #193A2F; --gold: #DDB25E; --gold-soft: #3A2E15;
    --ok: #6ED096; --ok-soft: #183323; --warn: #F2B65C; --warn-soft: #3A2B13; --bad: #F18D8D; --bad-soft: #3B1D1D;
    --info: #86AEEA; --info-soft: #1A2A41; --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1513; --surface: #17201C; --surface-2: #1F2A25; --line: #2D3A34; --ink: #E8EFEA; --muted: #9AABA1;
  --accent: #5CC6A3; --accent-ink: #0A1712; --accent-soft: #193A2F; --gold: #DDB25E; --gold-soft: #3A2E15;
  --ok: #6ED096; --ok-soft: #183323; --warn: #F2B65C; --warn-soft: #3A2B13; --bad: #F18D8D; --bad-soft: #3B1D1D;
  --info: #86AEEA; --info-soft: #1A2A41; --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.6; }
h1, h2, h3, h4 { font-family: var(--f-display); margin: 0; line-height: 1.25; text-wrap: balance; font-weight: 600; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
img { max-width: 100%; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; direction: ltr; unicode-bidi: embed; }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: embed; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { font-size: 12px; color: var(--muted); font-weight: 600; }
.wrap { max-width: 1240px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)); }
.hidden, [hidden] { display: none !important; }

/* brand mark: two linked rings */
.mark { position: relative; display: inline-block; width: 34px; height: 24px; flex: none; }
.mark i { position: absolute; top: 1px; width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--accent); }
.mark i + i { inset-inline-start: 11px; border-color: var(--gold); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--f-display); font-weight: 700; font-size: 20px; letter-spacing: .01em; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 8px 16px; cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--ink); line-height: 1.4; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.gold { background: var(--gold); color: #fff; border-color: var(--gold); }
.btn.wa { background: #1F8F55; border-color: #1F8F55; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 12px 22px; font-size: 16px; border-radius: 11px; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger.armed { background: var(--bad); color: var(--surface); }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; font-size: 18px; line-height: 1; }
.icon-btn:hover { background: var(--bad-soft); color: var(--bad); }

/* fields */
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=search], input[type=url], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%; min-width: 0; }
input[type=number], input[type=tel], input[type=email], input[type=url] { direction: ltr; text-align: right; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 5px; accent-color: var(--accent); }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.card h3 { font-size: 16px; margin-bottom: 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.full { grid-column: 1 / -1; }

/* pills, bars */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }
.pill.gold { background: var(--gold-soft); color: var(--gold); }
.bar { height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; display: flex; }
.bar > i { display: block; height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }

/* tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th { text-align: start; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td input, td select { border-color: transparent !important; background: transparent !important; padding: 7px; box-shadow: none !important; }
td input:hover, td select:hover { border-color: var(--line) !important; }
td input:focus, td select:focus { border-color: var(--accent) !important; background: var(--surface) !important; }
td.c, th.c { text-align: center; }
.empty-row td { padding: 24px; text-align: center; color: var(--muted); }

/* dialog, toasts */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); padding: 0; width: min(580px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
dialog::backdrop { background: rgba(8, 14, 11, .5); }
dialog form, dialog .dlg-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
dialog .end { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toasts { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); inset-inline-start: 50%; transform: translateX(50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; transition: opacity .3s; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.out { opacity: 0; }

.setup-note { max-width: 620px; margin: 60px auto; background: var(--warn-soft); color: var(--ink); border-radius: 14px; padding: 24px; }
.setup-note h2 { font-size: 20px; margin-bottom: 8px; }
.loading { padding: 60px 0; text-align: center; color: var(--muted); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto 10px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media (max-width: 760px) {
  .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
}
@media print {
  .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border-color: #ccc; }
}
