/* ---------------------------------------------------------------------------
 * Binteca TenderOps
 *
 * The design system is shared with Binteca SalesOps (src/views/layout.js in
 * that repo) so the two products read as one suite: the same tokens, the same
 * Apple-style typography and radii, the same frosted-glass chrome, the same
 * dark-mode palette. Class names are TenderOps's own — this is a restyle, not
 * a rewrite, so public/app.js renders unchanged.
 *
 * Keep the :root / dark-mode token blocks in step with SalesOps when either
 * moves. Everything below is expressed in tokens for exactly that reason.
 * ------------------------------------------------------------------------- */

:root {
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-active: #005bb5;
  --accent-light: rgba(0, 113, 227, 0.08);
  --bg: #f5f5f7;
  --bg-gradient: radial-gradient(circle at 50% 0%, rgba(0, 113, 227, 0.04) 0%, transparent 70%);
  --panel: rgba(255, 255, 255, 0.85);
  --panel-solid: #ffffff;
  --panel-subtle: #fbfbfd;
  --panel-hover: rgba(0, 113, 227, 0.03);
  --ink: #1d1d1f;
  --ink-secondary: #424245;
  --muted: #86868b;
  --hair: rgba(0, 0, 0, 0.08);
  --hair-subtle: rgba(0, 0, 0, 0.04);
  --ok: #34c759;
  --ok-bg: rgba(52, 199, 89, 0.1);
  --ok-border: rgba(52, 199, 89, 0.25);
  --warn: #ff9500;
  --warn-bg: rgba(255, 149, 0, 0.1);
  --warn-border: rgba(255, 149, 0, 0.25);
  --bad: #ff3b30;
  --bad-bg: rgba(255, 59, 48, 0.1);
  --bad-border: rgba(255, 59, 48, 0.25);
  --info: #5856d6;
  --info-bg: rgba(88, 86, 214, 0.1);
  --info-border: rgba(88, 86, 214, 0.25);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 9999px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05), 0 2px 6px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 16px 40px -6px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.03);
  --blur: blur(20px) saturate(180%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #2997ff;
    --accent-hover: #47a7ff;
    --accent-active: #147ce5;
    --accent-light: rgba(41, 151, 255, 0.12);
    --bg: #000000;
    --bg-gradient: radial-gradient(circle at 50% 0%, rgba(41, 151, 255, 0.08) 0%, transparent 70%);
    --panel: rgba(28, 28, 30, 0.85);
    --panel-solid: #1c1c1e;
    --panel-subtle: #2c2c2e;
    --panel-hover: rgba(255, 255, 255, 0.04);
    --ink: #f5f5f7;
    --ink-secondary: #d2d2d7;
    --muted: #86868b;
    --hair: rgba(255, 255, 255, 0.12);
    --hair-subtle: rgba(255, 255, 255, 0.06);
    --ok: #30d158;
    --ok-bg: rgba(48, 209, 88, 0.15);
    --ok-border: rgba(48, 209, 88, 0.3);
    --warn: #ffd60a;
    --warn-bg: rgba(255, 214, 10, 0.15);
    --warn-border: rgba(255, 214, 10, 0.3);
    --bad: #ff453a;
    --bad-bg: rgba(255, 69, 58, 0.15);
    --bad-border: rgba(255, 69, 58, 0.3);
    --info: #7d7aff;
    --info-bg: rgba(125, 122, 255, 0.16);
    --info-border: rgba(125, 122, 255, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.65);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  scroll-padding-top: 68px;
}

body {
  width: 100%;
  max-width: 100vw;
  position: relative;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "SF Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13.5px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease, opacity 0.15s ease;
}

a:hover {
  opacity: 0.85;
}

/* ---------------------------------------------------------------------------
 * Header & navigation
 * ------------------------------------------------------------------------- */

.app-header {
  background: var(--panel);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--hair);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  max-width: 100vw;
  overflow-x: clip;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.header-container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--ink);
}

.brand-badge {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 113, 227, 0.3);
  flex-shrink: 0;
}

.brand-mark {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: block;
  border-radius: 6px;
}

.brand-mark-dark {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .brand-mark:not(.brand-mark-dark) {
    display: none;
  }
  .brand-mark-dark {
    display: block;
  }
}

.brand-title {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.app-nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 12px 10px 24px;
}

