/* ==========================================================================
   Innovation Hub — components.css
   One component set for every page. Each block is documented with live
   markup on components.html. Class naming: .component, .component-part,
   .component--variant is NOT used; variants are plain modifiers (.btn-primary).
   ========================================================================== */

/* ---------- Buttons ---------- */
.btn {
  --btn-h: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--ih-space-2);
  block-size: var(--btn-h); padding-inline: var(--ih-space-4);
  border: 1px solid transparent; border-radius: var(--ih-radius-md);
  font-weight: 600; font-size: var(--ih-text-base); line-height: 1; white-space: nowrap;
  background: transparent; color: var(--ih-text);
  transition: background var(--ih-duration-fast) var(--ih-ease), border-color var(--ih-duration-fast) var(--ih-ease), color var(--ih-duration-fast) var(--ih-ease), box-shadow var(--ih-duration-fast) var(--ih-ease);
  user-select: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn .icon { inline-size: 18px; block-size: 18px; }
.btn-sm { --btn-h: 32px; padding-inline: var(--ih-space-3); font-size: var(--ih-text-sm); border-radius: var(--ih-radius-sm); }
.btn-lg { --btn-h: 48px; padding-inline: var(--ih-space-6); font-size: var(--ih-text-md); }
.btn-block { inline-size: 100%; }

.btn-primary { background: var(--ih-primary); color: var(--ih-text-on-brand); box-shadow: var(--ih-shadow-xs); }
.btn-primary:hover { background: var(--ih-primary-hover); }
.btn-primary:active { background: var(--ih-primary-active); }
.btn-secondary { background: var(--ih-surface); border-color: var(--ih-border-strong); color: var(--ih-text); box-shadow: var(--ih-shadow-xs); }
.btn-secondary:hover { background: var(--ih-surface-sunken); }
.btn-ghost { color: var(--ih-text-muted); }
.btn-ghost:hover { background: var(--ih-surface-sunken); color: var(--ih-text); }
.btn-link { color: var(--ih-link); padding-inline: var(--ih-space-2); }
.btn-link:hover { background: var(--ih-primary-soft); }
.btn-accent { background: var(--ih-accent); color: var(--ih-neutral-900); }
.btn-accent:hover { background: var(--ih-yellow-300); }
.btn-danger { background: #B42F2F; color: #FFFFFF; }
.btn-danger:hover { background: #962424; }
.btn-danger-soft { color: var(--ih-danger); }
.btn-danger-soft:hover { background: var(--ih-danger-bg); }

.btn-icon { inline-size: var(--btn-h); padding: 0; }
.btn-icon.btn-ghost { color: var(--ih-text-muted); }

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; inline-size: 18px; block-size: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-block-start-color: transparent; color: var(--ih-text-on-brand);
  animation: ih-spin 0.7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { color: var(--ih-primary); }
@keyframes ih-spin { to { transform: rotate(360deg); } }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-start-start-radius: var(--ih-radius-md); border-end-start-radius: var(--ih-radius-md); }
.btn-group .btn:last-child { border-start-end-radius: var(--ih-radius-md); border-end-end-radius: var(--ih-radius-md); }
.btn-group .btn + .btn { margin-inline-start: -1px; }

/* Indicator dot on icon buttons (e.g. unread notifications) */
.has-dot { position: relative; }
.has-dot::after { content: ""; position: absolute; inset-block-start: 8px; inset-inline-end: 9px; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--ih-yellow-400); box-shadow: 0 0 0 2px var(--ih-surface); }

/* ---------- Segmented control ---------- */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--ih-surface-sunken); border-radius: var(--ih-radius-md); }
.segmented button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--ih-text-muted); font-weight: 600; font-size: var(--ih-text-sm); padding: 6px 12px; border-radius: 6px; }
.segmented button .icon { inline-size: 16px; block-size: 16px; }
.segmented button[aria-pressed="true"] { background: var(--ih-surface); color: var(--ih-text); box-shadow: var(--ih-shadow-xs); }
html[data-theme="dark"] .segmented button[aria-pressed="true"] { background: var(--ih-surface-raised); }
/* The same control as links, for a choice that loads its own page (a period, a view). */
.segmented a { display: inline-flex; align-items: center; gap: 6px; color: var(--ih-text-muted); font-weight: 600; font-size: var(--ih-text-sm); padding: 6px 12px; border-radius: 6px; text-decoration: none; }
.segmented a:hover { color: var(--ih-text); }
.segmented a[aria-current="page"] { background: var(--ih-surface); color: var(--ih-text); box-shadow: var(--ih-shadow-xs); }
html[data-theme="dark"] .segmented a[aria-current="page"] { background: var(--ih-surface-raised); }
.segmented.is-block { display: flex; }
.segmented.is-block button { flex: 1; justify-content: center; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field + .field { margin-block-start: var(--ih-space-4); }
.label { font-weight: 600; font-size: var(--ih-text-sm); color: var(--ih-text); display: flex; align-items: center; gap: 6px; }
.label .req { color: var(--ih-danger); }
.label .optional { font-weight: 400; color: var(--ih-text-subtle); }
.help { font-size: var(--ih-text-xs); color: var(--ih-text-subtle); }
.error-text { font-size: var(--ih-text-xs); color: var(--ih-danger); display: flex; align-items: center; gap: 6px; font-weight: 600; }
.error-text .icon { inline-size: 14px; block-size: 14px; }

.input, .select, .textarea {
  inline-size: 100%; min-block-size: 40px; padding: 0 var(--ih-space-3);
  background: var(--ih-surface); color: var(--ih-text);
  border: 1px solid var(--ih-border-strong); border-radius: var(--ih-radius-md);
  font-size: var(--ih-text-base);
  transition: border-color var(--ih-duration-fast) var(--ih-ease), box-shadow var(--ih-duration-fast) var(--ih-ease);
}
html[lang="ar"] :is(.input, .select, .textarea) { font-size: 15px; }
.textarea { padding-block: 10px; min-block-size: 96px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--ih-text-subtle); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ih-neutral-400); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ih-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ih-focus-ring) 35%, transparent); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--ih-surface-sunken); color: var(--ih-text-subtle); cursor: not-allowed; }
.is-invalid :is(.input, .select, .textarea), :is(.input, .select, .textarea)[aria-invalid="true"] { border-color: var(--ih-danger); }
.is-invalid :is(.input, .select, .textarea):focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ih-danger) 25%, transparent); }

.select {
  appearance: none; padding-inline-end: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23757087' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 16px; background-position: right 12px center;
}
[dir="rtl"] .select { background-position: left 12px center; }

/* Input with an icon or a button inside */
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .icon { position: absolute; inset-inline-start: 12px; color: var(--ih-text-subtle); pointer-events: none; inline-size: 18px; block-size: 18px; }
.input-wrap > .icon ~ .input { padding-inline-start: 40px; }
.input-wrap > .input-end { position: absolute; inset-inline-end: 4px; }
.input-wrap > .input-end ~ .input, .input-wrap .input:has(~ .input-end) { padding-inline-end: 44px; }
.input-wrap .kbd { position: absolute; inset-inline-end: 10px; }

