/* Project Costing: "ledger" visual language.
   Warm paper, deep teal ink, brass rules, serif display type, monospaced tabular figures. */

@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-var.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("../fonts/instrument-sans-var.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --aq-paper: #f4efe2;
  --aq-paper-2: #fbf8f0;
  --aq-ink: #10302e;
  --aq-ink-deep: #0a2322;
  --aq-teal: #0f6e6e;
  --aq-teal-dark: #0b5555;
  --aq-brass: #b98a2e;
  --aq-brass-ink: #7a5710;
  --aq-brass-soft: #e7d6a8;
  --aq-rule: #d9d0ba;
  --aq-muted: #55645f;
  --aq-stamp: #a8372a;

  --aq-font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --aq-font-ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --aq-font-num: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --bs-body-bg: var(--aq-paper);
  --bs-body-color: var(--aq-ink);
  --bs-body-font-family: var(--aq-font-ui);
  --bs-body-font-size: 1rem;
  --bs-primary: var(--aq-teal);
  --bs-primary-rgb: 15, 110, 110;
  --bs-link-color: var(--aq-teal);
  --bs-link-hover-color: var(--aq-teal-dark);
  --bs-border-color: var(--aq-rule);
  --bs-border-radius: 0.125rem;
  --bs-border-radius-sm: 0.125rem;
  --bs-border-radius-lg: 0.25rem;
  --bs-focus-ring-color: rgba(185, 138, 46, 0.45);
}

body.aq-body {
  background-color: var(--aq-paper);
  /* very faint ruled-ledger lines */
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(16, 48, 46, 0.035) 31px 32px);
  font-feature-settings: "kern", "liga";
}

:focus-visible {
  outline: 3px solid var(--aq-brass);
  outline-offset: 2px;
}

.aq-skip {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 2000;
  background: var(--aq-ink);
  color: var(--aq-paper);
  padding: 0.6rem 1rem;
}
.aq-skip:focus { top: 0.5rem; }

h1, h2, h3, .aq-display {
  font-family: var(--aq-font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 72;
}

.aq-muted { color: var(--aq-muted); }
.aq-eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--aq-brass-ink);
}
.aq-num, .aq-tape-row span:last-child {
  font-family: var(--aq-font-num);
  font-variant-numeric: tabular-nums;
}

/* ---------- Buttons and forms ---------- */
.btn {
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 0.125rem;
}
.btn-primary {
  --bs-btn-bg: var(--aq-teal);
  --bs-btn-border-color: var(--aq-teal);
  --bs-btn-hover-bg: var(--aq-teal-dark);
  --bs-btn-hover-border-color: var(--aq-teal-dark);
  --bs-btn-active-bg: var(--aq-ink);
  --bs-btn-active-border-color: var(--aq-ink);
  --bs-btn-focus-shadow-rgb: 185, 138, 46;
  box-shadow: 0 2px 0 var(--aq-ink-deep);
}
.btn-primary:active { box-shadow: none; transform: translateY(2px); }

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--aq-muted);
}
.form-control, .form-select {
  background-color: var(--aq-paper-2);
  border: 1px solid #b9ae93;
  border-bottom-width: 2px;
  padding: 0.6rem 0.75rem;
}
.form-control:focus, .form-select:focus {
  background-color: #fff;
  border-color: var(--aq-teal);
  box-shadow: 0 0 0 0.2rem rgba(185, 138, 46, 0.3);
}

.alert { border-radius: 0.125rem; border-left-width: 4px; }

/* ---------- App shell ---------- */
.aq-shell { display: flex; min-height: 100vh; }

.aq-sidebar {
  --bs-offcanvas-width: 17rem;
  --bs-offcanvas-bg: var(--aq-ink);
  --bs-offcanvas-color: var(--aq-paper);
  /* Bootstrap makes .offcanvas-lg transparent from lg up; the sidebar stays solid ink */
  background-color: var(--aq-ink) !important;
  color: var(--aq-paper);
  border-right: 3px double var(--aq-brass);
}
@media (min-width: 992px) {
  .aq-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    flex: 0 0 17rem;
    display: flex;
    flex-direction: column;
  }
}
.aq-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(244, 239, 226, 0.14);
}
.aq-brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--aq-paper);
  text-decoration: none;
}
.aq-brand:hover { color: #fff; }
.aq-mark {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--aq-teal);
  color: var(--aq-paper-2);
  font-family: var(--aq-font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  border: 1px solid var(--aq-brass);
  /* clipped corner, like a torn ticket */
  clip-path: polygon(0 0, 78% 0, 100% 22%, 100% 100%, 0 100%);
}
.aq-brand-text {
  font-family: var(--aq-font-display);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.05;
}
.aq-sidebar-body { flex: 1 1 auto; overflow-y: auto; padding: 1.25rem 0.75rem; }
.aq-nav-group {
  margin: 1.1rem 0.75rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--aq-brass-soft);
}
.aq-nav-group:first-child { margin-top: 0; }
.aq-nav { list-style: none; margin: 0; padding: 0; }
.aq-nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  color: rgba(244, 239, 226, 0.88);
  text-decoration: none;
  border-left: 3px solid transparent;
}
a.aq-nav-link:hover { background: rgba(244, 239, 226, 0.07); color: #fff; }
.aq-nav-link.is-active {
  background: rgba(244, 239, 226, 0.1);
  border-left-color: var(--aq-brass);
  color: #fff;
  font-weight: 600;
}
.aq-nav-link.is-soon { color: rgba(244, 239, 226, 0.5); cursor: default; }
.aq-nav-link em {
  font-style: normal;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid rgba(244, 239, 226, 0.3);
  padding: 0 0.35rem;
}
.aq-sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1rem 1.5rem;
  font-size: 0.75rem;
  color: rgba(244, 239, 226, 0.65);
  border-top: 1px solid rgba(244, 239, 226, 0.14);
}