.app-nav a {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav a:hover {
  color: var(--ink);
  background: var(--hair-subtle);
  opacity: 1;
}

.app-nav a.active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.header-meta {
  display: contents;
}

.user-box [hidden] {
  display: none !important;
}

body:not(.authed) .user-box {
  display: none;
}

body:not(.is-admin) .admin-only {
  display: none;
}

.user-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-name:hover {
  color: var(--accent);
  opacity: 1;
}

/* Under 900px the header is TWO rows on a grid, not one clipped row. Rule
   #23, measured 2026-09-15 at 375px: `.user-box` becomes `display: contents`
   so `Sign out` sits on row one with the brand and `.header-meta` (Settings,
   optional Install App, role badge, email) spans row two cleanly. The
   not-signed-in rule above still hides the box, because it is more specific.
   The sidebar and scrim read the resulting height from --header-h, which
   app.js measures — the rows are not a fixed size. */
@media (max-width: 900px) {
  .header-container {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "toggle brand logout"
      "meta   meta  meta";
    align-items: center;
    column-gap: 10px;
    row-gap: 6px;
    padding: 6px 14px;
  }

  .nav-toggle {
    grid-area: toggle;
  }

  .brand {
    grid-area: brand;
    justify-self: start;
    min-width: 0;
  }

  .brand-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .user-box {
    display: contents;
    margin-left: 0;
  }

  .user-box [data-action="logout"] {
    grid-area: logout;
    justify-self: end;
  }

  .header-meta {
    grid-area: meta;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 8px;
    min-width: 0;
  }

  #user-role-badge {
    white-space: nowrap;
  }

  #user-name {
    margin-left: auto;
    max-width: 100%;
    min-width: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 480px) {
  .internal-badge {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
 * Layout
 * ------------------------------------------------------------------------- */

.app-body {
  flex: 1;
  display: flex;
  align-items: stretch;
  width: 100%;
  min-width: 0;
}

.main-container {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 24px 60px;
  overflow-x: hidden;
}

@media (max-width: 768px) {
  .main-container {
    padding: 16px 14px 48px;
  }
}

/* ---------------------------------------------------------------------------
 * Sidebar
 * ------------------------------------------------------------------------- */

.app-sidebar {
  position: fixed;
  top: var(--header-h, 52px);
  left: 0;
  bottom: 0;
  z-index: 90;
  width: 216px;
  background: var(--panel-subtle);
  border-right: 1px solid var(--hair);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  transition: width 0.2s ease, transform 0.2s ease;
}

.app-body,
.app-footer {
  padding-left: 216px;
  transition: padding-left 0.2s ease;
}

body.nav-collapsed .app-sidebar {
  width: 0;
  border-right-color: transparent;
}

body.nav-collapsed .app-body,
body.nav-collapsed .app-footer,
body:not(.authed) .app-body,
body:not(.authed) .app-footer {
  padding-left: 0;
}

body:not(.authed) .app-sidebar,
body:not(.authed) .nav-toggle {
  display: none;
}

.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  padding: 0;
  background: none;
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.nav-toggle:hover {
  color: var(--accent);
  background: var(--hair-subtle);
}

.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 14px;
  height: 1.5px;
  border-radius: 1px;
  background: currentColor;
}

.nav-toggle-icon {
  position: relative;
}

.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle-icon::before { top: -4.5px; }
.nav-toggle-icon::after { top: 4.5px; }

.sidebar-scrim {
  display: none;
}

/* The sidebar becomes an overlay drawer rather than a column: at 375px a
   216px column leaves nothing for the content beside it. */
@media (max-width: 900px) {
  .app-sidebar {
    width: min(272px, 82vw);
    height: calc(100dvh - var(--header-h, 52px));
    transform: translateX(-100%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
  }

  body.nav-open .app-sidebar {
    transform: none;
  }

  body.nav-collapsed .app-sidebar {
    width: min(272px, 82vw);
    border-right-color: var(--hair);
  }

  .app-body,
  .app-footer,
  body.nav-collapsed .app-body,
  body.nav-collapsed .app-footer {
    padding-left: 0;
  }

  body.nav-open .sidebar-scrim {
    display: block;
    position: fixed;
    inset: var(--header-h, 52px) 0 0 0;
    height: calc(100dvh - var(--header-h, 52px));
    z-index: 89;
    background: rgba(0, 0, 0, 0.42);
  }
}

.app-footer {
  border-top: 1px solid var(--hair);
  background: var(--panel-subtle);
  color: var(--muted);
  font-size: 12px;
}

.footer-container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .footer-container {
    padding: 14px;
  }
}

/* ---------------------------------------------------------------------------
 * View headers
 * ------------------------------------------------------------------------- */

.view-header {
  margin-bottom: 20px;
}

.view-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--ink);
  margin-bottom: 4px;
}

.view-subtitle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.view-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.view-header-row .view-header {
  flex: 1;
  min-width: 220px;
  margin-bottom: 0;
}

.view-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 640px) {
  .view-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .view-actions {
    width: 100%;
  }

  .view-actions .btn {
    flex: 1;
    justify-content: center;
  }

  .view-title {
    font-size: 19px;
  }
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 12px;
}

.back-link:hover {
  color: var(--accent);
  opacity: 1;
}

.section-title,
.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink);
  margin: 22px 0 12px;
}

.form-section-title {
  padding-top: 16px;
  border-top: 1px solid var(--hair);
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.section-header-row .section-title {
  margin-bottom: 0;
}

/* ---------------------------------------------------------------------------
 * KPI tiles
 * ------------------------------------------------------------------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--panel-solid);
  border: 1px solid var(--hair);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.kpi-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  font-weight: 600;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -0.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.kpi-card.warning {
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

.kpi-card.warning .kpi-value {
  color: var(--warn);
}

.kpi-card.urgent {
  border-color: var(--bad-border);
  background: var(--bad-bg);
}

.kpi-card.urgent .kpi-value {
  color: var(--bad);
}

@media (max-width: 600px) {
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .kpi-card {
    padding: 14px 16px;
  }

  .kpi-value {
    font-size: 19px;
  }
}

@media (max-width: 380px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------------------------------------------------
 * Panels & cards
 * ------------------------------------------------------------------------- */

.panels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
  gap: 18px;
  /* A grid item defaults to min-width:auto, so a wide table expands its own
   * track and scrolls the whole document rather than its own container.
   * rules: every web surface must not scroll horizontally at 375px. */
  align-items: start;
}

.panels-grid > * {
  min-width: 0;
}

@media (max-width: 900px) {
  .panels-grid {
    grid-template-columns: 1fr;
  }
}

.panel,
.detail-card {
  background: var(--panel-solid);
  border: 1px solid var(--hair);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  max-width: 100%;
  min-width: 0;
}

.panels-grid .panel {
  margin-bottom: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--ink);
}

.panel-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-light);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------
 * Tables
 * ------------------------------------------------------------------------- */

.table-container {
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  max-width: 100%;
  min-width: 0;
}

.app-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
}

.app-table td.row-actions {
  padding-left: 6px;
  padding-right: 6px;
  gap: 4px;
}

.app-table td.row-actions .btn {
  padding: 3px 7px;
  font-size: 11px;
}

.app-table th {
  text-align: left;
  font-size: 10.5px;
  line-height: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 6px 10px;
  border-bottom: 1px solid var(--hair);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--panel-subtle);
}

