/* ==========================================================
   Darb shared styles
   Base styles + the components every page reuses.
   See shared/components.html for a live example of each one.

   Contents
     1. Base
     2. Text
     3. Buttons
     4. Form fields
     5. Cards and tiles
     6. Chips, pills, segmented control
     7. Feedback: alert, toast, modal, spinner, skeleton, empty state
     8. Small pieces: avatar, divider, progress bar, table, glass
     9. Motion helpers
    10. Page building blocks: toolbar, table card, stat card, form row, side panel
    11. App layout: sidebar, header, footer (built by layout.js)
    12. Public layout: top bar and footer for the landing page
    13. Auth layout: logo + centered card
   13b. Error layout: logo + centered message (403, 404, 500)
    14. Responsive rules (tablet, phone, small phone)

   Rules:
   - Use the tokens from variables.css, never raw colors.
   - Use logical properties (margin-inline-start, not margin-left)
     so everything works in Arabic (RTL) too.
   ========================================================== */

@import url('variables.css');

/* ==========================================================
   1. Base
   ========================================================== */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* The "hidden" attribute always hides, even on elements we give a display to */
[hidden] {
  display: none !important;
}

/* Keyboard focus ring, same on every control */
:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* Soft colored glow background. Put it on a hero, an auth page or the home page. */
.bg-aurora {
  background: var(--gradient-aurora), var(--bg);
}

/* Centers page content and keeps it from getting too wide */
.container {
  width: 100%;
  max-width: var(--content-w);
  margin-inline: auto;
  padding-inline: 24px;
}

/* ==========================================================
   2. Text
   ========================================================== */

.display {            /* greetings, hero titles, big score numbers */
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 48px);
  font-weight: var(--display-weight);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0;
}

.page-title {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0;
}

.section-title {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
}

/* Small uppercase label above a title */
.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-text);
  margin: 0;
}

/* Brand gradient on text. Use on one or two words, not whole paragraphs. */
.text-gradient {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }

.link {
  color: var(--link-text);
  font-weight: 700;
}
.link:hover {
  text-decoration: underline;
}

/* ==========================================================
   3. Buttons
   <button class="btn btn-primary">Save</button>
   <button class="btn btn-secondary">Cancel</button>
   <button class="btn btn-ghost">Skip</button>
   <button class="btn-icon" aria-label="Close">(svg)</button>
   Sizes: btn-sm, btn-lg.  Full width: btn-block.
   Loading: add class "is-loading".
   ========================================================== */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background var(--dur-fast),
    border-color var(--dur-fast),
    box-shadow var(--dur) var(--ease),
    transform var(--dur-fast) var(--ease);
}
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -10px rgba(27, 68, 103, 0.65);
}
.btn-primary:active {
  transform: scale(0.97);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--text-3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-nav);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-danger {
  background: var(--risk);
  color: #fff;
}
.btn-danger:hover {
  background: var(--risk-text);
}

.btn-sm    { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-lg    { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Loading: hides the label and shows a spinner in its place */
.btn.is-loading {
  color: transparent;
  pointer-events: none;
}
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn-secondary.is-loading::after,
.btn-ghost.is-loading::after {
  border-color: var(--border-strong);
  border-top-color: var(--navy);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
}
.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.btn-icon:active {
  transform: scale(0.92);
}

/* ==========================================================
   4. Form fields
   <div class="field">
     <label class="label" for="email">Email</label>
     <input class="input" id="email" type="email">
     <p class="field-error">Shown only when there is an error</p>
   </div>
   ========================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  font-size: 13px;
  font-weight: 700;
}

.input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--bg);
  font-size: 14px;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
textarea.input {
  height: auto;
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}
.input::placeholder {
  color: var(--text-3);
}
.input:hover {
  border-color: var(--text-3);
}
.input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 4px var(--teal-tint);
}
.input.is-error {
  border-color: var(--risk);
}
.input.is-error:focus {
  box-shadow: 0 0 0 4px var(--risk-tint);
}

.field-hint  { margin: 0; font-size: 12.5px; color: var(--text-3); }
.field-error { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--risk-text); }

/* Input with a button inside it (password show / hide, search icon).
   <div class="input-group">
     <input class="input" type="password">
     <button class="btn-icon" type="button" data-password-toggle aria-label="Show password">(svg)</button>
   </div>
*/
.input-group {
  position: relative;
}
.input-group .input {
  padding-inline-end: 44px;
}
.input-group .btn-icon {
  position: absolute;
  inset-block-start: 5px;
  inset-inline-end: 5px;
}

/* Email and password boxes are always typed left to right, even on the Arabic page.
   Their group follows them, so the eye button stays at the end of the box. */
.input-group:has(.input[dir="ltr"]) {
  direction: ltr;
}

/* "Password" on one side, "Forgot password?" on the other */
.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

/* A red star after the label of a field that must be filled in:
   <label class="label is-required"> */
.label.is-required::after {
  content: ' *';
  color: var(--risk);
}

/* Searchable dropdown (built by ui.js from <select data-searchable>) */
.combo {
  position: relative;
}
/* the real dropdown stays in the page for the form, but out of sight */
.combo-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.combo-native.is-error + .combo .combo-input {
  border-color: var(--risk);
}
.combo-list {
  position: absolute;
  inset-block-start: calc(100% + 6px);
  inset-inline: 0;
  z-index: 50;
  max-height: 240px;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg);
  box-shadow: var(--shadow-float);
  list-style: none;
  overflow-y: auto;
}
.combo-list li {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.combo-list li:hover,
.combo-list li.is-active {
  background: var(--bg-hover);
}
.combo-list li.is-chosen {
  font-weight: 700;
  color: var(--navy);
}
.combo-list .combo-empty {
  color: var(--text-3);
  cursor: default;
}
.combo-list .combo-empty:hover {
  background: none;
}

/* Password rules under a password box: grey until met, then green with a tick.
   <ul class="rules"> <li data-rule="length">…</li> </ul>   (used on sign up and reset password) */
.rules {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
}
.rules li {
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color var(--dur-fast);
}
.rules li::before {
  content: '';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  font-size: 9px;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.rules li.is-met {
  color: var(--good-text);
}
.rules li.is-met::before {
  content: '✓';
  border-color: var(--good);
  background: var(--good);
  color: #fff;
}

/* Checkbox or radio with its label
   <label class="check"><input type="checkbox"> Remember me</label>
*/
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  cursor: pointer;
}
.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--navy);
  cursor: pointer;
}

