@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;600;700;800&display=swap');

* { box-sizing: border-box; }

:root { --gutter: 20px; }
@media (min-width: 860px) { :root { --gutter: 32px; } }

body {
  margin: 0;
  font-family: 'Nunito Sans', sans-serif;
  background: #F5F4ED;
  color: #141413;
}

input, select, button {
  font-family: inherit;
  font-size: 14px;
}

input:focus, select:focus {
  outline: none;
  border-color: #002440;
}

/* ---------- Login gate ---------- */

.gate-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate-card {
  background: #FFFFFF;
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 8px 30px rgba(0,36,64,0.08);
  border: 0.5px solid rgba(0,36,64,0.1);
  text-align: center;
}

.gate-logo {
  height: 34px;
  width: auto;
  margin-bottom: 20px;
}

.gate-card h1 {
  font-size: 20px;
  color: #002440;
  margin: 0 0 6px;
}

.gate-sub {
  font-size: 13px;
  color: #5E5D59;
  margin: 0 0 20px;
}

.gate-error {
  background: #FBEAEA;
  color: #A64D4D;
  font-size: 13px;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.gate-form label {
  font-size: 12px;
  font-weight: 700;
  color: #5E5D59;
}

.gate-form input {
  width: 100%;
  border: 1px solid rgba(0,36,64,0.2);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 4px;
}

.gate-form button {
  margin-top: 8px;
  background: #002440;
  color: #FFFFFF;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-weight: 700;
  cursor: pointer;
}

.gate-form button:hover { background: #013259; }

.gate-footnote {
  margin-top: 18px;
  font-size: 11px;
  color: #9C9A92;
}

/* ---------- App shell ---------- */

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #F5F4ED;
  transition: max-width 0.15s ease;
}

@media (min-width: 860px) {
  .app { max-width: 1080px; box-shadow: 0 0 0 1px rgba(0,36,64,0.06); }
  body { background: #E8E6DC; }
}

.app-header { background: #FFFFFF; }

.header-top {
  padding: 16px var(--gutter) 12px;
  border-bottom: 3px solid #F49700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-top .logo { height: 28px; width: auto; }

.logout-link {
  font-size: 12px;
  color: #5E5D59;
  text-decoration: none;
}
.logout-link:hover { text-decoration: underline; }

.header-bottom {
  background: #002440;
  color: #FFFFFF;
  padding: 14px var(--gutter) 18px;
}

.header-bottom .addr {
  font-size: 12px;
  color: #E3DACC;
  line-height: 1.4;
}

.header-bottom .tagline {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 700;
  color: #F49700;
}

.app-body {
  flex: 1;
  padding: var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 24px;
}

@media (min-width: 860px) {
  #rowsContainer {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
    align-items: start;
  }
  .row-card { margin-bottom: 0; }
}

.card {
  background: #FFFFFF;
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 0.5px solid rgba(0,36,64,0.12);
}

.card h2 {
  font-size: 14px;
  font-weight: 700;
  color: #002440;
  margin: 0;
}

.card label, .row-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #5E5D59;
}

.card input, .row-card input, .row-card select {
  border: 1px solid rgba(0,36,64,0.2);
  border-radius: 8px;
  padding: 9px 10px;
  width: 100%;
}

/* ---------- Row cards ---------- */

.row-card {
  background: #FFFFFF;
  border: 0.5px solid rgba(0,36,64,0.15);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.row-head span {
  font-weight: 700;
  font-size: 14px;
  color: #002440;
}

.remove-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #9C9A92;
}
.remove-btn:disabled { opacity: 0.3; cursor: default; }

.field-row { display: flex; gap: 10px; }
.field-row > label { flex: 1; }

.section-divider {
  height: 1px;
  background: rgba(0,36,64,0.1);
  border: none;
  margin: 0;
}

.section-title {
  font-weight: 700;
  font-size: 13px;
  color: #002440;
}

.price-field input {
  border-color: rgba(244,151,0,0.5);
}

.summary-box {
  background: #F5F4ED;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #002440;
}

.summary-line {
  display: flex;
  justify-content: space-between;
}

.summary-line.total {
  font-weight: 700;
  border-top: 1px solid rgba(0,36,64,0.15);
  padding-top: 4px;
  margin-top: 2px;
}

.glass-combined {
  font-size: 12px;
  color: #002440;
  background: #F5F4ED;
  border-radius: 8px;
  padding: 8px 10px;
  line-height: 1.5;
}

.pane-hint { font-size: 10px; color: #9C9A92; font-weight: 400; }

.dashed-btn {
  background: #FFFFFF;
  border: 1.5px dashed #F49700;
  color: #F49700;
  font-weight: 700;
  font-size: 14px;
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
}

.app-footer {
  position: sticky;
  bottom: 0;
  background: #FFFFFF;
  border-top: 1px solid rgba(0,36,64,0.12);
  padding: 14px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.footer-label { font-size: 13px; color: #5E5D59; }
.footer-total { font-size: 20px; font-weight: 800; color: #002440; }

.print-btn {
  background: #002440;
  color: #FFFFFF;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.print-btn:hover { background: #013259; }

/* ---------- Print output ---------- */

#printArea { display: none; }

@media print {
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 0;
  }
  .print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #002440;
    padding-bottom: 14px;
    margin-bottom: 18px;
  }
  .print-header img { height: 30px; }
  .print-header .addr { font-size: 11px; color: #5E5D59; margin-top: 6px; }
  .print-header .contact { font-size: 11px; color: #5E5D59; margin-top: 4px; }
  .print-title { text-align: right; }
  .print-title .doc-title { font-size: 20px; font-weight: 800; color: #F49700; }
  .print-title div { font-size: 11px; color: #5E5D59; }
  .print-customer { display: flex; gap: 30px; margin-bottom: 16px; }
  .print-customer .label { font-size: 10px; text-transform: uppercase; color: #9C9A92; font-weight: 700; }
  .print-customer .value { font-size: 14px; color: #002440; font-weight: 700; }
  table.print-table { border-collapse: collapse; width: 100%; font-size: 10.5px; }
  table.print-table th, table.print-table td { text-align: left; padding: 6px 4px; border-bottom: 1px solid rgba(0,36,64,0.15); }
  table.print-table thead th { border-bottom: 1.5px solid #002440; color: #002440; }
  table.print-table td.num, table.print-table th.num { text-align: right; }
  .print-totals { display: flex; justify-content: flex-end; margin-top: 14px; }
  .print-totals .box { width: 240px; }
  .print-totals .line { display: flex; justify-content: space-between; font-size: 12px; color: #5E5D59; }
  .print-totals .line.grand { font-size: 16px; font-weight: 800; color: #002440; border-top: 2px solid #002440; padding-top: 6px; margin-top: 6px; }
  .print-footnote { margin-top: 16px; padding-top: 12px; border-top: 1px solid rgba(0,36,64,0.15); font-size: 10px; color: #9C9A92; line-height: 1.5; }
  @page { margin: 14mm; }
}
