/* ==========================================================================
   Kane fleet header — tokens + top navigation bar.
   Copied from the kane-brand kit (reference/kane-tokens.css + kane-nav.css).
   Linked BEFORE styles.css so the app's own tokens still win where they
   overlap; the class names below are the kit contract — do not rename.
   Light mode only (Kane apps ship light-mode only).
   ========================================================================== */

/* ---- Kit design tokens (light) ----------------------------------------- */
:root {
  /* Brand */
  --brand: #003B73;        /* official Kane blue — header + primary buttons */
  --brand-hover: #00264a;  /* darker blue for hover on blue surfaces */
  --brand-accent: #e2231a; /* Kane accent red — use sparingly */
  --kane-blue: #003B73;    /* Kane blue for backgrounds / accents / fills */
  --brand-text: #003B73;   /* Kane blue as TEXT */

  /* Surfaces & text */
  --surface: #ffffff;      /* dropdowns, modals, popovers */
  --hover: #f0f3f7;
  --text: #1a2230;
  --border: #e3e8ef;
}

/* ---- Bar --------------------------------------------------------------- */
.topbar {
  background: var(--brand); color: #fff; padding: 0 24px; height: 64px; position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; box-shadow: var(--shadow);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
/* App-specific: this app's bar has always been sticky — keep that. */
.topbar { position: sticky; top: 0; z-index: 40; }

/* ---- Brand lockup (wordmark + divider + app subtitle) ------------------ */
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.wordmark-logo { height: 30px; width: auto; display: block; }
.brand-divider { width: 1px; height: 30px; background: rgba(255,255,255,.25); flex: none; }
.brand small {
  font-size: 12px; opacity: .8; font-weight: 400;
  /* App-specific: the subtitle also carries the open project's name, so clamp
     it rather than let a long name push the bar wide. */
  max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- Centre nav -------------------------------------------------------- */
.topnav { display: flex; gap: 4px; position: absolute; left: 50%; transform: translateX(-50%); }
.topnav a {
  color: rgba(255,255,255,.78); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px; transition: background .15s ease, color .15s ease;
}
.topnav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.topnav a.active { background: rgba(255,255,255,.18); color: #fff; }
.topnav a:focus-visible { box-shadow: 0 0 0 3px rgba(255,255,255,.55); }

/* App-specific: the Projects item is the only way back out of a project, so the
   nav has to read as controls rather than labels — outlined pills + icons, back
   arrow inside a project, grid on the project list. The Library item sits
   alongside it. The brand lockup goes home too (standard web convention). */
.topnav a {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  border: 1px solid rgba(255,255,255,.3); color: #fff;
}
.topnav a svg { flex: none; }
#nav-projects .ico-grid { display: none; }
#nav-projects.active .ico-grid { display: block; }
#nav-projects.active .ico-back { display: none; }
.brand-home { display: block; border-radius: 6px; text-decoration: none; }
.brand-home:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255,255,255,.55); }

/* ---- Right side: role badge + user menu -------------------------------- */
.user { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.role-badge {
  display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2); padding: 4px 11px; border-radius: 999px; color: #fff;
  font-size: 11px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase;
}
.user-name { font-size: 14px; font-weight: 600; color: #fff; }

.user-menu { position: relative; }
.user-trigger {
  display: flex; align-items: center; gap: 12px; background: transparent; border: none;
  cursor: pointer; padding: 8px 12px; border-radius: 999px; transition: background .15s ease;
}
.user-trigger:hover { background: rgba(255,255,255,.12); }

.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 100;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(16,24,40,.18); padding: 6px; min-width: 190px;
}
.dd-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: none; padding: 10px 12px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer;
}
.dd-item:hover { background: var(--hover); }
.dd-item svg { color: var(--muted); flex-shrink: 0; }
.dd-sep { height: 1px; background: var(--border); margin: 4px 6px; }

/* ---- App controls that live in the bar (Export Excel, autosave chip) ---- */
.topbar-btn {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); color: #fff;
  font-family: inherit; font-size: 14px; font-weight: 600; padding: 7px 14px;
  border-radius: 999px; cursor: pointer; white-space: nowrap;
  transition: background .15s ease;
}
.topbar-btn:hover { background: rgba(255,255,255,.22); }
.topbar .save-status {
  font-size: 12px; color: rgba(255,255,255,.78); white-space: nowrap;
}
.topbar .save-status:empty { display: none; }
.topbar .save-status.err { color: #ffd9a8; font-weight: 700; }

/* ---- Responsive -------------------------------------------------------- */
/* This app carries extra controls on the right AND two nav pills, so drop the
   absolute centring early enough that the nav can never sit under them. */
@media (max-width: 1240px) {
  .topnav { position: static; transform: none; }
}
/* Two nav pills plus Export Excel plus a full Kane name is more than one 64px
   row can hold honestly — clamp the two variable-length labels rather than let
   anything wrap into a taller, ragged bar. */
@media (max-width: 1120px) {
  .brand small { max-width: 22ch; }
  .user-name { display: inline-block; max-width: 15ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
}
@media (max-width: 760px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 10px 14px; padding: 12px 16px; }
  .topnav { order: 3; width: 100%; position: static; transform: none; }
  .brand small { max-width: 18ch; }
  .user { gap: 8px; }
}
