:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-soft: #eef4f8;
  --text: #172033;
  --text-soft: #627087;
  --text-faint: #8c98aa;
  --border: #dfe6ee;
  --border-strong: #c9d4df;
  --primary: #0f6d75;
  --primary-dark: #0a5158;
  --primary-soft: #e5f5f5;
  --accent: #d98e24;
  --accent-soft: #fff3dc;
  --danger: #c54545;
  --danger-soft: #fff0f0;
  --success: #24805b;
  --success-soft: #e7f6ef;
  --warning: #a3650f;
  --warning-soft: #fff5df;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.05), 0 1px 4px rgb(15 23 42 / 0.04);
  --shadow-md: 0 10px 28px rgb(15 23 42 / 0.08);
  --shadow-lg: 0 24px 70px rgb(15 23 42 / 0.18);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --sidebar-width: 318px;
  --topbar-height: 82px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 110px;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

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

button,
select {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 94px;
  padding: 10px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(15 109 117 / 0.13);
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgb(197 69 69 / 0.12);
}

::placeholder {
  color: #a0a9b7;
}

.ltr {
  direction: ltr;
  text-align: left;
}

.readonly-field {
  background: #f1f4f7;
  color: var(--text-soft);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 8px 0 28px rgb(15 23 42 / 0.04);
}

[dir="rtl"] .sidebar {
  inset: 0 0 0 auto;
  border-right: 0;
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 28px rgb(15 23 42 / 0.04);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 9px 20px rgb(15 109 117 / 0.24);
}

.brand-block h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.brand-block p {
  margin: 2px 0 0;
  color: var(--text-soft);
  direction: ltr;
  font-size: 11px;
  text-align: right;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 14px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

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

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 14px rgb(15 109 117 / 0.18);
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: 0 8px 18px rgb(15 109 117 / 0.24);
}

.button-ghost {
  border-color: var(--border-strong);
  background: var(--surface);
}

.button-ghost:hover:not(:disabled),
.button-soft:hover:not(:disabled) {
  border-color: #adc1ca;
  background: var(--surface-soft);
}

.button-soft {
  border-color: var(--border);
  background: #f7fafc;
  color: #314056;
}

.button-danger-soft {
  border-color: #f0c7c7;
  background: var(--danger-soft);
  color: var(--danger);
}

.button-danger-soft:hover:not(:disabled) {
  border-color: #e5a4a4;
  background: #ffe4e4;
}

.button-block {
  width: calc(100% - 40px);
  margin: 0 20px 16px;
}

.button-large {
  min-height: 46px;
  padding-inline: 22px;
}

.button-icon {
  font-size: 18px;
  line-height: 1;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 19px;
  line-height: 1;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-soft);
  color: var(--text);
}

.danger-icon:hover:not(:disabled) {
  border-color: #e8b2b2;
  background: var(--danger-soft);
  color: var(--danger);
}

.text-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.text-button:hover {
  text-decoration: underline;
}

.sidebar-search {
  position: relative;
  margin: 0 20px 10px;
}

.sidebar-search input {
  height: 42px;
  padding-right: 38px;
  border-color: var(--border);
  background: var(--surface-muted);
}

.search-icon {
  position: absolute;
  top: 50%;
  right: 13px;
  z-index: 1;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 21px;
}

.sidebar-filters {
  display: flex;
  gap: 7px;
  margin: 0 20px 16px;
}

.sidebar-filters select {
  height: 38px;
  border-color: var(--border);
  background: var(--surface-muted);
  font-size: 12px;
}

.sidebar-filters .icon-button {
  width: 38px;
  height: 38px;
}

.order-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px 9px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
}

.count-pill {
  display: inline-flex;
  min-width: 25px;
  min-height: 23px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 1px 8px;
  background: var(--surface-soft);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 800;
}

.count-pill-large {
  min-height: 36px;
  padding-inline: 12px;
  font-size: 12px;
}

.order-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
  scrollbar-width: thin;
  scrollbar-color: #c5d0d9 transparent;
}

.order-list-empty {
  margin: 18px 8px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 20px 14px;
  color: var(--text-soft);
  text-align: center;
  font-size: 12px;
}