.app-table td {
  padding: 6px 10px;
  line-height: 24px;
  border-bottom: 1px solid var(--hair-subtle);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-table td.row-actions {
  overflow: visible;
}

.app-table tbody tr:last-child td {
  border-bottom: 0;
}

.app-table tbody tr:hover {
  background: var(--panel-hover);
}

/* Under 860px eleven columns cannot share a phone's width, so a row becomes a
 * labelled block. Nothing scrolls sideways at any width: the table fits above
 * this breakpoint and stops being a table below it. */
@media (max-width: 860px) {
  .app-table,
  .app-table tbody,
  .app-table tr,
  .app-table td {
    display: block;
    width: 100%;
  }

  .app-table thead {
    display: none;
  }

  .app-table tr {
    border: 1px solid var(--hair);
    border-radius: var(--radius);
    background: var(--panel-solid);
    margin-bottom: 8px;
    padding: 6px 0;
  }

  .app-table tbody tr:hover {
    background: var(--panel-solid);
  }

  .app-table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 12px;
    padding: 6px 12px;
    line-height: 22px;
    border-bottom: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .app-table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
  }

  .app-table td.row-actions {
    width: 100%;
    padding: 8px 12px 4px;
  }

  .app-table td.row-actions::before {
    content: none;
  }
}

.col-measure {
  position: absolute;
  left: -10000px;
  top: 0;
  visibility: hidden;
  pointer-events: none;
  width: max-content;
}

.col-measure .app-table {
  width: max-content;
}

.col-measure .app-table td,
.col-measure .app-table th {
  overflow: visible;
  text-overflow: clip;
}

.col-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.col-tab {
  background: none;
  border: 1px solid var(--hair);
  border-radius: var(--radius-pill);
  color: var(--ink-secondary);
  font: inherit;
  font-size: 12px;
  padding: 4px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.col-tab:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.col-tab.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}

@media (max-width: 860px) {
  .col-tabs {
    display: none;
  }
}

.cell-popup {
  position: fixed;
  z-index: 300;
  max-width: 360px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  white-space: normal;
  overflow-wrap: anywhere;
}

.cell-popup[hidden] {
  display: none;
}

.table-link {
  font-weight: 600;
  color: var(--accent);
}

.table-link:hover {
  opacity: 0.8;
}

/* ---------------------------------------------------------------------------
 * Badges & chips
 * ------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  line-height: 1.25;
  white-space: nowrap;
}

.badge-green,
.badge-done {
  color: var(--ok);
  border-color: var(--ok-border);
  background: var(--ok-bg);
}

.badge-amber,
.badge-open {
  color: var(--warn);
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

.badge-red {
  color: var(--bad);
  border-color: var(--bad-border);
  background: var(--bad-bg);
}

.badge-blue {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background: var(--accent-light);
}

.badge-gray {
  color: var(--muted);
  border-color: var(--hair);
  background: var(--hair-subtle);
}

.days-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  color: var(--muted);
  background: var(--hair-subtle);
  border: 1px solid var(--hair);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.meta-line {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------------------------------------------------------------------------
 * Buttons
 * ------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.18s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.18s cubic-bezier(0.16, 1, 0.3, 1), color 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.18s cubic-bezier(0.16, 1, 0.3, 1), filter 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.28);
}

.btn:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 113, 227, 0.35);
  opacity: 1;
}

.btn:active {
  background: var(--accent-active);
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-sm {
  padding: 4px 11px;
  font-size: 12px;
  line-height: 18px;
}

.btn-outline,
.btn-ghost {
  background: var(--panel-solid);
  border-color: var(--hair);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.btn-outline:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  background: var(--panel-subtle);
  border-color: rgba(0, 0, 0, 0.16);
  filter: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  .btn-outline:hover:not(:disabled),
  .btn-ghost:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.26);
  }
}

.user-box .btn-outline {
  padding: 4px 11px;
  font-size: 12px;
}

.user-box .btn-outline:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: var(--panel-solid);
  border-color: var(--bad-border);
  color: var(--bad);
  box-shadow: none;
}

.btn-danger:hover:not(:disabled) {
  background: var(--bad-bg);
  border-color: var(--bad);
  filter: none;
  box-shadow: none;
}

.btn-link-danger {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.btn-link-danger:hover {
  color: var(--bad);
  background: var(--bad-bg);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
 * Forms
 * ------------------------------------------------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
}

@media (max-width: 680px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-field {
  margin-bottom: 0;
  width: 100%;
  min-width: 0;
}

.form-field.span-2 {
  grid-column: 1 / -1;
}

.form-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-field label .req {
  color: var(--bad);
  margin-left: 2px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
  width: 100%;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  background: var(--panel-solid);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-light);
}

.form-field textarea,
textarea {
  resize: vertical;
  min-height: 72px;
}

.form-hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.form-errors {
  display: block;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid var(--bad-border);
  background: var(--bad-bg);
  color: var(--bad);
}

.form-errors[hidden] {
  display: none;
}

.form-notice {
  display: block;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid var(--info-border);
  background: var(--info-bg);
  color: var(--info);
}

.form-errors ul {
  margin: 6px 0 0 18px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.toolbar input[type="search"],
.toolbar select {
  width: auto;
  min-width: 200px;
  flex: 1;
  max-width: 340px;
}

@media (max-width: 560px) {
  .toolbar {
    align-items: stretch;
  }

  .toolbar input[type="search"],
  .toolbar select {
    max-width: none;
    width: 100%;
    flex: 1 1 100%;
  }
}

.select-inline {
  width: auto;
  max-width: 170px;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* Repeater rows (requirements / partners inside the tender form) */
.repeater {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.repeater-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background: var(--panel-subtle);
}

.repeater-row.partner-row {
  grid-template-columns: 1fr 1fr auto 1fr auto;
}

.repeater-row input,
.repeater-row select {
  font-size: 13px;
  padding: 6px 10px;
  background: var(--panel-solid);
}

.repeater-row .mandatory-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.repeater-row .mandatory-toggle input {
  width: auto;
  accent-color: var(--accent);
}

.repeater-add {
  align-self: flex-start;
  margin-top: 8px;
}

@media (max-width: 720px) {
  .repeater-row,
  .repeater-row.partner-row {
    grid-template-columns: 1fr;
  }

  .repeater-row .btn-link-danger {
    justify-self: end;
  }
}

