/* DroneWorks QLD quote calculator — mobile-first styles. No external dependencies. */
:root {
  --green-900: #1f3a24;
  --green-800: #2f5233;
  --green-600: #4a7a4e;
  --green-100: #e6efe3;
  --wheat: #e4c66b;
  --wheat-100: #fbf3dc;
  --soil: #7a5a3a;
  --bg: #f5f3ec;
  --card: #ffffff;
  --ink: #1d231e;
  --muted: #5e675f;
  --line: #dcd8cc;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 58, 36, .06), 0 4px 16px rgba(31, 58, 36, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--green-800);
  color: #fff;
  border-bottom: 3px solid var(--wheat);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 38px; height: 38px; flex: none; border-radius: 10px; box-shadow: 0 0 0 2px rgba(255,255,255,.15); }
.brand-name { font-weight: 800; letter-spacing: .02em; font-size: 1.05rem; }
.brand-sub { font-size: .8rem; opacity: .8; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.topbar .btn-ghost svg { width: 18px; height: 18px; }

/* ---------- Banners ---------- */
.banner { padding: 10px 16px; font-size: .9rem; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.banner-example {
  background: repeating-linear-gradient(-45deg, var(--wheat-100), var(--wheat-100) 12px, #f7e9bd 12px, #f7e9bd 24px);
  color: #5a4210; border-bottom: 1px solid #e9d38f;
}
.banner-example strong { text-transform: uppercase; letter-spacing: .03em; }
.banner.inline { display: block; border-radius: 10px; border: 1px solid #e9d38f; margin: 0 0 8px; }
.banner-warn { background: #fdecea; color: var(--danger); }
.linklike { background: none; border: 0; padding: 0; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* ---------- Layout ---------- */
.layout { display: grid; gap: 14px; padding: 14px 12px 110px; max-width: 1040px; margin: 0 auto; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; border: 1px solid #ebe7dc; }
.card-title { margin: 0 0 12px; font-size: 1.1rem; color: var(--green-900); }

/* ---------- Fields ---------- */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.field { margin-bottom: 16px; }
.field > label, legend { display: block; font-weight: 650; font-size: .92rem; margin-bottom: 6px; color: var(--green-900); padding: 0; }
.opt { font-weight: 400; color: var(--muted); font-size: .8rem; margin-left: 4px; }
.opt.req { color: var(--soil); font-weight: 600; }
input[type="text"], input[type="number"], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
  font-size: 16px; /* prevents iOS zoom */
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(74,122,78,.2); }
input.invalid, select.invalid { border-color: var(--danger); background: #fffafa; }
select:disabled { background: #f3f2ee; color: var(--muted); }
.input-unit { display: flex; align-items: stretch; }
.input-unit input { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 1; min-width: 0; }
.input-unit .unit, .input-unit select {
  flex: none; width: auto; min-width: 72px; display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--line); border-left: 0; border-radius: 0 10px 10px 0; background: var(--green-100); color: var(--green-900); font-weight: 600; padding: 0 12px;
}
.hint { margin: 6px 0 0; font-size: .82rem; color: var(--muted); }
.error { margin: 6px 0 0; font-size: .85rem; color: var(--danger); font-weight: 600; min-height: 0; }
.error:empty { display: none; }

/* Segmented radio buttons */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segmented.two { grid-template-columns: 1fr 1fr; }
.segmented.compact { margin-top: 8px; }
.seg { position: relative; display: block; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.seg span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 46px; padding: 6px 8px; border-radius: 10px; border: 1.5px solid var(--line);
  background: #fff; font-weight: 600; font-size: .9rem; cursor: pointer; transition: all .15s;
}
.seg input:checked + span { background: var(--green-800); border-color: var(--green-800); color: #fff; }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px rgba(74,122,78,.35); }
.seg input:disabled + span { opacity: .45; cursor: not-allowed; }

.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--green-800); flex: none; }
.check em { font-style: normal; color: var(--soil); font-weight: 600; font-size: .85rem; }
label[for="setupEvents"] { margin-top: 8px; }

/* ---------- Result ---------- */
.result-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.quote-no { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.result-empty { color: var(--muted); padding: 18px 4px; text-align: center; }
.total-hero {
  background: linear-gradient(135deg, var(--green-800), var(--green-600)); color: #fff;
  border-radius: 12px; padding: 16px; margin-bottom: 12px; position: relative; overflow: hidden;
}
.total-hero::after { content: ""; position: absolute; right: -30px; bottom: -40px; width: 140px; height: 140px; border-radius: 50%; background: rgba(228,198,107,.18); }
.total-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.total-amount { font-size: 2.2rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.total-perha { font-size: .88rem; opacity: .92; margin-top: 2px; }
.is-example .total-hero::before {
  content: "EXAMPLE"; position: absolute; top: 10px; right: 12px; font-size: .7rem; font-weight: 800; letter-spacing: .1em;
  background: var(--wheat); color: #4b3a10; padding: 2px 8px; border-radius: 999px; z-index: 1;
}

.breakdown { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.breakdown th, .breakdown td { padding: 10px 0; border-bottom: 1px solid #eeebe2; vertical-align: top; }
.breakdown th { text-align: left; font-weight: 400; padding-right: 10px; }
.breakdown td { text-align: right; white-space: nowrap; font-weight: 600; }
.line-label { font-weight: 600; }
.line-detail { font-size: .82rem; color: var(--muted); }
.line-note { font-size: .78rem; color: var(--soil); margin-top: 2px; }
.muted-row td, .muted-row .line-label { color: var(--muted); font-weight: 500; }
.breakdown tfoot th { font-weight: 600; }
.breakdown tfoot tr.grand th, .breakdown tfoot tr.grand td { font-size: 1.1rem; font-weight: 800; color: var(--green-900); border-bottom: 0; border-top: 2px solid var(--green-800); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 16px; border-radius: 12px; border: 1.5px solid transparent;
  font-weight: 700; cursor: pointer; text-decoration: none; transition: background .15s, transform .05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--green-800); color: #fff; }
.btn-primary:not(:disabled):hover { background: var(--green-900); }
.btn-secondary { background: #fff; color: var(--green-900); border-color: var(--green-800); }
.btn-ghost { background: transparent; border-color: var(--line); min-height: 40px; padding: 0 12px; }
.btn-small { min-height: 40px; font-size: .9rem; background: var(--green-100); color: var(--green-900); }
.btn-icon { min-height: 40px; width: 40px; padding: 0; background: #f4f1ea; color: var(--muted); align-self: end; }
.btn-danger-link { background: none; color: var(--danger); padding: 0; min-height: 40px; margin-top: 8px; font-weight: 600; text-decoration: underline; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  display: grid; grid-template-columns: auto 1fr 1.3fr; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line);
  backdrop-filter: blur(6px); box-shadow: 0 -4px 16px rgba(0,0,0,.05);
}
.actionbar .btn { padding: 0 10px; font-size: .95rem; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--green-900); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: .9rem;
  transition: all .2s; z-index: 50; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Settings dialog ---------- */
.settings { padding: 0; border: 0; width: 100%; max-width: 760px; height: 100%; max-height: 100%; margin: 0 auto; background: var(--bg); color: var(--ink); }
.settings::backdrop { background: rgba(20, 30, 20, .5); }
.settings form { display: flex; flex-direction: column; height: 100%; }
.settings-head, .settings-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.settings-head { padding-top: calc(12px + env(safe-area-inset-top)); }
.settings-head h2 { margin: 0; font-size: 1.1rem; color: var(--green-900); }
.settings-foot { border-top: 1px solid var(--line); border-bottom: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.settings-foot .btn { flex: 1; }
.settings-body { flex: 1; overflow-y: auto; padding: 14px 16px 24px; -webkit-overflow-scrolling: touch; }
.settings h3 { font-size: .95rem; margin: 20px 0 8px; color: var(--green-900); }
.notice { background: var(--green-100); border-radius: 10px; padding: 10px 12px; font-size: .88rem; margin: 0 0 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sfield { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.sfield input, .sfield select { min-height: 44px; }
.rows { display: grid; gap: 10px; margin-bottom: 8px; }
.srow { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; background: #fff; padding: 10px; border-radius: 12px; border: 1px solid #ebe7dc; }
.srow .wide { grid-column: 1 / -1; }
#productRows .srow { grid-template-columns: 1fr 1fr 1fr; }
#productRows .srow .btn-icon { grid-column: 3; justify-self: end; }
.errors { background: #fdecea; color: var(--danger); border-radius: 10px; padding: 10px 12px; margin-top: 12px; font-size: .88rem; }
.errors ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Larger screens ---------- */
@media (min-width: 820px) {
  .layout { grid-template-columns: 1.1fr 1fr; align-items: start; padding-top: 20px; }
  .result { position: sticky; top: 84px; }
  .actionbar { left: 50%; transform: translateX(-50%); bottom: 16px; max-width: 560px; border-radius: 16px; border: 1px solid var(--line); }
  .settings { height: auto; max-height: 90vh; border-radius: 16px; margin: auto; }
  .srow { grid-template-columns: 2fr 1fr 1fr auto; }
  .srow .wide { grid-column: auto; }
  #productRows .srow { grid-template-columns: 2fr .7fr 1fr 1fr 1fr auto; }
  #productRows .srow .btn-icon { grid-column: auto; }
}

/* ---------- Print: one-page quote ---------- */
.print-quote { display: none; }

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 10.5pt; }
  .app, dialog { display: none !important; }
  .print-quote { display: block; color: #111; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pq-example { border: 2px dashed #b08a1e; color: #7a5c0c; text-align: center; font-weight: 800; letter-spacing: .08em; padding: 4px; margin-bottom: 10px; }
  .pq-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--green-800); padding-bottom: 10px; margin-bottom: 12px; }
  .pq-name { font-size: 20pt; font-weight: 800; color: var(--green-800); }
  .pq-tag { color: #444; margin-bottom: 4px; }
  .pq-contact { color: #333; font-size: 9.5pt; }
  .pq-meta { text-align: right; font-size: 10pt; }
  .pq-doc { font-size: 18pt; font-weight: 800; letter-spacing: .12em; color: var(--soil); }
  .pq-info { display: grid; grid-template-columns: 130px 1fr; gap: 3px 10px; margin: 0 0 12px; }
  .pq-info dt { font-weight: 700; color: #444; }
  .pq-info dd { margin: 0; }
  .pq-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
  .pq-table th { text-align: left; background: var(--green-100); padding: 6px 8px; font-size: 9.5pt; }
  .pq-table th:last-child, .pq-table td:last-child { text-align: right; white-space: nowrap; }
  .pq-table td { padding: 6px 8px; border-bottom: 1px solid #ddd; vertical-align: top; }
  .pq-l { font-weight: 600; }
  .pq-d { font-size: 9pt; color: #555; }
  .pq-table tfoot td { border-bottom: 0; padding: 4px 8px; }
  .pq-table tfoot tr:first-child td { border-top: 1.5px solid #999; padding-top: 8px; }
  .pq-grand td { font-size: 13pt; font-weight: 800; color: var(--green-900); border-top: 2px solid var(--green-800) !important; }
  .pq-perha td { font-size: 9pt; color: #555; }
  .pq-lic { margin-top: 16px; padding: 8px 10px; background: #f6f6f1; border-radius: 6px; page-break-inside: avoid; }
  .pq-lic h4 { margin: 0 0 4px; font-size: 10pt; color: var(--green-800); }
  .pq-lic ul { margin: 0; padding-left: 16px; columns: 2; font-size: 9pt; }
  .pq-disc { font-size: 8.5pt; color: #555; margin-top: 12px; }
  .pq-foot { margin-top: 10px; padding-top: 6px; border-top: 1px solid #ccc; font-size: 8.5pt; color: #666; text-align: center; }
}