.aq-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.aq-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--aq-rule);
  background: rgba(251, 248, 240, 0.9);
}
@media (min-width: 992px) {
  .aq-topbar { padding: 0.75rem 2.5rem; min-height: 3.25rem; }
}
.aq-topbar-title { font-family: var(--aq-font-display); font-weight: 600; }
.aq-menu-btn { border: 1px solid var(--aq-ink); padding: 0.45rem 0.6rem; }
.aq-menu-bars,
.aq-menu-bars::before,
.aq-menu-bars::after {
  display: block;
  width: 1.15rem;
  height: 2px;
  background: var(--aq-ink);
  content: "";
  position: relative;
}
.aq-menu-bars::before { top: -6px; position: absolute; }
.aq-menu-bars::after { top: 6px; position: absolute; }
.aq-env {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--aq-brass-ink);
  border: 1px dashed var(--aq-brass);
  padding: 0.15rem 0.5rem;
}
.aq-content { padding: 1.5rem 1rem 3rem; max-width: 80rem; width: 100%; }
@media (min-width: 992px) {
  .aq-content { padding: 2.25rem 2.5rem 4rem; }
}

/* ---------- Page header and cards ---------- */
.aq-pagehead {
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 3px double var(--aq-rule);
}
.aq-pagehead h1 { margin: 0; font-size: clamp(1.8rem, 1.2rem + 2vw, 2.6rem); }

.aq-card {
  position: relative;
  background: var(--aq-paper-2);
  border: 1px solid var(--aq-rule);
  padding: 1.5rem 1.5rem 1.25rem;
  box-shadow: 4px 4px 0 rgba(16, 48, 46, 0.06);
}
.aq-card::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  width: 2.75rem;
  height: 4px;
  background: var(--aq-brass);
}
.aq-card-title { font-size: 1.35rem; margin-bottom: 0.35rem; }

/* Numbered ledger list */
.aq-ledger { list-style: none; margin: 1.25rem 0 0; padding: 0; }
.aq-ledger li {
  display: grid;
  grid-template-columns: 2.25rem 1fr;
  column-gap: 0.75rem;
  padding: 0.7rem 0;
  border-top: 1px dotted #b9ae93;
}
.aq-ledger-no {
  grid-row: span 2;
  font-family: var(--aq-font-num);
  font-size: 0.85rem;
  color: var(--aq-brass-ink);
  padding-top: 0.15rem;
}
.aq-ledger-name { font-family: var(--aq-font-display); font-weight: 600; font-size: 1.05rem; }
.aq-ledger-text { color: var(--aq-muted); font-size: 0.92rem; }

.aq-facts { margin: 1.25rem 0 0; }
.aq-facts > div {
  display: flex;
  justify-content: space-between;
  padding: 0.55rem 0;
  border-top: 1px dotted #b9ae93;
}
.aq-facts dt { font-weight: 500; color: var(--aq-muted); }
.aq-facts dd { margin: 0; font-family: var(--aq-font-num); }

