/* Rumman — First 90 Days Evaluation
   Serious / sharp / document-grade. Inter (Latin) + IBM Plex Sans Arabic.
   Accent #ff4400 used sparingly for emphasis. Squared edges, hairline rules,
   no shadows, no decorative motion. Full RTL via logical properties. */

:root {
  --ink: #1c1c1e;
  --ink-2: #333336;
  --ink-soft: #5f5f66;
  --ink-faint: #8a8a91;
  --paper: #ffffff;
  --bg: #f6f6f6;
  --line: #e2e2e4;
  --line-strong: #c9c9cd;
  --rule: #1c1c1e;
  --accent: #ff4400;
  --accent-ink: #cc3600;
  --bad: #c02b1d;
  --maxw: 900px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-ar: "IBM Plex Sans Arabic", "Inter", -apple-system, "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-optical-sizing: auto;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  font-size: 15px;
}
html[lang="ar"] body,
html[lang="ar"] input,
html[lang="ar"] textarea,
html[lang="ar"] select,
html[lang="ar"] button { font-family: var(--font-ar); }

a { color: var(--accent); }

.tnum, .scorebox, .summary .cell .v, .rownum, .section > h2 .num,
.card .step, .legend .l b, .weight {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* ---------- Top bar ---------- */
.topbar { background: var(--paper); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 20; }
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; text-decoration: none; }
.brand-logo { height: 20px; width: auto; display: block; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--ink); background: var(--paper); color: var(--ink);
  padding: 9px 18px; border-radius: 0; font: inherit; font-weight: 600; font-size: 13px;
  letter-spacing: .01em; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px; transition: background .12s, color .12s;
}
.btn:hover { background: var(--ink); color: #fff; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn-ghost { border-color: transparent; color: var(--ink-soft); padding-inline: 10px; }
.btn-ghost:hover { background: transparent; color: var(--ink); }
.lang-toggle { min-width: 60px; justify-content: center; }

/* ---------- Page shell ---------- */
.page { max-width: var(--maxw); margin: 0 auto; padding: 28px 24px 88px; }
.sheet { background: var(--paper); border: 1px solid var(--rule); padding: 44px 48px; }
.doc-head { text-align: center; padding-bottom: 22px; margin-bottom: 8px; border-bottom: 1px solid var(--rule); }
.doc-head .eyebrow { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
html[lang="ar"] .eyebrow { letter-spacing: 0; }
.doc-head h1 { font-size: 27px; margin: 10px 0 6px; letter-spacing: -.4px; font-weight: 700; }
.doc-head p { color: var(--ink-soft); margin: 0 auto; font-size: 13.5px; max-width: 560px; }

/* ---------- Sections ---------- */
.section { margin-top: 30px; }
.section > h2 {
  font-size: 13px; margin: 0 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--rule);
  display: flex; align-items: baseline; gap: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
}
html[lang="ar"] .section > h2 { text-transform: none; letter-spacing: 0; font-size: 15px; }
.section > h2 .num { color: var(--accent); font-size: 12px; font-weight: 700; }
.section > h2 .weight {
  margin-inline-start: auto; font-size: 10px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent); border: 1px solid var(--accent); padding: 1px 7px;
}
html[lang="ar"] .section > h2 .weight { text-transform: none; letter-spacing: 0; }
.hint { color: var(--ink-soft); font-size: 12.5px; margin: -4px 0 12px; }