/* ---------------------------------------------------------------------------
 * Detail view
 * ------------------------------------------------------------------------- */

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

@media (max-width: 480px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

.detail-item {
  min-width: 0;
}

.detail-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
}

.detail-value {
  margin-top: 3px;
  font-size: 14px;
  word-break: break-word;
}

.text-section {
  margin-top: 18px;
}

.text-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.text-section-body {
  white-space: pre-wrap;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-secondary);
}

.empty-msg,
.loading-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------------------------------------------------------------------------
 * Modals
 * ------------------------------------------------------------------------- */

.modal {
  border: 1px solid var(--hair);
  border-radius: var(--radius-xl);
  padding: 0;
  width: min(760px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  background: var(--panel-solid);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-confirm {
  width: min(440px, calc(100vw - 32px));
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  padding: 24px 26px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 560px) {
  .modal-content {
    padding: 20px 16px;
  }
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--ink);
  margin-bottom: 16px;
}

.entity-choices { display: grid; gap: 10px; }
.entity-choice {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  text-align: left;
  min-height: 52px;
  white-space: normal;
}
.entity-choice strong { min-width: 0; font-size: 14px; font-weight: 600; line-height: 1.4; }
.entity-active { font-size: 12px; white-space: nowrap; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--hair);
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .modal-actions .btn {
    flex: 1;
    justify-content: center;
  }
}

.confirm-message {
  font-size: 13.5px;
  color: var(--ink-secondary);
  line-height: 1.5;
}

/* ---------------------------------------------------------------------------
 * Toasts
 * ------------------------------------------------------------------------- */

.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  padding: 11px 16px;
  border-radius: var(--radius);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.toast-success {
  background-color: #248a3d;
}

.toast.toast-error {
  background-color: #c9271e;
}

.toast.toast-info {
  background-color: var(--accent);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---------------------------------------------------------------------------
 * Sign-in / forced password change
 * ------------------------------------------------------------------------- */

.auth-wrap {
  min-height: calc(100vh - 220px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.auth-card {
  width: 100%;
  max-width: 410px;
  background: var(--panel);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-xl);
  padding: 40px 36px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: card-fade-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  .auth-card {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(28, 28, 30, 0.85);
  }
}

@keyframes card-fade-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-card .brand-badge {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #004fb0);
  font-size: 26px;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(0, 113, 227, 0.32);
}

.auth-card .brand-mark,
.auth-mark {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  margin: 0 auto 20px;
}

.auth-title {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
  color: var(--ink);
}

.auth-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.45;
}

.auth-card .form-field {
  text-align: left;
  margin-bottom: 18px;
}

.auth-card .form-field label {
  margin-bottom: 6px;
}

.auth-card input {
  padding: 11px 14px;
  font-size: 14px;
  border-radius: 10px;
}

.auth-card .btn {
  width: 100%;
  min-height: 44px;
  padding: 8px 18px;
  font-size: 14px;
  line-height: 26px;
  margin-top: 6px;
}

.auth-card .form-errors,
.auth-card .form-notice {
  text-align: left;
}

/* ---------------------------------------------------------------------------
 * Error page & noscript
 * ------------------------------------------------------------------------- */

.error-page {
  max-width: 480px;
  margin: 0 auto;
  padding: 64px 20px;
  text-align: center;
}

.error-code {
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -2px;
  color: var(--accent);
  line-height: 1;
}

.error-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-top: 12px;
  color: var(--ink);
}

.error-text {
  font-size: 13.5px;
  color: var(--muted);
  margin: 8px 0 24px;
  line-height: 1.5;
}

.error-home-link {
  display: inline-flex;
}

.noscript-warning {
  padding: 16px;
  margin: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 13.5px;
  text-align: center;
}

/* ==========================================================================
   BusinessHub additions
   ==========================================================================
   Everything above is the shared Binteca suite design — the same tokens,
   palette and chrome as SalesOps and TenderOps. Only what BusinessHub genuinely
   adds is below: the module label on a KPI card, the linked-service cards,
   the external-link nav treatment and the collection toolbar.

   These use the tokens above rather than literal colours, so they follow the
   suite's light and dark palettes without a second definition.
   ========================================================================== */

/* The module a figure belongs to, above its subject. Without it the dashboard
   is a wall of numbers with no way to tell HumanOps from AssetOps. */
.kpi-subject {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 2px;
}

.kpi-card .meta-line {
  margin-top: 6px;
}

/* A link that leaves the app is marked as such: SalesOps and TenderOps are
   separate deployments, and a nav item that opens a new tab should say so
   before it is clicked, not after. */
.app-nav a.nav-external {
  color: var(--ink-secondary);
}

.app-nav a.nav-external:hover {
  color: var(--accent);
}

.link-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.link-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.link-icon {
  font-size: 22px;
  line-height: 1;
}

.link-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.link-blurb {
  font-size: 12px;
  color: var(--muted);
}

/* The per-collection filter. min-width keeps it usable at 375px without
   pushing the toolbar wider than the viewport — estate rule #23. */
.search-input {
  min-width: 0;
  width: 100%;
  max-width: 260px;
}

.auth-card .btn-block + .btn-block {
  margin-top: 10px;
}

.btn-block {
  display: flex;
  width: 100%;
}

.form-field-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
}

.form-field-check input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.form-field-wide {
  grid-column: 1 / -1;
}

/* A grid item's min-width defaults to auto, so a wide table expands its own
   track and scrolls the whole document instead of its container. This is the
   rule that took /docs from 228px of horizontal overflow to 0 at 375px. */
.kpi-grid > *,
.panels-grid > * {
  min-width: 0;
}

@media (max-width: 600px) {
  .view-actions {
    width: 100%;
  }

  .search-input {
    max-width: none;
  }
}

/* --- Unified platform: module nav, line editor, documents ---------------- */

/* Twenty collections grouped under five modules. The group label toggles its
   own items; the group holding the current route opens itself. */
.nav-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}

