/* ==========================================================================
   D10 App — page styles (demo/app.html)
   Compact app shell (default theme: After Hours).
   1. Shell (grid, sidebar, top bar, banners)
   2. Overlays (notifications, command palette, drawer)
   3. Views (inbox, insights, roadmap, billing, team)
   4. Narrow screens (< 860px: sidebar + drawer become overlays)
   ========================================================================== */

/* 1. Shell --------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.45;
}

.app button {
  color: var(--ink);
}

/* Shared small bits */
.avatar {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--avatar, var(--c1));
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.avatar--lg {
  width: 30px;
  height: 30px;
  font-size: 11px;
}

.avatar--sm {
  width: 24px;
  height: 24px;
  font-size: 9px;
}

.meter {
  display: block;
  height: 4px;
  border-radius: 4px;
  background: var(--surface-3);
}

.meter--lg {
  height: 6px;
  border-radius: 6px;
}

/* Fill width comes from --w */
.meter__fill {
  display: block;
  width: var(--w, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--c1);
}

.meter__fill--warn {
  background: var(--warn);
}

.text-btn {
  padding: 0;
  border: 0;
  background: none;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

.app .text-btn {
  color: var(--ink-2);
}

.text-btn--md {
  padding: 1px 6px;
  font-size: inherit;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.app-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.app-card--stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-card--gap-lg {
  gap: 12px;
}

.app-card--flush {
  padding: 0;
  overflow: hidden;
}

.app-card__title {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.app-input {
  height: 36px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
}

/* Sidebar */
.app-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.app-ws {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 14px;
}

.app-ws__mark {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--action);
  color: var(--on-action);
  font-size: 12px;
  font-weight: 700;
}

.app-ws__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.app-ws__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-ws__plan {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.app-nav__head {
  padding: 14px 8px 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .06em;
  color: var(--ink-3);
}

.app .app-nav__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}

.app .app-nav__item[aria-current="page"] {
  background: var(--surface-3);
  color: var(--ink);
  font-weight: 600;
}

.app-nav__count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.seats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.seats__head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.app .seats__link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 12px;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}

.app-kit-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--inverse);
  color: var(--on-inverse);
  font-family: var(--font-mono);
  font-size: 11px;
  text-decoration: none;
}

.app-kit-pill:hover {
  color: var(--on-inverse);
}

.app-scrim {
  position: fixed;
  inset: 0;
  z-index: 49;
  background: rgba(0, 0, 0, .5);
}

/* Main column */
.app-body {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.dunning {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--neg-bg);
  color: var(--neg);
  font-size: 13px;
}

.dunning__spacer {
  flex: 1;
}

.app .dunning__btn {
  padding: 3px 12px;
  border: 1px solid var(--neg);
  border-radius: 999px;
  background: transparent;
  color: var(--neg);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.app-topbar {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.app-topbar__menu {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}

.crumbs {
  display: flex;
  gap: 6px;
  overflow: hidden;
  font-size: 13px;
  color: var(--ink-3);
  white-space: nowrap;
}

.app-topbar__spacer {
  flex: 1;
}

.app .search-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-3);
  cursor: pointer;
}

.search-btn__short {
  display: none;
}

.search-btn__kbd {
  padding: 0 5px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.notif-btn {
  position: relative;
}

.notif-btn__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  display: grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--action);
  color: var(--on-action);
  font-size: 10px;
  font-weight: 700;
}

/* 2. Overlays ------------------------------------------------------------ */
.notif-pop {
  position: absolute;
  top: 52px;
  right: 56px;
  z-index: 30;
  width: 360px;
  max-width: calc(100% - 32px);
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: pop .16s ease-out;
}