/* Input with a fixed prefix/suffix (currency, unit) */
.input-group { display: flex; }
.input-group .addon { display: inline-flex; align-items: center; padding: 0 var(--ih-space-3); background: var(--ih-surface-sunken); border: 1px solid var(--ih-border-strong); color: var(--ih-text-muted); font-weight: 600; font-size: var(--ih-text-sm); white-space: nowrap; }
.input-group .addon:first-child { border-inline-end: 0; border-start-start-radius: var(--ih-radius-md); border-end-start-radius: var(--ih-radius-md); }
.input-group .addon:last-child { border-inline-start: 0; border-start-end-radius: var(--ih-radius-md); border-end-end-radius: var(--ih-radius-md); }
.input-group .input { border-radius: 0; }
.input-group .input:first-child { border-start-start-radius: var(--ih-radius-md); border-end-start-radius: var(--ih-radius-md); }
.input-group .input:last-child { border-start-end-radius: var(--ih-radius-md); border-end-end-radius: var(--ih-radius-md); }

/* Checkbox, radio, switch */
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: var(--ih-text-base); line-height: 1.4; }
.check + .check { margin-block-start: var(--ih-space-3); }
.check input { appearance: none; margin: 1px 0 0; flex: none; inline-size: 18px; block-size: 18px; border: 1.5px solid var(--ih-border-strong); background: var(--ih-surface); border-radius: 5px; display: grid; place-items: center; cursor: pointer; transition: all var(--ih-duration-fast) var(--ih-ease); }
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background: var(--ih-primary); border-color: var(--ih-primary); }
.check input[type="checkbox"]:checked::after { content: ""; inline-size: 10px; block-size: 6px; border: 2px solid #fff; border-block-start: 0; border-inline-end: 0; transform: rotate(-45deg) translate(1px, -1px); }
[dir="rtl"] .check input[type="checkbox"]:checked::after { border-inline-end: 2px solid #fff; border-inline-start: 0; transform: rotate(45deg) translate(-1px, -1px); }
.check input[type="checkbox"]:indeterminate { background: var(--ih-primary); border-color: var(--ih-primary); }
.check input[type="checkbox"]:indeterminate::after { content: ""; inline-size: 8px; block-size: 2px; background: #fff; border-radius: 1px; }
.check input[type="radio"]:checked::after { content: ""; inline-size: 8px; block-size: 8px; border-radius: 50%; background: #fff; }
.check input:focus-visible { outline: 3px solid var(--ih-focus-ring); outline-offset: 2px; }
.check .check-text small { display: block; color: var(--ih-text-subtle); font-size: var(--ih-text-xs); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; margin: 0; flex: none; inline-size: 36px; block-size: 20px; border-radius: 10px; background: var(--ih-neutral-300); position: relative; cursor: pointer; transition: background var(--ih-duration-base) var(--ih-ease); }
html[data-theme="dark"] .switch input { background: var(--ih-neutral-700); }
.switch input::after { content: ""; position: absolute; inset-block-start: 2px; inset-inline-start: 2px; inline-size: 16px; block-size: 16px; border-radius: 50%; background: #fff; box-shadow: var(--ih-shadow-sm); transition: inset-inline-start var(--ih-duration-base) var(--ih-ease); }
.switch input:checked { background: var(--ih-primary); }
.switch input:checked::after { inset-inline-start: 18px; }
.switch input:focus-visible { outline: 3px solid var(--ih-focus-ring); outline-offset: 2px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--ih-space-4) var(--ih-space-5); align-items: start; }
.form-grid .field + .field { margin: 0; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--ih-space-2); padding-block-start: var(--ih-space-5); margin-block-start: var(--ih-space-5); border-block-start: 1px solid var(--ih-border); }

/* ---------- Card ---------- */
.card { background: var(--ih-surface); border: 1px solid var(--ih-border); border-radius: var(--ih-radius-lg); box-shadow: var(--ih-shadow-sm); min-inline-size: 0; }
html[data-theme="dark"] .card { box-shadow: none; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--ih-space-3); padding: var(--ih-space-4) var(--ih-space-5); border-block-end: 1px solid var(--ih-border); min-block-size: 60px; }
.card-title { font-size: var(--ih-text-md); font-weight: 700; }
.card-subtitle { font-size: var(--ih-text-sm); color: var(--ih-text-subtle); margin-block-start: 2px; }
.card-body { padding: var(--ih-space-5); }
.card-footer { padding: var(--ih-space-3) var(--ih-space-5); border-block-start: 1px solid var(--ih-border); display: flex; align-items: center; justify-content: space-between; gap: var(--ih-space-3); }
.card-flush .card-body { padding: 0; }
.card.is-interactive { transition: border-color var(--ih-duration-fast) var(--ih-ease), box-shadow var(--ih-duration-fast) var(--ih-ease), transform var(--ih-duration-fast) var(--ih-ease); }
.card.is-interactive:hover { border-color: var(--ih-purple-300); box-shadow: var(--ih-shadow-md); transform: translateY(-1px); }
.card.is-accent { border-block-start: 3px solid transparent; border-image: var(--ih-gradient) 1; border-image-slice: 1 0 0 0; }

/* ---------- Stat (KPI) ---------- */
.stat { padding: var(--ih-space-5); display: grid; gap: 6px; align-content: start; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: var(--ih-space-2); }
.stat-label { font-size: var(--ih-text-sm); font-weight: 600; color: var(--ih-text-muted); }
.stat-icon { inline-size: 36px; block-size: 36px; border-radius: var(--ih-radius-md); display: grid; place-items: center; background: var(--ih-primary-soft); color: var(--ih-primary); }
html[data-theme="dark"] .stat-icon { color: var(--ih-link); }
.stat-icon.is-accent { background: var(--ih-accent-soft); color: var(--ih-accent-text); }
.stat-value { font-size: 28px; line-height: 1.2; font-weight: 800; letter-spacing: -0.02em; }
.stat-value small { font-size: var(--ih-text-sm); font-weight: 600; color: var(--ih-text-subtle); letter-spacing: 0; margin-inline-start: 4px; }
.stat-meta { display: flex; align-items: center; gap: 6px; font-size: var(--ih-text-xs); color: var(--ih-text-subtle); }
.trend { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; }
.trend .icon { inline-size: 14px; block-size: 14px; }
.trend.is-up { color: var(--ih-success); }
.trend.is-down { color: var(--ih-danger); }

/* ---------- Badge, chip ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; block-size: 24px; padding: 0 10px; border-radius: var(--ih-radius-full); font-size: var(--ih-text-xs); font-weight: 600; white-space: nowrap; border: 1px solid transparent; background: var(--ih-surface-sunken); color: var(--ih-text-muted); }
.badge .dot { inline-size: 6px; block-size: 6px; border-radius: 50%; background: currentColor; }
.badge-brand { background: var(--ih-primary-soft); color: var(--ih-primary); }
html[data-theme="dark"] .badge-brand { color: var(--ih-link); }
.badge-success { background: var(--ih-success-bg); color: var(--ih-success); border-color: var(--ih-success-border); }
.badge-warning { background: var(--ih-warning-bg); color: var(--ih-warning); border-color: var(--ih-warning-border); }
.badge-danger { background: var(--ih-danger-bg); color: var(--ih-danger); border-color: var(--ih-danger-border); }
.badge-info { background: var(--ih-info-bg); color: var(--ih-info); border-color: var(--ih-info-border); }
.badge-spark { background: var(--ih-yellow-400); color: var(--ih-neutral-900); }
.badge-outline { background: transparent; border-color: var(--ih-border-strong); }

.chip { display: inline-flex; align-items: center; gap: 6px; block-size: 32px; padding: 0 12px; border-radius: var(--ih-radius-full); border: 1px solid var(--ih-border-strong); background: var(--ih-surface); color: var(--ih-text-muted); font-weight: 600; font-size: var(--ih-text-sm); }
.chip:hover { border-color: var(--ih-neutral-400); color: var(--ih-text); }
.chip[aria-pressed="true"] { background: var(--ih-primary-soft); border-color: var(--ih-primary); color: var(--ih-primary); }
html[data-theme="dark"] .chip[aria-pressed="true"] { color: var(--ih-link); border-color: var(--ih-link); }
.chip .icon { inline-size: 16px; block-size: 16px; }
.chip .count { font-size: 11px; background: var(--ih-surface-sunken); border-radius: 8px; padding: 1px 6px; }

/* ---------- Avatar ---------- */
.avatar { --av: 36px; inline-size: var(--av); block-size: var(--av); border-radius: 50%; flex: none; display: grid; place-items: center; overflow: hidden; background: var(--ih-purple-100); color: var(--ih-purple-700); font-weight: 700; font-size: calc(var(--av) * 0.36); line-height: 1; }
html[data-theme="dark"] .avatar { background: var(--ih-purple-900); color: var(--ih-purple-200); }
.avatar img { inline-size: 100%; block-size: 100%; object-fit: cover; }
.avatar-sm { --av: 28px; } .avatar-lg { --av: 48px; } .avatar-xl { --av: 72px; }
.avatar.tone-2 { background: var(--ih-yellow-100); color: var(--ih-yellow-800); }
.avatar.tone-3 { background: #DDF1EE; color: #1F6B62; }
.avatar.tone-4 { background: #F6E1E8; color: #8E3354; }
html[data-theme="dark"] .avatar.tone-2 { background: var(--ih-yellow-900); color: var(--ih-yellow-200); }
html[data-theme="dark"] .avatar.tone-3 { background: #173B37; color: #9ED9D0; }
html[data-theme="dark"] .avatar.tone-4 { background: #43202D; color: #F0B6C8; }
.avatar-group { display: flex; }
.avatar-group .avatar { box-shadow: 0 0 0 2px var(--ih-surface); }
.avatar-group .avatar + .avatar { margin-inline-start: -8px; }
.person { display: flex; align-items: center; gap: var(--ih-space-3); min-inline-size: 0; }
.person-name { font-weight: 600; }
.person-meta { font-size: var(--ih-text-xs); color: var(--ih-text-subtle); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { inline-size: 100%; font-size: var(--ih-text-sm); }
.table th, .table td { padding: 12px var(--ih-space-4); text-align: start; border-block-end: 1px solid var(--ih-border); vertical-align: middle; }
.table thead th { position: sticky; inset-block-start: 0; background: var(--ih-surface); font-size: var(--ih-text-xs); font-weight: 700; color: var(--ih-text-subtle); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
html[lang="ar"] .table thead th { text-transform: none; letter-spacing: 0; font-size: 13px; }
.table tbody tr { transition: background var(--ih-duration-fast) var(--ih-ease); }
.table tbody tr:hover { background: var(--ih-neutral-25); }
html[data-theme="dark"] .table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.table tbody tr[aria-selected="true"] { background: var(--ih-primary-soft); }
.table tbody tr:last-child td { border-block-end: 0; }
.table .col-check { inline-size: 44px; padding-inline-end: 0; }
.table .col-actions { inline-size: 56px; text-align: end; }
.table td.num, .table th.num { text-align: end; }
.th-sort { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; }
.th-sort .icon { inline-size: 14px; block-size: 14px; opacity: 0.5; }
.th-sort[aria-sort] .icon { opacity: 1; color: var(--ih-primary); }
.table-title { font-weight: 600; color: var(--ih-text); }
.table-title:hover { color: var(--ih-link); }
.table-sub { display: block; font-size: var(--ih-text-xs); color: var(--ih-text-subtle); margin-block-start: 2px; }

.toolbar { display: flex; align-items: center; gap: var(--ih-space-2); flex-wrap: wrap; padding: var(--ih-space-3) var(--ih-space-4); border-block-end: 1px solid var(--ih-border); }
.toolbar .input-wrap { flex: 1; min-inline-size: 200px; max-inline-size: 360px; }
.toolbar .spacer { flex: 1; }
.bulk-bar { display: none; align-items: center; gap: var(--ih-space-3); padding: 8px var(--ih-space-4); background: var(--ih-primary-soft); border-block-end: 1px solid var(--ih-border); font-weight: 600; font-size: var(--ih-text-sm); }
.bulk-bar.is-active { display: flex; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--ih-space-3); flex-wrap: wrap; padding: var(--ih-space-3) var(--ih-space-4); font-size: var(--ih-text-sm); color: var(--ih-text-subtle); }
.pages { display: flex; gap: 4px; }
.pages a, .pages span { min-inline-size: 32px; block-size: 32px; display: grid; place-items: center; padding: 0 8px; border-radius: var(--ih-radius-sm); color: var(--ih-text-muted); font-weight: 600; }
.pages a:hover { background: var(--ih-surface-sunken); text-decoration: none; }
.pages a[aria-current="page"] { background: var(--ih-primary); color: var(--ih-text-on-brand); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: var(--ih-space-1); border-block-end: 1px solid var(--ih-border); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 12px var(--ih-space-3); border: 0; background: none; color: var(--ih-text-muted); font-weight: 600; font-size: var(--ih-text-sm); white-space: nowrap; }
.tab:hover { color: var(--ih-text); }
.tab[aria-selected="true"] { color: var(--ih-primary); }
html[data-theme="dark"] .tab[aria-selected="true"] { color: var(--ih-link); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; inset-inline: var(--ih-space-3); inset-block-end: -1px; block-size: 2px; border-radius: 2px; background: currentColor; }
.tab .count { font-size: 11px; background: var(--ih-surface-sunken); color: var(--ih-text-muted); border-radius: 9px; padding: 1px 7px; }
.tab-panel { padding-block-start: var(--ih-space-5); }
.tab-panel[hidden] { display: none; }

/* ---------- Breadcrumb ---------- */
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: var(--ih-text-sm); color: var(--ih-text-subtle); list-style: none; }
.breadcrumb li { display: flex; align-items: center; gap: 6px; }
.breadcrumb li + li::before { content: "/"; color: var(--ih-border-strong); }
.breadcrumb a { color: var(--ih-text-muted); }
.breadcrumb [aria-current="page"] { color: var(--ih-text); font-weight: 600; }

/* ---------- Alert ---------- */
.alert { display: flex; gap: var(--ih-space-3); padding: var(--ih-space-4); border-radius: var(--ih-radius-md); border: 1px solid; font-size: var(--ih-text-sm); }
.alert > .icon { margin-block-start: 1px; }
.alert-title { font-weight: 700; margin-block-end: 2px; }
.alert-body { flex: 1; color: var(--ih-text); }
.alert-info { background: var(--ih-info-bg); border-color: var(--ih-info-border); } .alert-info > .icon { color: var(--ih-info); }
.alert-success { background: var(--ih-success-bg); border-color: var(--ih-success-border); } .alert-success > .icon { color: var(--ih-success); }
.alert-warning { background: var(--ih-warning-bg); border-color: var(--ih-warning-border); } .alert-warning > .icon { color: var(--ih-warning); }
.alert-danger { background: var(--ih-danger-bg); border-color: var(--ih-danger-border); } .alert-danger > .icon { color: var(--ih-danger); }
.alert-brand { background: var(--ih-primary-soft); border-color: transparent; } .alert-brand > .icon { color: var(--ih-primary); }

/* ---------- Toast ---------- */
.toasts { position: fixed; inset-block-end: var(--ih-space-5); inset-inline-end: var(--ih-space-5); z-index: 90; display: grid; gap: var(--ih-space-2); inline-size: min(380px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: var(--ih-space-3); padding: 14px var(--ih-space-4); background: var(--ih-neutral-900); color: #fff; border-radius: var(--ih-radius-md); box-shadow: var(--ih-shadow-lg); font-size: var(--ih-text-sm); font-weight: 500; animation: ih-toast-in var(--ih-duration-slow) var(--ih-ease); }
html[data-theme="dark"] .toast { background: var(--ih-neutral-800); border: 1px solid var(--ih-neutral-700); }
.toast .icon { margin-block-start: 1px; }
.toast.is-success .icon { color: #5CC594; } .toast.is-danger .icon { color: #F08080; } .toast.is-info .icon { color: #B5A6DC; }
.toast .toast-close { margin-inline-start: auto; background: none; border: 0; color: rgba(255,255,255,.6); padding: 0; }
.toast.is-leaving { animation: ih-toast-out var(--ih-duration-base) var(--ih-ease) forwards; }
@keyframes ih-toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes ih-toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Dropdown menu ---------- */
.dropdown { position: relative; }
.menu {
  position: absolute; z-index: 60; inset-block-start: calc(100% + 6px); inset-inline-end: 0; min-inline-size: 220px;
  padding: 6px; background: var(--ih-surface-raised); border: 1px solid var(--ih-border); border-radius: var(--ih-radius-lg); box-shadow: var(--ih-shadow-lg);
  display: none; /* closed menus take no space, so they can never widen the page */
}
[aria-expanded="true"] + .menu { display: block; animation: ih-menu-in var(--ih-duration-fast) var(--ih-ease); }
@keyframes ih-menu-in { from { opacity: 0; transform: translateY(-4px); } }
.menu.is-start { inset-inline-end: auto; inset-inline-start: 0; }
.menu.is-wide { inline-size: 360px; max-inline-size: calc(100vw - 24px); }
.menu-item { display: flex; align-items: center; gap: 10px; inline-size: 100%; padding: 9px 10px; border: 0; background: none; border-radius: var(--ih-radius-sm); color: var(--ih-text); font-size: var(--ih-text-sm); font-weight: 500; text-align: start; }
.menu-item:hover, .menu-item:focus-visible { background: var(--ih-surface-sunken); text-decoration: none; outline: none; }
.menu-item .icon { inline-size: 18px; block-size: 18px; color: var(--ih-text-subtle); }
.menu-item.is-danger, .menu-item.is-danger .icon { color: var(--ih-danger); }
.menu-item .menu-hint { margin-inline-start: auto; font-size: var(--ih-text-xs); color: var(--ih-text-subtle); }
.menu-sep { block-size: 1px; background: var(--ih-border); margin: 6px -6px; }
.menu-head { padding: 10px; display: flex; align-items: center; gap: var(--ih-space-3); }
.menu-title { padding: 8px 10px 4px; font-size: var(--ih-text-xs); font-weight: 700; color: var(--ih-text-subtle); text-transform: uppercase; letter-spacing: 0.06em; }
html[lang="ar"] .menu-title { text-transform: none; letter-spacing: 0; }

/* Notifications list (inside a menu or a card) */
.notice { display: flex; gap: var(--ih-space-3); padding: 10px; border-radius: var(--ih-radius-sm); }
.notice:hover { background: var(--ih-surface-sunken); }
.notice-body { flex: 1; min-inline-size: 0; font-size: var(--ih-text-sm); }
.notice-time { display: block; font-size: var(--ih-text-xs); color: var(--ih-text-subtle); margin-block-start: 2px; }
.notice.is-unread .notice-body::before { content: ""; float: inline-end; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--ih-primary); margin-block-start: 6px; }

/* ---------- Tooltip: data-tip="text" ---------- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; z-index: 70; inset-block-end: calc(100% + 8px); inset-inline-start: 50%; transform: translateX(-50%);
  padding: 6px 10px; border-radius: var(--ih-radius-sm); background: var(--ih-neutral-900); color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity var(--ih-duration-fast) var(--ih-ease);
}
[dir="rtl"] [data-tip]::after { transform: translateX(50%); }
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; transition-delay: 300ms; }
[data-tip-side="end"]::after { inset-block-end: auto; inset-block-start: 50%; inset-inline-start: calc(100% + 10px); transform: translateY(-50%) !important; }
/* Sidebar tooltips only when collapsed */
.sidebar .nav-link[data-tip]::after { display: none; }
@media (min-width: 1024px) { html[data-sidebar-collapsed="true"] .sidebar .nav-link[data-tip]::after { display: block; } }
html[data-sidebar-collapsed="true"] .sidebar { overflow: visible; }
html[data-sidebar-collapsed="true"] .sidebar-nav { overflow: visible; }

/* ---------- Dialog (native <dialog>) ---------- */
.dialog { inline-size: min(560px, calc(100vw - 32px)); max-block-size: calc(100vh - 64px); padding: 0; border: 0; border-radius: var(--ih-radius-xl); background: var(--ih-surface); color: var(--ih-text); box-shadow: var(--ih-shadow-lg); }
html[data-theme="dark"] .dialog { border: 1px solid var(--ih-border); }
.dialog::backdrop { background: rgba(18, 16, 24, 0.55); backdrop-filter: blur(2px); }
.dialog[open] { animation: ih-dialog-in var(--ih-duration-slow) var(--ih-ease); }
@keyframes ih-dialog-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--ih-space-3); padding: var(--ih-space-5) var(--ih-space-6) 0; }
.dialog-title { font-size: var(--ih-text-lg); font-weight: 700; }
.dialog-body { padding: var(--ih-space-4) var(--ih-space-6); color: var(--ih-text-muted); }
.dialog-footer { display: flex; justify-content: flex-end; gap: var(--ih-space-2); padding: var(--ih-space-4) var(--ih-space-6) var(--ih-space-5); }
.dialog-icon { inline-size: 44px; block-size: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--ih-danger-bg); color: var(--ih-danger); margin-block-end: var(--ih-space-3); }

/* ---------- Drawer (side panel) ---------- */
.drawer { position: fixed; inset-block: 0; inset-inline-end: 0; z-index: 80; inline-size: min(400px, 100vw); background: var(--ih-surface); box-shadow: var(--ih-shadow-lg); display: flex; flex-direction: column; transform: translateX(100%); transition: transform var(--ih-duration-slow) var(--ih-ease); visibility: hidden; }
[dir="rtl"] .drawer { transform: translateX(-100%); }
.drawer.is-open { transform: none; visibility: visible; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: var(--ih-space-4) var(--ih-space-5); border-block-end: 1px solid var(--ih-border); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--ih-space-5); }
.drawer-section + .drawer-section { margin-block-start: var(--ih-space-6); padding-block-start: var(--ih-space-6); border-block-start: 1px solid var(--ih-border); }
.drawer-section-title { font-size: var(--ih-text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ih-text-subtle); margin-block-end: var(--ih-space-1); }
html[lang="ar"] .drawer-section-title { text-transform: none; letter-spacing: 0; font-size: 13px; }

/* Colour swatches (tenant accent picker) */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { inline-size: 32px; block-size: 32px; border-radius: 50%; border: 2px solid var(--ih-surface); box-shadow: 0 0 0 1px var(--ih-border-strong); padding: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ih-text); }

/* ---------- Empty state ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: var(--ih-space-2); padding: var(--ih-space-12) var(--ih-space-6); }
.empty-art { inline-size: 64px; block-size: 64px; border-radius: var(--ih-radius-xl); display: grid; place-items: center; background: var(--ih-primary-soft); color: var(--ih-primary); margin-block-end: var(--ih-space-2); }
html[data-theme="dark"] .empty-art { color: var(--ih-link); }
.empty-art .icon { inline-size: 30px; block-size: 30px; stroke-width: 1.5; }
.empty-title { font-size: var(--ih-text-md); font-weight: 700; }
.empty-text { color: var(--ih-text-muted); max-inline-size: 380px; margin-block-end: var(--ih-space-3); }

/* ---------- Progress, meter ---------- */
.progress { block-size: 8px; background: var(--ih-surface-sunken); border-radius: var(--ih-radius-full); overflow: hidden; }
.progress > span { display: block; block-size: 100%; border-radius: inherit; background: var(--ih-primary); transition: inline-size var(--ih-duration-slow) var(--ih-ease); }
.progress.is-brand > span { background: var(--ih-gradient); }
[dir="rtl"] .progress.is-brand > span { background: linear-gradient(-45deg, #F4C827 0%, #A58374 46%, #5A4596 100%); }
.progress-sm { block-size: 6px; }
.progress-label { display: flex; justify-content: space-between; font-size: var(--ih-text-sm); margin-block-end: 6px; }
.progress-label span:last-child { color: var(--ih-text-subtle); font-variant-numeric: tabular-nums; }

/* ---------- Stepper (idea stages, workflow) ---------- */
.stepper { display: flex; list-style: none; counter-reset: step; }
.step { flex: 1; position: relative; display: grid; justify-items: center; gap: 8px; text-align: center; font-size: var(--ih-text-xs); font-weight: 600; color: var(--ih-text-subtle); padding-inline: 4px; }
.step::before { counter-increment: step; content: counter(step); position: relative; z-index: 1; inline-size: 32px; block-size: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--ih-surface); border: 2px solid var(--ih-border-strong); font-size: var(--ih-text-sm); font-weight: 700; color: var(--ih-text-subtle); }
.step::after { content: ""; position: absolute; inset-block-start: 15px; inset-inline-start: calc(50% + 16px); inline-size: calc(100% - 32px); block-size: 2px; background: var(--ih-border-strong); }
.step:last-child::after { display: none; }
.step.is-done { color: var(--ih-text-muted); }
.step.is-done::before { content: "✓"; background: var(--ih-primary); border-color: var(--ih-primary); color: #fff; }
.step.is-done::after { background: var(--ih-primary); }
.step.is-current { color: var(--ih-text); }
.step.is-current::before { border-color: var(--ih-primary); color: var(--ih-primary); box-shadow: 0 0 0 4px var(--ih-primary-soft); }
html[data-theme="dark"] .step.is-current::before { color: var(--ih-link); border-color: var(--ih-link); }

/* ---------- Timeline (activity) ---------- */
.timeline { list-style: none; display: grid; gap: var(--ih-space-4); }
.timeline li { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--ih-space-3); position: relative; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; inset-inline-start: 15px; inset-block: 34px -14px; inline-size: 2px; background: var(--ih-border); }
.timeline .tl-icon { inline-size: 32px; block-size: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--ih-surface-sunken); color: var(--ih-text-muted); }
.timeline .tl-icon .icon { inline-size: 16px; block-size: 16px; }
.timeline .tl-text { font-size: var(--ih-text-sm); padding-block-start: 6px; }
.timeline .tl-time { font-size: var(--ih-text-xs); color: var(--ih-text-subtle); }

/* ---------- Description list (detail pages) ---------- */
.dl { display: grid; grid-template-columns: minmax(120px, 180px) minmax(0, 1fr); gap: var(--ih-space-3) var(--ih-space-4); font-size: var(--ih-text-sm); }
.dl dt { color: var(--ih-text-subtle); font-weight: 600; }
.dl dd { margin: 0; color: var(--ih-text); }

/* ---------- List group ---------- */
.list { list-style: none; }
.list > li { display: flex; align-items: center; gap: var(--ih-space-3); padding: 12px var(--ih-space-5); border-block-end: 1px solid var(--ih-border); }
.list > li:last-child { border-block-end: 0; }

/* ---------- Skeleton loader ---------- */
.skeleton { display: block; border-radius: var(--ih-radius-sm); background: linear-gradient(90deg, var(--ih-surface-sunken) 25%, var(--ih-neutral-50) 50%, var(--ih-surface-sunken) 75%); background-size: 200% 100%; animation: ih-shimmer 1.4s infinite linear; }
html[data-theme="dark"] .skeleton { background: linear-gradient(90deg, var(--ih-neutral-800) 25%, var(--ih-neutral-700) 50%, var(--ih-neutral-800) 75%); background-size: 200% 100%; }
@keyframes ih-shimmer { to { background-position: -200% 0; } }

/* ---------- Spinner, kbd, divider ---------- */
.spinner { inline-size: 20px; block-size: 20px; border-radius: 50%; border: 2px solid var(--ih-primary-soft); border-block-start-color: var(--ih-primary); animation: ih-spin 0.7s linear infinite; }
.kbd { display: inline-grid; place-items: center; min-inline-size: 22px; block-size: 22px; padding: 0 6px; border: 1px solid var(--ih-border-strong); border-block-end-width: 2px; border-radius: 5px; font-family: var(--ih-font-mono); font-size: 11px; color: var(--ih-text-subtle); background: var(--ih-surface); }
.divider { display: flex; align-items: center; gap: var(--ih-space-3); color: var(--ih-text-subtle); font-size: var(--ih-text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
html[lang="ar"] .divider { text-transform: none; letter-spacing: 0; }
.divider::before, .divider::after { content: ""; flex: 1; block-size: 1px; background: var(--ih-border); }

@media (max-width: 767px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px var(--ih-space-4); }
  .dl dd { margin-block-end: var(--ih-space-3); }
  .toasts { inset-inline: 16px; inset-block-end: 16px; inline-size: auto; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { inline-size: 100%; }
}

/* Left-to-right input (email, URL, code) inside an Arabic page: keep the icon side padded */
[dir="rtl"] .input-wrap > .icon ~ .input[dir="ltr"] { padding-inline-end: 40px; padding-inline-start: 12px; text-align: end; }
[dir="rtl"] .input[dir="ltr"]::placeholder { text-align: end; }
@media (max-width: 767px) {
  .stat { padding: var(--ih-space-4); }
  .stat-value { font-size: 24px; }
  .stat-icon { inline-size: 32px; block-size: 32px; }
}

/* ==========================================================================
   Stage 2 components
   ========================================================================== */

/* ---------- Charts (drawn by charts.js) ---------- */
.chart { position: relative; margin: 0; min-inline-size: 0; }
.chart-plot svg { display: block; overflow: visible; }
.chart-grid { stroke: var(--ih-border); stroke-width: 1; }
.chart-base { stroke: var(--ih-border-strong); stroke-width: 1; }
.chart-tick { fill: var(--ih-text-subtle); font-size: 11px; font-family: inherit; }
.chart-value { fill: var(--ih-text); font-size: 12px; font-weight: 700; font-family: inherit; }
.chart-line { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { opacity: 0.1; }
.chart-dot { stroke: var(--ih-surface); stroke-width: 2; }
.chart-hl, .chart-cross { opacity: 0; pointer-events: none; }
.chart-hl.is-on { opacity: 1; }
.chart-cross { stroke: var(--ih-border-strong); stroke-width: 1; }
.chart-cross.is-on { opacity: 1; }
.chart-hit { fill: transparent; outline: none; cursor: default; }
.chart-hit.is-on, .chart-hit:focus-visible { fill: var(--ih-text); fill-opacity: 0.04; }

.chart-tip { position: absolute; z-index: 5; min-inline-size: 140px; padding: 8px 10px; border-radius: var(--ih-radius-md); background: var(--ih-surface-raised); border: 1px solid var(--ih-border); box-shadow: var(--ih-shadow-md); font-size: 12px; pointer-events: none; opacity: 0; transition: opacity var(--ih-duration-fast) var(--ih-ease); }
.chart-tip.is-visible { opacity: 1; }
.chart-tip-title { font-weight: 700; margin-block-end: 4px; color: var(--ih-text); }
.chart-tip-row { display: flex; align-items: center; gap: 6px; color: var(--ih-text-muted); white-space: nowrap; }
.chart-tip-row b { margin-inline-start: auto; padding-inline-start: 12px; color: var(--ih-text); font-variant-numeric: tabular-nums; }
.chart-key { inline-size: 10px; block-size: 10px; border-radius: 3px; flex: none; display: inline-block; }
.chart-key.is-line { block-size: 3px; inline-size: 14px; border-radius: 2px; }
.chart-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin-block-start: var(--ih-space-3); font-size: var(--ih-text-xs); color: var(--ih-text-muted); }
.chart-legend li { display: flex; align-items: center; gap: 6px; }

.chart-bars { display: grid; gap: 10px; grid-template-columns: minmax(90px, 0.9fr) minmax(0, 2fr) auto; }
.chart-bar-row { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center; gap: var(--ih-space-3); font-size: var(--ih-text-sm); border-radius: var(--ih-radius-xs); outline-offset: 4px; }
.chart-bar-label { color: var(--ih-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-bar-track { block-size: 12px; display: flex; }
.chart-bar-fill { display: block; block-size: 100%; border-start-end-radius: 4px; border-end-end-radius: 4px; }
.chart-bar-value { font-weight: 700; font-variant-numeric: tabular-nums; min-inline-size: 48px; text-align: end; white-space: nowrap; }
.chart-bars.is-funnel { grid-template-columns: max-content minmax(0, 1fr) max-content; }
.chart-bars.is-funnel .chart-bar-track { block-size: 20px; }
.chart-bar-row:hover .chart-bar-label { color: var(--ih-text); }

.chart-segments { display: flex; gap: 2px; block-size: 28px; }
.chart-seg { position: relative; display: flex; align-items: center; min-inline-size: 2px; border-radius: 4px; padding-inline: 8px; outline-offset: 2px; }
.chart-seg-label { color: #fff; font-size: 12px; font-weight: 700; white-space: nowrap; }

.chart.show-table :is(.chart-plot, .chart-bars, .chart-segments, .chart-legend) { display: none; }
.chart-table { margin-block-start: var(--ih-space-2); }
.chart-table .table th, .chart-table .table td { padding: 8px 12px; }

/* ---------- Hero figure (one per view) ---------- */
.hero-figure { font-size: 48px; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; }
.hero-figure small { font-size: var(--ih-text-lg); font-weight: 600; color: var(--ih-text-subtle); letter-spacing: 0; margin-inline-start: 6px; }

/* ---------- Welcome band (dashboards) ---------- */
.welcome { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: var(--ih-space-6); flex-wrap: wrap; padding: var(--ih-space-6) var(--ih-space-8); border-radius: var(--ih-radius-xl); color: #fff; background: radial-gradient(90% 140% at 100% 0%, rgba(244, 200, 39, 0.18), transparent 60%), var(--ih-sidebar-brand-bg, var(--ih-deep)); }
[dir="rtl"] .welcome { background: radial-gradient(90% 140% at 0% 0%, rgba(244, 200, 39, 0.18), transparent 60%), var(--ih-sidebar-brand-bg, var(--ih-deep)); }
.welcome h1 { color: #fff; font-size: var(--ih-text-2xl); }
.welcome p { color: rgba(255, 255, 255, 0.78); margin-block-start: 4px; }
.welcome .btn-secondary { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.25); color: #fff; box-shadow: none; }
.welcome .btn-secondary:hover { background: rgba(255, 255, 255, 0.18); }
.welcome-stats { display: flex; gap: var(--ih-space-8); flex-wrap: wrap; }
.welcome-stats div b { display: block; font-size: var(--ih-text-2xl); font-weight: 800; line-height: 1.2; }
.welcome-stats div span { font-size: var(--ih-text-xs); color: rgba(255, 255, 255, 0.7); }

/* ---------- Level and points ---------- */
.level { display: grid; gap: var(--ih-space-4); }
.level-top { display: flex; align-items: center; gap: var(--ih-space-4); }
.level-badge { inline-size: 56px; block-size: 56px; flex: none; border-radius: var(--ih-radius-lg); display: grid; place-items: center; background: var(--ih-accent-soft); color: var(--ih-accent-text); position: relative; }
.level-badge .icon { inline-size: 28px; block-size: 28px; }
.level-badge b { position: absolute; inset-block-end: -6px; inset-inline-end: -6px; min-inline-size: 22px; block-size: 22px; padding: 0 5px; border-radius: 11px; display: grid; place-items: center; font-size: 12px; background: var(--ih-primary); color: var(--ih-text-on-brand); box-shadow: 0 0 0 2px var(--ih-surface); }
.level-name { font-weight: 700; font-size: var(--ih-text-md); }
.level-points { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.level-points small { font-size: var(--ih-text-sm); font-weight: 600; color: var(--ih-text-subtle); letter-spacing: 0; margin-inline-start: 4px; }
.badges-row { display: flex; gap: var(--ih-space-2); flex-wrap: wrap; }
.achievement { inline-size: 40px; block-size: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--ih-primary-soft); color: var(--ih-primary); }
html[data-theme="dark"] .achievement { color: var(--ih-link); }
.achievement .icon { inline-size: 18px; block-size: 18px; }
.achievement.is-locked { background: var(--ih-surface-sunken); color: var(--ih-text-subtle); opacity: 0.7; }

/* ---------- Ranking (leaderboard) ---------- */
.rank-list { list-style: none; }
.rank-list li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: var(--ih-space-3); padding: 10px var(--ih-space-5); border-block-end: 1px solid var(--ih-border); }
.rank-list li:last-child { border-block-end: 0; }
.rank-list li.is-me { background: var(--ih-primary-soft); }
.rank-no { inline-size: 26px; block-size: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--ih-text-muted); background: var(--ih-surface-sunken); }
.rank-list li:first-child .rank-no { background: var(--ih-yellow-400); color: var(--ih-neutral-900); }
.rank-pts { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-pts small { font-weight: 500; color: var(--ih-text-subtle); margin-inline-start: 4px; }

/* ---------- Challenge tile ---------- */
.tile-list { display: grid; gap: var(--ih-space-3); }
.challenge { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: var(--ih-space-3); align-items: center; padding: var(--ih-space-4); border: 1px solid var(--ih-border); border-radius: var(--ih-radius-lg); background: var(--ih-surface); color: inherit; transition: border-color var(--ih-duration-fast) var(--ih-ease); }
.challenge:hover { border-color: var(--ih-purple-300); text-decoration: none; }
.challenge-icon { inline-size: 44px; block-size: 44px; border-radius: var(--ih-radius-md); display: grid; place-items: center; background: var(--ih-primary-soft); color: var(--ih-primary); }
html[data-theme="dark"] .challenge-icon { color: var(--ih-link); }
.challenge-title { font-weight: 700; }
.challenge-meta { font-size: var(--ih-text-xs); color: var(--ih-text-subtle); margin-block-start: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.challenge-meta span { display: inline-flex; align-items: center; gap: 4px; }
.challenge-meta .icon { inline-size: 13px; block-size: 13px; }

/* ---------- Mini stage dots (status at a glance in lists) ---------- */
.dots { display: inline-flex; gap: 3px; align-items: center; }
.dots i { inline-size: 14px; block-size: 4px; border-radius: 2px; background: var(--ih-border-strong); }
.dots i.on { background: var(--ih-primary); }
html[data-theme="dark"] .dots i.on { background: var(--ih-link); }

/* ---------- Due-date label ---------- */
.due { display: inline-flex; align-items: center; gap: 4px; font-size: var(--ih-text-xs); font-weight: 600; color: var(--ih-text-subtle); white-space: nowrap; }
.due .icon { inline-size: 14px; block-size: 14px; }
.due.is-soon { color: var(--ih-warning); }
.due.is-late { color: var(--ih-danger); }

/* ---------- Checklist (setup steps) ---------- */
.checklist { list-style: none; }
.checklist li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: var(--ih-space-3); align-items: center; padding: 12px var(--ih-space-5); border-block-end: 1px solid var(--ih-border); }
.checklist li:last-child { border-block-end: 0; }
.check-dot { inline-size: 24px; block-size: 24px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--ih-border-strong); color: transparent; }
.check-dot .icon { inline-size: 14px; block-size: 14px; stroke-width: 3; }
.checklist li.is-done .check-dot { background: var(--ih-success); border-color: var(--ih-success); color: #fff; }
html[data-theme="dark"] .checklist li.is-done .check-dot { color: var(--ih-neutral-950); }
.checklist li.is-done .checklist-title { color: var(--ih-text-muted); }
.checklist-title { font-weight: 600; }
.checklist-text { font-size: var(--ih-text-xs); color: var(--ih-text-subtle); }

/* ---------- Meter (usage against a cap; fill shows severity) ---------- */
.meter { block-size: 10px; border-radius: var(--ih-radius-full); background: var(--ih-primary-soft); overflow: hidden; }
.meter > span { display: block; block-size: 100%; border-radius: inherit; background: var(--ih-primary); }
.meter.is-warning { background: var(--ih-warning-bg); } .meter.is-warning > span { background: var(--ih-warning); }
.meter.is-danger { background: var(--ih-danger-bg); } .meter.is-danger > span { background: var(--ih-danger); }

/* ---------- Status row (integrations, services) ---------- */
.status-row { display: flex; align-items: center; gap: var(--ih-space-3); padding: 12px var(--ih-space-5); border-block-end: 1px solid var(--ih-border); }
.status-row:last-child { border-block-end: 0; }
.status-icon { inline-size: 36px; block-size: 36px; border-radius: var(--ih-radius-md); display: grid; place-items: center; background: var(--ih-surface-sunken); color: var(--ih-text-muted); flex: none; }
.status-row .grow { flex: 1; min-inline-size: 0; }

/* ---------- File upload ---------- */
.dropzone { position: relative; display: grid; justify-items: center; gap: 6px; padding: var(--ih-space-8) var(--ih-space-5); border: 2px dashed var(--ih-border-strong); border-radius: var(--ih-radius-lg); text-align: center; color: var(--ih-text-muted); cursor: pointer; transition: border-color var(--ih-duration-fast) var(--ih-ease), background var(--ih-duration-fast) var(--ih-ease); }
.dropzone:hover, .dropzone.is-over, .dropzone:focus-within { border-color: var(--ih-primary); background: var(--ih-primary-soft); }
.dropzone .icon { inline-size: 28px; block-size: 28px; color: var(--ih-primary); }
html[data-theme="dark"] .dropzone .icon { color: var(--ih-link); }
.dropzone b { color: var(--ih-text); }
.dropzone input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.file-list { list-style: none; display: grid; gap: var(--ih-space-2); margin-block-start: var(--ih-space-3); }
.file-item { display: flex; align-items: center; gap: var(--ih-space-3); padding: 10px 12px; border: 1px solid var(--ih-border); border-radius: var(--ih-radius-md); font-size: var(--ih-text-sm); background: var(--ih-surface); }
.file-item .file-icon { inline-size: 34px; block-size: 34px; border-radius: var(--ih-radius-sm); display: grid; place-items: center; background: var(--ih-primary-soft); color: var(--ih-primary); flex: none; }
html[data-theme="dark"] .file-item .file-icon { color: var(--ih-link); }
.file-item .grow { flex: 1; min-inline-size: 0; }
.file-item .file-size { display: block; font-size: var(--ih-text-xs); color: var(--ih-text-subtle); }

/* ---------- Character counter ---------- */
.counter { font-size: var(--ih-text-xs); color: var(--ih-text-subtle); font-variant-numeric: tabular-nums; white-space: nowrap; }
.counter.is-over { color: var(--ih-danger); font-weight: 700; }
.field-foot { display: flex; justify-content: space-between; gap: var(--ih-space-3); }

/* ---------- Comments ---------- */
.comments { list-style: none; display: grid; gap: var(--ih-space-5); }
.comment { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: var(--ih-space-3); }
.comment-head { display: flex; align-items: baseline; gap: var(--ih-space-2); flex-wrap: wrap; }
.comment-head b { font-size: var(--ih-text-sm); }
.comment-head span { font-size: var(--ih-text-xs); color: var(--ih-text-subtle); }
.comment-body { margin-block-start: 4px; font-size: var(--ih-text-sm); color: var(--ih-text); }
.comment-actions { display: flex; gap: var(--ih-space-3); margin-block-start: 6px; font-size: var(--ih-text-xs); }
.comment-actions button { border: 0; background: none; padding: 0; color: var(--ih-text-subtle); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.comment-actions button:hover { color: var(--ih-text); }
.comment-actions .icon { inline-size: 14px; block-size: 14px; }
.comment.is-reply { margin-inline-start: 48px; }
.composer { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: var(--ih-space-3); }
.composer-box { border: 1px solid var(--ih-border-strong); border-radius: var(--ih-radius-md); background: var(--ih-surface); }
.composer-box:focus-within { border-color: var(--ih-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ih-focus-ring) 35%, transparent); }
.composer-box .textarea { border: 0; box-shadow: none !important; min-block-size: 64px; background: transparent; }
.composer-foot { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border-block-start: 1px solid var(--ih-border); }

/* ---------- Scoring (evaluation) ---------- */
.criterion { display: grid; gap: var(--ih-space-2); padding-block: var(--ih-space-4); border-block-end: 1px solid var(--ih-border); }
.criterion:first-child { padding-block-start: 0; }
.criterion-head { display: flex; justify-content: space-between; gap: var(--ih-space-3); align-items: baseline; }
.criterion-name { font-weight: 700; }
.criterion-weight { font-size: var(--ih-text-xs); color: var(--ih-text-subtle); white-space: nowrap; }
.criterion-help { font-size: var(--ih-text-xs); color: var(--ih-text-subtle); }
.rating { display: inline-flex; gap: 6px; flex-wrap: wrap; border: 0; padding: 0; margin: 0; }
.rating legend { padding: 0; }
.rating label { position: relative; }
.rating input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.rating span { inline-size: 40px; block-size: 40px; display: grid; place-items: center; border: 1px solid var(--ih-border-strong); border-radius: var(--ih-radius-md); font-weight: 700; color: var(--ih-text-muted); cursor: pointer; background: var(--ih-surface); transition: all var(--ih-duration-fast) var(--ih-ease); }
.rating label:hover span { border-color: var(--ih-primary); color: var(--ih-text); }
.rating input:checked + span { background: var(--ih-primary); border-color: var(--ih-primary); color: var(--ih-text-on-brand); }
.rating input:focus-visible + span { outline: 3px solid var(--ih-focus-ring); outline-offset: 2px; }
.rating-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--ih-text-subtle); max-inline-size: 224px; }
.score-summary { display: flex; align-items: center; justify-content: space-between; gap: var(--ih-space-3); padding: var(--ih-space-4); border-radius: var(--ih-radius-md); background: var(--ih-surface-sunken); }
.score-big { font-size: 32px; font-weight: 800; line-height: 1; }
.score-big small { font-size: var(--ih-text-sm); color: var(--ih-text-subtle); font-weight: 600; margin-inline-start: 4px; }
.score-row { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(0, 1.4fr) 36px; gap: var(--ih-space-3); align-items: center; font-size: var(--ih-text-sm); }
.score-row + .score-row { margin-block-start: 10px; }
.score-row .num { text-align: end; font-weight: 700; }

/* ---------- Long forms: step list, sections, sticky action bar ---------- */
.form-steps { list-style: none; display: grid; gap: 2px; }
.form-steps a { display: flex; align-items: center; gap: var(--ih-space-3); padding: 10px 12px; border-radius: var(--ih-radius-md); color: var(--ih-text-muted); font-weight: 600; font-size: var(--ih-text-sm); }
.form-steps a:hover { background: var(--ih-surface-sunken); text-decoration: none; }
.form-steps .step-no { inline-size: 24px; block-size: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; border: 1.5px solid var(--ih-border-strong); flex: none; }
.form-steps a[aria-current="step"] { color: var(--ih-text); background: var(--ih-primary-soft); }
.form-steps a[aria-current="step"] .step-no { background: var(--ih-primary); border-color: var(--ih-primary); color: var(--ih-text-on-brand); }
.form-steps a.is-done .step-no { background: var(--ih-success); border-color: var(--ih-success); color: #fff; }
.form-section { scroll-margin-block-start: calc(var(--ih-topbar) + 24px); }
.form-section-head { margin-block-end: var(--ih-space-4); }
.form-section-head h2 { font-size: var(--ih-text-lg); }
.form-section-head p { color: var(--ih-text-muted); font-size: var(--ih-text-sm); margin-block-start: 2px; }
.sticky-side { position: sticky; inset-block-start: calc(var(--ih-topbar) + 24px); }
.action-bar { position: sticky; inset-block-end: 12px; z-index: 20; display: flex; align-items: center; justify-content: flex-end; gap: var(--ih-space-2); padding: var(--ih-space-3) var(--ih-space-4); margin-block-start: var(--ih-space-6); background: color-mix(in srgb, var(--ih-surface) 94%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--ih-border); border-radius: var(--ih-radius-lg); box-shadow: var(--ih-shadow-md); }
.action-bar .spacer { flex: 1; }

@media (max-width: 1023px) {
  .sticky-side { position: static; }
}
@media (max-width: 767px) {
  .welcome { padding: var(--ih-space-5); }
  .welcome h1 { font-size: var(--ih-text-xl); }
  .welcome-stats { gap: var(--ih-space-5); }
  .hero-figure { font-size: 36px; }
  .chart-bars { grid-template-columns: minmax(70px, 0.8fr) minmax(0, 1.4fr) auto; }
  .chart-bar-row { gap: var(--ih-space-2); }
  .comment.is-reply { margin-inline-start: 24px; }
  .challenge { grid-template-columns: 40px minmax(0, 1fr); }
  .challenge > :last-child { grid-column: 1 / -1; justify-self: start; }
  .action-bar { flex-wrap: wrap; }
  .action-bar .btn { flex: 1; }
  .action-bar .spacer { display: none; }
  .score-row { grid-template-columns: minmax(90px, 1fr) minmax(0, 1fr) 32px; }
}

/* Title cells keep a readable width; the table scrolls inside .table-wrap instead of squeezing them */
.table td:has(> .table-title), .table td:has(> .person) { min-inline-size: 200px; }
.table td:has(> .person) { min-inline-size: 160px; }

/* Long-form layout: step list beside the form; on smaller screens the steps become a horizontal strip */
.doc-layout.form-layout { grid-template-columns: 220px minmax(0, 1fr); }
@media (max-width: 1279px) {
  .doc-layout.form-layout { grid-template-columns: minmax(0, 1fr); }
  .form-layout .form-steps { display: flex; overflow-x: auto; scrollbar-width: none; gap: 4px; }
  .form-layout .form-steps a { white-space: nowrap; }
}

/* A block of code or a sample request, left to right in both languages (the BI feed's and webhooks' pages). */
.code-block {
  margin: 0;
  padding: var(--ih-space-3) var(--ih-space-4);
  background: var(--ih-surface-sunken);
  border: 1px solid var(--ih-border);
  border-radius: var(--ih-radius-sm);
  overflow-x: auto;
  white-space: pre;
  line-height: 1.6;
  direction: ltr;
  text-align: start;
}
.code-block code { background: none; padding: 0; }