.order-list-item {
  position: relative;
  display: block;
  width: 100%;
  margin: 0 0 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 13px;
  background: transparent;
  color: var(--text);
  text-align: right;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.order-list-item:hover {
  border-color: var(--border);
  background: var(--surface-muted);
}

.order-list-item.is-active {
  border-color: #b8d8da;
  background: var(--primary-soft);
  box-shadow: inset -3px 0 0 var(--primary);
}

.order-list-item-top,
.order-list-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.order-list-item strong {
  direction: ltr;
  font-size: 14px;
}

.order-list-item-company {
  display: block;
  overflow: hidden;
  margin: 5px 0;
  color: #33435a;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-list-item-bottom {
  color: var(--text-soft);
  font-size: 10px;
}

.mini-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 7px;
  background: #edf1f5;
  color: #566277;
  font-size: 9px;
  font-weight: 800;
}

.mini-status.status-open,
.status-chip.status-open {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.mini-status.status-done,
.status-chip.status-done {
  background: var(--success-soft);
  color: var(--success);
}

.mini-status.status-warning,
.status-chip.status-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.mini-status.status-cancelled,
.status-chip.status-cancelled {
  background: var(--danger-soft);
  color: var(--danger);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-top: 1px solid var(--border);
  padding: 13px 10px;
  background: var(--surface-muted);
}

.footer-separator {
  color: var(--border-strong);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgb(15 23 42 / 0.38);
  backdrop-filter: blur(2px);
}

.main-shell {
  min-height: 100vh;
  margin-right: var(--sidebar-width);
}

[dir="ltr"] .main-shell {
  margin-right: 0;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  background: rgb(255 255 255 / 0.92);
  backdrop-filter: blur(14px);
}

.topbar-title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar h2 {
  margin: 1px 0 0;
  font-size: 20px;
  line-height: 1.3;
}

.eyebrow {
  margin: 0;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
}

.menu-button {
  display: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.save-state {
  margin-left: 4px;
  color: var(--success);
  font-size: 11px;
  font-weight: 800;
}

.save-state.is-dirty {
  color: var(--warning);
}

.workspace {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 24px 28px 44px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.metric-card::after {
  position: absolute;
  top: -28px;
  left: -18px;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: var(--primary-soft);
  content: "";
  opacity: 0.75;
}

.metric-warning::after {
  background: var(--accent-soft);
}

.metric-label,
.metric-note {
  position: relative;
  z-index: 1;
  display: block;
}

.metric-label {
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 800;
}

.metric-value {
  position: relative;
  z-index: 1;
  display: block;
  margin: 3px 0;
  color: #183148;
  font-size: 27px;
  line-height: 1.2;
}

.metric-note {
  color: var(--text-faint);
  font-size: 10px;
}

.editor-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.editor-toolbar {
  display: flex;
  min-height: 65px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  background: linear-gradient(180deg, #fff, #fbfcfd);
}

.request-identity,
.editor-actions,
.heading-actions,
.sticky-save-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.request-number-badge {
  display: inline-flex;
  min-height: 35px;
  align-items: center;
  border-radius: 9px;
  padding: 5px 11px;
  background: #172b3f;
  color: #fff;
  direction: ltr;
  font-weight: 800;
}

.status-chip {
  display: inline-flex;
  min-height: 31px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eef2f5;
  color: #5b6677;
  font-size: 11px;
  font-weight: 800;
}

.dirty-indicator {
  color: var(--warning);
  font-size: 11px;
  font-weight: 800;
}

.section-nav {
  position: sticky;
  top: var(--topbar-height);
  z-index: 20;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  padding: 7px 18px;
  background: rgb(250 252 253 / 0.95);
  backdrop-filter: blur(10px);
  scrollbar-width: none;
}

.section-nav::-webkit-scrollbar {
  display: none;
}

.section-nav a {
  flex: 0 0 auto;
  border-radius: 8px;
  padding: 7px 11px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}

.section-nav a:hover {
  background: var(--surface-soft);
  color: var(--primary-dark);
}

.section-nav a.is-active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 5px 14px rgb(0 110 115 / 0.18);
}

.section-nav a.is-active:hover {
  background: var(--primary-dark);
  color: #fff;
}

.form-section {
  display: none;
  min-height: 420px;
  border-bottom: 0;
  padding: 28px 24px 30px;
}

.form-section.is-route-active {
  display: block;
  animation: route-panel-in 160ms ease-out;
}

@keyframes route-panel-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 20px;
}

.section-heading h3 {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.4;
}

.section-heading > p,
.section-heading div > p {
  max-width: 540px;
  margin: 5px 0 0;
  color: var(--text-soft);
  font-size: 11px;
}

.section-heading-actions {
  align-items: center;
}

.section-kicker {
  display: block;
  color: var(--primary);
  direction: ltr;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-align: right;
  text-transform: uppercase;
}

.form-grid {
  display: grid;
  gap: 15px;
}

.form-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  color: #435168;
  font-size: 11px;
  font-weight: 800;
}

.required-field > span::after {
  margin-right: 4px;
  color: var(--danger);
  content: "*";
}

.field-wide {
  width: 100%;
}

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

.field-span-3 {
  grid-column: span 3;
}

.two-column-block {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(360px, 0.7fr);
  gap: 18px;
  margin-top: 18px;
}

.document-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "icon content"
    "actions actions";
  gap: 11px 12px;
  align-content: center;
  border: 1px dashed #b9c7d2;
  border-radius: var(--radius-md);
  padding: 15px;
  background: var(--surface-muted);
}