.nav-group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
  cursor: pointer;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-group-label::after {
  content: "";
  margin-left: auto;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.nav-group-label:hover,
.nav-group-label.active {
  color: var(--accent);
  background: var(--accent-light);
}

.nav-group-items {
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}

.nav-group-items.open {
  display: flex;
}

.nav-group-items a {
  padding-left: 34px;
  font-size: 12px;
}

.nav-icon {
  display: inline-block;
  width: 18px;
  margin-right: 6px;
  text-align: center;
  font-size: 12px;
  line-height: 1;
  opacity: 0.75;
  flex-shrink: 0;
}

.app-nav a.active .nav-icon,
.nav-group-label.active .nav-icon {
  opacity: 1;
}

.nav-group:has(.nav-group-items.open) .nav-group-label::after {
  transform: rotate(45deg);
}

.nav-section {
  margin-top: 10px;
  padding: 0 10px 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted-cell {
  color: var(--muted);
  font-size: 12px;
}

/* A document number is claimed by the server and never reassigned, so it is
   shown rather than offered as an input. */
.assigned-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px dashed var(--hair);
  border-radius: var(--radius-sm);
  background: var(--panel-subtle);
  color: var(--ink-secondary);
}

.json-view {
  max-height: 220px;
  overflow: auto;
  font-size: 12px;
  background: var(--panel-subtle);
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin: 0;
}

/* Line items. The grid collapses to stacked rows on a phone, because five
   numeric columns cannot survive 375px and must not scroll the document. */
.line-editor {
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--panel-subtle);
}

.line-head,
.line-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) 70px minmax(0, 1.2fr) 76px 72px 72px;
  gap: 6px;
  align-items: center;
}

.line-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.line-row + .line-row {
  margin-top: 6px;
}

.line-row input {
  min-width: 0;
  font-size: 13px;
  padding: 6px 8px;
}

.line-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.line-total {
  font-size: 13px;
  color: var(--ink-secondary);
}

@media (max-width: 720px) {
  .line-head {
    display: none;
  }

  .line-row {
    grid-template-columns: 1fr 1fr;
    padding: 8px;
    border: 1px solid var(--hair);
    border-radius: var(--radius-sm);
    background: var(--panel-solid);
  }

  .line-row .line-desc {
    grid-column: 1 / -1;
  }
}

/* ---------------------------------------------------------------------------
 * Multi-Tenancy & Entity Switcher
 * ------------------------------------------------------------------------- */

.internal-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: var(--hair);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.role-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-light);
  color: var(--accent);
  letter-spacing: 0.2px;
}

.role-badge.role-super {
  background: rgba(175, 82, 222, 0.12);
  color: #af52de;
}

.role-badge.role-admin {
  background: rgba(0, 113, 227, 0.12);
  color: #0071e3;
}

.role-badge.role-accountant {
  background: rgba(52, 199, 89, 0.12);
  color: #34c759;
}

.role-badge.role-hr {
  background: rgba(255, 149, 0, 0.12);
  color: #ff9500;
}

.role-badge.role-sales {
  background: rgba(88, 86, 214, 0.12);
  color: #5856d6;
}

/* The entity selector's label is for screen readers: index.html has said so
   since the selector arrived, but nothing defined the class, so "Entity" was
   painted beside the control on every width and took 48px of the phone row. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden-field {
  display: none;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 0 16px;
}

.settings-body .u-s9 {
  margin-bottom: 0;
}

.settings-body .u-s10 {
  margin-top: 2px;
}

.settings-entity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-entity-row select {
  flex: 1 1 200px;
  width: auto;
  min-width: 0;
}

.settings-entity-row button {
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-xs {
  font-size: 11px;
  line-height: 16px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------------------------
 * GAAP Financial Statements & Reports
 * ------------------------------------------------------------------------- */

.gaap-wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.gaap-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--hair);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.gaap-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.gaap-tab-btn:hover {
  color: var(--ink);
  background: var(--panel-hover);
}

.gaap-tab-btn.active {
  color: var(--accent);
  background: var(--accent-light);
  border-color: var(--accent-light);
  font-weight: 600;
}

.gaap-header-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 16px 20px;
  backdrop-filter: var(--blur);
}

.gaap-status-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
}

.gaap-status-badge.balanced {
  background: var(--ok-bg);
  color: var(--ok);
  border: 1px solid var(--ok-border);
}

.gaap-status-badge.unbalanced {
  background: var(--bad-bg);
  color: var(--bad);
  border: 1px solid var(--bad-border);
}

.gaap-table {
  width: 100%;
  border-collapse: collapse;
}

.gaap-table th, .gaap-table td {
  padding: 10px 14px;
  font-size: 13px;
  text-align: left;
}

.gaap-table th.num, .gaap-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.gaap-section-header td {
  font-weight: 700;
  font-size: 13.5px;
  background: var(--panel-subtle);
  color: var(--ink);
  border-top: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
}

.gaap-row-total td {
  font-weight: 700;
  font-size: 13.5px;
  border-top: 1px solid var(--ink);
  border-bottom: 3px double var(--ink);
}

.gaap-row-subtotal td {
  font-weight: 600;
  border-top: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
}

.gaap-grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.gaap-summary-card {
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gaap-summary-card .title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
}

.gaap-summary-card .value {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.gaap-summary-card .subtitle {
  font-size: 12px;
  color: var(--muted);
}


/* ---------------------------------------------------------------------------
 * ProjectOps — board and roadmap (views over issues, sprints and epics)
 * ------------------------------------------------------------------------- */

.muted { color: var(--muted); }

.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.linklike:hover { color: var(--accent); }

.board-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin: 0 0 16px;
}
.board-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
.board-filters select {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--panel-subtle);
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  max-width: 100%;
}
.board-filters .board-check {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding-bottom: 8px;
  color: var(--ink);
}