/* ==========================================================
   5. Cards and tiles
   <div class="card">...</div>
   <a class="card card-hover" href="...">...</a>   (clickable card)
   ========================================================== */

.card {
  padding: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
}

.card-hover {
  display: block;
  transition:
    border-color var(--dur),
    box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.card-hover:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-float);
  transform: translateY(-3px);
}

/* Card with the brand gradient, for one highlighted thing per page */
.card-brand {
  background: var(--gradient-brand);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-brand);
}

/* Small grey tile for a label + number (KPIs, key-value pairs) */
.tile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--bg-tile);
}
.tile-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}

/* Responsive grid: as many columns as fit, each at least 240px wide */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

/* ==========================================================
   6. Chips, pills, segmented control
   ========================================================== */

/* Status badge
   <span class="chip chip-good">Operating</span>
   Colors: chip-good, chip-risk, chip-warn, chip-navy, chip-teal
*/
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--bg-muted);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.chip-good { background: var(--good-tint); color: var(--good-text); }
.chip-risk { background: var(--risk-tint); color: var(--risk-text); }
.chip-warn { background: var(--warn-tint); color: var(--warn-text); }
.chip-navy { background: var(--navy-tint); color: var(--navy); }
.chip-teal { background: var(--teal-tint); color: var(--teal-text); }

/* Pastel chips: to tell apart kinds of things with no good / bad meaning
   (user types, authorities). Avoid 6 (mint) next to a green status chip.
   <span class="chip chip-pastel-3">Business Owner</span> */
.chip-pastel-1 { background: var(--pastel-1-tint); color: var(--pastel-1-text); }
.chip-pastel-2 { background: var(--pastel-2-tint); color: var(--pastel-2-text); }
.chip-pastel-3 { background: var(--pastel-3-tint); color: var(--pastel-3-text); }
.chip-pastel-4 { background: var(--pastel-4-tint); color: var(--pastel-4-text); }
.chip-pastel-5 { background: var(--pastel-5-tint); color: var(--pastel-5-text); }
.chip-pastel-6 { background: var(--pastel-6-tint); color: var(--pastel-6-text); }
.chip-pastel-7 { background: var(--pastel-7-tint); color: var(--pastel-7-text); }
.chip-pastel-8 { background: var(--pastel-8-tint); color: var(--pastel-8-text); }
.chip-pastel-9  { background: var(--pastel-9-tint);  color: var(--pastel-9-text); }
.chip-pastel-10 { background: var(--pastel-10-tint); color: var(--pastel-10-text); }
.chip-pastel-11 { background: var(--pastel-11-tint); color: var(--pastel-11-text); }
.chip-pastel-12 { background: var(--pastel-12-tint); color: var(--pastel-12-text); }
.chip-pastel-13 { background: var(--pastel-13-tint); color: var(--pastel-13-text); }
.chip-pastel-14 { background: var(--pastel-14-tint); color: var(--pastel-14-text); }
.chip-pastel-15 { background: var(--pastel-15-tint); color: var(--pastel-15-text); }

/* Small colored dot before the chip text: <span class="chip chip-good chip-dot">Operating</span> */
.chip-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Quick replies and prompt suggestions
   <button class="pill">Assess a new idea</button>
   <button class="pill is-active">Chosen one</button>
*/
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
  background: var(--bg);
  color: var(--text-nav);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background var(--dur-fast),
    border-color var(--dur-fast),
    color var(--dur-fast),
    transform var(--dur-fast) var(--ease);
}
.pill:hover {
  border-color: var(--teal);
  color: var(--teal-text);
  transform: translateY(-1px);
}
.pill.is-active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

/* A dropdown filter that looks like a pill (explorers, admin lists)
   <select class="pill"><option value="">Sector</option> ... </select> */
select.pill {
  max-width: 220px;   /* long option names are cut in the closed dropdown, shown in full when open */
}

