/* Murphy Property Services — Fence Pricing Tool. Dark UI, forest-green accent. */
:root {
  --bg: #0a0a0a;
  --bg-elevated: #141414;
  --bg-surface: #1a1a1a;
  --bg-subtle: #111111;
  --text: #ededed;
  --text-muted: #a1a1a1;
  --text-faint: #737373;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --accent: #78c493;
  --accent-soft: rgba(120, 196, 147, 0.12);
  --accent-line: rgba(120, 196, 147, 0.24);
  --accent-deep: #2f6b45;
  --warn: #f5c26b;
  --warn-soft: rgba(245, 194, 107, 0.1);
  --white: #ffffff;
  --black: #0a0a0a;
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --max: 80rem;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(ellipse 70% 40% at 50% -10%, rgba(120, 196, 147, 0.07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.5); outline-offset: 2px; }

/* Top bar */
.topbar { border-bottom: 1px solid var(--border); background: rgba(10, 10, 10, 0.7); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; }
.topbar__inner { width: min(100% - 2.5rem, var(--max)); margin-inline: auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 0; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--white); }
.brand__logo { height: 30px; width: auto; max-width: 9rem; object-fit: contain; display: block; }
.brand__wordmark { display: inline-flex; align-items: baseline; gap: 0.4rem; letter-spacing: -0.02em; line-height: 1; white-space: nowrap; }
.brand__name { font-weight: 700; font-size: 1.05rem; color: var(--white); position: relative; padding-left: 0.85rem; }
.brand__name::before { content: ""; position: absolute; left: 0; top: 50%; width: 0.45rem; height: 0.45rem; margin-top: -0.25rem; border-radius: 2px; background: var(--accent); box-shadow: 0 0 12px rgba(120, 196, 147, 0.45); }
.brand__logo + .brand__wordmark .brand__name { padding-left: 0; }
.brand__logo + .brand__wordmark .brand__name::before { display: none; }
.brand__sub { font-weight: 500; font-size: 0.95rem; color: var(--text-muted); }
.muted { color: var(--text-muted); font-weight: 500; }
.topbar__actions { display: flex; gap: 0.5rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.75rem 1.35rem; border-radius: 999px; font-family: inherit; font-size: 0.9375rem;
  font-weight: 500; letter-spacing: -0.01em; text-decoration: none; border: 1px solid transparent; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn--sm { padding: 0.45rem 1rem; font-size: 0.875rem; }
.btn--primary { background: var(--white); color: var(--black); border-color: var(--white); }
.btn--primary:hover { background: #e8e8e8; border-color: #e8e8e8; }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.28); color: var(--white); }

/* Page */
.app { width: min(100% - 2.5rem, var(--max)); margin: 0 auto; padding: 2.25rem 0 4rem; }
.app__head { margin-bottom: 1.75rem; max-width: 46rem; }
.eyebrow { margin: 0 0 0.6rem; font-size: 0.75rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
h1 { margin: 0 0 0.6rem; font-size: clamp(1.85rem, 3.6vw, 2.5rem); line-height: 1.1; letter-spacing: -0.035em; font-weight: 600; color: var(--white); }
.lead { margin: 0; color: var(--text-muted); }
.lead strong { color: var(--text); font-weight: 500; }

.layout { display: grid; grid-template-columns: minmax(19rem, 25rem) minmax(0, 1fr); gap: 1.25rem; align-items: start; }

.panel { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.panel--inputs { position: sticky; top: 4.5rem; max-height: calc(100vh - 5.5rem); overflow: auto; scrollbar-width: thin; }
.panel__title { margin: 0 0 1rem; font-size: 0.8125rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }

/* Form */
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.85rem; }
.field label, .group legend { font-size: 0.8125rem; font-weight: 500; color: var(--text); }
.hint { color: var(--text-faint); font-weight: 400; font-size: 0.78rem; }
p.hint { margin: 0.35rem 0 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.75rem; }
input[type="number"], input[type="text"], input[type="search"], input[type="password"], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg-subtle);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0.55rem 0.7rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
select {
  appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23a1a1a1' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.75rem center;
}
select option { background: var(--bg-surface); color: var(--text); }
input[type="number"]:hover, input[type="text"]:hover, input[type="search"]:hover, input[type="password"]:hover, textarea:hover, select:hover { border-color: rgba(255, 255, 255, 0.24); }
input[type="number"]:focus, input[type="text"]:focus, input[type="search"]:focus, input[type="password"]:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); background: #0d0d10; box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled { opacity: 0.45; cursor: not-allowed; }
input::placeholder { color: var(--text-faint); }

.group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.85rem 0.85rem 0.3rem; margin: 0 0 0.85rem; background: rgba(255, 255, 255, 0.015); }
.group legend { padding: 0 0.35rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.72rem; }
.group > .hint:last-child { margin-bottom: 0.6rem; }