/* One column per status; at 375px the grid collapses to one column so
   nothing scrolls sideways (rule #23). */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  align-items: start;
}
.board-column {
  background: var(--panel-subtle);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 120px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.board-column.over {
  border-color: var(--accent);
  background: var(--accent-light);
}
.board-column-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 2px 4px 10px;
  display: flex;
  justify-content: space-between;
}
.board-count {
  font-weight: 500;
  color: var(--muted);
}
.board-cards { display: flex; flex-direction: column; gap: 8px; }
.board-empty { color: var(--muted); font-size: 12.5px; margin: 8px 4px; }

.issue-card {
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  padding: 10px 10px 8px;
  cursor: grab;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.issue-card:hover, .issue-card:focus-visible {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  outline: none;
  border-color: var(--accent);
}
.issue-card.dragging { opacity: 0.5; transform: scale(0.98); }
.issue-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.issue-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--muted);
}
.issue-title { font-size: 13.5px; font-weight: 500; line-height: 1.35; }
.issue-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-secondary);
}
.issue-move { display: block; margin-top: 8px; }
.issue-move select {
  width: 100%;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-subtle);
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}
/* Drag exists only where a pointer does; the menu is the phone's way and stays
   available everywhere so the two never disagree. */
@media (hover: hover) and (pointer: fine) {
  .issue-move select { color: var(--muted); }
}

.roadmap-project h2 { margin-bottom: 12px; }
.roadmap-epic {
  border-top: 1px solid var(--hair);
  padding: 12px 0;
}
.roadmap-epic-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 8px;
}
.roadmap-epic-title { font-size: 14px; font-weight: 600; }
.progress {
  height: 6px;
  background: var(--hair);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill { height: 100%; background: var(--accent); transition: width 0.3s ease; }
.roadmap-issues {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.roadmap-issues li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 13px;
}

/* ---------------------------------------------------------------------------
 * DriveOps Web Drive Explorer
 * ------------------------------------------------------------------------- */

.drive-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 100%;
}

.drive-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.drive-title-area {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drive-header-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

.drive-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.drive-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: min(200px, 100%);
  max-width: 400px;
}

.drive-search-box input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-sm);
  background: var(--panel-solid);
  color: var(--ink);
  font-size: 13px;
}

.drive-search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.drive-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.drive-shared-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drive-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 0;
}

.drive-shared-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.drive-shared-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  transition: all 0.18s ease;
  cursor: pointer;
}

.drive-shared-card:hover {
  background: var(--panel-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.drive-shared-icon {
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  flex-shrink: 0;
}

.drive-shared-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: visible;
}

.drive-shared-name {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: normal;
}

.drive-shared-level {
  font-size: 11px;
  color: var(--muted);
}

.drive-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 6px 2px;
  color: var(--muted);
}

.drive-crumb {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.drive-crumb:hover {
  text-decoration: underline;
}

.drive-crumb-sep {
  color: var(--muted);
  user-select: none;
}

.drive-crumb-current {
  font-weight: 600;
  color: var(--ink);
}

.drive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.drive-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  transition: all 0.18s ease;
  position: relative;
  min-height: 110px;
}

.drive-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.drive-card-folder {
  cursor: pointer;
  background: var(--panel-subtle);
  border-left: 3px solid var(--accent);
}

.drive-card-folder:hover {
  background: var(--panel-hover);
}

.drive-card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.drive-item-glyph {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}

.drive-item-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: visible;
}

.drive-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: normal;
}

.drive-item-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.drive-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--hair-subtle);
  padding-top: 8px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}