/* Every dropdown (pill filters and form boxes) gets the same soft rounded arrow
   instead of the browser's own. It sits on the end side (left in Arabic) and
   turns teal with the border on hover and focus. */
select.pill,
select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-inline-end: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235B6B7B' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px;
  cursor: pointer;
}
html[dir="rtl"] select.pill,
html[dir="rtl"] select.input {
  background-position: left 14px center;
}
select.pill:hover,
select.pill:focus,
select.input:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231F8E97' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
select.input:disabled {
  cursor: not-allowed;
}

/* Language toggle, tabs, filters
   <div class="segmented">
     <button class="segmented-item is-active">All</button>
     <button class="segmented-item">Drafts</button>
   </div>
*/
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--r-sm);
  background: var(--bg-muted);
}

.segmented-item {
  height: 30px;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}
.segmented-item:hover {
  color: var(--text);
}
.segmented-item.is-active {
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================
   7. Feedback
   ========================================================== */

/* Message box inside the page
   <div class="alert alert-risk">Wrong email or password.</div>
   Colors: alert-good, alert-risk, alert-warn, alert-info
*/
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--bg-tile);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  animation: fade-up var(--dur) var(--ease);
}
.alert-good { background: var(--good-tint); color: var(--good-text); }
.alert-risk { background: var(--risk-tint); color: var(--risk-text); }
.alert-warn { background: var(--warn-tint); color: var(--warn-text); }
.alert-info { background: var(--link-tint); color: var(--link-text); }

/* Toast: small message that pops up at the bottom and disappears.
   Show one from JavaScript with showToast('Saved', 'good') from ui.js. */
.toast-stack {
  position: fixed;
  inset-block-end: 24px;
  inset-inline: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: var(--r-pill);
  background: var(--text);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: var(--shadow-panel);
  animation: fade-up var(--dur) var(--ease);
  transition: opacity var(--dur), transform var(--dur);
}
.toast::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
}
.toast-good::before { background: #4FD39A; }
.toast-risk::before { background: #FF8585; }
.toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
}

/* Modal: uses the browser's own <dialog> element.
   <dialog class="modal" id="confirm-delete"> ... </dialog>
   Open:  <button data-modal-open="confirm-delete">
   Close: <button data-modal-close>
*/
.modal {
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-panel);
}
.modal[open] {
  animation: pop-in var(--dur) var(--ease);
}
.modal::backdrop {
  background: rgba(15, 36, 56, 0.35);
  backdrop-filter: blur(3px);
}
.modal-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 800;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* Spinner: <span class="spinner"></span> */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Skeleton: grey placeholder while data is loading.
   <div class="skeleton" style="height: 18px; width: 60%"></div> */
.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-subtle) 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

/* Empty state: shown when a list has nothing in it yet */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text-2);
  text-align: center;
}
.empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--teal-tint);
  color: var(--teal-text);
}

/* ==========================================================
   8. Small pieces
   ========================================================== */

/* Avatar: <span class="avatar">HA</span>   Smaller: avatar-sm */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }

/* Divider: <hr class="divider">  or with text: <div class="divider-text">or</div> */
.divider {
  height: 1px;
  margin: 0;
  border: none;
  background: var(--divider);
}
.divider-text {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 700;
}
.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Progress bar: <div class="bar"><div class="bar-fill" style="width: 72%"></div></div>
   Colors: bar-good, bar-warn, bar-risk (default is teal) */
.bar {
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--bg-muted);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 0.6s var(--ease);
}
.bar-good .bar-fill { background: var(--good); }
.bar-warn .bar-fill { background: var(--warn); }
.bar-risk .bar-fill { background: var(--risk); }

/* Data table (history, explorers, admin).
   Wrap it in <div class="table-wrap"> so it can scroll sideways on phones. */
.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  padding: 0 16px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  text-align: start;
  white-space: nowrap;
}
.table td {
  padding: 14px 16px;
  border-top: 1px solid var(--divider);
  font-size: 13.5px;
  vertical-align: middle;
  transition: background var(--dur-fast);
}
.table tbody tr:hover td {
  background: var(--bg-subtle);
}

/* Glass: only for things that float above the page
   (chat composer, slide-in panel, popovers, sticky headers). */
.glass {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(22px) saturate(170%);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-float);
}

.disclaimer {
  margin: 0;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

/* ==========================================================
   9. Motion helpers
   Add class "fade-up" to make something slide in when the page loads.
   For a list, give each item style="--i: 0", "--i: 1", ... to stagger them.
   ========================================================== */

.fade-up {
  animation: fade-up 0.5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* People who turn off animations in their system settings get none */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================
   10. Page building blocks
   ========================================================== */

/* Title row at the top of a page: title on one side, buttons on the other */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head p {
  margin: 4px 0 0;
}

/* Search box + filters above a list or table
   <div class="toolbar">
     <label class="search">(svg)<input type="search" placeholder="Search"></label>
     <button class="pill is-active">All</button>
     <button class="pill">Active</button>
   </div>
*/
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 240px;
  max-width: 320px;
  height: 40px;
  padding-inline: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text-3);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.search:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px var(--teal-tint);
}
.search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
}

