/* Shell, layout and shared components. Colours only through tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow-x: clip; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.6 var(--f-body); -webkit-font-smoothing: antialiased; }
[dir="rtl"] body { line-height: 1.75; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
h1, h2, h3, h4 { margin: 0; font-weight: 500; line-height: 1.25; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico-s { width: 16px; height: 16px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.mono { font-family: var(--f-mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); color: var(--primary); font-weight: 500; font-size: 14px; transition: background var(--dur), border-color var(--dur), color var(--dur); white-space: nowrap; }
.btn:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn .ico { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn-danger:hover { filter: brightness(1.08); background: var(--danger); }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-quiet:hover { border-color: var(--line); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-bg); border-color: var(--danger); }
.iconbtn { position: relative; display: inline-grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink-2); flex: none; transition: background var(--dur), color var(--dur); }
.iconbtn:hover { background: var(--primary-soft); color: var(--primary); }
.iconbtn.bare { border-color: transparent; background: transparent; }
.iconbtn .dot { position: absolute; top: 7px; inset-inline-end: 7px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: var(--surface); font: 600 10.5px/17px var(--f-mono); text-align: center; }
.link { color: var(--primary); font-weight: 500; text-decoration: underline; text-decoration-color: var(--primary-soft-2); text-underline-offset: 4px; background: none; border: 0; padding: 8px 0; }
.link:hover { text-decoration-color: var(--primary); }

/* ---------- forms ---------- */
.fld { display: grid; gap: 6px; }
.fld > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.fld .help { font-size: 12.5px; color: var(--ink-3); }
.input, .fld input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .fld select, .fld textarea, .select {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); transition: border-color var(--dur), box-shadow var(--dur); }
.fld textarea { padding: 10px 12px; min-height: 90px; resize: vertical; }
.input:focus, .fld input:focus, .fld select:focus, .fld textarea:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft-2); }
.fld .err { color: var(--danger); font-size: 13px; }
.fld .err:empty { display: none; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.switch { position: relative; width: 44px; height: 26px; flex: none; appearance: none; background: var(--line); border-radius: 13px; cursor: pointer; transition: background var(--dur); }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); transition: transform var(--dur); }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(18px); }
[dir="rtl"] .switch:checked::after { transform: translateX(-18px); }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); }
.seg button { border: 0; background: transparent; min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 13px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: 1 / -1; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); height: 100dvh; }
.side { position: relative; isolation: isolate; overflow: hidden; background: var(--chrome); color: var(--on-chrome); display: flex; flex-direction: column; padding: 20px 14px 14px; }
.side .mash { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; opacity: .12; pointer-events: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.brand svg { width: 32px; height: 32px; color: var(--chrome-accent); }
.brand b { display: block; font-weight: 500; font-size: 14.5px; line-height: 1.25; }
.brand small { color: var(--on-chrome-2); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; margin-inline: -4px; padding-inline: 4px; }
.nav-head { margin: 16px 10px 6px; font-size: 12px; color: var(--on-chrome-2); }
.nav a { position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: var(--on-chrome-2); text-decoration: none; transition: background var(--dur), color var(--dur); }
.nav a:hover { background: var(--chrome-hover); color: var(--on-chrome); }
.nav a[aria-current="page"] { background: var(--chrome-current); color: var(--on-chrome); }
.nav a[aria-current="page"]::before { content: ""; position: absolute; inset-inline-start: -10px; top: 11px; bottom: 11px; width: 3px; border-radius: 3px; background: var(--chrome-accent); }
.nav .count { margin-inline-start: auto; font: 500 11px/1 var(--f-mono); padding: 3px 7px; border-radius: 999px; border: 1px solid var(--chrome-accent-line); color: var(--chrome-accent-ink); }
.me { display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; margin-top: 10px; border-top: 1px solid var(--chrome-line); }
.avatar { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--chrome-fill); border: 1px solid var(--chrome-accent-line-2); color: var(--chrome-accent-ink); font: 600 13px/1 var(--f-body); }
.me div { min-width: 0; flex: 1; }
.me b { display: block; font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me small { color: var(--on-chrome-2); font-size: 12px; }
.me .iconbtn { background: transparent; border-color: transparent; color: var(--on-chrome-2); }
.me .iconbtn:hover { background: var(--chrome-press); color: var(--on-chrome); }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; gap: 10px; padding: 11px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 6; }
.gsearch { flex: 1; max-width: 620px; position: relative; display: flex; align-items: center; min-width: 0; }
.gsearch .ico { position: absolute; inset-inline-start: 14px; color: var(--ink-3); pointer-events: none; }
.gsearch input { width: 100%; min-height: 44px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding-inline: 44px 44px; }
.gsearch input:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-soft-2); }
.gsearch kbd { position: absolute; inset-inline-end: 10px; font: 500 12px var(--f-mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 7px; color: var(--ink-3); background: var(--surface); }
.top-spacer { flex: 1; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.lang-mini { min-height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--primary); font-weight: 500; font-size: 13px; }
.lang-mini:hover { background: var(--primary-soft); }
.menu-btn { display: none; }
.top-ask { display: none; color: var(--primary); }
.sample-bar { display: flex; align-items: center; gap: 10px; padding: 9px 24px; background: var(--accent-soft); color: var(--ink); font-size: 13.5px; border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.sample-bar .ico { color: var(--accent); flex: none; }
.sample-bar b { font-weight: 600; }
@media (max-width: 767px) { .sample-bar { padding: 8px 16px; font-size: 13px; align-items: flex-start; } }
.offline { display: flex; align-items: center; gap: 10px; padding: 10px 24px; background: var(--warn-bg); color: var(--warn-ink); font-size: 14px; font-weight: 500; border-bottom: 1px solid var(--warn-line); }
.view { flex: 1; min-height: 0; overflow: auto; outline: none; position: relative; }
.view.flush { overflow: hidden; }
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); }