.check { display: flex; align-items: center; gap: 0.55rem; font-size: 0.875rem; margin: 0 0 0.85rem; cursor: pointer; }
.check input { width: 1rem; height: 1rem; accent-color: var(--accent); margin: 0; }

.estimate { display: flex; justify-content: space-between; align-items: baseline; padding: 0.55rem 0.7rem; margin-bottom: 0.75rem; border-radius: var(--radius-sm); background: var(--accent-soft); font-size: 0.8125rem; color: var(--text-muted); }
.estimate__hint { margin: -0.45rem 0 0.75rem !important; }
.estimate strong { font-size: 1.1rem; color: var(--white); font-variant-numeric: tabular-nums; }

body.is-snake .posts-only { display: none !important; }

/* Prices panel */
.prices { margin-top: 0.5rem; border-top: 1px solid var(--border); padding-top: 0.85rem; }
.prices summary { cursor: pointer; font-weight: 500; font-size: 0.9rem; list-style: none; display: flex; align-items: baseline; gap: 0.35rem; flex-wrap: wrap; }
.prices summary::-webkit-details-marker { display: none; }
.prices summary::before { content: "▸"; color: var(--text-muted); transition: transform 0.15s ease; display: inline-block; }
.prices[open] summary::before { transform: rotate(90deg); }
.prices[open] summary { margin-bottom: 0.85rem; }
.price-fields { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.85rem; }
.price-row { display: grid; grid-template-columns: 1fr 8.5rem; align-items: center; gap: 0.6rem; font-size: 0.8125rem; padding: 0.4rem 0.5rem; border-radius: 8px; }
.price-row.is-missing { background: var(--warn-soft); }
.price-row__label { color: var(--text-muted); display: flex; flex-direction: column; }
.price-row__input { display: flex; align-items: center; gap: 0.3rem; color: var(--text-faint); }
.price-row__input input { padding: 0.35rem 0.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.price-row .unit { font-size: 0.72rem; white-space: nowrap; }
.flag { font-style: normal; font-size: 0.72rem; color: var(--warn); }
.flag--edit { color: var(--accent); }

/* Results */
.results__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.25rem 1rem; margin-bottom: 0.75rem; }
.results__head .panel__title { margin: 0; }
.summary { margin: 0; font-size: 0.8125rem; color: var(--text-muted); }

.warnings:empty { display: none; }
.warnings { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; }
.warning { margin: 0; font-size: 0.8125rem; color: var(--text-muted); padding: 0.5rem 0.75rem; border-left: 2px solid var(--border-strong); background: rgba(255, 255, 255, 0.02); border-radius: 0 8px 8px 0; }
.warning--alert { color: var(--warn); border-left-color: var(--warn); background: var(--warn-soft); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.875rem; }
.table th, .table td { padding: 0.7rem 0.8rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table thead th { font-size: 0.72rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); background: var(--bg-subtle); }
.table td:first-child { white-space: normal; min-width: 11rem; }
.table .num { text-align: right; }
.table .strong { color: var(--white); font-weight: 500; }
.item { display: block; color: var(--text); font-weight: 500; }
.item__detail { display: block; color: var(--text-faint); font-size: 0.75rem; }
.table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
.table tbody tr.is-zero td { color: var(--text-faint); }
.table tbody tr.is-zero .item { color: var(--text-muted); }
.table tbody tr.is-missing td { background: var(--warn-soft); }
.table tbody tr.is-missing .item__detail { color: var(--warn); }
.table tfoot th, .table tfoot td { border-bottom: 0; font-weight: 600; color: var(--white); background: var(--bg-subtle); }