/* Table inside a rounded card, with a grey header row.
   <div class="table-card"><table class="table"> ... </table></div>
   It scrolls sideways by itself when the screen is too narrow. */
.table-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  overflow-x: auto;
}
.table-card .table th {
  padding: 12px 16px;
  background: var(--bg-subtle);
}
.table-card .table tr:first-child td {
  border-top-color: var(--border);
}

/* Two lines in one table cell: name on top, detail under it */
.cell-title  { display: block; font-weight: 700; }
.cell-detail { display: block; font-size: 12.5px; color: var(--text-3); }

/* Number card for dashboards
   <div class="card stat">
     <span class="stat-label">Founder accounts</span>
     <span class="stat-value">128</span>
     <a class="link" href="...">View founders</a>
   </div>
   Put several inside <div class="grid stat-grid">. */
.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
}
.stat-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Form fields side by side. They stack on a phone.
   <div class="form-row"> <div class="field">…</div> <div class="field">…</div> </div> */
.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* A stack of fields with even spacing: <form class="form"> */
.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Side panel: slides in from the edge for details or an edit form.
   <aside class="panel" id="founder-panel">
     <div class="panel-head"> <h2 class="modal-title">Title</h2> <button class="btn-icon" data-panel-close>(x)</button> </div>
     <div class="panel-body"> ... </div>
     <div class="panel-foot"> <button class="btn btn-secondary" data-panel-close>Cancel</button> </div>
   </aside>
   Open it with <button data-panel-open="founder-panel">. Needs ui.js. */
.panel {
  position: fixed;
  inset-block: 16px;
  inset-inline-end: 16px;
  z-index: 250;
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  box-shadow: var(--shadow-panel);
  visibility: hidden;
  opacity: 0;
  transform: translateX(24px);
  transition:
    transform var(--dur) var(--ease),
    opacity var(--dur),
    visibility var(--dur);
}
html[dir="rtl"] .panel {
  transform: translateX(-24px);
}
.panel.is-open,
html[dir="rtl"] .panel.is-open {
  visibility: visible;
  opacity: 1;
  transform: none;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 12px;
}
.panel-body {
  flex: 1;
  padding: 4px 20px 20px;
  overflow-y: auto;
}
.panel-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--divider);
}

/* ==========================================================
   11. App layout (founder and admin pages)
   layout.js builds all of this. A page only needs:
     <body data-layout="founder" data-page="startups" data-title="nav.startups">
       <main> ...page content... </main>
   ========================================================== */

.app {
  display: flex;
  min-height: 100vh;
}

/* ----- Sidebar ----- */

.sidebar {
  position: sticky;
  inset-block-start: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;   /* phones: the real visible height, without the browser bars */
  padding: 12px 10px;
  background: var(--bg-subtle);
  border-inline-end: 1px solid var(--border);
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 2px 12px 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
/* The logo file has empty space above and below the drawing.
   "cover" with this shape trims that space away. */
.brand-logo {
  height: 38px;
  width: auto;
  aspect-ratio: 1890 / 748;
  object-fit: cover;
  object-position: 0 49%;
}
.brand-badge {
  font-size: 10px;
  letter-spacing: 0.06em;
}

.sidebar-label {
  padding: 16px 10px 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
}

/* The founder's Explore group: a light blue box under "New conversation" */
.sidebar-explore {
  margin: 12px 0 4px;
  padding: 2px 6px 6px;
  border: 1px solid #DDE6F3;
  border-radius: 14px;
  background: var(--navy-tint);
}
.sidebar-explore .sidebar-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 6px 6px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--navy);
}
.sidebar-explore .nav-item {
  color: var(--text);
}
.sidebar-explore .nav-item svg {
  color: var(--navy);
}
.sidebar-explore .nav-item:hover {
  background: var(--bg);
}

/* A thin line between parts of the sidebar */
.sidebar-divider {
  height: 1px;
  margin: 8px 10px;
  background: var(--border);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--text-nav);
  font-size: 13.5px;
  font-weight: 600;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.nav-item svg {
  flex-shrink: 0;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.nav-item.is-active {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}
.nav-item-strong {
  color: var(--text);
  font-weight: 700;
}
/* A long name in the sidebar is cut with "…" instead of wrapping */
.nav-item-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The middle of the sidebar: takes the free space and scrolls if the list is long */
.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-empty {
  margin: 0;
  padding: 16px 10px 4px;
  font-size: 12.5px;
  color: var(--text-3);
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* The signed-in person at the bottom of the sidebar */
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 12px;
  color: var(--text-2);
  transition: background var(--dur-fast);
}
a.user-card:hover {
  background: var(--bg-hover);
}
/* the part of the card that opens the profile page */
.user-card-link {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  border-radius: 10px;
}
.user-card-link:hover strong {
  color: var(--navy);
}

/* A guarded page (shared/guard.js) keeps its content hidden until the guard
   has checked that this person may see it. */
body.is-guarded:not(.is-allowed) .app-content {
  visibility: hidden;
}

.user-card-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}
.user-card-text strong {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 800;
}
.user-card-text small {
  font-size: 12px;
  color: var(--text-3);
}
.user-card-text strong,
.user-card-text small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* dark layer behind the sidebar when it is open on a phone */
.sidebar-backdrop {
  display: none;
}

