@charset "UTF-8";
/* layout.css — The app frame: page layout, sidebar, top bar and page heading.
   Loaded in order by templates/partials/styles.html. */

/* ============================= 5. App shell =============================== */
.app {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns var(--t-slow);
}
.app.is-collapsed {
  grid-template-columns: var(--nav-w-collapsed) minmax(0, 1fr);
}

.app__main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
  /* a tight top, so the breadcrumb sits just under the topbar; the sides
     and bottom keep the full gutter */
  padding: var(--s-3) var(--gutter) var(--gutter);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.app__backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 17, 31, 0.55);
  backdrop-filter: blur(2px);
  z-index: 900;
}

/* ============================== 6. Sidebar ================================ */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--nav-bg) 0%, var(--nav-bg-2) 100%);
  border-right: 1px solid var(--nav-border);
  overflow: hidden;
  z-index: 1000;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  height: var(--topbar-h);
  padding: 0 var(--s-5);
  flex: 0 0 auto;
  color: var(--nav-text-strong);
  border-bottom: 1px solid var(--nav-border);
}
.sidebar__logo {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
  color: #fff;
  font-size: 1.25rem;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
}
.sidebar__name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-lg);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.sidebar__nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--s-4) var(--s-3);
}

.nav__section {
  padding: var(--s-5) var(--s-3) var(--s-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--nav-text);
  opacity: 0.55;
  white-space: nowrap;
}
.nav__section:first-child {
  padding-top: 0;
}

.nav__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  height: 46px;
  padding: 0 var(--s-3);
  margin-bottom: 2px;
  border-radius: var(--r-md);
  color: var(--nav-text);
  font-size: var(--fs-md);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color var(--t), color var(--t);
}
.nav__link ion-icon {
  flex: 0 0 auto;
  font-size: 1.3rem;
  min-width: 24px;
}
.nav__label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--t);
}

.nav__link:hover {
  background: var(--nav-hover);
  color: var(--nav-text-strong);
}
.nav__link:hover ion-icon {
  color: var(--nav-accent);
}

/* current page: tinted panel + accent bar + accent icon */
.nav__link.is-active {
  background: var(--nav-active);
  color: var(--nav-text-strong);
  font-weight: 600;
}
.nav__link.is-active::before {
  content: "";
  position: absolute;
  left: calc(var(--s-3) * -1);
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 26px;
  border-radius: 0 4px 4px 0;
  background: var(--nav-accent);
}
.nav__link.is-active ion-icon {
  color: var(--nav-accent);
}

/* count pill on the right of a nav row */
.nav__count {
  flex: 0 0 auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  display: grid;
  place-items: center;
  border-radius: var(--r-full);
  background: var(--primary-500);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 600;
}

/* ---- folding group: a heading row with its own sub-links --------------------
   A native <details>, so it opens and closes with no script and the keyboard
   works for free. The <summary> borrows .nav__link for its look.          */
.nav__group > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.nav__group > summary::-webkit-details-marker {
  display: none;
}

/* the chevron on the right; flips when the group is open */
.nav__link .nav__caret {
  font-size: 1rem;
  min-width: 0;
  opacity: 0.7;
  transition: transform var(--t);
}
.nav__group[open] > summary .nav__caret {
  transform: rotate(180deg);
}

/* the current page is somewhere inside: light the heading, but leave the
   accent bar to the sub-link that is actually active */
.nav__link.has-active {
  color: var(--nav-text-strong);
}
.nav__link.has-active ion-icon {
  color: var(--nav-accent);
}

/* sub-links are text only, hanging off a thin guide line that runs down
   from the heading's icon */
.nav__sub {
  margin: 0 0 var(--s-2) calc(var(--s-3) + 11px);
  padding-left: var(--s-3);
  border-left: 1px solid var(--nav-border);
}
.nav__sub .nav__link {
  height: 38px;
}

/* ---- collapsed rail: a group's sub-links in a panel beside its icon --------
   Same reason as .nav-tip below for being a fixed element on <body>: the
   sidebar clips anything that hangs out of it. navigation.js fills and places it. */
