:root {
  --page-bg: #f4f6fb;
  --paper-bg: #ffffff;
  --border-color: #000000;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #dbeafe;
  --text-main: #0f172a;
  --text-soft: #475569;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Poppins', sans-serif;
  background: var(--page-bg);
  color: var(--text-main);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid #d4d8e0;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font-weight: 600;
  background: #ffffff;
  color: var(--text-main);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(15, 23, 42, 0.1);
}

.page-shell {
  padding: 2rem;
  max-width: 100%;
  overflow-x: hidden;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.4rem;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.status-pill {
  background: #fff;
  padding: 0.65rem 0.95rem;
  border-radius: 999px;
  color: var(--text-soft);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.07);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 1.5rem;
  align-items: start;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.06);
}

.card h2 {
  margin-top: 0;
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.9rem;
}

.input-grid,
.summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-soft);
}

input {
  border: 1px solid #d4d8e0;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  background: #fbfcfe;
}

.quote-container {
  display: flex;
  justify-content: center;
  min-width: 0;
  width: 100%;
}

.quote-sheet {
  position: relative;
  width: min(210mm, 100%);
  max-width: 100%;
  min-height: 297mm;
  background: var(--paper-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16mm;
  overflow: hidden;
  box-sizing: border-box;
}

.quote-heading {
  text-align: center;
  margin-bottom: 1.2rem;
}

.quote-heading h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  text-decoration: underline;
  font-style: italic;
}

.quote-heading p {
  margin: 0.4rem 0 0;
  font-size: 0.95rem;
  color: var(--text-soft);
}

.quote-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: stretch;
}

.customer-block,
.company-block {
  border: 1px solid #d7d7d7;
  border-radius: 10px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  height: 100%;
}

.detail-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.92rem;
}

.label {
  font-weight: 600;
  color: var(--text-soft);
}

.value {
  word-break: break-word;
}

.company-block h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}

.company-block p {
  margin: 0.2rem 0;
  font-size: 0.9rem;
}

.quote-meta {
  display: flex;
  justify-content: flex-end;
  gap: 1.3rem;
  margin-bottom: 1rem;
}

.meta-item {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
}

.meta-label {
  font-weight: 600;
  color: var(--text-soft);
}

.table-toolbar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.55rem;
  gap: 0.75rem;
}

.table-title {
  font-weight: 700;
  color: var(--text-main);
}


.table-wrapper {
  position: relative;
  z-index: 1;
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid #000;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border: 1px solid #000;
  padding: 0.55rem 0.5rem;
  text-align: center;
  font-size: 0.9rem;
}

th {
  background: #8faed3;
  color: #10223d;
  font-weight: 700;
}

tbody tr:nth-child(even) {
  background: #f8fbff;
}

tbody td input {
  width: 100%;
  border: 1px solid #d9dde4;
  border-radius: 6px;
  padding: 0.45rem 0.5rem;
}

.line-total {
  font-weight: 700;
}

.row-actions {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.action-menu-trigger {
  padding: 0.28rem 0.45rem;
  font-size: 0.9rem;
  box-shadow: none;
  border-radius: 6px;
  background: #f1f4f8;
  color: var(--text-main);
  line-height: 1;
}

.action-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.3rem);
  display: none;
  min-width: 110px;
  background: #fff;
  border: 1px solid #d9dde4;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
  z-index: 20;
}

.action-menu.show {
  display: block;
}

.action-menu-item {
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-radius: 0;
  background: #fff;
  color: var(--text-main);
  box-shadow: none;
}

.action-menu-item:hover {
  background: #f8fbff;
  transform: none;
}

.totals-panel {
  margin-top: 1rem;
  border-top: 1px solid #d9dde4;
  padding-top: 0.7rem;
  display: grid;
  gap: 0.35rem;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
}

.grand-total {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.footer {
  margin-top: 1.2rem;
  background: #f3e7c8;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  text-align: center;
}

.footer p,
.footer h4 {
  margin: 0.2rem 0;
}

.footer h4 {
  font-size: 0.98rem;
}

@media (max-width: 1024px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    order: 2;
  }

  .quote-container {
    order: 1;
  }
}