/* ----- Main column: header, page content, footer ----- */

.app-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.app-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--header-h);
  padding-inline: 24px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid var(--divider);
}
/* A page without data-title gets a header with no line and no background */
.app-header.is-bare {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom-color: transparent;
}

/* The menu button in the header only shows when the sidebar is hidden */
.header-toggle {
  display: none;
}
body.sidebar-collapsed .header-toggle {
  display: inline-flex;
}

.app-header-title {
  min-width: 0;
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 13px;
  color: var(--text-3);
  white-space: nowrap;
}
.breadcrumb strong {
  color: var(--text);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header-space {
  flex: 1;
}
.app-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-content {
  flex: 1;
  width: 100%;
  max-width: var(--content-w);
  margin-inline: auto;
  padding: 28px 28px 40px;
}

.app-footer {
  padding: 14px 24px;
}

/* Desktop: the toggle hides the sidebar completely */
@media (min-width: 961px) {
  body.sidebar-collapsed .sidebar {
    display: none;
  }
}

/* ==========================================================
   12. Public layout (landing page)
   <body data-layout="public">
   ========================================================== */

.public {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.public > main {
  flex: 1;
}

/* The top bar floats over the page as a rounded glass bar */
.public-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 100;
  padding: 16px 20px 0;
  margin-bottom: -84px;   /* lets the page slide under the bar */
}
.public-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1220px;
  margin-inline: auto;
  padding: 10px;
  padding-inline-start: 18px;
  border-radius: 22px;
  border-color: var(--border);
  /* almost solid, so the page sliding under the bar does not show through the links */
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-float);
}
.public-header .brand-logo { height: 42px; }

.public-nav {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}
.public-nav a {
  padding: 10px 14px;
  border-radius: 12px;
  color: var(--text-nav);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--dur);
}
.public-nav a:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.public-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.public-header-actions .btn {
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  font-size: 14px;
}
.public-header-actions .btn-ghost {
  color: var(--navy);
}
.public-header-actions .btn-primary {
  background: var(--navy);
}
/* the language button, same look everywhere */
.language-toggle {
  flex-shrink: 0;
  border-radius: var(--r-pill);
  color: var(--text-nav);
}
/* On the phone the language button is the same everywhere: a round button with only
   the globe. The language's name stays for screen readers (hidden from view, not removed). */
@media (max-width: 640px) {
  .language-toggle,
  .public-header-actions .language-toggle {   /* the landing page's header buttons have their own shape */
    aspect-ratio: 1;   /* as wide as it is tall: a circle, whatever height the page's buttons have */
    padding: 0;
    border-radius: var(--r-pill);
  }
  .language-toggle span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* The phone menu and its button are hidden on wide screens */
.public-menu-button,
.public-menu {
  display: none;
}
/* It floats over the page under the top bar, so the page does not jump when it opens. */
.public-menu {
  position: absolute;
  top: 100%;
  inset-inline: 12px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 24px 60px rgba(15, 36, 56, 0.2);
}
.public-menu-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 16px;
  font-weight: 700;
}
.public-menu-links > a:not(.btn) {
  padding: 13px 14px;
  border-radius: 14px;
  transition: background var(--dur);
}
.public-menu-links > a:not(.btn):active,
.public-menu-links > a:not(.btn):hover {
  background: var(--bg-hover);
}
.public-menu-links .btn {
  margin-top: 6px;
}
/* The button's three lines turn into an X while the menu is open. */
.menu-lines {
  position: relative;
  display: block;
  width: 20px;
  height: 14px;
}
.menu-lines i {
  position: absolute;
  inset-inline: 0;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: top var(--dur) var(--ease), rotate var(--dur) var(--ease), opacity var(--dur);
}
.menu-lines i:nth-child(1) { top: 0; }
.menu-lines i:nth-child(2) { top: 6px; }
.menu-lines i:nth-child(3) { top: 12px; }
body.public-menu-open .menu-lines i:nth-child(1) { top: 6px; rotate: 45deg; }
body.public-menu-open .menu-lines i:nth-child(2) { opacity: 0; }
body.public-menu-open .menu-lines i:nth-child(3) { top: 6px; rotate: -45deg; }

.public-footer {
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
}
.public-footer-inner {
  max-width: 1220px;
  margin-inline: auto;
  padding: 48px 20px 28px;
}
.public-footer-top {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px;
  padding-bottom: 36px;
}
.public-footer-about {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  max-width: 360px;
}
.public-footer-about p {
  margin: 0;
  color: var(--text-2);
}
.public-footer-column {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-nav);
}
.public-footer-column strong {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}
.public-footer-column a:hover {
  color: var(--teal-text);
}
.public-footer-email {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.public-footer-accounts {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.social {
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--bg);
}
.social:hover {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
  transform: translateY(-2px);
}
.public-footer-bottom {
  display: flex;
  justify-content: space-between;
  gap: 8px 24px;
  flex-wrap: wrap;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-3);
}