.document-card.has-document {
  border-style: solid;
  border-color: #aad0d2;
  background: #f2fbfb;
}

.document-card-icon {
  grid-area: icon;
  display: grid;
  width: 50px;
  height: 58px;
  place-items: center;
  border-radius: 7px;
  background: #d94f4f;
  color: #fff;
  direction: ltr;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 6px 12px rgb(217 79 79 / 0.16);
}

.document-card-content {
  grid-area: content;
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
}

.document-card-content strong,
.document-card-content span,
.document-card-content small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-card-content strong {
  font-size: 12px;
}

.document-card-content span {
  margin-top: 2px;
  color: #34455c;
  direction: ltr;
  font-size: 12px;
  text-align: right;
}

.document-card-content small {
  margin-top: 3px;
  color: var(--text-soft);
  font-size: 9px;
}

.document-card-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: 7px;
}

#itemsTableWrap {
  scroll-margin-top: 106px;
}

.items-table-wrap,
.comparison-table-wrap,
.quote-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.items-table,
.comparison-table,
.quote-table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
}

.items-table {
  min-width: 1020px;
}

.items-table th,
.items-table td,
.comparison-table th,
.comparison-table td,
.quote-table th,
.quote-table td {
  border-bottom: 1px solid var(--border);
  padding: 11px 10px;
  text-align: right;
  vertical-align: middle;
}

.items-table th,
.comparison-table th,
.quote-table th {
  background: #f3f6f9;
  color: #4b596e;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.items-table td,
.comparison-table td,
.quote-table td {
  color: #2d3a4e;
  font-size: 11px;
}

.items-table tbody tr:last-child td,
.comparison-table tbody tr:last-child td,
.quote-table tbody tr:last-child td {
  border-bottom: 0;
}

.items-table tbody tr:hover {
  background: #fbfcfd;
}

.items-table .item-code,
.items-table .item-name,
.items-table .numeric-cell,
.items-table .currency-cell {
  direction: ltr;
  text-align: left;
}

.items-table .item-code {
  font-weight: 800;
  white-space: nowrap;
}

.items-table .item-name {
  min-width: 240px;
  max-width: 380px;
  color: #1e2f45;
  font-weight: 700;
}

.items-table .subline {
  display: block;
  margin-top: 2px;
  color: var(--text-faint);
  direction: rtl;
  font-size: 9px;
  font-weight: 400;
  text-align: right;
}

.items-table .actions-column {
  width: 126px;
  text-align: center;
}

.items-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #f8fafc;
}

.items-pagination[hidden] {
  display: none;
}

.pagination-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
  color: var(--text-soft);
  font-size: 11px;
}

.pagination-summary strong {
  color: #34455c;
  font-size: 11px;
}

.page-size-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.page-size-control select {
  width: 68px;
  height: 34px;
  padding: 0 8px;
  direction: ltr;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
}

.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  direction: ltr;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 5px;
}

.pagination-button {
  display: inline-grid;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: #34455c;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  transition: border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.pagination-button:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  transform: translateY(-1px);
}