/* ---------- Fields ---------- */
.grid { display: grid; gap: 14px 20px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
html[lang="ar"] .field label { text-transform: none; letter-spacing: 0; font-size: 12.5px; }
input[type=text], input[type=date], input[type=number], select, textarea {
  font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong);
  border-radius: 0; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--paper);
}
textarea { resize: vertical; min-height: 36px; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: #b3b3b8; }
.field.invalid input, .field.invalid select { border-color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.form { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.form th, table.form td { border: 1px solid var(--line-strong); padding: 8px 10px; text-align: start; vertical-align: middle; }
table.form thead th { background: var(--paper); font-size: 11px; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-bottom-color: var(--rule); }
html[lang="ar"] table.form thead th { text-transform: none; letter-spacing: 0; font-size: 12.5px; }
table.form td.center, table.form th.center { text-align: center; }
table.form input, table.form select, table.form textarea { border: none; background: transparent; padding: 4px 2px; }
table.form input:focus, table.form select:focus, table.form textarea:focus { box-shadow: inset 0 -1px 0 var(--accent); }
table.form tfoot td { background: #fafafa; font-weight: 700; }
.rownum { color: var(--ink-faint); text-align: center; width: 32px; font-weight: 600; }

.scorebox { display: inline-flex; align-items: baseline; gap: 2px; font-weight: 700; }
.scorebox b { font-size: 15px; }
.scorebox .den { color: var(--ink-faint); font-size: 12px; font-weight: 500; }

/* ---------- Summary ---------- */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--rule); }
.summary .cell { padding: 16px 18px; border-inline-end: 1px solid var(--line-strong); }
.summary .cell:last-child { border-inline-end: none; }
.summary .cell .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); font-weight: 700; }
html[lang="ar"] .summary .cell .k { text-transform: none; letter-spacing: 0; font-size: 12px; }
.summary .cell .v { font-size: 30px; font-weight: 700; margin-top: 6px; line-height: 1; direction: ltr; letter-spacing: -.5px; }
.summary .cell .v .den { font-size: 14px; color: var(--ink-faint); font-weight: 500; }
.summary .cell .sub { font-size: 11.5px; color: var(--ink-soft); margin-top: 5px; }
.summary .cell.final { background: var(--ink); }
.summary .cell.final .k { color: rgba(255,255,255,.6); }
.summary .cell.final .v { color: var(--accent); }
.summary .cell.final .v .den { color: rgba(255,255,255,.55); }
.summary .cell.final .sub { color: rgba(255,255,255,.8); }

/* ---------- Choices ---------- */
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line-strong); border-radius: 0; padding: 11px 14px; cursor: pointer; transition: border-color .12s; }
.choice:hover { border-color: var(--ink); }
.choice input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.choice.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice .label { font-weight: 600; }