/* ==========================================================
   13. Auth layout (sign up, log in, reset password, admin login)
   <body data-layout="auth">
     <main> ...form... </main>
   layout.js adds the photo side and the language switch.
   ========================================================== */

.auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
}

/* ----- Darb's panel ----- */

.auth-side {
  position: sticky;
  inset-block-start: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: 32px 44px 44px;
  overflow: hidden;
  background:
    radial-gradient(70% 50% at 0% 0%, var(--teal-tint), transparent 70%),
    radial-gradient(70% 60% at 100% 100%, var(--navy-tint), transparent 70%),
    var(--bg-subtle);
  border-inline-end: 1px solid var(--border);
}
.auth-side .brand-logo { height: 48px; }

/* Background of the panel, layer 1: a field of fine dots that fades toward the edges */
.auth-side::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(27, 68, 103, 0.16) 1px, transparent 1.5px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse 75% 60% at 50% 50%, #000 15%, transparent 75%);
  mask-image: radial-gradient(ellipse 75% 60% at 50% 50%, #000 15%, transparent 75%);
  pointer-events: none;
}
/* layer 2: two soft lights that drift very slowly */
.auth-side::after {
  content: '';
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(32% 28% at 28% 30%, rgba(31, 142, 151, 0.20), transparent 70%),
    radial-gradient(34% 30% at 72% 72%, rgba(44, 110, 150, 0.20), transparent 70%);
  pointer-events: none;
  animation: auth-lights 18s ease-in-out infinite alternate;
}
@keyframes auth-lights {
  from { transform: translate(-3%, -2%) rotate(0deg); }
  to   { transform: translate(3%, 3%) rotate(8deg); }
}
/* everything on the panel sits above those two layers */
.auth-side > * {
  position: relative;
  z-index: 1;
}

.auth-side-middle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  width: 100%;
  max-width: 440px;
  margin-inline: auto;
}
.auth-side-title {
  margin: 0;
  font-size: clamp(28px, 3vw, 42px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
}
html[dir="rtl"] .auth-side-title {
  line-height: 1.4;
  letter-spacing: 0;
}
.auth-side-note {
  margin: 12px 0 0;
  font-size: 15px;
  color: var(--text-2);
}
/* the line at the bottom of the panel */
.auth-side-caption {
  display: flex;
  flex-wrap: wrap;
  gap: 0 8px;
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.auth-side-caption .accent {
  color: var(--teal);
}

/* ----- The live demo on the panel (layout.js plays it) -----
   One small chat window: the founder's message, Darb's steps, then the score. */

.demo {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: var(--bg);
  box-shadow: 0 40px 80px -36px rgba(27, 68, 103, 0.45);
  animation: demo-float 7s ease-in-out infinite;
}
@keyframes demo-float {
  50% { translate: 0 -8px; }
}
.demo-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--divider);
  font-size: 14px;
}
/* small green dot: "online" */
.demo-online {
  width: 8px;
  height: 8px;
  margin-inline-start: auto;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 4px var(--good-tint);
}

.demo-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 372px;   /* fixed, so the window does not jump while the demo plays */
  padding: 18px;
}

/* 1. the founder's message. It starts where writing starts:
   on the left in English, on the right in Arabic. */
.demo-message {
  align-self: flex-start;
  max-width: 88%;
  min-height: 46px;
  margin: 0;
  padding: 11px 15px;
  border-radius: 18px;
  border-end-start-radius: 5px;
  text-align: start;
  background: var(--bg-muted);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
}
.demo-caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-inline-start: 2px;
  background: var(--teal);
  vertical-align: text-bottom;
  animation: demo-blink 1s steps(1) infinite;
}
@keyframes demo-blink {
  50% { opacity: 0; }
}

/* 2. Darb's steps */
.demo-steps {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
}
.demo-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease), color 0.3s;
}
.demo-steps li.is-visible {
  opacity: 1;
  transform: none;
}
/* the mark before each step: a spinning ring while Darb works on it... */
.demo-steps li::before {
  content: '';
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
/* ...and a filled tick when it is done */
.demo-steps li.is-done {
  color: var(--text);
}
.demo-steps li.is-done::before {
  content: '✓';
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--teal);
  color: #fff;
  font-size: 10px;
  animation: none;
}

/* 3. the score */
.demo-result {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: auto;
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: var(--shadow-brand);
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}
.demo-result.is-visible {
  opacity: 1;
  transform: none;
}
.demo-ring {
  position: relative;
  flex-shrink: 0;
  width: 92px;
  height: 92px;
}
.demo-ring svg {
  width: 100%;
  height: 100%;
  rotate: -90deg;   /* so the ring starts filling from the top */
}
.demo-ring circle {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}
.demo-ring-track {
  stroke: rgba(255, 255, 255, 0.16);
}
.demo-ring-fill {
  stroke: #6FE0A8;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 1.1s var(--ease), stroke 0.3s;
}
.demo-result.is-warn .demo-ring-fill {
  stroke: #F2CB6B;
}
.demo-ring strong {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.demo-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.demo-title {
  font-size: 15px;
  font-weight: 700;
}

/* ----- The form side ----- */

.auth-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.auth-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 28px 0;
}
/* "Back to home", on every auth page */
.auth-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 700;
  transition: color var(--dur-fast);
}
.auth-home:hover {
  color: var(--navy);
}
html[dir="rtl"] .auth-home svg {
  transform: scaleX(-1);
}

