/* ===================== ION-Green Quotation Generator ===================== */
:root {
  --brand: #3a2d7d;          /* ION-Green deep purple */
  --brand-light: #ecebf7;
  --accent: #6fb52b;         /* ION-Green leaf green */
  --ink: #1c1c28;
  --muted: #5b6072;
  --line: #d7dae6;
  --bg: #eef0f6;
  --page-w: 794px;           /* ~A4 at 96dpi */
  --page-h: 1123px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

/* ---------- App header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.app-header__brand { display: flex; align-items: center; gap: 14px; }
.app-header__brand img { height: 40px; }
.app-header__brand h1 { font-size: 17px; margin: 0; color: var(--brand); }
.app-header__brand p { margin: 0; font-size: 12px; color: var(--muted); }
.app-header__actions { display: flex; gap: 10px; }

/* ---------- Buttons ---------- */
.btn {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: #16226e; }
.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover { filter: brightness(0.93); }
.btn--ghost { background: #fff; color: var(--brand); border-color: var(--line); }
.btn--ghost:hover { background: var(--brand-light); }
.btn--sm { padding: 6px 12px; font-size: 12px; }

/* ---------- Layout ---------- */
.layout { display: flex; align-items: flex-start; }

/* ---------- Form panel ---------- */
.form-panel {
  position: sticky;
  top: 61px;
  width: 360px;
  flex: 0 0 360px;
  height: calc(100vh - 61px);
  overflow-y: auto;
  padding: 20px;
  background: #fff;
  border-right: 1px solid var(--line);
}
.form-section { margin-bottom: 22px; }
.form-section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand);
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--brand-light);
}
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input,
.field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}
.field input:focus,
.field select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.field input:disabled { background: #f1f2f6; color: #9aa0b0; cursor: not-allowed; }
.field small { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }
.hint-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: #eef7e6;
  border-radius: 4px;
  padding: 1px 6px;
  vertical-align: middle;
}
.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.toggle-row input { width: auto; margin: 0; cursor: pointer; }
.toggle-row span { user-select: none; }
.amount-words-out {
  display: block;
  padding: 8px 10px;
  background: var(--brand-light);
  border-radius: 6px;
  font-size: 12px;
  font-style: italic;
  color: var(--brand);
  min-height: 20px;
}

