/* orga.report – one stylesheet for the whole app.
   Colours only through variables from the database (assets/core/look.js); the values here are the
   fallback for the very first start (combination Petrol – Himmel – Blau, light).
   Logical properties (inline-start/end) so the layout also works right to left (Arabic). */

:root {
  --bg: #FCF7F2; --surface: #FFFFFF; --surface-2: #F2EBDE; --ink: #344042; --muted: #4F4843;
  --line: #F2EBDE; --line-strong: #DDD1C3; --accent: #003D54; --accent-ink: #003D54; --accent-soft: #CCF2FA; --on-accent: #FFFFFF;
  --p1: #3B0012; --p1-soft: #FFD9DE; --p2: #5C4500; --p2-soft: #FFF2D4; --p3: #002C60; --p3-soft: #C0E6FF;
  --good: #124F00; --good-soft: #E3FAE0; --overlay: rgba(52, 64, 66, .45);
  --shadow: 0 1px 2px rgba(52, 64, 66, .08), 0 4px 16px rgba(52, 64, 66, .06);
  --topic-1: #00BFDE; --topic-2: #159BFF; --topic-3: #2E4AED;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Arabic", sans-serif;
  --r-s: 10px; --r: 14px; --r-l: 20px;
  --gap: 16px;
  --tabs-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: 220ms;
  color-scheme: light;
}
:root[data-mode="dark"] { color-scheme: dark; }
:root[data-motion="focus"] { --dur: 0ms; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 var(--font); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.icon { flex: none; display: block; }

/* ------------------------------------------------------------ start */
.boot { min-height: 80vh; display: grid; place-items: center; }
.boot-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.7); } }
.boot-fail { font-family: var(--font); padding: 48px 24px; text-align: center; max-width: 420px; margin: 0 auto; color: var(--ink); }
.boot-fail-title { font-size: 19px; font-weight: 700; }
.boot-fail button { margin-top: 12px; padding: 14px 22px; border: 0; border-radius: 24px; background: var(--accent); color: var(--on-accent); font-weight: 700; }
.boot-fail-err { margin-top: 20px; font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------ frame */
.shell { min-height: 100vh; min-height: 100dvh; }
.main { padding-bottom: calc(var(--tabs-h) + var(--safe-b) + 24px); }
.side { display: none; }
.tabs {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; letter-spacing: .01em;
}
.tab.on { color: var(--accent-ink); }
.tab .icon { width: 24px; height: 24px; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 248px 1fr; }
  .tabs { display: none; }
  .main { padding-bottom: 40px; min-width: 0; }
  .side {
    display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; height: 100dvh;
    padding: 18px 12px; border-inline-end: 1px solid var(--line); background: var(--surface);
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 18px; }
  .side-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-s);
    color: var(--ink); text-decoration: none; font-weight: 600;
  }
  .side-link:hover { background: var(--surface-2); }
  .side-link.on { background: var(--accent-soft); color: var(--accent-ink); }
  .side-gap { flex: 1; }
}

.update-bar {
  display: flex; align-items: center; gap: 10px; margin: 10px 16px 0; padding: 10px 14px;
  background: var(--accent-soft); color: var(--accent-ink); border-radius: var(--r); font-weight: 600; font-size: 15px;
}
.update-bar span { flex: 1; }
.update-bar button { border: 0; background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 6px 14px; font-weight: 700; }