.drive-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.drive-file-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-pdf { background: rgba(255, 59, 48, 0.12); color: #ff3b30; }
.badge-word { background: rgba(0, 113, 227, 0.12); color: #0071e3; }
.badge-excel { background: rgba(52, 199, 89, 0.12); color: #34c759; }
.badge-video { background: rgba(175, 82, 222, 0.12); color: #af52de; }
.badge-image { background: rgba(255, 149, 0, 0.12); color: #ff9500; }
.badge-code { background: rgba(90, 200, 250, 0.12); color: #007aff; }
.badge-doc { background: rgba(88, 86, 214, 0.12); color: #5856d6; }

.drive-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  text-align: center;
  background: var(--panel);
  border: 1px dashed var(--hair);
  border-radius: var(--radius);
  color: var(--muted);
}

.drive-empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.drive-preview-modal-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 900px;
  width: 90vw;
  max-height: 90vh;
}

.drive-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--hair);
  padding-bottom: 10px;
}

.drive-preview-body {
  overflow: auto;
  max-height: calc(85vh - 100px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.drive-preview-body iframe,
.drive-preview-body img,
.drive-preview-body video {
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.drive-preview-markdown {
  width: 100%;
  text-align: left;
  padding: 16px;
  background: var(--panel-solid);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  overflow-x: auto;
}

.drive-dropzone {
  border: 2px dashed var(--accent);
  background: var(--accent-light);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--accent);
  font-weight: 600;
  transition: all 0.2s ease;
}

.drive-col-icon { width: 40px; text-align: center; font-size: 16px; }
.drive-col-actions { text-align: right; }
.drive-clickable-row { cursor: pointer; }
.drive-clickable-row:hover { background: var(--panel-hover); }
.drive-filename-wrap { display: flex; flex-direction: column; min-width: 0; }
.drive-filepath-sub { font-size: 11px; color: var(--muted); }
.drive-preview-iframe { width: 100%; height: 75vh; border: none; border-radius: var(--radius-sm); }
.drive-preview-media { max-width: 100%; max-height: 70vh; border-radius: var(--radius-sm); object-fit: contain; display: block; margin: 0 auto; }
.drive-preview-audio { width: 100%; margin: 24px 0; }
.drive-preview-pre { white-space: pre-wrap; font-family: monospace; font-size: 13px; margin: 0; }
.drive-preview-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.drive-preview-meta-title { margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drive-preview-meta-sub { font-size: 12px; color: var(--muted); }
.drive-empty-padding { padding: 32px; }
.drive-empty-meta { font-size: 11px; word-break: break-all; color: var(--muted); }
.drive-download-btn-margin { margin-top: 16px; }

/* -------------------------------------------------------------------------
 * Mobile Drive Navigation & PWA Controls (OneDrive Style)
 * ------------------------------------------------------------------------- */
.mobile-drive-bar {
  display: none;
}

.mobile-drive-bar[hidden],
body:not(.authed) .mobile-drive-bar {
  display: none !important;
}

@media (max-width: 768px) {
  .mobile-drive-bar[hidden],
  body:not(.authed) .mobile-drive-bar {
    display: none !important;
  }
  .mobile-drive-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--panel-solid);
    border-top: 1px solid var(--hair);
    z-index: 100;
    align-items: center;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
  }
  .mobile-drive-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 44px;
    min-height: 44px;
    font-size: 11px;
    line-height: 1.2;
    color: var(--muted);
    text-decoration: none;
    background: none;
    border: none;
    padding: 4px 12px;
    cursor: pointer;
    font-family: inherit;
  }
  .mobile-drive-item.active,
  .mobile-drive-item:hover {
    color: var(--accent);
  }
  .mobile-drive-icon {
    font-size: 18px;
    line-height: 1;
  }
  .drive-view {
    padding-bottom: 72px;
  }
}

/* ---------------------------------------------------------------------------
 * Entity Switch & Document Sync Busy Popup
 * ------------------------------------------------------------------------- */

.entity-busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 13, 0.76);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.entity-busy-overlay[hidden] {
  display: none !important;
}

.entity-busy-card {
  width: min(390px, 100%);
  background: linear-gradient(180deg, #161b26 0%, #0d111a 100%);
  border: 1px solid rgba(11, 99, 243, 0.38);
  border-radius: 20px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.75), 0 0 32px rgba(11, 99, 243, 0.25);
  padding: 32px 26px 28px;
  text-align: center;
  color: #f1f5f9;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.entity-busy-spinner-wrap {
  position: relative;
  width: 68px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.entity-busy-spinner {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3.5px solid rgba(255, 255, 255, 0.08);
  border-top-color: #00f2fe;
  border-right-color: #0b63f3;
  animation: entitySpin 0.9s cubic-bezier(0.55, 0.15, 0.45, 0.85) infinite;
}

@keyframes entitySpin {
  to { transform: rotate(360deg); }
}

.entity-busy-icon {
  font-size: 28px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

.entity-busy-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #ffffff;
}

.entity-busy-name {
  font-size: 14px;
  font-weight: 600;
  color: #00e5ff;
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid rgba(0, 229, 255, 0.25);
  padding: 4px 14px;
  border-radius: 999px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-busy-status {
  margin: 0;
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.45;
  padding: 0 4px;
}

.entity-busy-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  margin-top: 6px;
}

.entity-busy-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, #0b63f3, #00f2fe);
  border-radius: 2px;
  animation: entityBar 1.2s infinite ease-in-out;
}

@keyframes entityBar {
  0% { left: -40%; width: 40%; }
  50% { width: 60%; }
  100% { left: 100%; width: 40%; }
}

/* AI Assist */
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0 0 4px;
}

.stack {
  display: flex;
  flex-direction: column;
}

.stack > label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}

.stack > label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  cursor: pointer;
}

.row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.gaap-status-badge {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

pre.ai-answer {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  margin: 0;
  line-height: 1.45;
}

/* Utility classes replacing inline style attributes, which the CSP
   (style-src 'self') blocks. Script-set el.style still works and still
   overrides these, which the show/hide toggles rely on. */
.u-ok { color: var(--ok); }
.u-bad { color: var(--bad); }
.u-s1 { padding: 1.5rem 0; }
.u-s2 { display:flex;align-items:center;gap:1rem;margin-bottom:1.25rem; }
.u-s3 { border-radius:14px;box-shadow:0 4px 12px rgba(0,0,0,0.3); }
.u-s4 { font-size:1.1rem;display:block; }
.u-s5 { font-size:0.85rem; }
.u-s6 { padding-left: 1.25rem; line-height: 1.8; font-size: 0.95rem; }
.u-s7 { display:inline-block;padding:2px 6px;border-radius:4px;background:rgba(255,255,255,0.1);font-family:sans-serif; }
.u-s8 { padding: 1rem 0; }
.u-s9 { background: rgba(0, 113, 227, 0.08); border: 1px solid rgba(0, 113, 227, 0.25); border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 1.25rem; font-size: 0.85rem; }
.u-s10 { margin-top: 1rem; border-top: 1px solid var(--hair, rgba(255,255,255,0.1)); padding-top: 1rem; }
.u-s11 { display:flex;align-items:center;justify-content:space-between;margin-top:0.5rem; }
.u-s12 { justify-content:flex-start;text-align:left;padding:12px 16px; }
.u-s13 { display:flex;gap:6px;flex-wrap:wrap; }
.u-s14 { gap:12px;max-width:720px; }
.u-s15 { gap:8px; }
.u-s16 { margin-top:16px;display:none; }
.u-s17 { display: none; }

/* Users screen: module allow-list choices */
.module-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 2px 12px; }
.module-choices[hidden] { display: none; }