.notif-pop__head {
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.notif {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.notif__dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
}

.notif__body {
  flex: 1;
}

.notif__ago {
  font-size: 12px;
  color: var(--ink-3);
}

.notif.is-unread {
  background: var(--surface-2);
}

.notif.is-unread .notif__dot {
  background: var(--action);
}

/* Command palette */
.palette {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  padding-top: 10vh;
  background: rgba(0, 0, 0, .45);
}

.palette__dialog {
  width: min(560px, 92%);
  height: fit-content;
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: pop .16s ease-out;
}

.palette__input {
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  font-size: 15px;
  outline: none;
}

.palette__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.palette__item:hover,
.palette__item:focus-visible {
  background: var(--surface-2);
}

.palette__kind {
  width: 60px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
}

.palette__label {
  flex: 1;
}

/* Content area + request drawer */
.app-content {
  display: flex;
  flex: 1;
  min-width: 0;
  overflow: auto;
}

.app-view {
  flex: 1;
  min-width: 0;
  padding: 16px 20px 40px;
}

.drawer {
  z-index: 45;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 380px;
  max-width: 100%;
  border-left: 1px solid var(--line);
  background: var(--surface);
  animation: pop .16s ease-out;
}

.drawer__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.drawer__close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.drawer__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  overflow: auto;
}

.drawer__title {
  font-size: 17px;
  line-height: 1.3;
}

.drawer__facts {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 6px 10px;
  margin: 0;
  font-size: 13px;
}

.drawer__facts dt {
  color: var(--ink-3);
}

.drawer__facts dd {
  margin: 0;
}

.comments {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.comments__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comment {
  display: flex;
  gap: 10px;
}

.comment__body {
  font-size: 13px;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comment-form__input {
  padding: 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--canvas);
  resize: vertical;
}

.mentions {
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface-2);
}

.mentions__item {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.mentions__role {
  font-size: 12px;
  color: var(--ink-3);
}

.app .comment-form__submit {
  align-self: flex-end;
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--action);
  color: var(--on-action);
  font-weight: 600;
  cursor: pointer;
}