/* ---------- Auth and error pages ---------- */
.aq-auth { display: grid; min-height: 100vh; grid-template-columns: 1fr; }
@media (min-width: 992px) {
  .aq-auth { grid-template-columns: minmax(26rem, 5fr) 6fr; }
}
.aq-auth-art {
  display: none;
  flex-direction: column;
  gap: 2rem;
  padding: 3rem;
  background: var(--aq-ink);
  color: var(--aq-paper);
  border-right: 3px double var(--aq-brass);
  background-image: repeating-linear-gradient(to bottom, transparent 0 39px, rgba(244, 239, 226, 0.05) 39px 40px);
}
@media (min-width: 992px) {
  .aq-auth-art { display: flex; }
}
.aq-auth-brand { display: flex; align-items: center; gap: 0.8rem; }
.aq-auth-brand-sm { margin-bottom: 2.5rem; color: var(--aq-ink); }
.aq-auth-claim {
  margin: 0;
  font-family: var(--aq-font-display);
  font-weight: 500;
  font-size: clamp(2.2rem, 1.2rem + 2.2vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
}
.aq-auth-foot { margin: auto 0 0; font-size: 0.8rem; color: rgba(244, 239, 226, 0.6); }

/* Receipt tape illustration */
.aq-tape {
  position: relative;
  max-width: 26rem;
  padding: 3rem 1.25rem 1.5rem;
  background: var(--aq-paper-2);
  color: var(--aq-ink);
  font-size: 0.85rem;
  transform: rotate(-1.2deg);
  box-shadow: 8px 10px 0 rgba(0, 0, 0, 0.25);
  /* zig-zag torn bottom edge */
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 10px), 95% 100%, 90% calc(100% - 10px), 85% 100%,
    80% calc(100% - 10px), 75% 100%, 70% calc(100% - 10px), 65% 100%, 60% calc(100% - 10px), 55% 100%,
    50% calc(100% - 10px), 45% 100%, 40% calc(100% - 10px), 35% 100%, 30% calc(100% - 10px), 25% 100%,
    20% calc(100% - 10px), 15% 100%, 10% calc(100% - 10px), 5% 100%, 0 calc(100% - 10px));
}
.aq-tape-stamp {
  position: absolute;
  right: 1rem;
  top: 0.9rem;
  border: 2px solid var(--aq-stamp);
  color: var(--aq-stamp);
  padding: 0.05rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transform: rotate(6deg);
}
.aq-tape-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.3rem 0; }
.aq-tape-rule { margin: 0.5rem 0; border-top: 1px dashed #8b8267; }
.aq-tape-total {
  margin-top: 0.4rem;
  padding-top: 0.6rem;
  border-top: 2px solid var(--aq-ink);
  font-weight: 700;
  font-size: 1.05rem;
}

.aq-auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 1.25rem;
  max-width: 34rem;
  width: 100%;
  margin: 0 auto;
}
@media (min-width: 992px) {
  .aq-auth-panel { padding: 3rem; }
}
.aq-login h1 { font-size: clamp(2rem, 1.4rem + 1.5vw, 2.8rem); margin-bottom: 0.5rem; }
.aq-login form { margin-top: 2rem; }
.aq-auth-version { margin: 2.5rem 0 0; font-family: var(--aq-font-num); font-size: 0.75rem; color: var(--aq-muted); }

.aq-error h1 { font-size: 2.2rem; }
.aq-error-code {
  margin: 0;
  font-family: var(--aq-font-display);
  font-weight: 700;
  font-size: clamp(4.5rem, 3rem + 6vw, 7.5rem);
  line-height: 1;
  color: var(--aq-brass);
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* ---------- Tables, chips, forms (P2) ---------- */
.aq-narrow { max-width: 32rem; }
.aq-card a:not(.btn), .aq-pagehead a:not(.btn) { text-decoration-thickness: 1px; text-underline-offset: 3px; }

.aq-table { --bs-table-bg: transparent; font-size: 0.92rem; }
.aq-table thead th {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--aq-muted);
  border-bottom: 2px solid var(--aq-ink);
  padding: 0.8rem 1rem;
  background: rgba(16, 48, 46, 0.03);
}
.aq-table td, .aq-table tbody th { padding: 0.75rem 1rem; vertical-align: middle; border-color: var(--aq-rule); }
.aq-table tbody th { font-weight: 600; }
.aq-detail { min-width: 14rem; max-width: 28rem; word-break: break-word; font-family: var(--aq-font-num); font-size: 0.78rem; color: var(--aq-muted); }