/* Shared by the auth pages that have more than one screen (forgot / reset password):
   only the screen with "is-active" shows. */
.screen {
  display: none;
}
.screen.is-active {
  display: block;
  animation: fade-up 0.5s var(--ease) both;
}
/* round icon above the title of a result screen */
.screen-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 20px;
  border-radius: 20px;
  background: var(--teal-tint);
  color: var(--teal-text);
}
.screen-icon.is-warn {
  background: var(--warn-tint);
  color: var(--warn-text);
}
.screen-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
.auth-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin-inline: auto;
  padding: 24px 28px 56px;
}

/* While an auth page is finding out who is here (for example right after
   coming back from Google), the form is hidden and a spinner shows instead.
   The page adds "is-checking" to <html> and removes it when it is ready. */
html.is-checking main {
  visibility: hidden;
}
html.is-checking .auth-panel {
  position: relative;
}
html.is-checking .auth-panel::after {
  content: '';
  position: absolute;
  inset-block-start: 45%;
  inset-inline-start: calc(50% - 16px);
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* big question-style title used on auth pages */
.auth-title {
  margin: 0;
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
}
html[dir="rtl"] .auth-title {
  line-height: 1.45;
  letter-spacing: 0;
}
.auth-sub {
  margin: 8px 0 28px;
  font-size: 16px;
  color: var(--text-2);
}
/* "Already have an account? Sign in" */
.auth-switch {
  margin: 28px 0 0;
  font-size: 14px;
  color: var(--text-2);
}

/* Google button */
.btn-google {
  gap: 10px;
}

/* ==========================================================
   13b. Error layout (403, 404, 500 pages)
   layout.js builds it for <body data-layout="error">:
   the logo and the language button on top, the page's <main> centered.
   ========================================================== */

.error-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.error-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
}

.error-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 520px;
  margin-inline: auto;
  padding: 24px 16px 72px;
  text-align: center;
}
.error-main p {
  margin: 0;
}

/* the buttons under the message, side by side (stacked on a phone) */
.error-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}
@media (max-width: 640px) {
  .error-top {
    padding: 12px 16px;
  }
  .error-actions {
    width: 100%;
  }
  .error-actions .btn {
    flex: 1 1 100%;
  }
}

/* ==========================================================
   14. Responsive rules
     Tablet        960px and below: sidebar becomes a drawer
     Phone         640px and below: everything in one column
     Small phone   400px and below: tighter spacing
   ========================================================== */

@media (max-width: 1100px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* landing top bar: the links move into the phone menu */
  .public-nav,
  .public-auth {
    display: none;
  }
  .public-menu-button {
    display: inline-flex;
  }
  body.public-menu-open .public-menu {
    display: block;
    animation: fade-up var(--dur) var(--ease);
  }
}

@media (max-width: 960px) {
  /* auth pages: Darb's panel shrinks to a strip with just the logo */
  .auth {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }
  .auth-side {
    position: relative;
    height: auto;
    padding: 16px 20px;
    border-inline-end: none;
    border-bottom: 1px solid var(--border);
  }
  .auth-side-middle,
  .auth-side-caption {
    display: none;
  }
  .auth-main {
    justify-content: flex-start;
    padding: 20px 20px 40px;
  }
  .auth-top {
    padding: 16px 20px 0;
  }

  /* The sidebar becomes a drawer that slides in over the page */
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(var(--sidebar-w), 84vw);
    visibility: hidden;   /* hidden while closed, so it never flashes or leaks its shadow */
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease), visibility var(--dur);
  }
  html[dir="rtl"] .sidebar {
    transform: translateX(100%);
  }
  body.sidebar-open .sidebar,
  html[dir="rtl"] body.sidebar-open .sidebar {
    visibility: visible;
    transform: none;
    box-shadow: var(--shadow-panel);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(15, 36, 56, 0.35);
    animation: fade-in var(--dur);
  }

  .header-toggle {
    display: inline-flex;
  }

  .app-header {
    padding-inline: 12px;
  }
  .app-content {
    padding: 20px 16px 32px;
  }

  /* bigger touch targets in the drawer */
  .nav-item {
    min-height: 42px;
  }
}

