:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --danger: #ef4444;
  --dark: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --white: #ffffff;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --radius: 16px;
}

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--dark);
  font-family: "Inter", Arial, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.sidebar {
  width: 280px;
  background: #ffffff;
  border-right: 1px solid var(--border);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 50;
  overflow-y: auto;
  padding: 18px 16px 22px;
  transition: 0.3s ease;
}

.brand {
  display: flex;
  align-items: center;
  min-height: 74px;
  margin-bottom: 14px;
  padding: 10px 8px 18px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  display: block;
  width: 210px;
  max-height: 62px;
  object-fit: contain;
  object-position: left center;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  display: grid;
  place-items: center;
  color: var(--white);
  font-weight: 800;
  font-size: 20px;
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
}

.brand-name span {
  color: var(--primary);
}

.sidebar-nav {
  display: grid;
  gap: 12px;
}

.nav-section {
  padding: 10px;
  border: 1px solid #edf2f7;
  border-radius: 14px;
  background: #fbfdff;
}

.nav-section-primary {
  padding: 6px;
  background: transparent;
  border-color: transparent;
}

.nav-title {
  font-size: 12px;
  color: #64748b;
  text-transform: uppercase;
  font-weight: 800;
  margin: 0 8px 8px;
  letter-spacing: 0.04em;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  color: #334155;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 3px;
  transition: 0.2s ease;
}

.nav-link:last-child {
  margin-bottom: 0;
}

.nav-link:hover,
.nav-link.active {
  background: #eef6ff;
  border-color: #bfdbfe;
  color: var(--primary);
}

.nav-link.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  color: #64748b;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
  color: var(--primary);
}

.main {
  margin-left: 280px;
  width: calc(100% - 280px);
  min-height: 100vh;
}

.topbar {
  height: 74px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.menu-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--dark);
  display: none;
}

.menu-btn svg,
.icon-btn svg,
.search-box svg,
.search-field svg,
.search-result-icon svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.search-box {
  max-width: 540px;
  width: 100%;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 13px 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  background: #f8fafc;
}