/* Status chips always carry a text label; colour is only a hint */
.aq-chip {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  color: var(--aq-ink);
  background: transparent;
  white-space: nowrap;
}
.aq-chip-ok { color: #1c6b3a; }
.aq-chip-off { color: #6b6b6b; border-style: dashed; }
.aq-chip-warn { color: var(--aq-brass-ink); }

.aq-user-btn { display: flex; align-items: center; gap: 0.6rem; padding: 0.25rem 0.5rem; border: 1px solid transparent; }
.aq-user-btn:hover, .aq-user-btn.show { border-color: var(--aq-rule); background: var(--aq-paper-2); }
.aq-user-name { font-weight: 600; max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aq-topbar-end { display: flex; align-items: center; gap: 1rem; }
.dropdown-menu { border-radius: 0.125rem; border-color: var(--aq-rule); background: var(--aq-paper-2); }
.dropdown-item:active { background: var(--aq-teal); }

.aq-secret {
  margin: 0 0 1.25rem;
  padding: 1rem 1.25rem;
  font-family: var(--aq-font-num);
  font-weight: 500;
  font-size: clamp(1.2rem, 1rem + 1.5vw, 1.8rem);
  letter-spacing: 0.06em;
  word-break: break-all;
  background: var(--aq-ink);
  color: var(--aq-paper);
  border-left: 4px solid var(--aq-brass);
  user-select: all;
}

.aq-filters { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); align-items: end; }
.aq-filters-go { display: flex; gap: 0.5rem; }
.aq-pager { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-top: 1rem; }

/* ---------- Settings, catalog and market (P3) ---------- */
.aq-tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 1.5rem; border-bottom: 2px solid var(--aq-ink); }
.aq-tab {
  padding: 0.6rem 1rem;
  font-weight: 600;
  color: var(--aq-ink);
  text-decoration: none;
  border: 1px solid transparent;
  border-bottom: 0;
  margin-bottom: -2px;
}
.aq-tab:hover { background: var(--aq-paper-2); color: var(--aq-teal); }
.aq-tab.is-active { background: var(--aq-ink); color: var(--aq-paper); }

.aq-group-title {
  margin: 0;
  padding: 0.9rem 1rem;
  font-size: 1.1rem;
  border-bottom: 2px solid var(--aq-ink);
  background: rgba(16, 48, 46, 0.04);
}
.aq-row-off { opacity: 0.6; }
.aq-row-new { background: rgba(185, 138, 46, 0.08); }

/* Market status chips: colour is a hint, the label is the signal */
.aq-chip-below, .aq-chip-above { color: var(--aq-stamp); background: transparent; }
.aq-chip-low, .aq-chip-high { color: var(--aq-brass-ink); }
.aq-chip-mid { color: #1c6b3a; }
.aq-chip-open { color: #1f4f8f; }
.aq-chip-unavailable { color: #6b6b6b; border-style: dashed; }

.aq-template-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); margin-top: 1.5rem; }
.aq-template { display: flex; flex-direction: column; gap: 0.15rem; }
.aq-template .aq-card-title a { color: var(--aq-ink); text-decoration: none; }
.aq-template .aq-card-title a:hover { color: var(--aq-teal); text-decoration: underline; }
.aq-template-price { margin: 0.25rem 0 0; font-size: 1.5rem; font-weight: 500; }

.aq-fact-strong dt, .aq-fact-strong dd { font-weight: 700; color: var(--aq-ink); }
.aq-fact-total { border-top: 2px solid var(--aq-ink) !important; }
.aq-fact-total dt { font-weight: 700; color: var(--aq-ink); }
.aq-fact-total dd { font-size: 1.15rem; font-weight: 600; }

.aq-inline-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-start; padding: 0.5rem 1rem; }
.aq-inline-cell { flex: 1 1 14rem; }
.aq-inline-narrow { flex: 0 0 7rem; }
.aq-edit-row > td { background: rgba(16, 48, 46, 0.03); padding: 0.25rem 1rem 0.75rem !important; }
.aq-bench-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.aq-bench-form .aq-inline-cell { flex: 1 1 8rem; }
.aq-mini-label { display: block; font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--aq-muted); }
.aq-inline-check { flex: 0 0 auto; display: flex; align-items: center; gap: 0.4rem; padding-bottom: 0.3rem; }
.aq-logo-preview { padding: 0.75rem; background: #fff; border: 1px dashed var(--aq-rule); display: inline-block; }
.aq-logo-preview img { max-height: 5rem; max-width: 16rem; display: block; }

/* Narrow phones (360 px): keep the top bar inside the viewport */
@media (max-width: 575.98px) {
  .aq-topbar-end { gap: 0.5rem; min-width: 0; }
  .aq-topbar-title { display: none; }
  .aq-env { display: none; }
  .aq-user-btn .aq-chip { display: none; }
  .aq-user-name { max-width: 7rem; }
}

/* Site footer: company link and Android download */
.aq-sitefoot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.4rem 1.5rem;
  padding: 1rem 1.25rem; margin-top: auto; font-size: 0.8rem; color: var(--aq-muted, #5d6a63);
  border-top: 1px solid var(--aq-rule, #d9d0bd);
}
@media (min-width: 992px) { .aq-sitefoot { padding: 1rem 2.5rem; } }
.aq-sitefoot a { color: inherit; text-decoration: none; }
.aq-sitefoot a.aq-sitefoot-apk { text-decoration: underline; text-underline-offset: 2px; }
.aq-sitefoot a:hover, .aq-sitefoot a:focus-visible { color: var(--aq-ink, #1d2a26); }
.aq-sitefoot-apk { font-weight: 600; }
.aq-sitefoot-auth { border-top: 0; padding: 0.5rem 0 0; margin-top: 1rem; }
.aq-auth-foot a, .aq-sidebar-foot a { color: inherit; text-decoration: none; }