.pagination-button.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px rgb(15 109 117 / 0.18);
}

.pagination-button.pagination-edge {
  min-width: 34px;
  padding: 0 8px;
  font-size: 17px;
}

.pagination-ellipsis {
  display: inline-grid;
  min-width: 24px;
  height: 36px;
  place-items: center;
  color: var(--text-faint);
  font-weight: 900;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.row-action-button {
  min-width: 31px;
  height: 31px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
}

.row-action-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
  color: var(--primary-dark);
}

.row-action-button.delete:hover {
  border-color: #e4b0b0;
  background: var(--danger-soft);
  color: var(--danger);
}

.empty-state {
  padding: 46px 20px;
  text-align: center;
}

.empty-state-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 24px;
  font-weight: 300;
}

.empty-state h4 {
  margin: 0 0 4px;
  font-size: 14px;
}

.empty-state p {
  max-width: 520px;
  margin: 0 auto 14px;
  color: var(--text-soft);
  font-size: 11px;
}

.suppliers-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.supplier-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.supplier-card[open] {
  box-shadow: var(--shadow-sm);
}

.supplier-card summary {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-muted);
  cursor: pointer;
  list-style: none;
}

.supplier-card summary::-webkit-details-marker {
  display: none;
}

.supplier-card summary::after {
  color: var(--text-soft);
  content: "⌄";
  font-size: 16px;
  transition: transform 0.18s ease;
}

.supplier-card[open] summary::after {
  transform: rotate(180deg);
}

.supplier-card-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.supplier-number {
  display: grid;
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  place-items: center;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  direction: ltr;
  font-size: 11px;
  font-weight: 900;
}

.supplier-card-title-text {
  min-width: 0;
}

.supplier-card-title strong,
.supplier-card-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supplier-card-title strong {
  font-size: 12px;
}

.supplier-card-title span {
  color: var(--text-soft);
  direction: ltr;
  font-size: 9px;
  text-align: right;
}

.supplier-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

.supplier-body .field-full {
  grid-column: span 2;
}

.supplier-body .field > span {
  font-size: 10px;
}

.supplier-body input,
.supplier-body select,
.supplier-body textarea {
  font-size: 12px;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.summary-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px;
  background: var(--surface-muted);
}

.summary-card span,
.summary-card strong {
  display: block;
}

.summary-card span {
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 800;
}

.summary-card strong {
  margin-top: 3px;
  color: #20364f;
  direction: ltr;
  font-size: 21px;
  text-align: right;
}

.summary-total-card {
  border-color: #add1d3;
  background: var(--primary-soft);
}

.summary-total-card strong {
  color: var(--primary-dark);
  font-size: 17px;
}

.comparison-panel {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.comparison-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--border);
  padding: 13px 15px;
  background: var(--surface-muted);
}

.comparison-panel-header h4 {
  margin: 0;
  font-size: 13px;
}

.comparison-panel-header small {
  color: var(--text-soft);
  font-size: 9px;
}

.comparison-table-wrap {
  border: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.comparison-table {
  min-width: 670px;
}

.final-notes-field {
  margin-top: 16px;
}

.sticky-save-bar {
  position: sticky;
  bottom: 0;
  z-index: 22;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--border);
  padding: 12px 18px;
  background: rgb(255 255 255 / 0.94);
  box-shadow: 0 -12px 28px rgb(15 23 42 / 0.07);
  backdrop-filter: blur(12px);
}

.sticky-save-bar strong,
.sticky-save-bar span {
  display: block;
}

.sticky-save-bar strong {
  font-size: 12px;
}

.sticky-save-bar span {
  color: var(--text-soft);
  font-size: 10px;
}