/* 3. Views --------------------------------------------------------------- */
.app-note {
  display: block;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

/* Inbox · saved views */
.saved-views {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.app .saved-views__tab {
  padding: 8px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-3);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.app .saved-views__tab[aria-pressed="true"] {
  border-bottom-color: var(--action);
  color: var(--ink);
}

.saved-views__n {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.saved-views__spacer {
  flex: 1;
}

.app .saved-views__save {
  border: 0;
  background: none;
  color: var(--ink-3);
  font-size: 13px;
  cursor: pointer;
}

/* Inbox · bulk bar */
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--inverse);
  color: var(--on-inverse);
  font-size: 13px;
}

.bulk-bar__spacer {
  flex: 1;
}

.app .bulk-bar__btn,
.app .bulk-bar__clear {
  background: none;
  color: inherit;
  font-size: 12px;
  cursor: pointer;
}

.app .bulk-bar__btn {
  padding: 2px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
}

.app .bulk-bar__clear {
  border: 0;
  text-decoration: underline;
}

/* Inbox · table */
.inbox {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.inbox__row {
  display: grid;
  grid-template-columns: 36px minmax(220px, 2.4fr) minmax(120px, 1.2fr) 80px 80px 110px 70px;
  align-items: center;
  min-width: 760px;
  height: 36px;
  border-bottom: 1px solid var(--line);
}

.inbox__row--head {
  height: 30px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
}

.inbox__row:not(.inbox__row--head):hover {
  background: var(--surface-2);
}

.inbox__row.is-selected {
  background: var(--action-tint);
}

.inbox__row.is-open {
  background: var(--surface-3);
}

.inbox__check {
  display: grid;
  place-items: center;
}

.app .checkbox {
  width: 15px;
  height: 15px;
  padding: 0;
  border: 1.5px solid var(--line-2);
  border-radius: 4px;
  background: transparent;
  color: var(--canvas);
  font-size: 9px;
  cursor: pointer;
}

.app .checkbox[aria-checked="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--canvas);
}

.app .inbox__title {
  padding: 0 12px 0 0;
  overflow: hidden;
  border: 0;
  background: none;
  color: var(--ink);
  font-weight: 500;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.inbox__account {
  padding-right: 12px;
  overflow: hidden;
  color: var(--ink-2);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox__arr {
  padding-right: 12px;
  text-align: right;
}

.inbox__row:not(.inbox__row--head) .inbox__arr {
  font-family: var(--font-mono);
  font-size: 12px;
}

.inbox__src {
  font-size: 12px;
  color: var(--ink-2);
}

.theme-pill {
  padding: 1px 7px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  white-space: nowrap;
}

.inbox__age {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

/* Insights */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.kpi__label {
  font-size: 12px;
  color: var(--ink-2);
}

.kpi__value {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}

.kpi__delta {
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--pos-bg);
  color: var(--pos);
  font-family: var(--font-mono);
  font-size: 11px;
}

.kpi__delta--neg {
  background: var(--neg-bg);
  color: var(--neg);
}

.theme-bars {
  margin-top: 12px;
}

.theme-bars__head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.theme-bar {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 70px 60px;
  align-items: center;
  gap: 10px;
  height: 30px;
}

.theme-bar__track {
  height: 14px;
  border-radius: 3px;
  background: var(--surface-2);
}

.theme-bar__fill {
  display: block;
  width: var(--w, 0%);
  height: 100%;
  border-radius: 3px;
  background: var(--c1);
}

.theme-bar__value {
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
}

.theme-bar__delta {
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Roadmap board */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.board__col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 300px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.board__head {
  display: flex;
  justify-content: space-between;
  padding: 4px 6px;
}

.board__n {
  font-family: var(--font-mono);
  color: var(--ink-3);
}

.board-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.board-card__title {
  font-weight: 600;
}

.board-card__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.board-card__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.board-card__moves {
  display: flex;
  gap: 3px;
}

.board-card__move {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: var(--surface);
  cursor: pointer;
}

.board-card__move:disabled {
  opacity: .3;
  cursor: default;
}

/* Billing + Team pages */
.app-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 860px;
}

.app-page__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.app-page__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: -.02em;
}

.app .demo-toggle {
  padding: 4px 12px;
  border: 1px dashed var(--line-2);
  border-radius: 999px;
  background: none;
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
}

.billing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.plan__name {
  font-size: 20px;
}

.plan__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.pill-btn {
  padding: 6px 12px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
}

.usage {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.usage__head {
  display: flex;
  justify-content: space-between;
}

.usage__value {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* Payment method (red border while a payment has failed) */
.payment {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.payment.is-failed {
  border-color: var(--neg);
}

.payment__brand {
  display: grid;
  place-items: center;
  width: 44px;
  height: 30px;
  border-radius: 6px;
  background: var(--surface-3);
  font-family: var(--font-mono);
  font-size: 11px;
}

.payment__text {
  flex: 1;
}

.payment__note {
  font-size: 13px;
  color: var(--ink-3);
}

.payment.is-failed .payment__note {
  color: var(--neg);
}

.app .payment__btn {
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--action);
  color: var(--on-action);
  font-weight: 600;
  cursor: pointer;
}

.invoices {
  overflow-x: auto;
}

.invoice {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 110px 90px 60px;
  align-items: center;
  gap: 10px;
  min-width: 520px;
  height: 40px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.invoice__no {
  font-family: var(--font-mono);
  font-size: 12px;
}

.invoice__amt {
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
}

.invoice__pdf {
  font-size: 12px;
}

.status-pill {
  justify-self: start;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--pos-bg);
  color: var(--pos);
  font-family: var(--font-mono);
  font-size: 11px;
}

.status-pill--neg {
  background: var(--neg-bg);
  color: var(--neg);
}

/* Team */
.team-invite {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.team-invite__email {
  flex: 1;
  min-width: 200px;
  padding: 0 12px;
}

.team-invite__role {
  padding: 0 8px;
}

.app .team-invite__send {
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--action);
  color: var(--on-action);
  font-weight: 600;
  cursor: pointer;
}

.members {
  margin: 0;
  list-style: none;
}

.member {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 120px 90px;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.member__who {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.member__name {
  font-weight: 600;
}

.member__email {
  font-size: 12px;
  color: var(--ink-3);
}

.member__role {
  font-size: 13px;
}

.member__status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--pos);
}

.member__status--invited {
  color: var(--warn);
}

.sso-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px;
}

.sso-card__text {
  flex: 1;
  color: var(--ink-2);
}

.sso-card__link {
  font-weight: 600;
}

/* 4. Narrow screens ------------------------------------------------------ */
@media (max-width: 859px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Sidebar becomes an off-canvas drawer (opened via ☰) */
  .app-nav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    display: none;
    width: 260px;
  }

  .app-nav.is-open {
    display: flex;
  }

  .app-topbar__menu {
    display: block;
  }

  .app .search-btn {
    min-width: 0;
  }

  .search-btn__long {
    display: none;
  }

  .search-btn__short {
    display: inline;
  }

  .drawer {
    position: fixed;
    inset: 0 0 0 auto;
  }
}