/* ------------------------------------------------------------ page */
.page { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.page-wide { max-width: 980px; }
.bar {
  position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: calc(52px + var(--safe-t)); padding-top: var(--safe-t); margin: 0 -16px; padding-inline: 8px;
  background: transparent; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
  border-bottom: 1px solid transparent;
}
.bar-compact {
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
  border-bottom-color: var(--line);
}
.bar-title { font-weight: 700; font-size: 16px; opacity: 0; transition: opacity var(--dur) var(--ease); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.bar-compact .bar-title { opacity: 1; }
.bar-side { display: flex; align-items: center; min-width: 0; }
.bar-actions { justify-content: flex-end; gap: 4px; }
.bar-back {
  display: flex; align-items: center; gap: 2px; border: 0; background: none; color: var(--accent-ink);
  font-weight: 600; padding: 8px 6px; min-height: 44px; border-radius: var(--r-s);
}
[dir="rtl"] .bar-back .icon, [dir="rtl"] .row-chev .icon { transform: scaleX(-1); }
.title { font-size: 32px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 6px; }
.title-sub { margin: -2px 0 10px; color: var(--muted); }
.page-body { padding-top: 8px; }

/* ------------------------------------------------------------ grouped lists */
.section { margin: 0 0 22px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 4px 8px; }
.section-foot { font-size: 13px; color: var(--muted); margin: 8px 4px 0; }
.group { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.group > * + * { border-top: 1px solid var(--line); }
.group > .row + .row { border-top: 0; }
.group > .row + .row::before { content: ""; position: absolute; top: 0; inset-inline: 56px 0; border-top: 1px solid var(--line); }
.row {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px;
  padding: 10px 14px; background: none; border: 0; text-align: start; color: var(--ink); text-decoration: none;
}
.row-tap { transition: background var(--dur) var(--ease); }
.row-tap:active { background: var(--surface-2); }
@media (hover: hover) { .row-tap:hover { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); } }
.row-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent); color: #fff; flex: none; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 500; overflow-wrap: anywhere; }
.row-title.danger { color: var(--p1); }
.row-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row-value { color: var(--muted); font-size: 15px; text-align: end; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-chev, .row-check { color: var(--muted); flex: none; }
.row-check { color: var(--accent-ink); }
.pad { padding: 12px 14px; }
.section-plain { }
.row-form { display: flex; gap: 8px; align-items: center; }
.row-form input { flex: 1; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin: -8px 0 22px; flex-wrap: wrap; }

/* ------------------------------------------------------------ controls */
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-s);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
}
textarea { resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.time-input { width: auto !important; min-height: 36px !important; padding: 4px 10px !important; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px;
  border-radius: 999px; border: 0; font-weight: 700; transition: transform var(--dur) var(--ease), opacity var(--dur);
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-secondary { background: var(--accent-soft); color: var(--accent-ink); }
.btn-ghost { background: none; color: var(--accent-ink); }
.btn-danger { background: var(--p1-soft); color: var(--p1); }
.btn-full { width: 100%; }
.btn-small { min-height: 40px; padding: 8px 14px; }
:root[data-motion="fun"] .btn:active:not(:disabled) { transform: scale(.96); }
.link { border: 0; background: none; color: var(--accent-ink); padding: 8px 0 0; font-weight: 600; text-align: start; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: none; color: var(--accent-ink);
}
.icon-btn:active { background: var(--surface-2); }
.badge {
  position: absolute; top: 4px; inset-inline-end: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--p1); color: var(--p1-soft); font-size: 11px; font-weight: 800; display: grid; place-items: center;
}
.badge-inline { position: static; margin-inline-start: auto; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg-opt { flex: 1; min-height: 38px; border: 0; background: none; border-radius: 9px; font-weight: 600; color: var(--muted); padding: 6px 8px; }
.seg-opt.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.switch { position: relative; flex: none; display: inline-block; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch-track { display: block; width: 51px; height: 31px; border-radius: 16px; background: var(--line-strong); transition: background var(--dur) var(--ease); }
.switch-thumb { position: absolute; top: 2px; inset-inline-start: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform var(--dur) var(--ease); }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
[dir="rtl"] .switch input:checked + .switch-track .switch-thumb { transform: translateX(-20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; min-width: 48px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.field-label { font-size: 14px; font-weight: 600; color: var(--muted); }
.field-hint { font-size: 13px; color: var(--muted); }
.field-error { font-size: 13px; color: var(--p1); }

.note { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r); background: var(--accent-soft); color: var(--accent-ink); margin: 12px 0; font-size: 15px; }
.note-error { background: var(--p1-soft); color: var(--p1); }

.empty { text-align: center; padding: 48px 20px; }
.empty-icon { width: 60px; height: 60px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); margin-bottom: 14px; }
.empty-title { font-size: 18px; font-weight: 700; margin: 0 0 6px; }
.empty-text { color: var(--muted); margin: 0 auto 8px; max-width: 34ch; }

.skel { display: block; height: 14px; border-radius: 7px; background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }

.meter { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.meter span.warn { background: var(--p1); }
.meter-text { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

/* ------------------------------------------------------------ sheet and toasts */
.overlay { position: fixed; inset: 0; z-index: 50; background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; animation: fade var(--dur) var(--ease); }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: var(--r-l) var(--r-l) 0 0; padding-bottom: var(--safe-b);
  animation: rise var(--dur) var(--ease);
}
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: var(--r-l); max-height: 80vh; } }
.sheet-head { position: relative; display: flex; align-items: center; gap: 8px; padding: 18px 8px 8px 18px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 19px; }
.sheet-grip { position: absolute; top: 7px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: var(--line-strong); }
.sheet-body { padding: 8px 18px 12px; overflow: auto; }
.sheet-foot { padding: 8px 18px 16px; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
:root[data-motion="focus"] * { animation-duration: 0ms !important; transition-duration: 0ms !important; }

.toasts { position: fixed; z-index: 60; inset-inline: 0; bottom: calc(var(--tabs-h) + var(--safe-b) + 12px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; max-width: 520px; padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--bg); box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: rise var(--dur) var(--ease); font-weight: 500; }
.toast-error { background: var(--p1); color: var(--p1-soft); }
.toast button { border: 0; background: none; color: inherit; font-weight: 800; text-decoration: underline; padding: 4px; }

/* ------------------------------------------------------------ appearance: colour gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 8px; border-radius: var(--r);
  border: 2px solid transparent; background: var(--surface); box-shadow: var(--shadow); text-align: start; color: var(--ink);
}
.tile.on { border-color: var(--accent); }
.tile-name { font-size: 13px; font-weight: 600; padding: 0 4px 2px; line-height: 1.3; }
.tile-check { position: absolute; top: 12px; inset-inline-end: 12px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.pv { border-radius: 10px; padding: 10px; border: 1px solid; display: flex; flex-direction: column; gap: 8px; }
.pv-card { border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 5px; }
.pv-line { display: block; height: 5px; border-radius: 3px; width: 80%; }
.pv-line.short { width: 50%; }
.pv-btn { display: grid; place-items: center; align-self: flex-end; width: 34px; height: 14px; border-radius: 7px; }
.pv-btn span { width: 14px; height: 3px; border-radius: 2px; }
.pv-fams { display: flex; gap: 3px; }
.pv-fams span { flex: 1; height: 8px; border-radius: 4px; }

/* ------------------------------------------------------------ sign-in */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px calc(24px + var(--safe-b)); }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card h1 { font-size: 30px; margin: 10px 0 0; letter-spacing: -.02em; }
.login-sub { color: var(--muted); margin: 2px 0 28px; }
.login-card form { text-align: start; display: flex; flex-direction: column; gap: 8px; }
.login-hint { color: var(--muted); margin: 0 0 8px; }
.code-input { font-size: 26px !important; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.login-lang { margin-top: 28px; }