.modal {
  width: min(1180px, calc(100vw - 30px));
  max-height: min(92vh, 920px);
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.modal::backdrop {
  background: rgb(15 23 42 / 0.54);
  backdrop-filter: blur(3px);
}

.modal > form {
  display: flex;
  max-height: min(92vh, 920px);
  flex-direction: column;
}

.modal-header {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
}

.modal-header h3 {
  margin: 2px 0 0;
  font-size: 17px;
}

.modal-tabs {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  padding: 8px 18px;
  background: var(--surface-muted);
}

.modal-tab {
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 11px;
  background: transparent;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 800;
}

.modal-tab:hover {
  background: var(--surface-soft);
}

.modal-tab.is-active {
  border-color: #b8d8da;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.modal-body {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.product-tab-panel {
  display: none;
}

.product-tab-panel.is-active {
  display: block;
}

.modal-footer {
  display: flex;
  min-height: 65px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid var(--border);
  padding: 12px 18px;
  background: var(--surface-muted);
}

.modal-footer > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-validation {
  color: var(--danger);
  font-size: 11px;
  font-weight: 800;
}

.quote-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  border: 1px solid #c6e2e3;
  border-radius: 10px;
  padding: 10px 12px;
  background: #f1fbfb;
}

.quote-help strong {
  font-size: 12px;
}

.quote-help span {
  color: var(--text-soft);
  font-size: 10px;
}

.quote-table {
  min-width: 1060px;
}

.quote-table td {
  padding: 9px 8px;
}

.quote-table input,
.quote-table select {
  min-width: 100px;
  height: 37px;
  font-size: 11px;
}

.quote-table .supplier-quote-name {
  min-width: 170px;
  font-weight: 800;
}

.quote-table .select-quote-cell {
  text-align: center;
}