.search-box span {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-box span svg {
  width: 18px;
  height: 18px;
}

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

.icon-btn {
  position: relative;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #475569;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.icon-btn:hover {
  background: #f1f5f9;
  color: var(--primary);
}

.badge {
  position: absolute;
  top: -7px;
  right: -8px;
  background: var(--danger);
  color: var(--white);
  font-size: 10px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 18px;
  border-left: 1px solid var(--border);
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: linear-gradient(135deg, #cbd5e1, #94a3b8);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
}

.user-profile strong {
  font-size: 14px;
}

.user-profile form {
  margin: 0;
}

.logout-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.logout-btn:hover {
  color: var(--danger);
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 18px;
  background: #eef3f6;
}

.auth-shell {
  width: min(430px, 100%);
}

.auth-logo {
  display: block;
  width: min(300px, 80%);
  max-height: 110px;
  margin: 0 auto 24px;
  object-fit: contain;
}

.auth-panel {
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  margin-bottom: 7px;
  font-size: 24px;
}

.auth-panel > p {
  margin-bottom: 22px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-panel .field {
  margin-bottom: 16px;
}

.auth-panel .btn {
  width: 100%;
  margin-top: 4px;
}

.auth-panel .auth-help {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.content {
  padding: 28px 36px 42px;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header-split {
  justify-content: space-between;
}

.page-heading-inline {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page-actions form {
  margin: 0;
}

.status-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-form select {
  min-width: 150px;
  height: 42px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--dark);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.page-header h1 {
  font-size: 26px;
  font-weight: 800;
}

.page-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
}

.back-btn {
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  cursor: pointer;
  font-size: 20px;
  display: grid;
  place-items: center;
}

.quotation-card,
.work-panel,
.metric-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.quotation-card {
  overflow: hidden;
}

.form-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  padding: 28px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 22px;
}

.section-title span {
  color: var(--primary);
  font-size: 21px;
}

.section-title svg {
  display: block;
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  font-size: 13px;
  color: #334155;
  font-weight: 700;
}

label .required {
  color: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--dark);
  outline: none;
  background: var(--white);
  transition: 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

input[readonly] {
  background: #f8fafc;
  color: #475569;
  cursor: default;
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.has-error input,
.has-error select,
.has-error textarea,
.input-error {
  border-color: var(--danger);
}

.has-error input:focus,
.has-error select:focus,
.has-error textarea:focus,
.input-error:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.was-validated input:invalid,
.was-validated select:invalid,
.was-validated textarea:invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.form-error {
  color: #b91c1c;
  display: block;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  margin-top: 6px;
}

.form-error-top {
  padding: 0 28px 18px;
}

.form-error-table {
  padding: 14px;
  margin-top: 0;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.items-section {
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

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

.btn {
  border: none;
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
}

.btn-outline {
  background: var(--white);
  color: var(--primary);
  border: 1px solid #93c5fd;
}

.btn-outline:hover {
  background: var(--primary-light);
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 13px;
  font-weight: 800;
}

.status-pill.is-optimistic,
.status-badge.is-optimistic {
  outline: 2px solid rgba(37, 99, 235, 0.2);
  outline-offset: 2px;
}

.is-submitting {
  opacity: 0.78;
  pointer-events: none;
}

.is-submitting button[type="submit"] {
  cursor: wait;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 940px;
  border-collapse: separate;
  border-spacing: 0;
}

th {
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  text-align: left;
  padding: 15px 14px;
  font-weight: 800;
  border-bottom: 1px solid var(--border);
  line-height: 1.3;
}

td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 14px;
}

tr:last-child td {
  border-bottom: none;
}

.item-name {
  font-weight: 700;
  margin-bottom: 3px;
}

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

.table-input {
  max-width: 120px;
  padding: 10px 12px;
}

.table-text-input {
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

.table-text-input:focus {
  border-color: transparent;
  box-shadow: none;
}

.item-name-input {
  font-weight: 700;
  margin-bottom: 5px;
}

.item-desc-input {
  color: var(--muted);
  font-size: 12px;
}

.tax-select {
  min-width: 130px;
  padding: 10px 12px;
}

.line-total {
  font-weight: 700;
  white-space: nowrap;
}

.more-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  color: var(--muted);
}

.remove-row-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff1f2;
  color: #b91c1c;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.remove-row-btn:hover {
  background: #fee2e2;
}

.bottom-section {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr;
  gap: 24px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}

.editor {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

.editor textarea {
  border: none;
  box-shadow: none;
  border-radius: 0;
  min-height: 150px;
}

.summary-card {
  border: 1px solid #bfdbfe;
  border-radius: 16px;
  background: linear-gradient(180deg, #eff6ff, #ffffff);
  padding: 22px;
  height: fit-content;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  color: #475569;
  font-size: 14px;
}

.summary-row strong {
  color: var(--dark);
}

.summary-row.discount strong {
  color: var(--success);
}

.summary-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.grand-total {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.grand-total span {
  font-size: 17px;
  font-weight: 800;
}

.grand-total strong {
  color: var(--primary);
  font-size: 28px;
  font-weight: 900;
}

.action-bar {
  padding: 22px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #ffffff;
}

.action-center {
  display: flex;
  justify-content: center;
  flex: 1;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 40;
}

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

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

.metric-card {
  padding: 22px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}

.metric-card strong {
  display: block;
  font-size: 30px;
  font-weight: 900;
}

.metric-card .metric-money {
  font-size: 22px;
}

.metric-card a,
.metric-card small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card a:hover {
  color: var(--primary);
}

.dashboard-recent {
  margin-top: 4px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.panel-heading h2 {
  font-size: 18px;
  margin-bottom: 5px;
}

.panel-heading p {
  color: var(--muted);
  font-size: 13px;
}

.dashboard-table {
  border: 0;
  border-radius: 0;
}

.dashboard-table table {
  min-width: 760px;
}

.settings-logo-preview {
  width: 100%;
  max-width: 360px;
  margin-bottom: 22px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.settings-logo-preview img {
  display: block;
  width: 100%;
  max-height: 100px;
  object-fit: contain;
  object-position: left center;
}

.customer-profile {
  margin-bottom: 24px;
}

.customer-contact {
  padding: 22px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.customer-contact h2 {
  margin-bottom: 18px;
  font-size: 18px;
}

.customer-contact .detail-list {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.address-value {
  line-height: 1.5;
}

.customer-metrics {
  margin-bottom: 0;
}

.report-filter {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  background: var(--white);
}

.report-filter .field {
  width: 190px;
}

.report-filter .statement-customer-field {
  width: min(360px, 100%);
}

.report-filter .btn {
  height: 44px;
}

.overdue-text {
  color: #b91c1c;
  font-weight: 800;
}

.report-section + .report-section {
  margin-top: 22px;
}

.search-page-panel {
  margin-bottom: 20px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.search-page-form {
  display: grid;
  gap: 8px;
}

.search-page-form > div {
  display: flex;
  gap: 10px;
}

.search-page-form .btn {
  flex: 0 0 auto;
}

.search-results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.search-result-section {
  min-width: 0;
}

.search-result-list {
  display: grid;
}

.search-result-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.search-result-item:last-child {
  border-bottom: 0;
}

.search-result-item:hover {
  background: #f8fafc;
}

.search-result-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
}

.search-result-copy {
  min-width: 0;
}

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

.search-result-copy strong {
  margin-bottom: 4px;
  font-size: 14px;
}

.search-result-copy small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.search-result-action {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.payment-metrics {
  margin-bottom: 20px;
}

.invoice-receipts {
  margin-top: 24px;
}

.compact-empty-state {
  padding: 30px 24px;
}

.receipt-customer {
  margin-bottom: 20px;
}

.statement-customer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 18px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.statement-customer h2 {
  margin-bottom: 5px;
  font-size: 20px;
}

.statement-customer p,
.statement-customer span {
  color: var(--muted);
  font-size: 13px;
}

.statement-customer > div:last-child {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 5px;
}

.work-panel {
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.work-panel h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.work-panel p {
  color: var(--muted);
  line-height: 1.6;
}

.error-panel {
  align-items: flex-start;
}

.error-copy {
  max-width: 640px;
}

.list-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: visible;
}

.list-panel > .table-wrap,
.list-panel > .dashboard-table {
  border-right: 0;
  border-left: 0;
  border-radius: 0;
}

.list-panel > .table-wrap:last-child,
.list-panel > .dashboard-table:last-child {
  border-bottom: 0;
}

.list-panel.is-loading {
  opacity: 0.68;
  pointer-events: none;
}

.inline-filter {
  flex: 1;
  min-width: 220px;
}

.inline-filter label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.inline-filter input {
  min-height: 42px;
}

.inline-filter-empty td {
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

.list-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.search-field {
  position: relative;
  flex: 1;
}

.search-field span {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-field input {
  padding-left: 42px;
}

.btn-small {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
}

.status-draft {
  color: #1d4ed8;
  background: #dbeafe;
}

.status-sent {
  color: #854d0e;
  background: #fef3c7;
}

.status-accepted,
.status-paid {
  color: #166534;
  background: #dcfce7;
}

.status-rejected,
.status-cancelled {
  color: #991b1b;
  background: #fee2e2;
}

.status-converted,
.status-partially_paid {
  color: #334155;
  background: #e2e8f0;
}

.empty-state {
  padding: 54px 24px;
  text-align: center;
}

.empty-state h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--muted);
  margin-bottom: 18px;
}

.pagination-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.page-indicator {
  color: #334155;
  font-weight: 700;
}

.alert {
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
  font-size: 14px;
  font-weight: 700;
}

.flash-stack {
  margin-bottom: 18px;
}

.flash-stack .alert:last-child {
  margin-bottom: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.48);
}

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

.modal-panel {
  display: flex;
  flex-direction: column;
  width: min(680px, 100%);
  max-height: calc(100vh - 36px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24);
}

.modal-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.modal-header h2 {
  font-size: 18px;
  line-height: 1.25;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  color: #334155;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

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

.modal-body .page-header,
.modal-body .alert {
  display: none;
}

.modal-body .quotation-card {
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}

.modal-form {
  min-height: 100%;
}

.modal-form .form-top {
  display: block;
  padding: 20px;
}

.modal-form .section-title {
  margin-bottom: 16px;
  font-size: 15px;
}

.modal-form .form-grid {
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.modal-form textarea {
  min-height: 92px;
}

.modal-form .action-bar {
  position: sticky;
  bottom: 0;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #ffffff;
  box-shadow: 0 -8px 20px rgba(15, 23, 42, 0.06);
}

.modal-loading {
  padding: 24px;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}

body.has-modal {
  overflow: hidden;
}

@media (max-width: 640px) {
  .modal-backdrop {
    align-items: stretch;
    padding: 0;
  }

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

  .modal-header {
    padding: 14px 16px;
  }

  .modal-form .form-top {
    padding: 16px;
  }

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

  .modal-form .action-bar {
    padding: 14px 16px;
  }
}

.alert-success {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #86efac;
}

.alert-danger {
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fecaca;
}

.detail-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.detail-list strong {
  font-size: 14px;
}

.notes-preview {
  color: #334155;
  line-height: 1.7;
  white-space: pre-line;
}

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

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334155;
  font-size: 14px;
  font-weight: 700;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
}

@media (max-width: 1180px) {
  .form-top,
  .bottom-section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .overlay.show {
    display: block;
  }

  .main {
    margin-left: 0;
    width: 100%;
  }

  .menu-btn {
    display: block;
  }

  .topbar {
    padding: 0 18px;
  }

  .content {
    padding: 22px 18px 36px;
  }

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

  .user-profile strong {
    display: none;
  }

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

  .search-results-grid {
    grid-template-columns: 1fr;
  }

  .customer-contact .detail-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    height: auto;
    padding: 14px 16px;
    align-items: flex-start;
    gap: 14px;
  }

  .topbar-left {
    width: 100%;
  }

  .topbar-actions {
    gap: 12px;
  }

  .search-box {
    display: none;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .form-top,
  .items-section,
  .bottom-section,
  .action-bar {
    padding: 20px;
  }

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

  .customer-contact .detail-list {
    grid-template-columns: 1fr;
  }

  .report-filter {
    align-items: stretch;
    flex-direction: column;
  }

  .search-page-form > div {
    flex-direction: column;
  }

  .report-filter .field {
    width: 100%;
  }

  .statement-customer {
    flex-direction: column;
  }

  .statement-customer > div:last-child {
    align-items: flex-start;
  }

  .section-header-row {
    align-items: flex-start;
    gap: 14px;
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .page-actions,
  .status-form {
    width: 100%;
  }

  .status-form {
    align-items: stretch;
    flex-direction: column;
  }

  .status-form select {
    width: 100%;
  }

  .action-bar,
  .work-panel,
  .page-header-split,
  .list-toolbar,
  .pagination-row {
    flex-direction: column;
    align-items: stretch;
  }

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

  .action-center,
  .action-bar > .btn,
  .action-bar button {
    width: 100%;
  }

  .grand-total {
    flex-direction: column;
    align-items: flex-start;
  }

  .grand-total strong {
    font-size: 25px;
  }
}
