/* Global Horizon — reset, layout shell, typography. */

*, *::before, *::after { box-sizing: border-box; }

/* The hidden attribute always wins, even over a component's display: flex. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

p { margin: 0; }

a { color: var(--navy-700); text-decoration: none; }
a:hover { color: var(--ember); }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

img { max-width: 100%; height: auto; display: block; }

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

:focus-visible {
  outline: 2px solid var(--navy-700);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: var(--z-modal);
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 0 0 var(--radius) 0;
}
.skip:focus { left: 0; }

/* Numeric columns line up. */
.tnum, .kpi__value, .task__due, .alert__time { font-variant-numeric: tabular-nums; }

.eyebrow {
  margin: 0;
  font-family: var(--font-display);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-400);
}

.link { font-size: 12px; font-weight: 600; color: var(--navy); }

.dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--grey); display: inline-block; flex-shrink: 0;
}

/* ---------------------------------------------------------------- shell
 * Phone first: app bar on top, content, bottom nav.
 * At >=1024px the rail appears and the bottom nav goes away.
 */

.shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: 'appbar' 'outlet' 'bottomnav';
  min-height: 100dvh;
}

.shell--bare { grid-template-rows: 1fr; grid-template-areas: 'outlet'; }
.shell--bare .rail,
.shell--bare .appbar,
.shell--bare .bottomnav { display: none; }

.outlet {
  grid-area: outlet;
  min-width: 0;
  overflow-y: auto;
  padding-bottom: calc(var(--safe-bottom) + 8px);
}

.boot {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; min-height: 60dvh; color: var(--ink-400);
}

/* ---- app bar (phone) */
.appbar {
  grid-area: appbar;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-top) + 12px) var(--gutter) 11px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: var(--z-nav);
}
.appbar__mark { border-radius: 7px; flex-shrink: 0; }
.appbar__brand { display: flex; flex-direction: column; min-width: 0; }
.appbar__name {
  font-family: var(--font-display); font-weight: 600; font-size: 15px;
  color: var(--navy); letter-spacing: -0.01em; line-height: 1.2;
}
.appbar__who {
  font-size: 10.5px; color: var(--ink-400);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.appbar__spacer { flex-grow: 1; }

/* ---- bottom nav (phone) */
.bottomnav {
  grid-area: bottomnav;
  display: flex; align-items: stretch;
  padding: 7px 6px calc(var(--safe-bottom) + 10px);
  background: var(--surface);
  border-top: 1px solid var(--line);
  position: sticky; bottom: 0; z-index: var(--z-nav);
}
.bottomnav__link {
  position: relative;
  flex: 1 1 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 0; min-height: 44px;
  font-size: 10px; font-weight: 600; color: var(--ink-400);
}
.bottomnav__link.is-active { color: var(--navy); }
.bottomnav__link:hover { color: var(--navy); }
.bottomnav__badge {
  position: absolute; top: 2px; right: 50%; transform: translateX(18px);
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--ember); color: #fff; font-size: 9.5px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface);
}

/* ---- rail (desktop) */
.rail { display: none; grid-area: rail; }

@media (min-width: 1024px) {
  .shell {
    grid-template-columns: var(--rail-w) 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: 'rail appbar' 'rail outlet';
  }
  .shell--bare { grid-template-columns: 1fr; grid-template-areas: 'outlet'; }

  .rail {
    display: flex; flex-direction: column;
    padding: 20px 14px 16px;
    background: var(--navy);
    position: sticky; top: 0; height: 100dvh;
  }
  .bottomnav { display: none; }
  .appbar { padding: 12px 28px; }
  .appbar__mark, .appbar__brand { display: none; }
  .outlet { padding-bottom: 32px; }
}

.rail__brand { padding: 2px 6px 22px; }
.rail__tagline {
  margin-top: 6px; padding-left: 3px;
  font-size: 10.5px; letter-spacing: 0.04em; color: var(--blue-300);
}
.rail__nav { display: flex; flex-direction: column; gap: 2px; }
.rail__link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px; border-radius: var(--radius-sm);
  font-size: 13.5px; color: #C2D6EA;
  transition: background var(--dur-fast) var(--ease);
}
.rail__link:hover { background: rgba(255,255,255,0.09); color: #fff; }
.rail__link.is-active { background: rgba(255,255,255,0.15); color: #fff; font-weight: 600; }
.rail__ico { display: flex; flex-shrink: 0; }
.rail__ico--ember { color: var(--ember); }
.rail__link--ask { background: rgba(255,255,255,0.09); color: #fff; }
.rail__rule { height: 1px; border: 0; background: rgba(255,255,255,0.12); margin: 16px 10px; }
.rail__spacer { flex-grow: 1; }
.rail__badge {
  margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: var(--radius-pill);
  background: var(--ember); color: #fff; font-size: 10.5px; font-weight: 600; text-align: center;
}
.rail__user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--radius); background: rgba(255,255,255,0.07);
}
.rail__userinfo { display: flex; flex-direction: column; min-width: 0; flex-grow: 1; }
.rail__username {
  font-size: 12.5px; font-weight: 600; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rail__userrole { font-size: 10.5px; color: var(--blue-300); }
.rail__user .iconbtn { color: var(--blue-200); border: 0; background: none; }
.rail__user .iconbtn:hover { color: #fff; }

/* Readable by a screen reader, invisible on screen. */
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
                   overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* The side menu now lists every area, which is more than a short laptop
   screen can show at once. The links scroll; the logo and Ask Horizon stay
   where they are, so nothing at the bottom becomes unreachable. */
@media (min-width: 900px) {
  /* Only `min-height: 0` and a scrollbar — deliberately NOT `flex: 1`, which
     would compete with .rail__spacer for the slack and stop the user block
     sitting at the bottom. With a zero minimum the nav is simply the part
     that gives way when the rail runs out of room. */
  .rail__nav { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .rail__nav::-webkit-scrollbar { width: 6px; }
  .rail__nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18); border-radius: 3px; }
  .rail__nav::-webkit-scrollbar-track { background: transparent; }
}
