/* Base: reset, typography, app shell layout. Reads tokens.css. */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: var(--fs);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
html[dir="rtl"] body { font-family: var(--font-ar); }

h1,h2,h3,h4 { line-height: 1.25; font-weight: 650; color: var(--text); text-wrap: balance; }
h1 { font-size: 1.4rem; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; }
p { color: var(--text-2); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd, .mono { font-family: var(--mono); font-size: .9em; }
small { font-size: .82rem; color: var(--text-3); }
img { max-width: 100%; display: block; }
hr { border: none; border-top: 1px solid var(--border); margin: var(--gap) 0; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---- App shell ---- */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  min-height: 100vh;
}
html[dir="rtl"] .app { direction: rtl; }
/* Mobile menu backdrop — hidden by default (desktop); shown only when the rail is open on mobile.
   Must be display:none here so it never occupies a grid column on desktop. */
.rail-scrim { display: none; }

/* Left rail */
.rail {
  background: var(--rail);
  color: var(--rail-ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.rail__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.rail__logo {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(150deg, var(--brand) 0%, var(--brand-700) 100%);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.rail__title { font-size: .95rem; font-weight: 680; color: #fff; letter-spacing: -.01em; }
.rail__sub { font-size: .68rem; color: var(--rail-ink-2); letter-spacing: .06em; text-transform: uppercase; }
.rail__scroll { padding: 10px 10px 20px; flex: 1; }
.rail__group { margin-top: 14px; }
.rail__group-label {
  font-size: .66rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--rail-ink-2); padding: 6px 10px 4px;
}
.rail__link {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 11px; border-radius: 8px;
  color: var(--rail-ink); font-weight: 500; font-size: .9rem;
  transition: background .12s, color .12s;
}
.rail__link:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.rail__link.is-active { background: var(--rail-active); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.rail__link svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.rail__foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.07); font-size: .72rem; color: var(--rail-ink-2); }

/* Main column */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar__title { font-weight: 640; font-size: 1rem; }
.topbar__spacer { flex: 1; }
.topbar__env {
  font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: var(--r-pill);
  background: var(--warn-bg); color: var(--warn-ink);
}
.topbar__btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text-2); cursor: pointer;
  display: grid; place-items: center;
}
.topbar__btn:hover { background: var(--panel-2); color: var(--text); }
.topbar__btn svg { width: 17px; height: 17px; }
.iconbtn-burger { display: none; }

.content { padding: 22px; max-width: 1360px; width: 100%; }

/* Page head */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head__main { min-width: 0; }
.page-head h1 { margin-bottom: 2px; }
.page-head__sub { color: var(--text-3); font-size: .9rem; }
.page-head__actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* Mobile */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: fixed; z-index: 60; width: min(84vw, var(--rail-w)); height: 100vh;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-pop);
  }
  html[dir="rtl"] .rail { transform: translateX(100%); }
  body.rail-open .rail { transform: none; }
  .rail-scrim { display: none; position: fixed; inset: 0; background: rgba(4,14,9,.5); z-index: 55; }
  body.rail-open .rail-scrim { display: block; }
  .iconbtn-burger { display: grid; }
  .content { padding: 16px; }
}