.nav-fly {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1200;
  min-width: 220px;
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: var(--s-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}
.nav-fly[hidden] {
  display: none;
}
.nav-fly__title {
  padding: var(--s-2) var(--s-3);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.nav-fly__item {
  display: block;
  padding: 9px var(--s-3);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--fs-md);
  white-space: nowrap;
}
.nav-fly__item:hover,
.nav-fly__item:focus-visible {
  background: var(--surface-3);
  color: var(--text);
  outline: none;
}
.nav-fly__item.is-active {
  background: var(--primary-50);
  color: var(--primary-600);
  font-weight: 600;
}

/* a plain rule between groups that need no heading of their own */
.nav__divider {
  height: 1px;
  margin: var(--s-4) var(--s-2);
  background: var(--nav-border);
}

/* a <button> (Log out posts a form) wearing the link's look */
.nav__link--btn {
  width: 100%;
  border: none;
  background: none;
  font: inherit;
  font-size: var(--fs-md);
  text-align: left;
  cursor: pointer;
}
.nav__link--danger:hover,
.nav__link--danger:hover ion-icon {
  color: #fca5a5;
}

/* NOTE: the sidebar once ended with a name/role footer. It was removed — the
   topbar profile dropdown carries the user's identity now, and repeating it
   at the bottom of the nav was redundant. */

/* ---- collapsed rail: icons only -------------------------------------------
   Only exists above the drawer breakpoint — below it the sidebar is an
   overlay drawer that always shows full labels, so scoping the whole rail to
   a min-width keeps the two modes from fighting each other.

   Labels are removed with display:none, not opacity:0 — an invisible label
   still takes its flex width and shoves the icon off-centre.              */
@media (min-width: 901px) {
  .app.is-collapsed .sidebar__name,
  .app.is-collapsed .nav__label,
  .app.is-collapsed .nav__count {
    display: none;
  }

  /* section headings become plain dividers when there's no room for words */
  .app.is-collapsed .nav__section {
    height: 1px;
    margin: var(--s-4) var(--s-2);
    padding: 0;
    font-size: 0;
    overflow: hidden;
    background: var(--nav-border);
  }
  .app.is-collapsed .nav__section:first-child {
    display: none;
  }

  /* with the labels gone, each row is a single centred icon */
  .app.is-collapsed .sidebar__brand,
  .app.is-collapsed .nav__link {
    justify-content: center;
    gap: 0;
    padding-inline: 0;
  }
  .app.is-collapsed .nav__link ion-icon {
    min-width: 0;
  }

  /* a group in the rail: no chevron and no inline sub-links — they open in
     the .nav-fly panel instead. A small corner mark says "opens a menu". */
  .app.is-collapsed .nav__caret,
  .app.is-collapsed .nav__sub {
    display: none;
  }
  .app.is-collapsed .nav__group > summary::after {
    content: "";
    position: absolute;
    right: 8px;
    bottom: 8px;
    border: 3px solid transparent;
    border-right-color: currentColor;
    border-bottom-color: currentColor;
    opacity: 0.6;
  }

}

/* ---- rail tooltip ---------------------------------------------------------
   Positioned fixed and appended to <body> by navigation.js. It cannot be a ::after
   on .nav__link: the sidebar clips with overflow:hidden and .sidebar__nav
   scrolls with overflow-y:auto, so a child pseudo-element is cut off at the
   rail's edge and never becomes visible.                                  */
.nav-tip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1200;
  padding: 7px 11px;
  border-radius: var(--r-sm);
  background: var(--text);
  color: var(--bg);
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.nav-tip.is-visible {
  opacity: 1;
  transform: none;
}
/* little arrow pointing back at the icon */
.nav-tip::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 100%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--text);
}

/* ========================= 7. Topbar & page head ========================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: var(--topbar-h);
  padding: var(--s-2) var(--gutter);
  background: var(--surface); /* fallback where color-mix() is unsupported */
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

/* a slim bar, so its controls are trimmed to fit it; scoped to .topbar so
   page buttons keep their size */
.topbar {
  padding-block: var(--s-1);
}
.topbar .icon-btn {
  width: 30px;
  height: 30px;
  font-size: 1.05rem;
}
.topbar .search {
  max-width: 420px;
}
.topbar .search ion-icon {
  left: 11px;
  font-size: 0.95rem;
}
.topbar .search input {
  height: 30px;
  padding-left: 33px;
  font-size: var(--fs-sm);
}
.topbar .search kbd {
  padding: 0 5px;
  font-size: 0.7rem;
}
.topbar .menu__trigger {
  padding: 2px 4px 2px 2px;
}
.topbar .menu__trigger .avatar {
  width: 26px;
  height: 26px;
}

/* the sidebar's brand row shares the bar's height, so its logo shrinks too */
.sidebar__brand .sidebar__logo {
  width: 28px;
  height: 28px;
  font-size: 0.95rem;
}