/* ---------- Items editor ---------- */
.items-editor { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.item-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.9fr 0.7fr 20px;
  gap: 6px;
  align-items: center;
}
.item-row input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 12px;
  font-family: inherit;
}
.item-row .del {
  cursor: pointer;
  border: none;
  background: transparent;
  color: #c0392b;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

/* ---------- Preview ---------- */
.preview {
  flex: 1;
  padding: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.page {
  position: relative;
  width: var(--page-w);
  min-height: var(--page-h);
  background: #fff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Repeating branded header on each page */
.page__header {
  height: 92px;
  flex: 0 0 92px;
  background:
    url("../images/logo.png") 32px center / auto 56px no-repeat;
  border-bottom: 3px solid var(--brand);
  position: relative;
}
.page__header::after {
  content: "0771-3147554  |  +91-9202836627\A info@ion-green.com  |  www.ion-green.com\A GSTIN: 22AAGCI1079Q2Z7\A CIN: U31908CT2021PTC011524";
  white-space: pre;
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--muted);
  text-align: right;
  line-height: 1.5;
}

/* Repeating branded footer */
.page__footer {
  height: 52px;
  flex: 0 0 52px;
  margin-top: auto;
  border-top: 3px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  font-size: 10.5px;
  color: var(--muted);
}
.page__footer::before { content: "ION-Green Energy Pvt Ltd"; font-weight: 600; color: var(--brand); }
.page__footer::after { content: "www.ion-green.com"; }

.page__body { flex: 1; padding: 22px 36px 10px; }

/* ---------- Document typography ---------- */
.doc-title {
  text-align: center;
  color: var(--brand);
  letter-spacing: 0.18em;
  font-size: 22px;
  margin: 4px 0 20px;
}
.meta-row { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.meta-to p, .meta-info p { margin: 0 0 2px; }
.meta-label { color: var(--muted); }
.meta-info { text-align: right; font-size: 13px; }
.subject {
  background: var(--brand-light);
  border-left: 4px solid var(--brand);
  padding: 10px 12px;
  margin: 14px 0;
}
.page__body p { margin: 0 0 10px; text-align: justify; }

.figure { text-align: center; margin: 18px 0; }
.figure img { max-width: 70%; height: auto; }
.figure figcaption { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 6px; }

.section-heading {
  color: var(--brand);
  font-size: 14px;
  margin: 18px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

/* ---------- Tables ---------- */
.scope-table, .bank-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 4px;
  font-size: 12.5px;
}
.scope-table th, .bank-table th {
  background: var(--brand);
  color: #fff;
  padding: 7px 8px;
  text-align: left;
  font-weight: 600;
}
.scope-table td, .bank-table td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  vertical-align: top;
}
.scope-table tbody tr:nth-child(even) td { background: #fafbff; }
.scope-table th:first-child, .scope-table td:first-child { width: 42px; text-align: center; }
.scope-table th:last-child, .scope-table td:last-child { width: 60px; text-align: center; }

.bullets { margin: 6px 0 10px; padding-left: 20px; }
.bullets li { margin-bottom: 5px; text-align: justify; }

.amount-box {
  margin: 16px 0;
  padding: 12px 14px;
  background: #fff7ef;
  border: 1px solid var(--accent);
  border-radius: 6px;
}
.amount-box p { margin: 0 0 4px; }
.amount-box p:last-child { margin-bottom: 0; }

.signature { margin-top: 60px; }
.signature p { margin: 0; }

/* ---------- Intake / Welcome modal ---------- */
.btn--block { width: 100%; margin-top: 8px; padding: 11px 16px; }

.intake-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(28, 28, 40, 0.55);
  backdrop-filter: blur(3px);
}
.intake-overlay.is-hidden { display: none; }

.intake-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 14px;
  padding: 28px 28px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: intakePop 0.18s ease-out;
}
@keyframes intakePop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.intake-logo { height: 46px; display: block; margin: 0 auto 14px; }
.intake-card h2 { text-align: center; color: var(--brand); margin: 0 0 4px; font-size: 20px; }
.intake-sub { text-align: center; color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.intake-card .field { margin-bottom: 16px; }
.intake-card label { font-weight: 600; color: var(--ink); }

/* ---------- Records drawer ---------- */
.records-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  justify-content: flex-end;
  background: rgba(28, 28, 40, 0.45);
}
.records-overlay.is-hidden { display: none; }

.records-panel {
  width: 460px;
  max-width: 92vw;
  height: 100%;
  background: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.2);
  animation: recordsSlide 0.18s ease-out;
}
@keyframes recordsSlide {
  from { transform: translateX(30px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}
.records-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.records-head h2 { margin: 0; font-size: 17px; color: var(--brand); }
.records-close {
  border: none;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.records-close:hover { color: var(--ink); }

.records-search {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.records-search input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
}
.records-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }

.records-status { padding: 10px 20px 0; margin: 0; font-size: 12px; color: var(--muted); }

.records-list { flex: 1; overflow-y: auto; padding: 12px 20px 20px; }

.record-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 14px;
  margin-bottom: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.record-card:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06); }
.record-card__top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.record-card__no { font-weight: 700; color: var(--brand); font-size: 13px; }
.record-card__amt { font-weight: 700; color: var(--accent); white-space: nowrap; }
.record-card__name { margin: 3px 0 2px; font-size: 14px; }
.record-card__meta { font-size: 12px; color: var(--muted); }
.record-card__tags { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.record-tag {
  font-size: 10.5px;
  background: var(--brand-light);
  color: var(--brand);
  border-radius: 4px;
  padding: 2px 7px;
}
.record-card__actions { margin-top: 10px; display: flex; gap: 8px; }
.records-empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 13px; }

/* ---------- Print ---------- */
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .no-print { display: none !important; }
  .layout { display: block; }
  .preview { padding: 0; gap: 0; }
  .page {
    width: 100%;
    min-height: 100vh;
    box-shadow: none;
    page-break-after: always;
  }
  .page:last-child { page-break-after: auto; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .layout { flex-direction: column; }
  .form-panel { position: static; width: 100%; flex: none; height: auto; border-right: none; border-bottom: 1px solid var(--line); }
  .preview { padding: 16px; }
  .page { width: 100%; max-width: var(--page-w); }
}
