:root {
  --blue-900: #1F4E9E;
  --blue-700: #3D6DAE;
  --blue-400: #6E9BD0;
  --link: #2563C9;
  --bg: #F3F6F9;
  --card: #FFFFFF;
  --ink: #16253A;
  --muted: #4B5B70;
  --line: #E6ECF2;
  --yellow: #F6C94C;
  --yellow-ink: #8A6400;
  --green: #1F7A52;
  --brick: #B5452E;
  --tint: #E8F0FB;
  --shadow: 0 1px 3px rgba(22, 37, 58, 0.08);
  --radius: 16px;
  font-family: 'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif;
  color: var(--ink);
}

[dir='rtl'] { font-family: 'IBM Plex Sans Arabic', 'IBM Plex Sans', system-ui, sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; background: #DDE5EE; }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; position: relative; }

.hero {
  background: linear-gradient(165deg, var(--blue-900) 0%, var(--blue-700) 65%, var(--blue-400) 100%);
  color: #fff; padding: calc(env(safe-area-inset-top, 0px) + 20px) 20px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
[dir='rtl'] .hero { background: linear-gradient(195deg, var(--blue-900) 0%, var(--blue-700) 65%, var(--blue-400) 100%); }
.hero h1 { margin: 0; font-weight: 300; font-size: 32px; line-height: 1.15; }
.hero .sub { font-size: 14px; color: #E3ECF8; line-height: 1.5; margin: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 600; font-size: 22px; }
.brand svg { width: 26px; height: 32px; }

.lang { display: flex; background: rgba(255,255,255,0.18); border-radius: 22px; padding: 3px; }
.lang button { min-width: 44px; height: 38px; border-radius: 19px; border: 0; background: transparent; color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; }
.lang button.on { background: #fff; color: var(--blue-900); }
.lang button[data-l='ar'] { font-family: 'IBM Plex Sans Arabic', sans-serif; font-size: 15px; }

.iconbtn { width: 44px; height: 44px; border-radius: 22px; border: 0; background: rgba(255,255,255,0.18); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; }
.iconbtn svg { width: 20px; height: 20px; }
[dir='rtl'] .flip { transform: scaleX(-1); }

.progress { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #E3ECF8; }
.chev { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-weight: 600; letter-spacing: 6px; font-size: 18px; color: rgba(255,255,255,0.35); }
.chev b { color: var(--yellow); font-weight: 600; }
[dir='rtl'] .chev { display: inline-block; transform: scaleX(-1); }

.body { flex: 1; padding: 16px 20px 8px; display: flex; flex-direction: column; gap: 10px; }
.label { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 6px; }
.note { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 0; }
.foot { padding: 12px 20px calc(env(safe-area-inset-bottom, 0px) + 24px); display: flex; flex-direction: column; gap: 8px; }
.indep { font-size: 11px; line-height: 1.45; color: var(--muted); text-align: center; margin: 0; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card.info, .card.warn, .card.alert, .card.ok { border-top: 4px solid var(--blue-700); display: flex; gap: 10px; align-items: flex-start; }
.card.warn { border-top-color: var(--yellow); }
.card.alert { border-top-color: var(--brick); }
.card.ok { border-top-color: var(--green); }
.pastille { width: 22px; height: 22px; border-radius: 11px; color: #fff; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--blue-700); }
.warn .pastille { background: #D9A21B; }
.alert .pastille { background: var(--brick); }
.ok .pastille { background: var(--green); }
.card p { margin: 0; font-size: 14px; line-height: 1.5; }

.btn { height: 54px; border-radius: 27px; border: 0; background: var(--yellow); color: var(--ink); font-weight: 600; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost { background: var(--card); color: var(--link); box-shadow: 0 1px 4px rgba(22,37,58,0.15); }
.btn.danger { background: var(--brick); color: #fff; }
.btn.small { height: 44px; font-size: 14px; width: auto; padding: 0 18px; }
.linkbtn { background: none; border: 0; color: var(--link); font-weight: 500; font-size: 15px; min-height: 44px; cursor: pointer; padding: 0; }

.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { height: 66px; border-radius: 14px; border: 2px solid transparent; background: var(--card); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
.tile .code { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 15px; color: var(--link); }
.tile .name { font-size: 13px; }
.tile.on, .chip.on, .opt.on { border-color: var(--link); background: var(--tint); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 44px; padding: 0 14px; border-radius: 22px; border: 2px solid transparent; background: var(--card); box-shadow: var(--shadow); font-size: 14px; cursor: pointer; }

.field { background: var(--card); border-radius: 14px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); }
.field span { font-size: 12px; color: var(--muted); }
.field input, .field textarea, .field select { border: 0; outline: 0; background: transparent; font-size: 16px; font-weight: 600; padding: 2px 0; width: 100%; }
.field textarea { font-family: 'IBM Plex Mono', monospace; font-size: 13px; font-weight: 500; resize: vertical; }
.field:focus-within { box-shadow: 0 0 0 2px var(--link); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.doc { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.doc.todo { background: transparent; box-shadow: none; border: 1.5px dashed #A9B7C7; }
.doc.busy { border-top: 4px solid var(--yellow); }
.doc .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.doc .t { font-weight: 600; font-size: 15px; }
.doc .h { font-size: 13px; color: var(--muted); }
.tag { font-size: 13px; font-weight: 600; color: var(--green); white-space: nowrap; }
.tag.warn { color: var(--yellow-ink); }
.tag.missing { color: var(--brick); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 12px; background: var(--tint); color: var(--blue-900); padding: 3px 8px; border-radius: 6px; }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.opt { height: 56px; border-radius: 14px; border: 2px solid transparent; background: var(--card); box-shadow: var(--shadow); font-size: 15px; text-align: start; padding: 0 16px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; }

.list { background: var(--card); border-radius: var(--radius); padding: 4px 16px; box-shadow: var(--shadow); }
.li { display: flex; gap: 12px; align-items: center; min-height: 48px; border-bottom: 1px solid var(--line); font-size: 14px; padding: 8px 0; }
.li:last-child { border-bottom: 0; }
.li .m { font-family: 'IBM Plex Mono', monospace; font-weight: 600; width: 16px; color: var(--link); }
.li .m.ok { color: var(--green); }
.li .m.warn { color: #D9A21B; }
.li .m.missing { color: var(--brick); }
.li .m.todo { color: #C7D3E0; }
.li .grow { flex: 1; line-height: 1.45; }
[dir='rtl'] .li .m { transform: scaleX(-1); }

.price { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid rgba(255,255,255,0.25); padding-top: 12px; }
.price b { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 26px; }
.mono { font-family: 'IBM Plex Mono', monospace; }

.filecard { cursor: pointer; text-decoration: none; color: inherit; display: block; }
.filecard .row { display: flex; justify-content: space-between; align-items: center; }
.filecard .t { font-weight: 600; font-size: 16px; }
.filecard .h { font-size: 13px; color: var(--muted); margin-top: 2px; }
.badge { font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 8px; background: var(--tint); color: var(--blue-900); }
.badge.pret, .badge.decision { background: #E2F1E9; color: var(--green); }
.badge.a_corriger { background: #F7E3DE; color: var(--brick); }

.sheet-wrap { position: fixed; inset: 0; background: rgba(22,37,58,0.45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { background: var(--bg); width: 100%; max-width: 480px; border-radius: 28px 28px 0 0; padding: 22px 20px calc(env(safe-area-inset-bottom, 0px) + 24px); display: flex; flex-direction: column; gap: 12px; max-height: 88vh; overflow: auto; }
.sheet h2 { margin: 0; font-weight: 500; font-size: 22px; }

.chat { display: flex; flex-direction: column; gap: 8px; max-height: 45vh; overflow: auto; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.bubble.me { align-self: flex-end; background: var(--blue-900); color: #fff; border-end-end-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--card); box-shadow: var(--shadow); border-end-start-radius: 4px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; z-index: 20; max-width: 90%; }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }
.hidden { display: none !important; }