/* Release-Polish Rule #37: phone touch targets (<= 480px) */
@media (max-width: 480px) {
  .nav-toggle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .brand,
  .user-name,
  .auth-card a,
  .app-footer a,
  .back-link,
  .table-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }

  .app-nav a,
  .nav-group-label {
    min-height: 44px;
    line-height: 26px;
  }

  button:not(.mobile-drive-item):not(.nav-toggle):not(.entity-choice),
  .btn,
  .btn-sm,
  .btn-xs,
  .user-box .btn-outline,
  .view-actions .btn,
  .app-table td.row-actions .btn,
  .btn-link-danger,
  .gaap-tab-btn,
  .col-tab,
  .linklike,
  a.btn {
    min-height: 44px;
    line-height: 26px;
    padding: 8px 12px;
  }

  .btn-xs,
  button[data-action="drive-refresh"],
  button[data-action="modal-close"] {
    min-width: 44px;
  }

  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.hidden-field),
  select,
  .select-inline {
    min-height: 44px;
  }

  input[type="checkbox"],
  input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 12px;
    margin: 0;
    flex-shrink: 0;
    background: transparent;
    border: 0;
    cursor: pointer;
    display: inline-grid;
    place-items: center;
    position: relative;
  }

  input[type="checkbox"]::before,
  input[type="radio"]::before {
    content: "";
    width: 20px;
    height: 20px;
    border: 1.5px solid var(--muted);
    border-radius: 6px;
    background: var(--panel-solid);
    transition: background-color 0.15s ease, border-color 0.15s ease;
  }

  input[type="radio"]::before {
    border-radius: 50%;
  }

  input[type="checkbox"]:checked::before,
  input[type="radio"]:checked::before {
    background: var(--accent);
    border-color: var(--accent);
  }

  input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    width: 5px;
    height: 10px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: translateY(-1px) rotate(45deg);
  }

  input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffffff;
  }

  input[type="checkbox"]:focus-visible,
  input[type="radio"]:focus-visible {
    box-shadow: none;
  }

  input[type="checkbox"]:focus-visible::before,
  input[type="radio"]:focus-visible::before {
    border-color: var(--accent);
    box-shadow: 0 0 0 3.5px var(--accent-light);
  }

  .check,
  .form-field-check,
  .board-check {
    min-height: 44px;
  }

  .account-tab,
  .receipt-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

/* ---------------------------------------------------------------------------
 * Account Hub, Activity, Billing & Printable Receipts
 * ------------------------------------------------------------------------- */

.account-tabs {
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.account-tab {
  white-space: nowrap;
}

.account-tab:focus-visible,
.receipt-link:focus-visible,
.billing-plan-card:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.account-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.account-table th,
.account-table td:first-child {
  white-space: nowrap;
}

.account-table td {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.account-table th.num,
.account-table td.num {
  text-align: right;
  white-space: nowrap;
}

.tabular-num {
  font-variant-numeric: tabular-nums;
}

.cell-value {
  display: inline-block;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.cell-wrap {
  max-width: 340px;
}

@media (max-width: 860px) {
  .account-table td:first-child {
    white-space: normal;
  }
  .cell-wrap {
    max-width: 100%;
  }
  #account-tab-body {
    padding-bottom: 72px;
  }
}

.account-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--hair);
}

.account-page-btns {
  display: flex;
  gap: 8px;
}

.account-popia-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 18px;
}

.account-popia-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background: var(--panel-subtle);
  min-width: 0;
}

.account-danger-box {
  border-color: var(--bad-border);
  background: var(--bad-bg);
}

.account-popia-box h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}

.account-delete-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.account-popia-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.billing-sub-grid {
  margin-top: 8px;
}

.billing-sub-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--hair);
}

.billing-checkout-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

.billing-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 12px;
}

.billing-plan-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background: var(--panel-subtle);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  min-width: 0;
}

.billing-plan-card.selected {
  border-color: var(--accent);
  background: var(--accent-light);
}

.billing-plan-card input[type="radio"] {
  margin-top: 2px;
  flex-shrink: 0;
}

.billing-plan-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.billing-plan-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.billing-optin {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-secondary);
  cursor: pointer;
}

.billing-optin input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .panel {
    padding: 16px 14px;
  }
  .panel-head > div {
    min-width: 0;
    max-width: 100%;
  }
  .account-panel-actions {
    width: 100%;
  }
  .account-panel-actions .btn,
  .account-popia-actions .btn,
  .billing-sub-actions .btn {
    width: 100%;
    max-width: 100%;
  }
  .account-popia-grid {
    grid-template-columns: 1fr;
  }
  .account-popia-box {
    padding: 14px;
  }
  .account-popia-box label {
    overflow-wrap: anywhere;
  }
  .billing-optin input[type="checkbox"] {
    width: 44px;
    height: 44px;
  }
}

.billing-pay-ref {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Printable SaaS Billing Receipt */
.receipt-body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

.receipt-shell {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.receipt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.receipt-toolbar .back-link {
  margin-bottom: 0;
}

.receipt-sheet {
  background: var(--panel-solid);
  border: 1px solid var(--hair);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

.receipt-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--accent);
}

.receipt-brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.receipt-product-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.receipt-issuer-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.receipt-issuer-meta {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.receipt-title-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  text-align: right;
}

.receipt-heading {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--ink);
  margin-top: 4px;
}

.receipt-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.receipt-date {
  font-size: 12px;
  color: var(--muted);
}

.receipt-summary-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin: 20px 0;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--accent-light);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}

.receipt-kicker {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.receipt-amount {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.receipt-summary-right {
  text-align: right;
  min-width: 0;
}

.receipt-ref-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  color: var(--ink-secondary);
  overflow-wrap: anywhere;
}

.receipt-parties {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

.receipt-party {
  min-width: 0;
}

.receipt-party p {
  font-size: 13px;
  color: var(--ink-secondary);
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.receipt-party p.receipt-strong {
  font-weight: 600;
  color: var(--ink);
}

.receipt-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.receipt-table-section {
  margin-top: 8px;
}

.receipt-foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--hair);
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 640px) {
  .receipt-sheet {
    padding: 18px 14px;
  }
  .receipt-title-block {
    align-items: flex-start;
    text-align: left;
  }
  .receipt-summary-right {
    text-align: left;
  }
}

@media print {
  .no-print {
    display: none !important;
  }
  .receipt-body {
    background: #ffffff;
    color: #1d1d1f;
  }
  .receipt-shell {
    max-width: none;
    padding: 0;
  }
  .receipt-sheet {
    border: 0;
    box-shadow: none;
    padding: 0;
    background: #ffffff;
  }
  .receipt-table,
  .receipt-table tbody,
  .receipt-table tr,
  .receipt-table td {
    display: revert !important;
    width: auto !important;
  }
  .receipt-table thead {
    display: table-header-group !important;
  }
  .receipt-table tr {
    border: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
  }
  .receipt-table td::before {
    content: none !important;
  }
}
