:root {
  --brand-orange: #FF5A00;
  --brand-orange-deep: #C44500;
  --brand-green: #2E8B00;
  --brand-green-deep: #1A5C00;
  --bg: #f4f1ec;
  --bg-elevated: #ffffff;
  --bg-subtle: #ece8e1;
  --text: #1a1a1a;
  --text-secondary: #5a5752;
  --text-tertiary: #7a766f;
  --border: #d8d2c8;
  --border-strong: #1a1a1a;
  --border-subtle: #e6e1d8;
  --fill-secondary: #d9d4cb;
  --turf: #3b8c2a;
  --beds: #d97706;
  --edge: #0f766e;
  --info-bg: #eef6ff;
  --info-border: #b8d4f0;
  --info-text: #1e3a5f;
  --shadow: 0 8px 24px rgba(26, 26, 26, 0.08);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-synthesis: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.app {
  width: min(430px, 100%);
  margin: 0 auto;
  padding: calc(0.75rem + var(--safe-top)) 0.9rem calc(1.5rem + var(--safe-bottom));
}

.draft-banner {
  background: #fff4e5;
  border: 1px solid #f0c98a;
  color: #6a4300;
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  font-size: 0.92rem;
  margin-bottom: 0.85rem;
}

.header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.85rem;
}

.header img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #111;
  border: 1px solid rgba(255, 90, 0, 0.45);
}

.header h1 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.25;
  font-weight: 700;
}

.header p {
  margin: 0.15rem 0 0;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.switch {
  display: flex;
  gap: 0.35rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem;
  margin-bottom: 0.95rem;
  position: sticky;
  top: var(--safe-top);
  z-index: 5;
}

.switch button {
  flex: 1;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  padding: 0.45rem 0.5rem;
}

.switch button[aria-pressed="true"] {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(26, 26, 26, 0.12);
}

.section {
  margin-bottom: 1.1rem;
}

.section-title {
  margin: 0 0 0.55rem;
  font-size: 1.12rem;
  font-weight: 700;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1rem 1.2rem;
  box-shadow: var(--shadow);
}

.estimate-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.company {
  font-size: 1.2rem;
  font-weight: 700;
}

.estimate-label {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.15rem;
}

.customer-meta {
  color: var(--text-secondary);
  font-size: 0.92rem;
  text-align: right;
}

.phone {
  margin-top: 0.15rem;
}

.scope {
  margin-top: 1.15rem;
  font-size: 1rem;
}

.lines {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.95rem;
}

.lines th,
.lines td {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.lines th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.lines .num,
.lines th.num {
  text-align: right;
  white-space: nowrap;
  padding-left: 0.6rem;
}

.lines .work {
  padding-right: 0.5rem;
}

.lines tfoot td {
  border-bottom: 0;
  font-weight: 700;
  padding-top: 0.7rem;
  font-size: 1.05rem;
}

.sign-label {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 650;
}

.pad {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafafa;
  touch-action: none;
  cursor: crosshair;
  -webkit-user-select: none;
  user-select: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn {
  min-height: 48px;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  font: inherit;
  font-size: 1rem;
  font-weight: 650;
  cursor: pointer;
  flex: 1 1 auto;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand-orange);
  color: #fff;
  border: 0;
}

.btn-primary:not(:disabled):active {
  background: var(--brand-orange-deep);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.hint {
  margin-top: 0.65rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.flow {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.flow-node {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
}

.flow-node strong {
  display: block;
  font-size: 0.98rem;
}

.flow-node span {
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.flow-arrow {
  color: var(--text-tertiary);
  font-size: 0.82rem;
  padding: 0 0.2rem;
}

.callout {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info-text);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  font-size: 0.92rem;
}

.callout strong {
  display: block;
  margin-bottom: 0.2rem;
}

.tool-row,
.depth-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.75rem;
  align-items: center;
}

.seg {
  display: flex;
  flex: 1;
  gap: 0.3rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.22rem;
}

.seg button {
  flex: 1;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  padding: 0.35rem 0.3rem;
}

.seg button[aria-pressed="true"] {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(26, 26, 26, 0.1);
}

.depth-row .label {
  font-size: 0.95rem;
  font-weight: 600;
  margin-right: 0.15rem;
}

.map-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem;
  margin-bottom: 0.85rem;
}

.map-wrap h3,
.areas h3,
.block h3 {
  margin: 0 0 0.55rem;
  font-size: 1rem;
}

.map {
  display: block;
  width: 100%;
  height: auto;
}

.map [data-area] {
  cursor: pointer;
}

.lede,
.note {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin: 0 0 0.7rem;
}

.area-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0.7rem 0;
}

.area-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  cursor: pointer;
  min-height: 64px;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
}

.area-row.selected {
  border-color: var(--border-strong);
}

.area-row .name {
  font-weight: 650;
  font-size: 0.98rem;
}

.area-row .meta {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.1rem;
}

.toggle {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  flex-shrink: 0;
}

.toggle-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.switch-ctl {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #cfc9bf;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.switch-ctl[aria-checked="true"] {
  background: var(--brand-green);
}

.switch-ctl::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.switch-ctl[aria-checked="true"]::after {
  transform: translateX(20px);
}

.pulled,
.selected-line {
  font-size: 0.92rem;
  margin: 0.55rem 0;
}

.block {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 0.85rem 1rem;
  margin-bottom: 0.85rem;
}

.line-card {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
  margin-bottom: 0.5rem;
}

.line-card .top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}

.line-card .title {
  font-weight: 650;
}

.kind {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.kind.product {
  background: #e8f4e4;
  color: var(--brand-green-deep);
}

.line-card .from {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0.2rem 0 0.45rem;
}

.line-card .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 0.6rem;
  font-size: 0.88rem;
}

.line-card .grid span {
  color: var(--text-tertiary);
}

.totals {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.98rem;
}

.totals td {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.totals td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.totals tr:last-child td {
  border-bottom: 0;
  font-weight: 700;
  padding-top: 0.55rem;
}

.po-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.po-table th,
.po-table td {
  padding: 0.45rem 0.3rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.po-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

.po-table .num {
  text-align: right;
  white-space: nowrap;
}

.po-table tfoot td {
  border-bottom: 0;
  font-weight: 700;
  padding-top: 0.55rem;
}

.scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

[hidden] {
  display: none !important;
}