.grand { margin-top: 1rem; margin-left: auto; max-width: 22rem; display: flex; flex-direction: column; gap: 0.4rem; }
.grand > div { display: flex; justify-content: space-between; font-size: 0.9rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.grand strong { color: var(--text); font-weight: 500; }
.grand__total { margin-top: 0.35rem; padding-top: 0.6rem; border-top: 1px solid var(--border-strong); }
.grand__total span { color: var(--white); font-weight: 500; }
.grand__total strong { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.03em; color: var(--white); }

.note { margin: 1.1rem 0 0; font-size: 0.8125rem; color: var(--text-muted); padding: 0.65rem 0.8rem; border-radius: var(--radius-sm); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.note--faint { background: transparent; border: 0; padding: 0; color: var(--text-faint); font-size: 0.75rem; margin-top: 0.6rem; }

.coming-soon { text-align: center; padding: 3.5rem 1.5rem; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.coming-soon h3 { margin: 0.9rem 0 0.4rem; font-size: 1.15rem; letter-spacing: -0.02em; font-weight: 600; color: var(--white); }
.coming-soon p { margin: 0 auto; color: var(--text-muted); max-width: 28rem; }
.coming-soon__badge { display: inline-block; padding: 0.25rem 0.7rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 0.72rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; }


textarea { resize: vertical; min-height: 2.6rem; line-height: 1.45; }
.is-invalid { border-color: #f08a8a !important; box-shadow: 0 0 0 3px rgba(240, 138, 138, 0.12) !important; }
.req { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

/* Tabs */
.tabs { display: flex; gap: 0.25rem; padding: 0.2rem; border: 1px solid var(--border); border-radius: 999px; background: rgba(255, 255, 255, 0.02); }
.tab { font: inherit; font-size: 0.85rem; font-weight: 500; color: var(--text-muted); background: transparent; border: 0; border-radius: 999px; padding: 0.35rem 0.9rem; cursor: pointer; transition: background 0.15s ease, color 0.15s ease; }
.tab:hover { color: var(--white); }
.tab.is-active { background: rgba(255, 255, 255, 0.09); color: var(--white); }

.btn--xs { padding: 0.3rem 0.7rem; font-size: 0.78rem; }
.btn--danger:hover { border-color: rgba(240, 138, 138, 0.5); color: #f5a3a3; background: rgba(240, 138, 138, 0.08); }

/* Loaded quote banner */
.loaded-banner { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; flex-wrap: wrap; margin: -0.5rem 0 1.25rem; padding: 0.7rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--accent-line); background: var(--accent-soft); font-size: 0.875rem; }
.loaded-banner__label { display: block; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); font-weight: 500; }
.loaded-banner strong { color: var(--white); font-weight: 600; }
.loaded-banner .hint { display: block; }

/* Save card */
.save-card { margin-top: 1.4rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.015); }
.save-card__title { margin: 0 0 0.75rem; font-size: 0.8125rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.save-card__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.save-status { font-size: 0.8125rem; color: var(--text-muted); }
.save-status--ok { color: #8fd8a8; }
.save-status--error { color: #f5a3a3; }

/* Quotes view */
.quotes-toolbar { display: flex; gap: 0.6rem; margin-bottom: 0.75rem; }
.quotes-toolbar input { flex: 1; }
.quotes-status { margin: 0 0 0.75rem; font-size: 0.8125rem; color: var(--text-muted); }
.quotes-status--error { color: #f5a3a3; }
.quotes-table td.wrap { white-space: normal; min-width: 9rem; }
.quotes-table td.actions { text-align: right; }
.quotes-table td.actions .btn + .btn { margin-left: 0.3rem; }
.quotes-table tr.is-current td { background: var(--accent-soft); }
.quotes-table tbody tr:last-child td { border-bottom: 0; }

/* Dialogs */
.modal { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg-elevated); color: var(--text); padding: 0; width: min(100% - 2rem, 26rem); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.modal--wide { width: min(100% - 2rem, 38rem); }
.modal::backdrop { background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(3px); }
.modal__body { padding: 1.25rem; }
.modal__title { margin: 0 0 0.35rem; font-size: 1.1rem; font-weight: 600; letter-spacing: -0.02em; color: var(--white); }
.modal .hint { display: block; margin-bottom: 0.9rem; }
.modal__error { min-height: 1.2em; margin: 0 0 0.5rem; font-size: 0.8125rem; color: #f5a3a3; }
.modal__actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
.modal .table-wrap { max-height: 50vh; overflow: auto; }

.print-only { display: none; }

/* Responsive: stack */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .panel--inputs { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 760px) {
  .topbar__inner { flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; justify-content: center; }
  .tab { flex: 1; }
  .quotes-table thead { display: none; }
  .quotes-table, .quotes-table tbody, .quotes-table tr, .quotes-table td { display: block; width: 100%; }
  .quotes-table tr { padding: 0.75rem 0.85rem; border-bottom: 1px solid var(--border); }
  .quotes-table td { border: 0; padding: 0.15rem 0; white-space: normal; text-align: left !important; }
  .quotes-table td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 6.5rem; color: var(--text-faint); font-size: 0.75rem; }
  .quotes-table td:first-child::before { display: none; }
  .quotes-table td.actions { padding-top: 0.5rem; }
}
@media (max-width: 560px) {
  .app { width: min(100% - 1.5rem, var(--max)); padding-top: 1.5rem; }
  .topbar__inner { width: min(100% - 1.5rem, var(--max)); }
  .brand__sub { font-size: 0.85rem; }
  .panel { padding: 1rem; }
  .table th, .table td { padding: 0.55rem 0.55rem; }
  .grand { max-width: none; }
}

/* Print / Save PDF: light, compact, inputs summarized via the results header */
@media print {
  @page { margin: 14mm; }
  :root { --text: #111; --text-muted: #444; --text-faint: #666; --border: #ddd; --border-strong: #bbb; --white: #000; }
  body { background: #fff !important; color: #111; font-size: 10.5pt; }
  .no-print, .topbar__actions, .panel--inputs { display: none !important; }
  .topbar { position: static; background: none; border-bottom: 1px solid #ccc; backdrop-filter: none; }
  .print-only { display: block; }
  .print-date { margin: 0.4rem 0 0; color: #555; font-size: 9pt; }
  .print-customer { margin: 0 0 1rem; font-size: 10.5pt; color: #111; }
  .print-customer:empty { display: none; }
  .print-customer p { margin: 0.3rem 0 0; color: #444; }
  .tabs, .loaded-banner, .save-card, dialog { display: none !important; }
  .layout { display: block; }
  .panel { border: 0; padding: 0; background: none; }
  .app { width: 100%; padding: 1rem 0 0; }
  .lead { display: none; }
  .brand__name { color: #111; }
  .brand__name::before { background: var(--accent-deep); box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .brand__sub { color: #444; }
  h1 { font-size: 20pt; }
  .table th, .table td { padding: 0.4rem 0.6rem; }
  .eyebrow { color: var(--accent-deep); }
  .table-wrap { border: 1px solid #ccc; overflow: visible; }
  .table thead th, .table tfoot th, .table tfoot td { background: #f3f3f3 !important; color: #111; }
  .table tbody tr.is-missing td { background: #fff4dc !important; }
  .table tr { break-inside: avoid; }
  .note { background: #eef6f0; border-color: #cfe5d6; color: #333; }
  .warning { background: none; color: #444; }
  .warning--alert { color: #8a5a00; }
}