/* ---------- pages ---------- */
.page { padding: 28px 28px 80px; max-width: 1280px; margin: 0 auto; display: grid; gap: 22px; }
.page > * { min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.page-head h1 { font: 500 30px/1.2 var(--f-latin); font-variation-settings: "opsz" 96; letter-spacing: -.01em; }
[dir="rtl"] .page-head h1 { font: 500 30px/1.35 var(--f-kufi); letter-spacing: 0; }
.page-head p { color: var(--ink-2); max-width: 68ch; margin-top: 6px; }
.page-head .acts { display: flex; flex-wrap: wrap; gap: 8px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 18px 20px; min-width: 0; }
.panel > h2, .panel-h { font-size: 15px; font-weight: 500; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.panel-h .btn { margin-inline-start: auto; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.subtabs button { position: relative; border: 0; background: none; min-height: 44px; padding: 0 14px; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.subtabs button:hover { color: var(--primary); }
.subtabs button[aria-selected="true"] { color: var(--primary); }
.subtabs button[aria-selected="true"]::after { content: ""; position: absolute; inset-inline: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--primary); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters .select, .filters .input { width: auto; min-width: 170px; }
.search-in { position: relative; flex: 1; min-width: 200px; max-width: 400px; display: flex; align-items: center; }
.search-in .ico { position: absolute; inset-inline-start: 12px; color: var(--ink-3); pointer-events: none; }
.search-in .input { padding-inline: 40px; } /* symmetric: inputs use dir=auto, so 'start' may not match the icon side */
.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); display: grid; justify-items: center; gap: 8px; }
.empty h3 { font: 400 26px/1.3 var(--f-kufi); color: var(--primary); }

/* ---------- tables ---------- */
.tbl-wrap { position: relative; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: start; padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl th { font-weight: 500; font-size: 12.5px; color: var(--ink-2); background: var(--surface-2); white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl td.n, .tbl th.n { text-align: end; font-variant-numeric: tabular-nums; }
.tbl td strong { display: block; font-weight: 500; }
.tbl td small { display: block; color: var(--ink-2); font-size: 12.5px; }
.tbl .acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.tbl .is-off td { color: var(--ink-3); }

/* ---------- pills, tags, file glyphs ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: var(--line-soft); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.pill.info { background: var(--info-bg); color: var(--info-ink); }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); }
.ft { font: 600 10.5px/1 var(--f-mono); padding: 4px 6px; border-radius: 4px; }
.ft.pdf { background: var(--pdf-bg); color: var(--pdf); }
.ft.xls { background: var(--xls-bg); color: var(--xls); }
.ft.doc { background: var(--doc-bg); color: var(--doc); }
.glyph { position: relative; width: 36px; height: 44px; flex: none; }
.glyph svg { width: 100%; height: 100%; }
.glyph em { position: absolute; bottom: 6px; inset-inline: 0; text-align: center; font: 600 9px/1 var(--f-mono); font-style: normal; color: var(--surface); }
.glyph.pdf { color: var(--pdf); } .glyph.xls { color: var(--xls); } .glyph.doc { color: var(--doc); }

/* ---------- overlays ---------- */
.ov-scrim { position: fixed; inset: 0; z-index: 70; background: var(--scrim); animation: fade .18s both; }
.dialog { position: fixed; z-index: 71; top: 50%; left: 50%; translate: -50% -50%; width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--sh-2); padding: 24px; display: grid; gap: 14px; animation: pop .2s var(--ease) both; }
.dialog h2 { font: 500 21px/1.3 var(--f-latin); }
[dir="rtl"] .dialog h2 { font-family: var(--f-kufi); }
.dialog .acts { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.drawer { position: fixed; z-index: 71; top: 0; bottom: 0; inset-inline-end: 0; width: min(560px, 100vw); background: var(--surface); border-inline-start: 1px solid var(--line); box-shadow: var(--sh-2); display: flex; flex-direction: column; animation: slide-in .24s var(--ease) both; }
[dir="rtl"] .drawer { animation-name: slide-in-rtl; }
.drawer.wide { width: min(980px, 100vw); }
.drawer-h { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-h h2 { font: 500 19px/1.3 var(--f-latin); flex: 1; min-width: 0; }
[dir="rtl"] .drawer-h h2 { font-family: var(--f-kufi); }
.drawer-b { flex: 1; overflow: auto; padding: 20px; display: grid; gap: 16px; align-content: start; }
.drawer-f { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.menu-pop { position: absolute; z-index: 30; top: calc(100% + 8px); inset-inline-end: 0; width: min(380px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: var(--sh-2); padding: 8px; animation: pop .16s var(--ease) both; }
.menu-pop h3 { font-size: 14px; padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; }
.note-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 10px; border-radius: 10px; text-align: start; width: 100%; border: 0; background: none; }
.note-item:hover { background: var(--surface-2); }
.note-item.unread { background: var(--primary-soft); }
.note-item .ico { color: var(--accent); margin-top: 2px; }
.note-item b { display: block; font-weight: 500; font-size: 14px; }
.note-item small { color: var(--ink-2); font-size: 12.5px; }
#toasts { position: fixed; z-index: 90; top: 16px; left: 50%; translate: -50% 0; display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--sh-2); animation: pop .2s var(--ease) both; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
@keyframes slide-in-rtl { from { transform: translateX(-40px); opacity: 0; } }


/* ---------- responsive ---------- */
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 50; inset-block: 0; inset-inline-start: 0; width: min(290px, 86vw); transform: translateX(-105%); visibility: hidden; transition: transform .28s var(--ease), visibility .28s; }
  [dir="rtl"] .side { transform: translateX(105%); }
  .side.open { transform: none !important; visibility: visible; }
  .menu-btn { display: inline-grid; }
  .top { padding: 10px 12px; gap: 8px; }
  .gsearch kbd { display: none; }
  .gsearch input { padding-inline: 40px; }
  .page { padding: 20px 14px 110px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .top-ask { display: inline-grid; place-items: center; }
}
/* SRS 0.4.1.5: 44 px touch targets on tablets and phones (up to 1279 px) and on any touch screen. */
@media (max-width: 1279px), (pointer: coarse) {
  .iconbtn, .btn, .btn-sm, .lang-mini, .subtabs button, .seg button, .ad-cell { min-height: 44px; }
  .iconbtn, .ad-ib { width: 44px; height: 44px; }
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .lang-mini { padding: 0 10px; }
  .page-head h1 { font-size: 25px; }
  .filters .select, .filters .input { min-width: 0; width: 100%; }
  .filters > label, .filters > .select { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .filters > .search-in { flex: 1 1 100%; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