.quote-table input[type="radio"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.bulk-modal {
  width: min(820px, calc(100vw - 30px));
}

.bulk-instructions {
  margin-bottom: 15px;
  border: 1px solid #c7dce4;
  border-radius: 10px;
  padding: 12px 14px;
  background: #f4f9fb;
}

.bulk-instructions strong,
.bulk-instructions code,
.bulk-instructions p {
  display: block;
}

.bulk-instructions strong {
  margin-bottom: 6px;
  font-size: 11px;
}

.bulk-instructions code {
  overflow-x: auto;
  border-radius: 7px;
  padding: 8px 10px;
  background: #1f2c3a;
  color: #e7f8f8;
  direction: ltr;
  font-family: Consolas, monospace;
  font-size: 11px;
  text-align: left;
  white-space: nowrap;
}

.bulk-instructions p {
  margin: 7px 0 0;
  color: var(--text-soft);
  font-size: 10px;
}

.bulk-textarea {
  min-height: 250px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.8;
}

.bulk-preview {
  margin-top: 10px;
  border-radius: 8px;
  padding: 8px 11px;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 10px;
}

.bulk-preview.is-valid {
  background: var(--success-soft);
  color: var(--success);
}

.bulk-preview.is-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.toast-region {
  position: fixed;
  right: 24px;
  bottom: 22px;
  z-index: 100;
  display: flex;
  width: min(370px, calc(100vw - 32px));
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px 13px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease both;
  pointer-events: auto;
}

.toast.is-success {
  border-right: 4px solid var(--success);
}

.toast.is-error {
  border-right: 4px solid var(--danger);
}

.toast.is-warning {
  border-right: 4px solid var(--warning);
}

.toast-icon {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 900;
}

.toast-content strong,
.toast-content span {
  display: block;
}

.toast-content strong {
  font-size: 11px;
}

.toast-content span {
  margin-top: 1px;
  color: var(--text-soft);
  font-size: 10px;
}

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

@media (max-width: 1280px) {
  .form-grid-4 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .suppliers-grid {
    grid-template-columns: 1fr;
  }

  .supplier-card summary {
    min-height: 54px;
  }

  .supplier-body {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .supplier-body .field-full {
    grid-column: span 4;
  }
}

@media (max-width: 1050px) {
  :root {
    --sidebar-width: 292px;
  }

  .workspace {
    padding-inline: 18px;
  }

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

  .form-grid-4,
  .form-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-span-3 {
    grid-column: span 2;
  }

  .two-column-block {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 860px) {
  .sidebar {
    width: min(340px, calc(100vw - 48px));
    transform: translateX(105%);
    transition: transform 0.22s ease;
  }

  [dir="rtl"] .sidebar {
    transform: translateX(105%);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop[hidden] {
    display: none;
  }

  .main-shell {
    margin-right: 0;
  }

  .menu-button {
    display: inline-grid;
  }

  .topbar {
    padding-inline: 16px;
  }

  .topbar-actions .save-state,
  .topbar-actions .button-ghost {
    display: none;
  }

  .editor-toolbar,
  .section-heading,
  .comparison-panel-header,
  .quote-help {
    align-items: stretch;
    flex-direction: column;
  }

  .editor-actions {
    width: 100%;
  }

  .editor-actions .button {
    flex: 1;
  }

  .section-heading-actions {
    align-items: stretch;
  }

  .heading-actions {
    justify-content: flex-start;
  }

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

  .supplier-body .field-full {
    grid-column: span 2;
  }

  .sticky-save-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .sticky-save-actions {
    width: 100%;
  }

  .sticky-save-actions .button {
    flex: 1;
  }
}

@media (max-width: 620px) {
  :root {
    --topbar-height: 72px;
  }

  body {
    font-size: 13px;
  }

  .topbar h2 {
    font-size: 16px;
  }

  .eyebrow {
    display: none;
  }

  .topbar-actions .button-primary {
    min-width: 96px;
    padding-inline: 10px;
  }

  .workspace {
    padding: 12px 10px 28px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .metric-card {
    padding: 12px;
  }

  .metric-value {
    font-size: 22px;
  }

  .metric-note {
    display: none;
  }

  .editor-card {
    border-radius: 14px;
  }

  .editor-toolbar {
    padding: 11px;
  }

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

  .section-nav {
    padding-inline: 10px;
  }

  .form-section {
    padding: 22px 14px;
  }

  .form-grid-4,
  .form-grid-3,
  .supplier-body,
  .summary-cards {
    grid-template-columns: 1fr;
  }

  .field-span-2,
  .field-span-3,
  .supplier-body .field-full {
    grid-column: span 1;
  }

  .heading-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .heading-actions .count-pill {
    grid-column: span 2;
    justify-self: start;
  }

  .document-card-actions {
    flex-wrap: wrap;
  }

  .modal {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .modal > form {
    max-height: 100vh;
  }

  .modal-body {
    padding: 15px;
  }

  .modal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-footer > div {
    width: 100%;
  }

  .modal-footer .button {
    flex: 1;
  }

  .toast-region {
    right: 16px;
    bottom: 14px;
  }
}

@media (max-width: 760px) {
  .items-pagination {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
  }

  .pagination-summary {
    justify-content: space-between;
  }

  .pagination-controls {
    justify-content: center;
    flex-wrap: wrap;
  }

  .pagination-button {
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  :root {
    --text: #000;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 9pt;
  }

  .sidebar,
  .sidebar-backdrop,
  .topbar,
  .dashboard-grid,
  .editor-toolbar,
  .section-nav,
  .sticky-save-bar,
  .heading-actions,
  .document-card-actions,
  .row-actions,
  .toast-region,
  .editor-actions,
  .button,
  .icon-button {
    display: none !important;
  }

  .main-shell {
    margin: 0 !important;
  }

  .workspace {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  .editor-card {
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .form-section {
    display: block !important;
    break-inside: avoid;
    border: 0;
    padding: 10px 0;
  }

  .form-section + .form-section {
    border-top: 1px solid #999;
  }

  input,
  select,
  textarea {
    border: 0;
    padding: 0;
    background: transparent;
    box-shadow: none !important;
    color: #000;
  }

  textarea {
    min-height: 40px;
  }

  .field > span {
    color: #333;
  }

  .supplier-card,
  .supplier-card[open] {
    break-inside: avoid;
    box-shadow: none;
  }

  .supplier-card > * {
    display: block !important;
  }

  .supplier-card summary::after {
    display: none;
  }

  .items-pagination {
    display: none !important;
  }

  .items-table-wrap,
  .comparison-table-wrap,
  .quote-table-wrap {
    overflow: visible;
    border-color: #777;
  }

  .items-table,
  .comparison-table {
    min-width: 0;
  }

  .items-table th,
  .items-table td,
  .comparison-table th,
  .comparison-table td {
    border-color: #999;
    padding: 5px;
    font-size: 7.5pt;
  }

  .items-table .actions-column,
  .items-table td:last-child {
    display: none;
  }
}

.sidebar-account-links {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 11px;
}

.sidebar-account-links span {
  width: 100%;
  color: rgba(255, 255, 255, 0.65);
  text-align: center;
}

.sidebar-account-links a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-weight: 700;
}

.sidebar-account-links a:hover {
  color: #fff;
  text-decoration: underline;
}