.icon-btn {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  font-size: 1.3rem;
  cursor: pointer;
  transition: background-color var(--t-fast), color var(--t-fast),
    border-color var(--t-fast);
}
.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

/* unread dot on the bell */
.icon-btn[data-dot]::after {
  content: "";
  position: absolute;
  transform: translate(11px, -11px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}

.search {
  position: relative;
  flex: 1 1 auto;
  max-width: 420px;
}
.search ion-icon {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  font-size: 1.15rem;
  color: var(--text-3);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 42px;
  padding: 0 var(--s-4) 0 42px;
  font: inherit;
  font-size: var(--fs-md);
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid transparent;
  border-radius: var(--r-full);
  outline: none;
  transition: background-color var(--t), border-color var(--t),
    box-shadow var(--t);
}
.search input::placeholder {
  color: var(--text-3);
}
.search input:focus {
  background: var(--surface);
  border-color: var(--primary-500);
  box-shadow: var(--ring);
}
.search kbd {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  padding: 2px 7px;
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  pointer-events: none;
}
.search input:focus ~ kbd {
  opacity: 0;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  margin-left: auto;
}
.topbar__actions .avatar {
  margin-left: var(--s-2);
  border: 2px solid var(--border);
}

/* ---- dropdown menu (topbar profile) ---- */
.menu {
  position: relative;
  flex: 0 0 auto;
}
.menu__trigger {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  padding: 3px 6px 3px 3px;
  margin-left: var(--s-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background-color var(--t-fast), border-color var(--t-fast);
}
.menu__trigger:hover,
.menu__trigger[aria-expanded="true"] {
  background: var(--surface-3);
  border-color: var(--border);
}
.menu__caret {
  font-size: 0.95rem;
  color: var(--text-3);
  transition: transform var(--t);
}
.menu__trigger[aria-expanded="true"] .menu__caret {
  transform: rotate(180deg);
}

.menu__panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 600;
  min-width: 244px;
  padding: var(--s-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  animation: menu-in 0.16s var(--ease);
}
.menu__panel[hidden] {
  display: none;
}
@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.menu__header {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  min-width: 0;
}
.menu__header strong {
  display: block;
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
}
.menu__header small {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu__sep {
  height: 1px;
  margin: var(--s-2) 0;
  background: var(--border);
}

.menu__item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 10px var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text-2);
  transition: background-color var(--t-fast), color var(--t-fast);
}
.menu__item ion-icon {
  font-size: 1.2rem;
  color: var(--text-3);
  transition: color var(--t-fast);
}
.menu__item:hover {
  background: var(--surface-3);
  color: var(--text);
}
.menu__item:hover ion-icon {
  color: var(--primary-600);
}
.menu__item--danger,
.menu__item--danger ion-icon {
  color: var(--danger);
}
.menu__item--danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}
.menu__item--danger:hover ion-icon {
  color: var(--danger);
}

/* phone: pin the panel to the screen edge so it can't overflow */
@media (max-width: 420px) {
  .menu__panel {
    position: fixed;
    top: var(--topbar-h);
    right: var(--s-3);
    left: var(--s-3);
    min-width: 0;
  }
}

/* ---- page head ---- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
}
/* the path above the title — small, in the brand blue */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--primary-600);
  margin-bottom: 2px;
}
.breadcrumb a {
  color: var(--primary-600);
}
.breadcrumb a:hover {
  color: var(--primary-500);
  text-decoration: underline;
}
/* the "/" between steps stays grey, so the path reads as steps */
.breadcrumb > span:not(:last-child) {
  color: var(--text-3);
}
.page-title {
  font-size: var(--fs-2xl);
}
/* the page's own title (main_base.html): small and clear, about h4 size.
   Other headings that reuse .page-title keep their size. */
.page-head .page-title {
  font-size: 1.05rem;
  line-height: 1.3;
}
.page-sub {
  margin-top: var(--s-1);
  color: var(--text-2);
  font-size: var(--fs-md);
}
.page-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
/* the buttons beside the page title (Add Item Group, New Invoice, ...):
   compact, to sit with the small title */
.page-head__actions .btn {
  height: 30px;
  padding: 0 var(--s-3);
  gap: 6px;
  font-size: var(--fs-sm);
  border-radius: var(--r-sm);
}
.page-head__actions .btn ion-icon {
  font-size: 1rem;
}
