/* Screen styling only. The printed A4 sheet keeps its isolated PDF stylesheet. */

@font-face {
  font-family: "Vazirmatn";
  src: url("/static/vendor/fonts/Vazirmatn-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("/static/vendor/fonts/Vazirmatn-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --nikan-font: Vazirmatn, "IRANSans", Tahoma, "Segoe UI", system-ui, sans-serif;
  --ink-950: #122033;
  --ink-900: #172b45;
  --brand-600: #3563e9;
  --brand-700: #254edb;
  --brand-050: #eef3ff;
  --success: #159a8c;
  --success-050: #e9f7f5;
  --warning: #d99b2b;
  --warning-050: #fff7e8;
  --danger: #d64550;
  --danger-050: #fff0f1;
  --canvas: #f4f7fb;
  --surface: #ffffff;
  --text: #1b2533;
  --muted: #697586;
  --border: #dce3ec;
  --border-strong: #cbd5e1;
  --sidebar-width: 224px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(18, 32, 51, 0.04), 0 8px 24px rgba(18, 32, 51, 0.04);
  --shadow-md: 0 14px 40px rgba(18, 32, 51, 0.1);
  --focus-ring: 0 0 0 3px rgba(53, 99, 233, 0.2);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--canvas);
}

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: var(--canvas);
  font-family: var(--nikan-font);
  font-size: 0.95rem;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
optgroup,
select,
textarea {
  font: inherit;
}

a {
  color: var(--brand-600);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--brand-700);
}

:focus-visible {
  outline: 3px solid rgba(53, 99, 233, 0.3);
  outline-offset: 3px;
}

[x-cloak] {
  display: none !important;
}

.skip-link {
  position: fixed;
  inset-block-start: 0.75rem;
  inset-inline-start: 0.75rem;
  z-index: 2000;
  padding: 0.65rem 0.9rem;
  color: #fff;
  background: var(--ink-950);
  border-radius: var(--radius-sm);
  transform: translateY(-180%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  color: #fff;
  transform: translateY(0);
}

/* Shared controls */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.card-body {
  padding: 1.35rem;
}

.form-label {
  margin-bottom: 0.4rem;
  color: #3e4c5f;
  font-size: 0.84rem;
  font-weight: 700;
}

.form-control,
.form-select,
.input-group-text {
  min-height: 44px;
  border-color: var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  background-color: var(--surface);
  box-shadow: none;
}

.form-control,
.form-select {
  padding: 0.65rem 0.8rem;
}

.form-control::placeholder {
  color: #9aa6b5;
}

.form-control:hover,
.form-select:hover {
  border-color: #aebbc9;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--brand-600);
  box-shadow: var(--focus-ring);
}

.form-check-input:checked {
  border-color: var(--brand-600);
  background-color: var(--brand-600);
}

textarea.form-control {
  min-height: 96px;
}

input[type="number"],
input[inputmode="numeric"] {
  padding-block: 0.55rem;
}

.field-hint,
.form-text {
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.65;
}

fieldset {
  min-width: 0;
}

fieldset legend {
  width: 100%;
  margin-bottom: 1.15rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border);
  color: var(--ink-950);
  font-size: 1rem;
  font-weight: 700;
}