@media (max-width: 640px) {
  .container {
    padding-inline: 16px;
  }

  .stat-grid,
  .form-row {
    grid-template-columns: minmax(0, 1fr);
  }

  /* page title row: the buttons go under the title, full width */
  .page-head {
    align-items: stretch;
    flex-direction: column;
  }
  .page-head .btn {
    width: 100%;
  }

  /* the search box takes the whole first line, filters wrap under it */
  .search {
    flex-basis: 100%;
    max-width: none;
  }

  /* tables keep their columns and scroll sideways */
  .table {
    min-width: 560px;
  }

  /* side panel becomes a full screen sheet */
  .panel {
    inset: 0;
    width: 100%;
    border: none;
    border-radius: 0;
  }

  .modal-actions,
  .panel-foot {
    flex-direction: column-reverse;
  }
  .modal-actions .btn,
  .panel-foot .btn {
    width: 100%;
  }

  /* comfortable touch size for form controls (16px also stops iPhone zooming in) */
  .input {
    height: 46px;
    font-size: 16px;
  }
  .btn {
    height: 44px;
  }
  .btn-sm {
    height: 38px;
  }


  .public-header {
    padding: 10px 12px 0;
  }
  /* The footer on a phone, short and centered: the logo and one sentence, the links
     in one row, then the email and icons. The two small headings are not needed here. */
  .public-footer-inner {
    padding: 36px 20px 22px;
  }
  .public-footer-top {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    justify-items: center;
    padding-bottom: 24px;
    text-align: center;
  }
  .public-footer-about {
    align-items: center;
    gap: 10px;
    max-width: 320px;
    font-size: 13.5px;
    line-height: 1.7;
    text-wrap: balance;
  }
  .public-footer-column {
    align-items: center;
  }
  .public-footer-column strong {
    display: none;
  }
  nav.public-footer-column {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 26px;
    font-size: 14.5px;
    font-weight: 700;
  }
  .public-footer-column:last-child {
    gap: 14px;
  }
  .public-footer-accounts {
    order: -1;
    justify-content: center;
    gap: 10px;
    margin-top: 0;
  }
  .public-footer-email {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
  }
  .public-footer-bottom {
    justify-content: center;
    padding-top: 16px;
    font-size: 12px;
    text-align: center;
  }
}

@media (max-width: 400px) {
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ==========================================================
   Profile pages: the founder's Profile and the admin's Profile share this layout.
   A hero card (avatar, name, badge, facts), then two columns
   (details | smaller cards), then full-width cards (security, session).
   ========================================================== */

/* the gap between the hero, the columns and the cards under them */
.profile-hero + .profile-columns,
.profile-columns ~ section {
  margin-top: 14px;
}

/* ----- Who is signed in ----- */

.profile-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 22px;
  background: var(--gradient-aurora), var(--bg);
}
.profile-avatar {
  width: 64px;
  height: 64px;
  font-size: 22px;
  box-shadow: var(--shadow-brand);
}
.profile-hero-text {
  flex: 1 1 240px;
  min-width: 0;
}
.profile-hero-name {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.profile-hero-name h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}
.profile-hero-line {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}
.profile-hero-facts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.profile-hero-fact {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 112px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.7);
  font-size: 12px;
}
.profile-hero-fact strong {
  font-size: 14px;
}

/* ----- Columns ----- */

.profile-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}
.profile-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.profile-card {
  padding: 22px;
}
.profile-card > .text-3,
.profile-card-head .text-3,
.profile-row .text-3 {
  margin: 4px 0 0;
  font-size: 13px;
}
.profile-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* "@" and "+966" in front of the box */
.profile-prefix {
  display: flex;
  align-items: stretch;
}
.profile-prefix-sign {
  display: inline-flex;
  align-items: center;
  padding-inline: 12px;
  border: 1px solid var(--border-strong);
  border-inline-end: none;
  border-start-start-radius: var(--r-sm);
  border-end-start-radius: var(--r-sm);
  background: var(--bg-subtle);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 700;
}
.profile-prefix .input {
  border-start-start-radius: 0;
  border-end-start-radius: 0;
}

.input[readonly] {
  background: var(--bg-subtle);
  color: var(--text-2);
}

.profile-form-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}
.profile-form-foot .text-3 {
  margin-inline-end: auto;
  font-size: 12.5px;
}

/* ----- Security ----- */

.profile-password .rules {
  margin: 0;
}

@media (max-width: 960px) {
  .profile-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  /* the hero on a phone: a smaller avatar beside the name, then the facts in one row */
  .profile-hero,
  .profile-card {
    padding: 16px;
  }
  .profile-hero {
    gap: 14px;
  }
  .profile-avatar {
    width: 48px;
    height: 48px;
    font-size: 17px;
  }
  .profile-hero-text {
    flex-basis: 0;
  }
  .profile-hero-name h3 {
    font-size: 19px;
  }
  .profile-hero-facts {
    width: 100%;
    gap: 6px;
  }
  .profile-hero-fact {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    font-size: 11px;
  }
  .profile-hero-fact strong {
    font-size: 13px;
  }
  .profile-form-foot .btn {
    flex: 1;
  }
}

/* iPhone zooms the page in when a text box's text is smaller than 16px, and it stays
   zoomed after sending. On phones every text box uses 16px, so it never zooms. */
@media (max-width: 640px) {
  input,
  select,
  textarea,
  .input,
  .composer-input {
    font-size: 16px;
  }
}

/* Release 2 pages on the hosted website: a menu item that does not open yet, and the page that replaces them */
.nav-item.is-soon {
  cursor: default;
  opacity: 0.75;
}
.nav-item.is-soon:hover {
  background: transparent;
  color: var(--text-nav);
}
.soon-badge {
  margin-inline-start: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--pastel-2-tint);
  color: var(--pastel-2-text);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.soon-page {
  margin: 40px auto;
  max-width: 480px;
}