@media (max-width: 768px) {
  .page-shell {
    padding: 0.85rem;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
  }

  .control-panel,
  .quote-container {
    width: 100%;
    min-width: 0;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-group {
    justify-content: center;
  }

  .quote-sheet {
    width: 100%;
    max-width: 100%;
    min-height: auto;
    padding: 0.95rem;
    border-radius: 10px;
  }

  .table-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .ghost-btn {
    width: 100%;
  }

  .quote-top {
    grid-template-columns: 1fr;
  }

  .quote-meta {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.7rem;
  }

  .detail-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .table-wrapper {
    margin: 0;
  }

  table {
    min-width: 640px;
  }

  th,
  td {
    padding: 0.45rem 0.35rem;
    font-size: 0.82rem;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .action-menu {
    left: 0;
    right: auto;
  }
}

@media (max-width: 480px) {
  .page-shell {
    padding: 0.6rem;
  }

  .card {
    padding: 0.8rem;
  }

  .quote-sheet {
    padding: 0.75rem;
  }

  .quote-top,
  .quote-meta,
  .totals-row {
    width: 100%;
  }

  .quote-heading h1 {
    font-size: 1.2rem;
  }

  .quote-heading p {
    font-size: 0.8rem;
  }

  .company-block,
  .customer-block {
    padding: 0.75rem;
  }

  .totals-row {
    font-size: 0.9rem;
  }

  .action-menu-trigger {
    padding: 0.32rem 0.45rem;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 6mm;
  }

  body {
    background: #ffffff;
    color: #1e1e1e;
    margin: 0;
    padding: 0;
  }

  .toolbar,
  .control-panel {
    display: none !important;
  }

  .page-shell {
    padding: 0;
  }

  .quote-container {
    display: block;
    width: 100%;
  }

  .quote-sheet {
    width: 100%;
    max-width: 100%;
    min-height: auto;
    background: #ffffff;
    box-shadow: none;
    border: 1px solid #000000;
    border-radius: 0;
    margin: 0;
    padding: 7mm 8mm 6mm;
    overflow: visible;
    font-size: 11px;
    color: #1e1e1e;
  }

  .quote-heading {
    margin-bottom: 0.45rem;
  }

  .quote-heading h1 {
    font-size: 1.1rem;
  }

  .quote-heading p {
    font-size: 0.78rem;
  }

  .quote-top {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
    align-items: start;
  }

  .customer-block,
  .company-block {
    padding: 0.5rem;
    font-size: 0.82rem;
    background: #ffffff;
    border: 1px solid #d7d7d7;
  }

  .detail-row {
    grid-template-columns: 88px 1fr;
    gap: 0.3rem;
    margin-bottom: 0.18rem;
  }

  .quote-meta {
    margin-bottom: 0.45rem;
    gap: 0.8rem;
    font-size: 0.82rem;
  }

  .watermark {
    display: none !important;
  }

  .table-toolbar,
  .row-actions {
    display: none !important;
  }

  .table-wrapper {
    border: 1px solid #000000;
    overflow: hidden;
    background: #ffffff;
  }

  table {
    width: 100%;
    font-size: 0.76rem;
  }

  th,
  td {
    padding: 0.25rem 0.28rem;
    page-break-inside: avoid;
    color: #1e1e1e;
  }

  th {
    background: #8faed3;
    color: #10223d;
  }

  tr {
    page-break-inside: avoid;
  }

  .totals-panel {
    margin-top: 0.45rem;
    gap: 0.2rem;
  }

  .totals-row {
    font-size: 0.84rem;
  }

  .footer {
    margin-top: 0.5rem;
    padding: 0.5rem 0.7rem;
    background: #f3e7c8;
    color: #1e1e1e;
  }

  .table-wrapper th:last-child,
  .table-wrapper td:last-child {
    display: none !important;
  }
}

body.exporting .table-toolbar,
body.exporting .row-actions,
body.exporting .actions-head {
  display: none !important;
}