.btn {
  min-height: 42px;
  padding: 0.58rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  transition: transform 150ms ease, box-shadow 150ms ease, color 150ms ease,
    background-color 150ms ease, border-color 150ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:focus-visible {
  box-shadow: var(--focus-ring);
}

.btn-primary {
  border-color: var(--brand-600);
  background: var(--brand-600);
  box-shadow: 0 8px 18px rgba(53, 99, 233, 0.18);
}

.btn-primary:hover,
.btn-primary:focus {
  border-color: var(--brand-700);
  background: var(--brand-700);
}

.btn-outline-secondary {
  border-color: var(--border-strong);
  color: #445267;
  background: var(--surface);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  border-color: #aebbc9;
  color: var(--ink-950);
  background: #f8fafc;
}

.btn-sm {
  min-height: 36px;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
}

.btn-lg {
  min-height: 50px;
  padding-inline: 1.35rem;
}

.alert {
  border-width: 1px;
  border-radius: var(--radius-sm);
}

.alert-danger {
  border-color: #f1c4c8;
  color: #942f39;
  background: var(--danger-050);
}

.alert-warning {
  border-color: #f0d59f;
  color: #78520f;
  background: var(--warning-050);
}

.badge {
  padding: 0.42em 0.65em;
  border-radius: 7px;
  font-weight: 700;
}

.text-bg-success {
  color: #087366 !important;
  background: var(--success-050) !important;
}

.text-bg-warning {
  color: #94620c !important;
  background: var(--warning-050) !important;
}

.text-bg-danger {
  color: #b33440 !important;
  background: var(--danger-050) !important;
}

.text-bg-secondary {
  color: #446084 !important;
  background: #edf2f8 !important;
}

.text-secondary {
  color: var(--muted) !important;
}

.table-responsive {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.table {
  margin-bottom: 0;
  color: var(--text);
}

.table > :not(caption) > * > * {
  padding: 0.85rem 0.8rem;
  border-color: var(--border);
}

.table thead th {
  color: #536174;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.table-light,
.table-light > th,
.table-light > td {
  --bs-table-bg: #f8fafc;
}

.table-hover > tbody > tr:hover > * {
  --bs-table-bg-state: #f6f8ff;
}

.table-warning,
.table-warning > th,
.table-warning > td {
  --bs-table-bg: #fff8e9;
  --bs-table-hover-bg: #fff3d5;
}

/* Authenticated application shell */

.app-sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 1030;
  display: flex;
  width: var(--sidebar-width);
  min-height: 100vh;
  padding: 1.35rem 1rem 1rem;
  overflow-y: auto;
  flex-direction: column;
  color: #eaf0f7;
  background:
    radial-gradient(circle at 110% -10%, rgba(53, 99, 233, 0.22), transparent 35%),
    linear-gradient(180deg, var(--ink-950) 0%, #10243d 100%);
  border-inline-end: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
  display: flex;
  gap: 0.8rem;
  min-height: 54px;
  padding: 0.25rem 0.4rem;
  align-items: center;
  color: #fff;
  text-decoration: none;
}

.sidebar-brand:hover {
  color: #fff;
}

.brand-mark {
  display: inline-flex;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.09);
}

/* The site mark is supplied on a white PNG canvas.  Clip that canvas here so
   every instance reads as one deliberate circular badge, rather than a white
   square sitting inside a rounded container. */
.brand-mark--logo {
  overflow: hidden;
  background: #fff;
  border-color: rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  box-shadow: 0 5px 16px rgba(3, 13, 30, 0.22);
}

.brand-mark--logo .brand-logo-image {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  filter: contrast(1.04) saturate(0.92);
}

.sidebar-brand .brand-mark--logo {
  width: 52px;
  height: 52px;
  flex-basis: 52px;
}

.auth-aside .brand-mark--logo,
.setup-intro .brand-mark--logo {
  width: 64px;
  height: 64px;
  flex-basis: 64px;
}

.sidebar-brand strong {
  display: block;
  font-size: 1.14rem;
  line-height: 1.45;
}

.sidebar-brand small {
  display: block;
  color: #aebdce;
  font-size: 0.7rem;
}

.sidebar-create-form {
  margin: 1.5rem 0 1.25rem;
}

.sidebar-create-button {
  display: flex;
  width: 100%;
  min-height: 48px;
  gap: 0.65rem;
  padding: 0.7rem 0.9rem;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: #fff;
  background: linear-gradient(135deg, #3e70f6, var(--brand-600));
  box-shadow: 0 10px 24px rgba(15, 35, 72, 0.36);
  font-weight: 700;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.sidebar-create-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 13px 28px rgba(15, 35, 72, 0.42);
}

.sidebar-nav {
  display: grid;
  gap: 0.4rem;
}

.sidebar-nav-link {
  position: relative;
  display: flex;
  min-height: 54px;
  gap: 0.8rem;
  padding: 0.72rem 0.85rem;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: #cbd6e3;
  text-decoration: none;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.sidebar-nav-link::after {
  position: absolute;
  inset-block: 0.7rem;
  inset-inline-end: -1rem;
  width: 3px;
  border-radius: 3px 0 0 3px;
  content: "";
  background: transparent;
}

.sidebar-nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-nav-link.is-active {
  color: #fff;
  background: linear-gradient(100deg, rgba(53, 99, 233, 0.88), rgba(53, 99, 233, 0.68));
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(4, 16, 37, 0.24);
}

.sidebar-nav-link.is-active::after {
  background: #75a0ff;
}

.sidebar-nav-link img,
.sidebar-create-button img,
.sidebar-user-menu img,
.mobile-create-button img {
  flex: 0 0 auto;
}

.sidebar-user-menu {
  position: relative;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.11);
}

.sidebar-user-menu summary {
  display: flex;
  min-height: 52px;
  gap: 0.7rem;
  padding: 0.55rem 0.35rem;
  align-items: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  list-style: none;
}

.sidebar-user-menu summary::-webkit-details-marker,
.mobile-user-menu summary::-webkit-details-marker {
  display: none;
}

.user-avatar {
  display: inline-flex;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
}

.user-copy {
  min-width: 0;
  flex: 1;
}

.user-copy strong,
.user-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy strong {
  color: #fff;
  font-size: 0.84rem;
}

.user-copy small {
  color: #9eb0c4;
  font-size: 0.7rem;
}

.user-chevron {
  transition: transform 160ms ease;
}

.sidebar-user-menu[open] .user-chevron {
  transform: rotate(180deg);
}

.sidebar-user-menu form {
  padding: 0.2rem 0.35rem 0.45rem;
}

.sidebar-user-menu button {
  display: flex;
  width: 100%;
  min-height: 42px;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  color: #d7e0eb;
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-user-menu button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
}

.app-main {
  min-height: 100vh;
  margin-inline-start: var(--sidebar-width);
}

.app-content {
  width: min(100%, 1500px);
  margin-inline: auto;
  padding: 1.75rem 1.6rem 3rem;
}

.mobile-app-header,
.mobile-bottom-nav {
  display: none;
}

/* Public, authentication, setup and errors */

.public-shell-body {
  background:
    radial-gradient(circle at 15% 5%, rgba(53, 99, 233, 0.09), transparent 28rem),
    var(--canvas);
}

.public-main {
  min-height: 100vh;
}

.auth-shell {
  display: grid;
  width: min(100%, 1080px);
  min-height: 560px;
  margin: 0 auto;
  padding: 2rem;
  grid-template-columns: minmax(320px, 0.85fr) minmax(380px, 1fr);
  align-items: stretch;
}

.auth-aside {
  position: relative;
  display: flex;
  padding: clamp(2rem, 5vw, 4rem);
  overflow: hidden;
  flex-direction: column;
  gap: 1.25rem;
  justify-content: center;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  color: #fff;
  background:
    radial-gradient(circle at 20% 5%, rgba(92, 133, 246, 0.3), transparent 38%),
    linear-gradient(145deg, #17314f, var(--ink-950));
}

.auth-aside .auth-brand {
  display: inline-flex;
  gap: 0.75rem;
  align-items: center;
  align-self: center;
  flex-direction: column;
  color: #fff;
  text-align: center;
}

.auth-brand strong {
  font-size: 1.25rem;
}

.auth-trust {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  color: #9fb1c5;
  font-size: 0.75rem;
}

.auth-panel {
  display: flex;
  padding: clamp(2rem, 5vw, 4rem);
  align-items: center;
  border: 1px solid var(--border);
  border-inline-end: 0;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.auth-form-wrap {
  width: min(100%, 390px);
  margin-inline: auto;
}

.auth-kicker {
  margin-bottom: 0.4rem;
  color: var(--brand-600);
  font-size: 0.76rem;
  font-weight: 700;
}

.auth-title {
  margin-bottom: 0.55rem;
  color: var(--ink-950);
  font-size: 1.65rem;
  font-weight: 700;
}

.auth-subtitle {
  margin-bottom: 1.6rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-form .form-control {
  min-height: 48px;
}

.auth-submit {
  width: 100%;
  min-height: 48px;
  margin-top: 0.4rem;
}

.focused-form-shell {
  width: min(100%, 600px);
  margin-inline: auto;
  padding-block: 2rem;
}

.focused-form-card {
  padding: clamp(1.35rem, 4vw, 2.25rem);
}

.setup-shell {
  display: grid;
  width: min(100%, 1260px);
  margin-inline: auto;
  padding: 2rem;
  grid-template-columns: minmax(250px, 0.36fr) minmax(0, 1fr);
  gap: 1.4rem;
  align-items: start;
}

.setup-intro {
  position: sticky;
  top: 2rem;
  padding: 1.65rem;
  border-radius: var(--radius-lg);
  color: #fff;
  background:
    radial-gradient(circle at 0 0, rgba(69, 112, 235, 0.3), transparent 35%),
    var(--ink-950);
  box-shadow: var(--shadow-md);
}

.setup-intro .auth-brand {
  margin-bottom: 2.2rem;
}

.setup-intro h1 {
  margin-bottom: 0.65rem;
  font-size: 1.45rem;
  font-weight: 700;
}

.setup-intro > p {
  margin-bottom: 1.4rem;
  color: #b8c6d7;
  font-size: 0.82rem;
}

.setup-steps {
  display: grid;
  gap: 0.35rem;
}

.setup-steps a {
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  color: #d4deea;
  font-size: 0.79rem;
  text-decoration: none;
}

.setup-steps a:hover,
.setup-steps a:focus {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.setup-form-panel {
  min-width: 0;
  padding: clamp(1.2rem, 3vw, 2rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.setup-form-panel fieldset {
  margin-bottom: 1.15rem !important;
  padding: 1.15rem 1.2rem 0.2rem;
  scroll-margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
}

.setup-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  padding: 1rem 0 0.2rem;
  justify-content: flex-start;
  background: linear-gradient(0deg, #fff 76%, rgba(255, 255, 255, 0));
}

.error-shell {
  display: grid;
  min-height: 100vh;
  padding: 2rem;
  place-items: center;
}

.error-card {
  width: min(100%, 560px);
  padding: clamp(2rem, 6vw, 4rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.error-mark {
  display: inline-flex;
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: var(--brand-050);
}

.error-mark img {
  filter: brightness(0) saturate(100%) invert(34%) sepia(95%) saturate(1188%) hue-rotate(208deg) brightness(92%);
}

.error-code {
  margin-bottom: 0.25rem;
  color: var(--brand-600);
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.3;
}

.error-message {
  margin: 0 auto 1.4rem;
  color: #455468;
  font-size: 1rem;
}

/* Existing interaction contracts */

.suggest-anchor {
  position: relative;
}

.suggest-anchor .suggest-list,
.suggest-anchor > .list-group-item {
  position: absolute;
  inset-inline: 0;
  top: 0.25rem;
  z-index: 1050;
  max-height: 16rem;
  overflow-y: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.document-lines td,
.document-lines th {
  vertical-align: middle;
}

.totals-table th {
  width: 60%;
}

/* Document workspace ----------------------------------------------------- */

.document-workspace {
  min-width: 0;
  padding-bottom: 2.5rem;
}

.document-command-card {
  display: flex;
  gap: 1.5rem;
  padding: clamp(1.15rem, 2vw, 1.7rem);
  align-items: flex-start;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.document-workspace--issued .document-command-card {
  border-inline-start: 4px solid var(--success);
}

.document-workspace--void .document-command-card {
  border-inline-start: 4px solid var(--danger);
}

.document-command-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.document-back-link {
  display: inline-flex;
  gap: 0.38rem;
  margin-bottom: 0.8rem;
  align-items: center;
  color: #566579;
  font-size: 0.79rem;
  font-weight: 700;
  text-decoration: none;
}

.document-back-link img {
  filter: brightness(0) saturate(100%) invert(37%) sepia(13%) saturate(942%) hue-rotate(175deg) brightness(91%);
}

.document-back-link:hover {
  color: var(--brand-700);
}

.document-title-row h1 {
  margin: 0.22rem 0 0;
  color: var(--ink-950);
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  font-weight: 700;
  line-height: 1.45;
}

.document-kicker,
.document-subtitle,
.document-finality-note,
.document-version-link {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
}

.document-kicker {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.document-subtitle {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.document-subtitle span::before {
  margin-inline-end: 0.55rem;
  color: var(--border-strong);
  content: "•";
}

.document-status {
  display: inline-flex;
  padding: 0.26rem 0.55rem;
  align-items: center;
  border-radius: 999px;
  font-size: 0.71rem;
  line-height: 1.45;
}

.document-status--draft {
  color: #446084;
  background: #edf2f8;
}

.document-status--issued {
  color: #087366;
  background: var(--success-050);
}

.document-status--void {
  color: #b33440;
  background: var(--danger-050);
}

.document-flow {
  display: flex;
  max-width: 640px;
  gap: 0.55rem;
  margin: 1.15rem 0 0;
  padding: 0;
  list-style: none;
}

.document-flow li {
  display: flex;
  min-width: 0;
  gap: 0.38rem;
  padding: 0.48rem 0.58rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: #6e7c8e;
  background: #fafbfd;
  font-size: 0.73rem;
  font-weight: 700;
  white-space: nowrap;
}

.document-flow li span {
  display: inline-grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border-radius: 50%;
  color: #6e7c8e;
  background: #e9eef5;
  font-size: 0.67rem;
}

.document-flow li.is-current {
  border-color: rgba(53, 99, 233, 0.25);
  color: var(--brand-700);
  background: var(--brand-050);
}

.document-flow li.is-current span {
  color: #fff;
  background: var(--brand-600);
}

.document-finality-note,
.document-version-link {
  margin-top: 1rem;
  color: #3e6b64;
  font-size: 0.79rem;
}

.document-version-link {
  color: var(--muted);
}

.document-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.document-actions form {
  margin: 0;
}

.document-print-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

.document-print-actions .btn {
  min-height: 42px;
  white-space: nowrap;
}

.document-print-menu,
.archive-print-menu {
  position: relative;
  margin: 0;
}

.document-print-menu > summary,
.archive-print-menu > summary {
  align-items: center;
  cursor: pointer;
  list-style: none;
}

.document-print-menu > summary::-webkit-details-marker,
.archive-print-menu > summary::-webkit-details-marker {
  display: none;
}

.document-print-menu-popover,
.archive-print-menu-popover {
  position: absolute;
  z-index: 1050;
  inset-inline-end: 0;
  inset-block-start: calc(100% + 0.42rem);
  display: grid;
  min-width: 168px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: #fff;
  box-shadow: 0 14px 30px rgba(18, 32, 51, 0.16);
}

.document-print-menu-popover a,
.archive-print-menu-popover a {
  min-height: 42px;
  padding: 0.7rem 0.85rem;
  color: var(--ink);
  font-size: 0.82rem;
  text-decoration: none;
  white-space: nowrap;
}

.document-print-menu-popover a:hover,
.document-print-menu-popover a:focus-visible,
.archive-print-menu-popover a:hover,
.archive-print-menu-popover a:focus-visible {
  color: var(--brand-700);
  background: var(--brand-050);
  outline: 0;
}

.document-print-menu-popover a + a,
.archive-print-menu-popover a + a {
  border-top: 1px solid var(--border);
}

/* Issued-document corrections: a manager edits in a clear, bounded mode
   rather than inside table cells.  These styles are intentionally scoped to
   document pages so catalogue/customer management remains untouched. */
.document-edit-trigger {
  white-space: nowrap;
}

.document-edit-safety-note {
  display: flex;
  gap: 0.65rem;
  margin-top: 1rem;
  padding: 0.8rem 0.95rem;
  align-items: flex-start;
  border: 1px solid #c8dafd;
  border-inline-start: 4px solid var(--brand-600);
  border-radius: var(--radius-sm);
  color: #355071;
  background: #f4f8ff;
  font-size: 0.78rem;
  line-height: 1.7;
}

.document-edit-safety-note strong {
  flex: 0 0 auto;
  color: var(--ink-950);
}

.document-line-edit-panel:empty {
  display: none;
}

.document-line-edit-card {
  margin-top: 0.9rem;
  padding: clamp(0.9rem, 2vw, 1.2rem);
  border: 1px solid #a9c4fa;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #f7faff, #fff);
  box-shadow: 0 12px 28px rgba(35, 87, 184, 0.1);
}

.document-line-edit-heading,
.document-line-edit-actions {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  justify-content: space-between;
}

.document-line-edit-heading {
  margin-bottom: 1rem;
}

.document-line-edit-heading h3 {
  margin: 0.12rem 0 0;
  color: var(--ink-950);
  font-size: 1rem;
}

.document-line-edit-heading p,
.document-line-edit-actions span,
.document-line-edit-kicker {
  color: var(--muted);
  font-size: 0.75rem;
}

.document-line-edit-heading p {
  margin: 0.18rem 0 0;
  line-height: 1.65;
}

.document-line-edit-kicker {
  color: var(--brand-700);
  font-weight: 700;
}

.document-line-warranty-edit {
  margin: 0;
  padding: 0.86rem;
  border: 1px solid var(--border);
  border-radius: 0.72rem;
  background: #fff;
}

.document-line-warranty-edit legend {
  float: none;
  width: auto;
  margin: 0 0 0.45rem;
  padding: 0;
}

.document-line-edit-actions {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px dashed #d8e2f0;
}

.document-line-edit-actions .btn {
  min-height: 44px;
}

.document-revision-history {
  margin-top: 1.25rem;
  padding: clamp(1rem, 2.2vw, 1.35rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.document-revision-history-heading,
.document-revision-list li,
.document-revision-pdfs {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: space-between;
}

.document-revision-history-heading h2 {
  margin: 0;
  color: var(--ink-950);
  font-size: 0.98rem;
}

.document-revision-history-heading p {
  margin: 0.18rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.document-revision-history-heading > span {
  flex: 0 0 auto;
  padding: 0.32rem 0.6rem;
  border-radius: 999px;
  color: var(--brand-700);
  background: var(--brand-050);
  font-size: 0.73rem;
  font-weight: 700;
}

.document-revision-list {
  display: grid;
  gap: 0.65rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.document-revision-list li {
  padding: 0.75rem 0.82rem;
  border: 1px solid #e5ebf3;
  border-radius: 0.72rem;
  background: #fbfcfe;
}

.document-revision-list li.is-current {
  border-color: #a9c4fa;
  background: #f4f8ff;
}

.document-revision-copy strong,
.document-revision-copy span {
  display: block;
}

.document-revision-copy strong {
  color: var(--ink-950);
  font-size: 0.82rem;
}

.document-revision-copy span,
.document-revision-pdfs > span {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.document-revision-pdfs {
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.document-revision-pdfs a {
  min-height: 34px;
  padding: 0.42rem 0.62rem;
  border: 1px solid #cbd8ed;
  border-radius: 0.5rem;
  color: var(--brand-700);
  background: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: none;
}

.document-revision-pdfs a:hover,
.document-revision-pdfs a:focus-visible {
  border-color: var(--brand-600);
  color: #fff;
  background: var(--brand-600);
  outline: 0;
}

@media (max-width: 767.98px) {
  .document-edit-safety-note,
  .document-line-edit-heading,
  .document-line-edit-actions,
  .document-revision-history-heading,
  .document-revision-list li {
    align-items: stretch;
    flex-direction: column;
  }

  .document-line-edit-heading > .btn,
  .document-line-edit-actions .btn,
  .document-revision-pdfs a {
    width: 100%;
    min-height: 44px;
    text-align: center;
  }

  .document-revision-pdfs {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr;
  }

  .document-revision-history-heading > span {
    align-self: flex-start;
  }
}

/* A table wrapper needs horizontal scrolling on mid-size desktops.  Keeping
   this menu in normal flow prevents that wrapper from clipping a popup below
   its row, while still giving the user one clear print control. */
.archive-print-menu[open] .archive-print-menu-popover {
  position: static;
  margin-top: 0.42rem;
}

.document-actions--mobile,
.document-mobile-action-bar {
  display: none;
}

.document-header-form,
.document-record-card {
  margin-top: 1.25rem;
}

.document-form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
}

.document-form-section,
.document-record-card,
.document-items-section,
.document-financial-summary {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.document-form-section {
  padding: clamp(1rem, 2.2vw, 1.35rem);
}

.document-section-heading {
  display: flex;
  min-width: 0;
  gap: 0.7rem;
  align-items: flex-start;
}

.document-section-number {
  display: inline-grid;
  width: 29px;
  height: 29px;
  flex: 0 0 29px;
  place-items: center;
  border-radius: 9px;
  color: var(--brand-700);
  background: var(--brand-050);
  font-size: 0.8rem;
  font-weight: 700;
}

.document-section-heading h2,
.document-record-heading h2 {
  margin: 0;
  color: var(--ink-950);
  font-size: 1rem;
  font-weight: 700;
}

.document-section-heading p,
.document-record-heading p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.65;
}

.document-form-section > .row {
  margin-top: 1rem;
}

.document-check-field {
  display: inline-flex;
  min-height: 44px;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: #435166;
  background: #fafbfd;
  font-size: 0.82rem;
}

.document-check-field .form-check-input {
  float: none;
  margin: 0;
}

.document-form-save {
  display: flex;
  gap: 0.9rem;
  margin-top: 1rem;
  padding: 0.85rem 0.95rem;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.74);
  font-size: 0.78rem;
}

.document-record-card {
  padding: clamp(1rem, 2.2vw, 1.4rem);
}

.document-record-banner {
  display: flex;
  gap: 0.7rem;
  padding: 0.82rem 0.95rem;
  align-items: center;
  border: 1px solid #b9e2dc;
  border-radius: var(--radius-sm);
  color: #176d63;
  background: var(--success-050);
}

.document-record-banner--void {
  border-color: #f0c1c6;
  color: #a33742;
  background: var(--danger-050);
}

.document-record-banner-mark {
  display: inline-grid;
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--success);
  font-size: 0.78rem;
  font-weight: 700;
}

.document-record-banner--void .document-record-banner-mark {
  background: var(--danger);
}

.document-record-banner strong,
.document-record-banner p {
  display: block;
}

.document-record-banner p {
  margin: 0.08rem 0 0;
  font-size: 0.75rem;
}

.document-record-heading {
  display: flex;
  gap: 1rem;
  margin: 1.25rem 0 1rem;
  align-items: flex-start;
  justify-content: space-between;
}

.document-subject-chip,
.document-line-count,
.document-server-computed {
  display: inline-flex;
  padding: 0.25rem 0.52rem;
  align-items: center;
  border-radius: 999px;
  color: #496175;
  background: #f0f4f8;
  font-size: 0.71rem;
  font-weight: 700;
  white-space: nowrap;
}

.document-facts-grid {
  display: grid;
  margin: 0;
  border-block: 1px solid var(--border);
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.document-facts-grid > div {
  min-width: 0;
  padding: 0.8rem;
  border-inline-start: 1px solid var(--border);
}

.document-facts-grid > div:first-child {
  border-inline-start: 0;
}

.document-facts-grid .document-fact-wide {
  grid-column: span 2;
}

.document-facts-grid dt {
  margin-bottom: 0.22rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
}

.document-facts-grid dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink-950);
  font-size: 0.82rem;
  font-weight: 700;
}

.document-outcome-form {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.9rem 0;
  align-items: center;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 220px) auto;
}

.document-outcome-form .form-label,
.document-outcome-form .field-hint {
  display: block;
  margin: 0;
}

.document-outcome-feedback {
  margin: 0 0 0.9rem;
  padding: 0.58rem 0.75rem;
  border: 1px solid #b8e3dc;
  border-radius: var(--radius-sm);
  color: #0b6f64;
  background: var(--success-050);
  font-size: 0.8rem;
  font-weight: 700;
}

.document-outcome-feedback--error {
  border-color: #f1c4c1;
  background: #fff4f3;
  color: #a2342d;
}

.document-edit-guidance,
.document-issued-amounts {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafbfd;
}

.document-edit-guidance {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  justify-content: space-between;
}

.document-edit-guidance strong,
.document-edit-guidance span,
.document-issued-amounts-heading strong,
.document-issued-amounts-heading span {
  display: block;
}

.document-edit-guidance strong,
.document-issued-amounts-heading strong {
  color: var(--ink-950);
  font-size: 0.84rem;
}

.document-edit-guidance span,
.document-issued-amounts-heading span {
  margin-top: 0.13rem;
  color: var(--muted);
  font-size: 0.74rem;
}

.document-issued-amounts .row {
  margin-top: 0.9rem;
}

.document-editor-shell {
  display: grid;
  min-width: 0;
  gap: 1rem;
  margin-top: 1rem;
  align-items: start;
  grid-template-columns: minmax(0, 1fr) minmax(285px, 338px);
}

.document-items-section {
  padding: clamp(1rem, 2.2vw, 1.35rem);
}

.document-items-heading {
  display: flex;
  gap: 0.8rem;
  margin-bottom: 1rem;
  align-items: center;
  justify-content: space-between;
}

.document-lines-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.document-lines {
  width: 100%;
}

.document-lines > :not(caption) > * > * {
  padding: 0.78rem 0.7rem;
  border-color: var(--border);
}

.document-lines thead th {
  color: #536174;
  background: #f8fafc;
  font-size: 0.74rem;
}

.document-lines tbody td:nth-child(4),
.document-lines tbody td:nth-child(5) {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.document-lines tbody td:nth-child(5) {
  color: var(--ink-950);
  font-weight: 700;
}

.document-lines-empty {
  padding: 2.1rem 1rem !important;
  text-align: center;
  color: var(--muted);
  background: #fbfcfe;
}

.document-lines-empty strong,
.document-lines-empty span {
  display: block;
}

.document-lines-empty strong {
  color: #546275;
  font-size: 0.84rem;
}

.document-lines-empty span {
  margin-top: 0.18rem;
  font-size: 0.75rem;
}

.document-line-actions .btn-group {
  direction: ltr;
}

.document-line-actions .btn {
  min-width: 32px;
}

.document-add-line {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid #d8e3ff;
  border-radius: var(--radius-sm);
  background: #f8faff;
}

.document-add-line-heading,
.document-add-line-footer {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
}

.document-add-line-heading {
  margin-bottom: 0.9rem;
}

.document-add-line-heading strong {
  color: var(--ink-950);
  font-size: 0.88rem;
}

.document-add-line-heading span,
.document-add-line-footer span {
  color: var(--muted);
  font-size: 0.74rem;
}

.document-add-line-footer {
  margin-top: 0.9rem;
}

.document-financial-rail {
  position: sticky;
  top: 1.25rem;
}

.document-financial-summary {
  overflow: hidden;
}

.document-financial-heading {
  display: flex;
  gap: 0.75rem;
  padding: 1rem;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.document-financial-heading span,
.document-financial-heading strong {
  display: block;
}

.document-financial-heading > div > span {
  color: var(--muted);
  font-size: 0.72rem;
}

.document-financial-heading strong {
  margin-top: 0.1rem;
  color: var(--ink-950);
  font-size: 0.95rem;
}

.document-server-computed {
  color: #087366;
  background: var(--success-050);
}

.document-financial-summary .totals-table > tbody > tr > * {
  padding: 0.72rem 1rem;
  border-color: var(--border);
}

.document-financial-summary .totals-table th {
  color: #59687a;
  font-size: 0.8rem;
}

.document-financial-summary .totals-table td {
  color: var(--ink-950);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.document-financial-summary .totals-table .totals-grand-total > * {
  padding-block: 0.95rem;
  border-top: 1px solid #b6c7f7;
  color: #183987;
  background: var(--brand-050);
}

.document-financial-summary .totals-table .totals-grand-total th,
.document-financial-summary .totals-table .totals-grand-total td {
  font-size: 0.9rem;
}

.document-warnings {
  margin-bottom: 0.8rem;
  padding: 0.85rem 0.9rem;
  font-size: 0.78rem;
}

.document-issue-readiness {
  margin-top: 0.8rem;
  padding: 0.85rem 0.9rem;
  border: 1px solid #b9e2dc;
  border-radius: var(--radius-sm);
  color: #176d63;
  background: var(--success-050);
}

.document-issue-readiness.is-incomplete {
  border-color: #f0d59f;
  color: #78520f;
  background: var(--warning-050);
}

.document-issue-readiness strong,
.document-issue-readiness span {
  display: block;
}

.document-issue-readiness strong {
  font-size: 0.79rem;
}

.document-issue-readiness span {
  margin-top: 0.12rem;
  font-size: 0.73rem;
}

/* Archive workspace ------------------------------------------------------ */

.archive-workspace {
  min-width: 0;
  padding-bottom: 2.5rem;
}

.archive-command-card {
  display: flex;
  gap: 1rem;
  padding: clamp(1.15rem, 2vw, 1.7rem);
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.archive-kicker {
  color: var(--brand-600);
  font-size: 0.74rem;
  font-weight: 700;
}

.archive-command-card h1 {
  margin: 0.18rem 0 0;
  color: var(--ink-950);
  font-size: clamp(1.4rem, 2.4vw, 1.95rem);
  font-weight: 700;
}

.archive-command-card p {
  margin: 0.18rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.archive-create-button {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  white-space: nowrap;
}

.archive-create-button img {
  filter: brightness(0) invert(1);
}

.archive-alert,
.archive-expired-alert {
  margin: 1rem 0 0;
  padding: 0.8rem 0.95rem;
}

.archive-expired-alert strong,
.archive-expired-alert span {
  display: block;
}

.archive-expired-alert span {
  margin-top: 0.1rem;
  font-size: 0.77rem;
}

.archive-filters {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.archive-filters summary {
  display: flex;
  min-height: 50px;
  gap: 0.5rem;
  padding: 0.7rem 0.85rem;
  align-items: center;
  cursor: pointer;
  list-style: none;
  color: var(--ink-950);
  font-size: 0.84rem;
  font-weight: 700;
}

.archive-filters summary::-webkit-details-marker {
  display: none;
}

.archive-filters summary img {
  margin-inline-start: auto;
  transition: transform 160ms ease;
}

.archive-filters[open] summary img {
  transform: rotate(180deg);
}

.archive-filter-state {
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  color: var(--brand-700);
  background: var(--brand-050);
  font-size: 0.68rem;
}

.archive-filter-form {
  padding: 1.1rem;
  border-top: 1px solid var(--border);
}

.archive-filter-heading,
.archive-results-heading {
  display: flex;
  gap: 0.85rem;
  margin-bottom: 0.9rem;
  align-items: center;
  justify-content: space-between;
}

.archive-filter-heading strong,
.archive-filter-heading span,
.archive-results-heading strong,
.archive-results-heading span {
  display: block;
}

.archive-filter-heading strong,
.archive-results-heading strong {
  color: var(--ink-950);
  font-size: 0.9rem;
}

.archive-filter-heading span,
.archive-results-heading span {
  margin-top: 0.08rem;
  color: var(--muted);
  font-size: 0.74rem;
}

.archive-clear-link {
  color: #556579;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.archive-filter-submit {
  width: 100%;
}

.archive-empty-state {
  padding: clamp(2rem, 8vw, 4rem) 1.25rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.7);
}

.archive-results {
  margin-top: 1rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.archive-results-heading {
  margin: 0;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.archive-results-heading > span {
  padding: 0.25rem 0.52rem;
  border-radius: 999px;
  color: #496175;
  background: #f0f4f8;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.archive-table-wrap {
  overflow-x: auto;
}

.archive-table {
  min-width: 970px;
}

.archive-table > :not(caption) > * > * {
  padding: 0.82rem 0.75rem;
  border-color: var(--border);
}

.archive-table thead th {
  color: #536174;
  background: #f8fafc;
  font-size: 0.74rem;
}

.archive-table tbody td {
  font-size: 0.82rem;
}

.archive-table tbody td:nth-child(1) a {
  color: var(--brand-600);
  font-weight: 700;
  text-decoration: none;
}

.archive-table tbody td:nth-child(4),
.archive-table tbody td:nth-child(5),
.archive-table tbody td:nth-child(6) {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.archive-row > td:first-child {
  border-inline-start: 4px solid var(--brand-600);
}

.archive-row--issued > td:first-child {
  border-inline-start-color: var(--success);
}

.archive-row--void > td:first-child {
  border-inline-start-color: var(--danger);
}

.archive-row.table-warning > td:first-child {
  border-inline-start-color: var(--warning);
}

.archive-row-action .btn {
  min-width: 58px;
}

.archive-row-actions {
  display: flex;
  gap: 0.42rem;
  align-items: center;
  justify-content: flex-end;
}

.archive-open-document {
  min-width: 112px !important;
  white-space: nowrap;
}

.archive-row-actions .archive-print-menu > summary {
  min-height: 40px;
  justify-content: center;
  white-space: nowrap;
}

.archive-pagination {
  display: flex;
  gap: 0.8rem;
  padding: 0.95rem 1.15rem;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
}

.archive-pagination strong,
.archive-pagination span {
  display: block;
}

.archive-pagination strong {
  color: var(--ink-950);
  font-size: 0.79rem;
}

.archive-pagination span {
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.72rem;
}

@media (min-width: 768px) {
  .archive-filters > summary {
    display: none;
  }

  .archive-filters > .archive-filter-form {
    display: block !important;
    border-top: 0;
  }
}

@media (max-width: 991.98px) {
  :root {
    --mobile-header-height: 64px;
    --mobile-nav-height: 72px;
  }

  .app-sidebar {
    display: none;
  }

  .mobile-app-header {
    position: fixed;
    inset-block-start: 0;
    inset-inline: 0;
    z-index: 1040;
    display: flex;
    min-height: var(--mobile-header-height);
    padding: 0.65rem 0.9rem;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 6px 18px rgba(18, 32, 51, 0.06);
    backdrop-filter: blur(12px);
  }

  .mobile-brand {
    display: flex;
    gap: 0.55rem;
    align-items: center;
    color: var(--ink-950);
    text-decoration: none;
  }

  .mobile-brand .brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-color: rgba(53, 99, 233, 0.18);
    background: var(--brand-050);
  }

  .mobile-brand .brand-mark img {
    filter: brightness(0) saturate(100%) invert(34%) sepia(95%) saturate(1188%) hue-rotate(208deg) brightness(92%);
  }

  .mobile-brand .brand-mark--logo {
    width: 46px;
    height: 46px;
    flex-basis: 46px;
    background: #fff;
    border-color: rgba(18, 32, 51, 0.12);
    box-shadow: 0 3px 9px rgba(18, 32, 51, 0.1);
  }

  .mobile-brand .brand-mark--logo .brand-logo-image {
    width: 100%;
    height: 100%;
    filter: contrast(1.04) saturate(0.92);
  }

  .mobile-header-actions {
    display: flex;
    gap: 0.55rem;
    align-items: center;
  }

  .mobile-header-actions form {
    margin: 0;
  }

  .mobile-create-button {
    display: flex;
    min-height: 42px;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    align-items: center;
    border: 0;
    border-radius: 9px;
    color: #fff;
    background: var(--brand-600);
    font-size: 0.78rem;
    font-weight: 700;
  }

  .mobile-user-menu {
    position: relative;
  }

  .mobile-user-menu summary {
    display: flex;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    list-style: none;
    background: #fff;
  }

  .mobile-user-menu summary img {
    filter: brightness(0) saturate(100%) invert(15%) sepia(18%) saturate(1224%) hue-rotate(173deg) brightness(95%);
  }

  .mobile-user-popover {
    position: absolute;
    inset-block-start: calc(100% + 0.6rem);
    inset-inline-end: 0;
    width: 210px;
    padding: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    box-shadow: var(--shadow-md);
  }

  .mobile-user-popover > strong,
  .mobile-user-popover > small {
    display: block;
  }

  .mobile-user-popover > small {
    margin-bottom: 0.7rem;
    color: var(--muted);
    font-size: 0.72rem;
  }

  .mobile-user-popover button {
    display: flex;
    width: 100%;
    min-height: 40px;
    gap: 0.45rem;
    padding: 0.45rem 0.65rem;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: #49576a;
    background: #f8fafc;
  }

  .mobile-user-popover button img {
    filter: brightness(0) saturate(100%) invert(36%) sepia(10%) saturate(684%) hue-rotate(178deg) brightness(91%);
  }

  .app-main {
    margin-inline-start: 0;
    padding-top: var(--mobile-header-height);
  }

  .app-content {
    padding: 1.15rem 1rem calc(var(--mobile-nav-height) + 1.5rem);
  }

  .mobile-bottom-nav {
    position: fixed;
    inset-block-end: 0;
    inset-inline: 0;
    z-index: 1040;
    display: flex;
    min-height: var(--mobile-nav-height);
    padding: 0.45rem max(0.35rem, env(safe-area-inset-left)) max(0.4rem, env(safe-area-inset-bottom));
    align-items: stretch;
    justify-content: space-around;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -8px 22px rgba(18, 32, 51, 0.07);
    backdrop-filter: blur(12px);
  }

  .mobile-nav-link {
    display: flex;
    min-width: 64px;
    min-height: 54px;
    gap: 0.2rem;
    padding: 0.35rem 0.45rem;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    color: #7a8798;
    flex-direction: column;
    font-size: 0.68rem;
    text-decoration: none;
  }

  .mobile-nav-link img {
    filter: brightness(0) saturate(100%) invert(55%) sepia(11%) saturate(517%) hue-rotate(176deg) brightness(94%);
  }

  .mobile-nav-link.is-active {
    color: var(--brand-600);
    background: var(--brand-050);
    font-weight: 700;
  }

  .mobile-nav-link.is-active img {
    filter: brightness(0) saturate(100%) invert(34%) sepia(95%) saturate(1188%) hue-rotate(208deg) brightness(92%);
  }

  .setup-shell {
    grid-template-columns: 1fr;
  }

  .setup-intro {
    position: static;
  }
}

@media (max-width: 767.98px) {
  body {
    font-size: 0.91rem;
  }

  .auth-shell {
    min-height: 100vh;
    padding: 0;
    grid-template-columns: 1fr;
  }

  .auth-aside {
    min-height: 168px;
    padding: 1.35rem 1.25rem 1.6rem;
    border-radius: 0 0 24px 24px;
  }

  .auth-trust {
    display: none;
  }

  .auth-panel {
    margin-top: -1rem;
    padding: 2rem 1.2rem 2.5rem;
    border: 0;
    border-radius: 24px 24px 0 0;
    box-shadow: none;
  }

  .auth-title {
    font-size: 1.4rem;
  }

  .setup-shell {
    padding: 0;
    gap: 0;
  }

  .setup-intro {
    padding: 1.35rem 1rem;
    border-radius: 0 0 24px 24px;
  }

  .setup-intro .auth-brand {
    margin-bottom: 1.2rem;
  }

  .setup-steps {
    display: none;
  }

  .setup-form-panel {
    margin-top: -0.8rem;
    padding: 1.4rem 0.85rem 2rem;
    border-inline: 0;
    border-bottom: 0;
    border-radius: 22px 22px 0 0;
    box-shadow: none;
  }

  .setup-form-panel fieldset {
    padding-inline: 0.85rem;
  }

  .setup-actions .btn {
    width: 100%;
  }

  .error-shell {
    padding: 1rem;
  }

  .error-card {
    padding: 2rem 1.25rem;
  }

  .card-body {
    padding: 1.05rem;
  }
}

@media (max-width: 420px) {
  .mobile-create-button span {
    display: none;
  }

  .mobile-create-button {
    width: 42px;
    padding: 0;
    justify-content: center;
  }

  .mobile-nav-link {
    min-width: 0;
    padding-inline: 0.25rem;
  }
}

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

  .document-facts-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 991.98px) {
  .document-command-card {
    gap: 1rem;
  }

  .document-editor-shell {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
  }

  .document-facts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .document-facts-grid > div:nth-child(odd) {
    border-inline-start: 0;
  }

  .document-facts-grid > div:nth-child(n + 3) {
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 767.98px) {
  .document-workspace {
    padding-bottom: calc(var(--mobile-nav-height) + 5.5rem);
  }

  .document-command-card {
    display: block;
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .document-actions--desktop {
    display: none;
  }

  .document-mobile-action-bar {
    position: fixed;
    inset-inline: 0;
    inset-block-end: var(--mobile-nav-height);
    z-index: 1038;
    display: block;
    padding: 0.45rem max(0.75rem, env(safe-area-inset-left));
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -6px 18px rgba(18, 32, 51, 0.08);
    backdrop-filter: blur(12px);
  }

  .document-actions--mobile {
    display: flex;
    width: 100%;
    gap: 0.4rem;
    justify-content: stretch;
    flex-wrap: nowrap;
  }

  .document-actions--mobile > a,
  .document-actions--mobile > form,
  .document-actions--mobile > .document-print-actions,
  .document-actions--mobile > details {
    min-width: 0;
    flex: 1 1 0;
  }

  .document-actions--mobile .btn {
    width: 100%;
    min-height: 42px;
    padding-inline: 0.55rem;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .document-actions--mobile .document-print-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .document-back-link {
    margin-bottom: 0.65rem;
  }

  .document-title-row h1 {
    font-size: 1.35rem;
  }

  .document-flow {
    display: grid;
    gap: 0.35rem;
    max-width: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .document-flow li {
    gap: 0.28rem;
    padding: 0.42rem;
    justify-content: center;
    font-size: 0.65rem;
    white-space: normal;
  }

  .document-flow li span {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
  }

  .document-form-section,
  .document-record-card,
  .document-items-section {
    padding: 1rem;
  }

  .document-form-save,
  .document-edit-guidance,
  .document-add-line-heading,
  .document-add-line-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .document-form-save .btn,
  .document-edit-guidance .btn,
  .document-add-line-footer .btn {
    width: 100%;
  }

  .document-record-heading {
    flex-direction: column;
  }

  .document-facts-grid {
    grid-template-columns: 1fr;
  }

  .document-facts-grid > div,
  .document-facts-grid > div:nth-child(odd) {
    border-inline-start: 0;
    border-top: 1px solid var(--border);
  }

  .document-facts-grid > div:first-child {
    border-top: 0;
  }

  .document-facts-grid .document-fact-wide {
    grid-column: auto;
  }

  .document-outcome-form {
    grid-template-columns: 1fr;
  }

  .document-outcome-form .btn {
    width: 100%;
  }

  .document-editor-shell {
    display: flex;
    flex-direction: column;
  }

  .document-items-section,
  .document-financial-rail {
    width: 100%;
  }

  .document-financial-rail {
    position: static;
  }

  .document-items-heading {
    align-items: flex-start;
  }

  .document-lines-card {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  .document-lines,
  .document-lines tbody,
  .document-lines tr,
  .document-lines td {
    display: block;
    width: 100%;
  }

  .document-lines thead {
    display: none;
  }

  .document-lines tbody {
    display: grid;
    gap: 0.7rem;
  }

  .document-lines tbody tr {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
  }

  .document-lines tbody td {
    display: flex;
    min-height: 39px;
    gap: 1rem;
    padding: 0.62rem 0.72rem !important;
    align-items: baseline;
    justify-content: space-between;
    border: 0;
    border-bottom: 1px solid #edf1f5;
    color: var(--ink-950);
    text-align: start !important;
    white-space: normal !important;
  }

  .document-lines tbody td:last-child {
    border-bottom: 0;
  }

  .document-lines tbody td::before {
    min-width: 5.75rem;
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 700;
  }

  .document-lines tbody td:nth-child(2) {
    align-items: flex-start;
  }

  .document-lines tbody td:nth-child(2)::before {
    flex: 0 0 5.75rem;
  }

  .document-lines tbody td:nth-child(5) {
    color: var(--brand-700);
  }

  .document-lines .document-line-actions {
    align-items: center;
  }

  .document-lines .document-line-actions .btn-group {
    display: flex;
  }

  .document-lines .document-line-actions .btn {
    min-width: 40px;
    min-height: 40px;
  }

  .document-lines .document-lines-empty {
    display: block;
    min-height: 0;
    padding: 1.6rem 1rem !important;
    border: 0;
    text-align: center !important;
  }

  .document-lines .document-lines-empty::before {
    display: none;
  }

  .document-add-line {
    padding: 0.9rem;
  }

  .document-financial-heading {
    padding: 0.9rem;
  }

  .document-warnings {
    margin-bottom: 0.7rem;
  }
}

@media (max-width: 767.98px) {
  .archive-workspace {
    padding-bottom: calc(var(--mobile-nav-height) + 1.75rem);
  }

  .archive-command-card {
    padding: 1rem;
    border-radius: var(--radius-md);
    align-items: flex-start;
  }

  .archive-command-card h1 {
    font-size: 1.35rem;
  }

  .archive-create-button {
    width: 44px;
    min-height: 44px;
    padding: 0;
    justify-content: center;
    font-size: 0;
  }

  .archive-create-button img {
    width: 17px;
    height: 17px;
  }

  .archive-filters {
    border-radius: var(--radius-sm);
  }

  .archive-filter-form {
    padding: 0.9rem;
  }

  .archive-filter-heading {
    align-items: flex-start;
  }

  .archive-filter-heading > div {
    min-width: 0;
  }

  .archive-filter-submit {
    min-height: 44px;
  }

  .archive-results {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .archive-results-heading {
    padding: 0.9rem 0.15rem;
    border-bottom: 0;
  }

  .archive-table-wrap {
    overflow: visible;
  }

  .archive-table,
  .archive-table tbody,
  .archive-table tr,
  .archive-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .archive-table thead {
    display: none;
  }

  .archive-table tbody {
    display: grid;
    gap: 0.75rem;
  }

  .archive-table tbody tr {
    overflow: hidden;
    border: 1px solid var(--border);
    border-inline-start: 4px solid var(--brand-600);
    border-radius: var(--radius-sm);
    background: #fff;
    box-shadow: var(--shadow-sm);
  }

  .archive-table tbody tr.archive-row--issued {
    border-inline-start-color: var(--success);
  }

  .archive-table tbody tr.archive-row--void {
    border-inline-start-color: var(--danger);
  }

  .archive-table tbody tr.table-warning {
    border-color: #f0d59f;
    border-inline-start-color: var(--warning);
  }

  .archive-table tbody td {
    display: flex;
    min-height: 39px;
    gap: 0.9rem;
    padding: 0.58rem 0.7rem !important;
    align-items: baseline;
    justify-content: space-between;
    border: 0;
    border-bottom: 1px solid #edf1f5;
    color: var(--ink-950);
    text-align: start !important;
    white-space: normal !important;
  }

  .archive-table tbody td::before {
    min-width: 5.45rem;
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.71rem;
    font-weight: 700;
  }

  .archive-table tbody td:nth-child(2),
  .archive-table tbody td:nth-child(3) {
    align-items: flex-start;
  }

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

  .archive-table tbody td:first-child {
    padding-top: 0.75rem !important;
    border-inline-start: 0;
  }

  .archive-table tbody td:nth-child(6) {
    color: var(--brand-700);
    font-weight: 700;
  }

  .archive-row-action {
    align-items: stretch !important;
    flex-direction: column;
  }

  .archive-row-action::before {
    min-width: 0 !important;
  }

  .archive-row-actions {
    display: grid;
    width: 100%;
    gap: 0.45rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .archive-row-action .btn,
  .archive-row-actions .archive-print-menu > summary {
    width: 100%;
    min-width: 0 !important;
    min-height: 44px;
    padding-inline: 0.55rem;
    justify-content: center;
    font-size: 0.72rem;
  }

  .archive-row-actions .archive-print-menu {
    width: 100%;
    min-width: 0;
  }

  .archive-row-actions .archive-print-menu[open] {
    grid-column: 1 / -1;
  }

  .archive-row-actions .archive-print-menu-popover {
    width: 100%;
    min-width: 0;
  }

  .archive-pagination {
    padding: 0.9rem 0.15rem 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Pre-invoice composer --------------------------------------------------- */

.proforma-composer {
  --composer-blue: #3563e9;
  --composer-soft-blue: #f4f7ff;
  --composer-line: #dce5f2;
}

.proforma-composer-feedback {
  margin: 1rem 0 0;
}

.proforma-composer .document-header-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.25rem;
}

.proforma-composer .document-form-section {
  padding: clamp(1.1rem, 2.4vw, 1.5rem);
}

.proforma-buyer-section {
  border-color: #d9e4f2;
}

.proforma-buyer-query {
  position: relative;
  margin-top: 1.1rem;
}

.proforma-search-control {
  position: relative;
}

.proforma-search-control > img {
  position: absolute;
  inset-inline-start: 0.95rem;
  inset-block-start: 50%;
  z-index: 1;
  width: 19px;
  height: 19px;
  opacity: 0.72;
  pointer-events: none;
  transform: translateY(-50%);
}

.proforma-search-control > .form-control {
  min-height: 48px;
  padding-inline-start: 3.1rem;
  border-color: #cfdced;
  background: #fff;
  box-shadow: inset 0 1px 1px rgba(18, 32, 51, 0.02);
}

.proforma-search-control > .form-control:focus {
  border-color: var(--composer-blue);
  box-shadow: 0 0 0 0.2rem rgba(53, 99, 233, 0.13);
}

.proforma-buyer-suggestions,
.proforma-item-suggestions {
  position: relative;
  min-height: 0;
}

.proforma-search-loading {
  display: block;
  min-height: 1.25rem;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.74rem;
}

.proforma-search-loading.htmx-indicator {
  opacity: 0;
  transition: opacity 140ms ease;
}

.proforma-search-loading.htmx-request {
  opacity: 1;
}

.proforma-buyer-suggestions .suggest-list,
.proforma-item-suggestions .suggest-list,
.proforma-buyer-suggestions > .suggest-empty,
.proforma-item-suggestions > .suggest-empty {
  top: 0.4rem;
  max-height: min(24rem, 52vh);
  overflow: auto;
  border: 1px solid #d5e0ee;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(18, 32, 51, 0.16);
}

.proforma-item-suggestions > .suggest-error {
  border-color: #efc3c8;
  color: #9c2632;
  background: var(--danger-050);
  box-shadow: none;
}

/* A no-result message confirms that a free item is valid.  It must remain a
   quiet hint below the search, never a floating sheet over quantity, price or
   warranty controls.  Actual selectable catalogue results stay in the popup. */
.proforma-item-suggestions > .suggest-empty {
  position: static;
  min-height: 0;
  margin-top: 0.45rem;
  padding: 0.48rem 0.68rem;
  border: 1px dashed #c7d5e8;
  border-radius: 9px;
  color: #607188 !important;
  background: #f8faff;
  box-shadow: none;
  font-size: 0.72rem;
  line-height: 1.6;
}

.proforma-suggest-list {
  overflow: hidden;
}

.proforma-suggest-item {
  display: grid;
  min-height: 74px;
  gap: 0.8rem;
  padding: 0.8rem 0.9rem;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) minmax(9rem, auto) auto;
  text-align: start;
}

.proforma-suggest-item:hover,
.proforma-suggest-item.is-keyboard-active {
  z-index: 1;
  border-color: rgba(53, 99, 233, 0.3);
  color: inherit;
  background: var(--composer-soft-blue);
}

.proforma-suggest-item-copy,
.proforma-suggest-item-title,
.proforma-suggest-item-meta,
.proforma-suggest-item-price {
  min-width: 0;
}

.proforma-suggest-item-title,
.proforma-suggest-item-meta,
.proforma-suggest-item-price strong,
.proforma-suggest-item-price small {
  display: block;
}

.proforma-suggest-item-title {
  overflow: hidden;
  color: var(--ink-950);
  font-size: 0.88rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proforma-suggest-item-meta {
  display: flex;
  gap: 0.25rem 0.55rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.7rem;
}

.proforma-suggest-item-meta b {
  color: #627188;
  font-weight: 600;
}

.proforma-suggest-item-price {
  min-width: 8.5rem;
  color: var(--ink-950);
  font-variant-numeric: tabular-nums;
  text-align: end;
}

.proforma-suggest-item-price strong {
  font-size: 0.79rem;
}

.proforma-suggest-item-price small {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.67rem;
}

.proforma-suggest-action {
  display: inline-flex;
  min-width: 4.4rem;
  min-height: 32px;
  padding: 0.35rem 0.55rem;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(53, 99, 233, 0.38);
  border-radius: 8px;
  color: var(--composer-blue);
  font-size: 0.73rem;
  font-weight: 700;
}

.proforma-suggest-customer {
  display: flex;
  min-height: 54px;
  gap: 0.7rem;
  padding: 0.75rem 0.85rem;
  align-items: center;
  justify-content: space-between;
}

.proforma-suggest-customer:hover,
.proforma-suggest-customer.is-keyboard-active {
  z-index: 1;
  border-color: rgba(53, 99, 233, 0.3);
  color: inherit;
  background: var(--composer-soft-blue);
}

.suggest-empty {
  display: flex;
  gap: 0.75rem;
  min-height: 54px;
  padding: 0.7rem 0.8rem;
  align-items: center;
  justify-content: space-between;
  color: #5d6c80 !important;
  background: #fff;
}

.proforma-selected-item,
.document-add-line-heading > div {
  min-width: 0;
}

.proforma-buyer-section .form-label-note {
  color: var(--muted);
  font-size: 0.78em;
  font-weight: 400;
}

.proforma-buyer-status {
  display: flex;
  min-height: 1.65rem;
  margin-top: 0.5rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.76rem;
}

.proforma-buyer-status [hidden] {
  display: none !important;
}

.proforma-buyer-known {
  display: inline-flex;
  gap: 0.45rem;
  min-width: 0;
  align-items: center;
}

.proforma-buyer-known-pill {
  display: inline-flex;
  min-height: 28px;
  padding: 0.2rem 0.58rem;
  align-items: center;
  border: 1px solid rgba(21, 154, 140, 0.22);
  border-radius: 999px;
  color: #087b70;
  background: #e9f8f5;
  font-size: 0.69rem;
  font-weight: 700;
  white-space: nowrap;
}

.proforma-buyer-known-meta {
  overflow: hidden;
  color: #65758a;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proforma-buyer-unmatched {
  color: #68778a;
}

.proforma-buyer-guidance {
  color: #718095;
}

.proforma-buyer-feedback {
  margin: 0.72rem 0 0;
  border-radius: 10px;
  font-size: 0.77rem;
}

.proforma-save-buyer-choice {
  display: flex;
  gap: 0.68rem;
  min-height: 54px;
  margin-top: 0.72rem;
  padding: 0.72rem 0.82rem;
  align-items: center;
  border: 1px solid #dce7f7;
  border-radius: 11px;
  color: #425167;
  background: #f7faff;
  cursor: pointer;
}

.proforma-save-buyer-choice .form-check-input {
  float: none;
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
}

.proforma-save-buyer-choice strong,
.proforma-save-buyer-choice small {
  display: block;
}

.proforma-save-buyer-choice strong {
  color: var(--ink-950);
  font-size: 0.8rem;
}

.proforma-save-buyer-choice small {
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.71rem;
}

.proforma-buyer-details {
  margin-top: 0.82rem;
  overflow: hidden;
  border: 1px solid #dce5f1;
  border-radius: 12px;
  background: #fff;
}

.proforma-buyer-details > summary {
  display: flex;
  gap: 0.85rem;
  min-height: 64px;
  padding: 0.76rem 0.9rem;
  align-items: center;
  justify-content: space-between;
  color: #3d4c61;
  cursor: pointer;
  list-style: none;
}

.proforma-buyer-details > summary::-webkit-details-marker {
  display: none;
}

.proforma-buyer-details > summary > span,
.proforma-buyer-details > summary strong,
.proforma-buyer-details > summary small {
  display: block;
  min-width: 0;
}

.proforma-buyer-details > summary strong {
  color: var(--ink-950);
  font-size: 0.8rem;
}

.proforma-buyer-details > summary small {
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.71rem;
  font-weight: 400;
}

.proforma-buyer-details > summary img {
  flex: 0 0 auto;
  transition: transform 160ms ease;
}

.proforma-buyer-details[open] > summary {
  border-bottom: 1px solid #e3eaf4;
  background: #fbfcfe;
}

.proforma-buyer-details[open] > summary img {
  transform: rotate(180deg);
}

.proforma-buyer-details-content {
  padding: 0.95rem;
}

.proforma-buyer-details .form-control {
  min-height: 44px;
}

.proforma-options-section {
  padding: 0 !important;
  overflow: hidden;
}

.proforma-options-details > summary {
  display: flex;
  gap: 0.85rem;
  padding: 1rem 1.25rem;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-950);
  cursor: pointer;
  list-style: none;
}

.proforma-options-details > summary::-webkit-details-marker {
  display: none;
}

.proforma-options-details > summary strong,
.proforma-options-details > summary small {
  display: block;
}

.proforma-options-details > summary strong {
  font-size: 0.9rem;
}

.proforma-options-details > summary small {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 400;
}

.proforma-options-details > summary img {
  transition: transform 160ms ease;
}

.proforma-options-details[open] > summary {
  border-bottom: 1px solid var(--border);
  background: #fbfcfe;
}

.proforma-options-details[open] > summary img {
  transform: rotate(180deg);
}

.proforma-options-content {
  padding: 1.1rem 1.25rem 1.25rem;
}

.proforma-setting-toggles {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.proforma-setting-toggle-card {
  min-width: 0;
  padding: 0.78rem;
  border: 1px solid #e0e7f0;
  border-radius: 10px;
  background: #fbfcfe;
}

.proforma-toggle-fields {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.75rem;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
}

.proforma-toggle-fields--single {
  max-width: 10rem;
  grid-template-columns: 1fr;
}

.proforma-composer .document-editor-shell > .alert {
  grid-column: 1 / -1;
  margin: 0;
}

.proforma-composer .document-items-section {
  border-color: #d9e4f2;
}

.proforma-composer .document-add-line {
  margin-top: 1.15rem;
  padding: clamp(1rem, 2vw, 1.2rem);
  border-color: #d5e1f4;
  border-radius: 12px;
  background: #f8faff;
}

.document-add-line-heading {
  align-items: flex-start;
}

.document-add-line-heading strong {
  font-size: 0.93rem;
}

.document-add-line-heading span {
  display: block;
  margin-top: 0.16rem;
}

.proforma-custom-line-note {
  display: inline-flex !important;
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
  color: #627188 !important;
  background: #eef3f8;
  font-size: 0.68rem !important;
  font-weight: 700;
  white-space: nowrap;
}

.proforma-item-query {
  position: relative;
}

.proforma-selected-item {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #cbd9ff;
  border-radius: 9px;
  color: #314f9c;
  background: #eef3ff;
}

.proforma-selected-item span,
.proforma-selected-item strong {
  display: block;
}

.proforma-selected-item span {
  color: #5670aa;
  font-size: 0.67rem;
  font-weight: 700;
}

.proforma-selected-item strong {
  margin-top: 0.08rem;
  color: #1e3d8f;
  font-size: 0.82rem;
}

.proforma-free-item-state {
  display: flex;
  gap: 0.62rem;
  margin-top: 0.72rem;
  padding: 0.66rem 0.75rem;
  align-items: flex-start;
  border: 1px dashed #b9cae6;
  border-radius: 9px;
  color: #4c607b;
  background: #f5f8fd;
}

.proforma-free-item-state strong,
.proforma-free-item-state span {
  display: block;
}

.proforma-free-item-state strong {
  color: #29405f;
  font-size: 0.76rem;
}

.proforma-free-item-state span:not(.proforma-free-item-dot) {
  margin-top: 0.14rem;
  color: #687992;
  font-size: 0.69rem;
  line-height: 1.6;
}

.proforma-free-item-dot {
  flex: 0 0 auto;
  width: 0.56rem;
  height: 0.56rem;
  margin-top: 0.24rem;
  border-radius: 50%;
  background: var(--composer-blue);
  box-shadow: 0 0 0 4px rgba(53, 99, 233, 0.1);
}

.proforma-line-fields {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.9rem;
  grid-template-columns: minmax(5.5rem, 0.62fr) minmax(6rem, 0.75fr) minmax(10rem, 1.25fr);
}

.proforma-price-field .form-control {
  font-variant-numeric: tabular-nums;
}

.proforma-price-field .field-hint {
  display: block;
  margin-top: 0.26rem;
  color: #718198;
  font-size: 0.67rem;
}

.proforma-warranty-picker {
  margin-top: 0.9rem;
  padding: 0.88rem;
  border: 1px solid #dbe5f2;
  border-radius: 10px;
  background: #fff;
}

.proforma-warranty-heading {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
}

.proforma-warranty-heading .form-label,
.proforma-warranty-heading span {
  display: block;
}

.proforma-warranty-heading .form-label {
  margin: 0;
}

.proforma-warranty-heading div > span {
  margin-top: 0.14rem;
  color: #728198;
  font-size: 0.69rem;
}

.proforma-warranty-memory {
  flex: 0 0 auto;
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
  color: #4266af !important;
  background: #edf3ff;
  font-size: 0.66rem !important;
  font-weight: 700;
  white-space: nowrap;
}

.proforma-warranty-choices {
  display: flex;
  gap: 0.48rem;
  margin-top: 0.72rem;
  flex-wrap: wrap;
}

.proforma-warranty-choice {
  min-height: 42px;
  padding: 0.42rem 0.76rem;
  border: 1px solid #d5dfed;
  border-radius: 8px;
  color: #53647d;
  background: #fff;
  font-size: 0.74rem;
  font-weight: 700;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

.proforma-warranty-choice:hover,
.proforma-warranty-choice:focus-visible {
  border-color: #7da0ef;
  color: #284f9e;
  background: #f6f9ff;
  outline: none;
}

.proforma-warranty-choice.is-active {
  border-color: #4574ea;
  color: #fff;
  background: #3563e9;
  box-shadow: 0 4px 10px rgba(53, 99, 233, 0.16);
}

.proforma-warranty-selected {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.65rem;
  padding: 0.58rem 0.68rem;
  align-items: baseline;
  border: 1px solid #cbd9ff;
  border-radius: 8px;
  color: #3b568d;
  background: #f1f5ff;
}

.proforma-warranty-selected span {
  flex: 0 0 auto;
  color: #6079a8;
  font-size: 0.67rem;
  font-weight: 700;
}

.proforma-warranty-selected strong {
  min-width: 0;
  overflow: hidden;
  color: #24498f;
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proforma-warranty-custom {
  margin-top: 0.65rem;
}

.proforma-warranty-custom .form-control {
  min-height: 44px;
}

.proforma-warranty-library {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.75rem;
  padding-top: 0.72rem;
  border-top: 1px dashed #dce5f1;
}

.proforma-warranty-recent > span {
  display: block;
  margin-bottom: 0.4rem;
  color: #718198;
  font-size: 0.68rem;
  font-weight: 700;
}

.proforma-warranty-recent > div {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.proforma-warranty-recent button {
  min-height: 34px;
  max-width: 100%;
  padding: 0.25rem 0.55rem;
  overflow: hidden;
  border: 1px solid #dbe4f1;
  border-radius: 999px;
  color: #546783;
  background: #f8faff;
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proforma-warranty-recent button:hover,
.proforma-warranty-recent button:focus-visible {
  border-color: #8eadef;
  color: #264f9e;
  background: #eff4ff;
  outline: none;
}

.proforma-warranty-search > summary {
  min-height: 36px;
  cursor: pointer;
  color: #4267b2;
  font-size: 0.72rem;
  font-weight: 700;
}

.proforma-warranty-search-body {
  margin-top: 0.55rem;
}

.proforma-warranty-search-body .form-control {
  min-height: 42px;
}

.proforma-warranty-suggestions {
  position: relative;
}

.proforma-warranty-suggestions .suggest-list,
.proforma-warranty-suggestions > .suggest-empty {
  position: static;
  max-height: min(15rem, 38vh);
  margin-top: 0.5rem;
  overflow: auto;
  border: 1px solid #d9e3f0;
  border-radius: 8px;
  box-shadow: none;
}

.proforma-warranty-suggest-list .suggest-warranty {
  min-height: 44px;
  text-align: start;
}

.proforma-warranty-feedback {
  margin: 0.7rem 0 0;
  color: #718198;
  font-size: 0.69rem;
  line-height: 1.6;
}

.proforma-line-notes-field {
  margin-top: 0.85rem;
}

.proforma-line-notes-field .form-label {
  margin-bottom: 0.35rem;
}

.proforma-line-notes-field .form-control {
  min-height: 44px;
}

.proforma-composer .document-add-line-footer {
  margin-top: 1rem;
}

.proforma-composer .document-add-line-footer .btn {
  min-height: 42px;
  padding-inline: 1rem;
}

.proforma-composer .document-issue-readiness {
  line-height: 1.65;
}

.proforma-composer .document-actions--desktop {
  align-self: flex-start;
}

@media (min-width: 1100px) {
  .proforma-composer .document-command-card {
    gap: 1.1rem;
    padding: 0.95rem 1.2rem;
    align-items: center;
  }

  .proforma-composer .document-command-copy {
    display: grid;
    gap: 0 0.9rem;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .proforma-composer .document-back-link {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 0.22rem;
  }

  .proforma-composer .document-title-row {
    grid-column: 1;
    grid-row: 2;
  }

  .proforma-composer .document-flow {
    max-width: 320px;
    margin: 0;
    align-self: center;
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .proforma-composer .document-flow li {
    padding: 0.42rem 0.48rem;
  }

  .proforma-composer .document-title-row h1 {
    margin-top: 0.08rem;
    font-size: 1.55rem;
  }

  .proforma-composer .document-subtitle {
    margin-top: 0.18rem;
  }

  .proforma-composer .document-actions--desktop {
    flex-wrap: nowrap;
  }

  .proforma-composer .document-actions--desktop .btn {
    min-height: 40px;
    white-space: nowrap;
  }

  /* The draft header has a two-column stepper. Final and void records do
     not: keeping that empty column made a numbered pre-invoice title wrap
     into three lines and left an awkward blank command area. */
  .proforma-composer.document-workspace--issued .document-command-copy,
  .proforma-composer.document-workspace--void .document-command-copy {
    grid-template-columns: minmax(0, 1fr);
  }

  .proforma-composer.document-workspace--issued .document-back-link,
  .proforma-composer.document-workspace--issued .document-title-row,
  .proforma-composer.document-workspace--issued .document-finality-note,
  .proforma-composer.document-workspace--issued .document-version-link,
  .proforma-composer.document-workspace--void .document-back-link,
  .proforma-composer.document-workspace--void .document-title-row,
  .proforma-composer.document-workspace--void .document-finality-note,
  .proforma-composer.document-workspace--void .document-version-link {
    grid-column: 1;
  }

  .proforma-composer.document-workspace--issued .document-finality-note,
  .proforma-composer.document-workspace--void .document-finality-note {
    margin-top: 0.55rem;
  }

  .proforma-composer .document-form-section {
    padding: 1rem 1.2rem;
  }

  .proforma-buyer-query {
    margin-top: 0.72rem;
  }

  .proforma-search-control > .form-control {
    min-height: 44px;
  }

  .proforma-buyer-status {
    margin-top: 0.38rem;
  }

  .proforma-buyer-details {
    margin-top: 0.72rem;
  }
}

@media (max-width: 1099.98px) {
  /* Suggestions remain in the normal flow on touch layouts so a result
     never covers the save choice or the buyer details disclosure. */
  .proforma-buyer-suggestions .suggest-list {
    position: static;
    max-height: min(18rem, 42vh);
    margin-top: 0.45rem;
  }

  .proforma-buyer-details-content .row > [class*="col-"] {
    flex: 0 0 100%;
    width: 100%;
  }
}

@media (max-width: 991.98px) {
  .proforma-line-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .proforma-price-field {
    grid-column: span 2;
  }
}

@media (max-width: 767.98px) {
  .document-workspace.proforma-composer {
    padding-bottom: calc(var(--mobile-nav-height) + 10rem);
  }

  .proforma-composer .document-header-form {
    gap: 0.8rem;
    margin-top: 0.9rem;
  }

  .proforma-composer .document-form-section,
  .proforma-composer .document-items-section {
    padding: 0.95rem;
  }

  .proforma-buyer-status,
  .proforma-buyer-known {
    align-items: flex-start;
    flex-direction: column;
  }

  .proforma-buyer-known-meta {
    max-width: 100%;
    white-space: normal;
  }

  .proforma-save-buyer-choice {
    min-height: 56px;
    align-items: flex-start;
  }

  .proforma-buyer-details > summary {
    min-height: 64px;
    padding: 0.78rem 0.82rem;
  }

  .proforma-buyer-details-content {
    padding: 0.85rem;
  }

  .proforma-options-details > summary {
    padding: 0.95rem;
  }

  .proforma-options-content {
    padding: 0.95rem;
  }

  .proforma-setting-toggles,
  .proforma-toggle-fields {
    grid-template-columns: 1fr;
  }

  .proforma-toggle-fields--single {
    max-width: none;
  }

  .proforma-suggest-item {
    gap: 0.48rem 0.65rem;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .proforma-suggest-item-price {
    min-width: 0;
    grid-column: 1 / 2;
    text-align: start;
  }

  .proforma-suggest-action {
    min-height: 36px;
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .proforma-suggest-item-title,
  .proforma-suggest-item-meta {
    white-space: normal;
  }

  .proforma-line-fields {
    gap: 0.65rem;
  }

  .proforma-price-field,
  .proforma-line-fields > div:last-child {
    grid-column: span 2;
  }

  .proforma-free-item-state,
  .proforma-warranty-heading,
  .proforma-warranty-selected {
    align-items: flex-start;
    flex-direction: column;
  }

  .proforma-warranty-selected strong {
    width: 100%;
    white-space: normal;
  }

  .proforma-warranty-memory {
    white-space: normal;
  }

  .proforma-warranty-choices {
    display: grid;
    grid-template-columns: 1fr;
  }

  .proforma-warranty-choice {
    width: 100%;
    min-height: 44px;
    text-align: start;
  }

  .proforma-warranty-recent > div {
    display: grid;
    grid-template-columns: 1fr;
  }

  .proforma-warranty-recent button {
    width: 100%;
    min-height: 40px;
    text-align: start;
  }

  .proforma-composer .document-add-line-footer .btn {
    width: 100%;
  }

  .document-actions--mobile {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .document-actions--mobile > button,
  .document-actions--mobile > a,
  .document-actions--mobile > form,
  .document-actions--mobile > .document-print-actions,
  .document-actions--mobile > details {
    min-width: 0;
  }

  .document-actions--mobile > [data-save-draft] {
    grid-column: 1 / -1;
  }

  .document-actions--mobile > .document-print-actions {
    grid-column: 1 / -1;
  }

  .document-actions--mobile > details {
    width: 100%;
  }

  .document-actions--mobile > details > summary {
    width: 100%;
    min-height: 44px;
  }

  .document-actions--mobile .document-print-menu-popover {
    inset-inline-start: 0;
    inset-inline-end: auto;
    min-width: 190px;
  }

  .document-actions--mobile > button.btn,
  .document-actions--mobile > form .btn {
    min-height: 44px;
  }
}

/* Management tables become labelled records anywhere the app canvas is too
   narrow for seven columns. At 1024px the desktop sidebar still leaves only
   about 785px for content, so waiting for the phone breakpoint would create a
   horizontal page scroll on tablets. */
@media (max-width: 1099.98px) {
  .management-record-table,
  .management-record-table tbody,
  .management-record-table tr,
  .management-record-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .management-record-table thead {
    display: none;
  }

  .management-record-table tbody {
    display: grid;
    gap: 0.75rem;
  }

  .management-record-table tbody tr {
    overflow: hidden;
    border: 1px solid var(--border);
    border-inline-start: 4px solid var(--brand-600);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }

  .management-record-table tbody tr.table-secondary {
    border-inline-start-color: var(--muted);
    opacity: 0.88;
  }

  .management-record-table tbody td {
    display: flex;
    min-height: 40px;
    gap: 0.8rem;
    padding: 0.62rem 0.72rem !important;
    align-items: baseline;
    justify-content: space-between;
    border: 0;
    border-bottom: 1px solid #edf1f5;
    color: var(--ink-950);
    text-align: start !important;
    white-space: normal !important;
  }

  .management-record-table tbody td::before {
    min-width: 5.65rem;
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.71rem;
    font-weight: 700;
  }

  .management-record-table tbody td:first-child {
    align-items: flex-start;
    padding-top: 0.76rem !important;
  }

  .management-record-table tbody td:last-child {
    border-bottom: 0;
  }

  .management-record-table tbody td:last-child .btn {
    width: 100%;
    min-height: 44px;
  }

  .management-record-table .management-record-empty {
    display: block;
    min-height: 0;
    padding: 1.15rem !important;
    border: 0;
    text-align: center !important;
  }

  .management-record-table .management-record-empty::before {
    display: none;
  }
}

.archive-type-badge {
  display: inline-flex;
  margin-inline-start: 0.38rem;
  padding: 0.13rem 0.4rem;
  border-radius: 999px;
  color: #38517a;
  background: #edf2fb;
  font-size: 0.67rem;
  font-weight: 700;
  vertical-align: middle;
}

.archive-type-badge--invoice {
  color: #0d766b;
  background: var(--success-050);
}