/* ---------- Rating legend ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 14px; font-size: 12px; color: var(--ink-soft); }
.legend .l b { color: var(--accent); margin-inline-end: 4px; }

/* ---------- Action bar + alerts ---------- */
.actionbar { position: sticky; bottom: 0; margin-top: 32px; background: var(--paper); border-top: 1px solid var(--rule); padding: 16px 0 4px; display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.actionbar .spacer { margin-inline-end: auto; color: var(--ink-soft); font-size: 12.5px; }
.alert { display: none; padding: 11px 15px; border-radius: 0; font-size: 13.5px; font-weight: 600; margin-top: 16px; border-inline-start: 3px solid; }
.alert.ok { background: #f2f7f3; color: #1f6b43; border-color: #1f6b43; display: block; }
.alert.err { background: #fbf1ef; color: var(--bad); border-color: var(--bad); display: block; }
.alert.info { background: #fff6f2; color: var(--accent-ink); border-color: var(--accent); display: block; }

/* ---------- Landing ---------- */
.hero { text-align: center; padding: 40px 0 8px; }
.hero-logo { height: 30px; width: auto; margin: 0 auto 22px; display: block; }
.hero .eyebrow { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
html[lang="ar"] .hero .eyebrow { letter-spacing: 0; }
.hero h1 { font-size: 32px; margin: 12px 0 0; letter-spacing: -.6px; font-weight: 700; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin-top: 40px; border: 1px solid var(--rule); }
.card { background: var(--paper); border-inline-end: 1px solid var(--line-strong); padding: 28px; display: flex; flex-direction: column; text-decoration: none; color: inherit; transition: background .12s; }
.card:last-child { border-inline-end: none; }
.card:hover { background: #fafafa; }
.card .step { font-size: 11px; color: var(--accent); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
html[lang="ar"] .card .step { text-transform: none; letter-spacing: 0; }
.card h3 { margin: 12px 0 6px; font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.card p { margin: 0 0 20px; color: var(--ink-soft); font-size: 13px; flex: 1; }
.card .go { color: var(--accent); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
html[lang="ar"] .card .go { text-transform: none; letter-spacing: 0; }

@media (max-width: 760px) {
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr; }
  .summary .cell { border-inline-end: none; border-bottom: 1px solid var(--line-strong); }
  .cards { grid-template-columns: 1fr; }
  .card { border-inline-end: none; border-bottom: 1px solid var(--line-strong); }
  .card:last-child { border-bottom: none; }
  .sheet { padding: 26px 18px; }
  .doc-head h1 { font-size: 22px; }
  .hero h1 { font-size: 26px; }
}

/* =====================================================
   PRINT — the filing-ready PDF
   ===================================================== */
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff; font-size: 11px; }
  .topbar, .actionbar, .hint, .no-print, .alert { display: none !important; }
  .page { padding: 0; max-width: none; }
  .sheet { border: none; padding: 0; }
  .doc-head { margin-bottom: 12px; }
  .doc-head h1 { font-size: 17px; }
  .section { margin-top: 16px; break-inside: avoid; }
  input[type=text], input[type=date], input[type=number], select, textarea {
    border: none; border-bottom: 1px solid #999; background: transparent !important; border-radius: 0;
    padding: 1px 2px; color: #000; box-shadow: none !important; -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  textarea { border-bottom: none; }
  table.form, table.form th, table.form td { border-color: #999 !important; }
  table.form input, table.form select, table.form textarea { border-bottom: none; }
  table.form thead th, table.form tfoot td { background: #f2f2f2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .summary, .summary .cell { border-color: #999 !important; }
  .summary .cell.final { background: #1c1c1e !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .summary .cell.final .v { color: #ff4400 !important; }
  .choice { border: 1px solid #999 !important; padding: 6px 10px; break-inside: avoid; box-shadow: none !important; }
  .choice.sel { box-shadow: inset 0 0 0 2px #ff4400 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* =====================================================
   ACCESS GATE (Google Sign-In)
   ===================================================== */
html.locked .topbar, html.locked .page { display: none !important; }
html.locked, html.locked body { height: 100%; overflow: hidden; }

#authGate {
  position: fixed; inset: 0; z-index: 1000; background: var(--paper);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#authGate .authcard {
  width: 100%; max-width: 360px; text-align: center;
  border: 1px solid var(--rule); padding: 40px 32px;
}
#authGate .authlogo { height: 26px; width: auto; margin: 0 auto 24px; display: block; }
#authGate .authmsg { color: var(--ink-soft); font-size: 14px; margin: 0 0 22px; }
#authGate .gbtn { display: flex; justify-content: center; min-height: 44px; }
#authGate .autherr { color: var(--bad); font-size: 13px; font-weight: 600; margin: 18px 0 0; min-height: 18px; }

.user-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-soft); margin-inline-end: 4px; }
.user-chip .ue { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .signout {
  appearance: none; border: 1px solid var(--line-strong); background: var(--paper);
  color: var(--ink-soft); width: 26px; height: 26px; border-radius: 0; cursor: pointer;
  font-size: 13px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.user-chip .signout:hover { border-color: var(--ink); color: var(--ink); }
@media (max-width: 620px) { .user-chip .ue { max-width: 110px; } }

/* ---------- Template editor (Google-Forms-style edit mode) ---------- */
body.tpl-editing [data-tpl-ren] { outline: 1px dashed var(--accent); outline-offset: 2px; cursor: text; min-width: 12px; }
body.tpl-editing [data-tpl-ren]:focus { outline: 2px solid var(--accent); background: #fff8f5; }

/* in edit mode the form is not fillable; answer controls are locked */
body.tpl-editing select,
body.tpl-editing input[type=radio],
body.tpl-editing input[type=checkbox],
body.tpl-editing input[type=number],
body.tpl-editing input[type=date] { pointer-events: none; background: #f4f4f4; color: var(--ink-faint); }
body.tpl-editing .choice { pointer-events: none; }
/* text inputs & textareas become inline placeholder editors */
.tpl-phedit { font-style: italic; color: var(--ink-soft) !important; background: #fff8f5 !important; box-shadow: inset 0 0 0 1px var(--accent) !important; }

.tpl-x {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
  border: 1px solid var(--bad); background: #fff; color: var(--bad); cursor: pointer; font-size: 13px;
  line-height: 1; padding: 0; border-radius: 0; z-index: 5;
}
tr .tpl-x { position: absolute; top: 3px; inset-inline-start: 3px; }
.field .tpl-x { position: absolute; top: 0; inset-inline-end: 0; }
.section > h2 .tpl-x { margin-inline-start: 8px; border-color: var(--bad); }
.tpl-removed { display: none !important; }
body.tpl-editing .tpl-removed { opacity: .4; outline: 1px dashed var(--bad); }
body.tpl-editing tr.tpl-removed { display: table-row !important; }
body.tpl-editing .field.tpl-removed { display: flex !important; }
body.tpl-editing section.tpl-removed { display: block !important; }
.tpl-reset { display: none; }
body.tpl-editing .tpl-reset { display: inline-flex; }
