/* v31 Home tabs + Estimates + client proposal page. Tokens from theme.css. */
/* ---------- home: Projects | Estimates | Time ---------- */
.home-tabs { display: flex; gap: 4px; padding: 4px; margin: .25rem 0 1rem; background: var(--surface-3); border: 1px solid var(--line); border-radius: 16px; position: relative; z-index: 1; } /* v32: not sticky - it slid under the sticky app header on iPhone */
.home-tab { flex: 1 1 0; display: flex; align-items: center; justify-content: center; gap: .4rem; min-height: 46px; border-radius: 12px; color: var(--ink-2); font-weight: 700; text-decoration: none; font-size: .98rem; transition: background var(--dur), color var(--dur), box-shadow var(--dur); }
.home-tab:hover { color: var(--ink); }
.home-tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.home-tab.active .icon { color: var(--accent); }
.ht-count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: .78rem; display: inline-grid; place-items: center; }
.home-tab.active .ht-count { background: var(--accent); color: var(--accent-ink); }

/* ---------- list ---------- */
.est-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: 0 0 .9rem; }
.est-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: .75rem 1rem; }
.est-stat b { display: block; font-size: 1.35rem; font-family: var(--font-display); }
.est-stat span { color: var(--muted); font-size: .88rem; }
.est-stat.ok b { color: var(--ok); }
.est-list { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); margin-top: .8rem; }
.est-card { display: block; color: inherit; text-decoration: none; }
.est-card:hover { border-color: var(--accent-line); box-shadow: var(--shadow-2); }
.est-c-top { display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start; }
.est-c-title { min-width: 0; }
.est-c-title small { color: var(--muted); font-weight: 650; font-size: .82rem; }
.est-c-title h3 { margin: .1rem 0 0; overflow-wrap: anywhere; }
.est-c-client { display: flex; align-items: center; gap: .35rem; margin: .45rem 0 .6rem; font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.est-c-addr { overflow: hidden; text-overflow: ellipsis; }
.est-c-foot { display: flex; align-items: center; gap: .6rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.est-c-total { font-size: 1.2rem; font-family: var(--font-display); margin-right: auto; }
.badge.est-st { font-size: .78rem; }
.badge.st-est-draft { background: var(--surface-3); color: var(--ink-2); }
.badge.st-est-sent { background: var(--info-bg); color: var(--info); }
.badge.st-est-signed { background: var(--ok-bg); color: var(--ok); }
.badge.st-est-declined { background: var(--bad-bg); color: var(--bad); }
.est-company-btn { margin-top: 1.2rem; }

/* ---------- editor ---------- */
.est-editor { max-width: 760px; margin: 0 auto; }
.est-topline { display: flex; justify-content: space-between; align-items: center; margin: .1rem 0 -.2rem; }
.est-topline .back-link { padding-left: .2rem; }
.est-head { align-items: flex-start; flex-wrap: nowrap; }
.est-head h1 { font-size: 1.55rem; overflow-wrap: anywhere; }
.est-editor .card { margin-bottom: .9rem; }
.est-card-sec h2 { display: flex; align-items: center; gap: .45rem; font-size: 1.1rem; margin: 0 0 .7rem; }
.est-card-sec h2 .icon { color: var(--accent); }
.est-sec-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.est-sec-head h2 { margin: 0; }
.est-form { display: flex; flex-wrap: wrap; gap: .7rem; }
.est-form .field { flex: 1 1 100%; display: flex; flex-direction: column; gap: .3rem; margin: 0; }
.est-form .field.half { flex: 1 1 calc(50% - .4rem); min-width: 140px; }
.est-form input, .est-form select, .est-form textarea { width: 100%; box-sizing: border-box; }
.est-editor input:disabled, .est-editor select:disabled, .est-editor textarea:disabled { opacity: 1; background: var(--surface-2); color: var(--ink); -webkit-text-fill-color: var(--ink); }

.est-action { border-width: 1.5px; }
.est-action.draft { border-color: var(--accent-line); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }
.est-action.sent { border-color: color-mix(in srgb, var(--info) 35%, var(--line)); }
.est-action.signed { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: linear-gradient(180deg, var(--ok-bg), var(--surface) 75%); }
.est-action.declined { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.est-a-head { display: flex; gap: .7rem; align-items: center; margin-bottom: .8rem; }
.est-a-head b { display: block; font-size: 1.05rem; } .est-a-head small { color: var(--muted); }
.est-a-ic { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 12px; background: var(--surface); color: var(--accent); box-shadow: var(--shadow-1); }
.est-a-ic.ok { color: var(--ok); } .est-a-ic.bad { color: var(--bad); } .est-a-ic.info { color: var(--info); }
.btn.block { width: 100%; justify-content: center; }
.est-sig { display: block; max-width: 280px; width: 100%; height: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin: 0 0 .8rem; }
.est-decline-msg { font-style: italic; }
.est-share { display: grid; gap: .6rem; margin-bottom: .6rem; }
.est-share input { width: 100%; box-sizing: border-box; font-size: .9rem; }
.est-share .btn-row .btn { flex: 1 1 auto; justify-content: center; }
.est-ok { display: flex; align-items: center; gap: .4rem; color: var(--ok); font-weight: 700; }
.est-warn { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; background: var(--warn-bg); color: var(--warn); padding: .6rem .8rem; border-radius: 12px; }

.est-lines { display: grid; gap: .9rem; }
.est-group { display: grid; gap: .55rem; }
.est-g-head { display: flex; align-items: center; gap: .6rem; }
.est-g-name { flex: 1; font-weight: 750; font-size: 1.02rem; border: 0; border-bottom: 1.5px dashed var(--line-2); border-radius: 0; background: transparent; padding: .35rem 0; min-height: 40px; color: var(--ink); }
.est-g-name:focus { outline: none; border-bottom-color: var(--accent); }
.est-g-head small { color: var(--muted); font-weight: 700; }
.est-line { border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius-md); padding: .55rem .6rem .6rem; }
.est-l-top { display: flex; gap: .4rem; align-items: center; }
.est-l-desc { flex: 1; min-width: 0; font-weight: 650; }
.est-l-del { min-height: 40px; min-width: 40px; color: var(--muted); }
.est-l-nums { display: grid; grid-template-columns: 1fr 1.05fr 1.35fr 1.3fr; gap: .4rem; margin-top: .45rem; align-items: end; }
.est-l-f { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.est-l-f > span { font-size: .72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.est-l-f input, .est-l-f select { width: 100%; min-width: 0; box-sizing: border-box; padding-left: .5rem; padding-right: .3rem; }
.est-l-tot { text-align: right; }
.est-l-total { font-size: 1.02rem; min-height: 44px; display: flex; align-items: center; justify-content: flex-end; }
.est-add-line { justify-self: start; }
.est-line-actions { margin-top: .8rem; }

.est-totals { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.est-pct-row { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-bottom: .8rem; }
.est-pct { display: flex; flex-direction: column; gap: .2rem; font-weight: 700; font-size: .9rem; }
.est-pct small { font-weight: 400; opacity: .75; font-size: .76rem; }
.est-pct-in { position: relative; }
.est-pct-in input { width: 100%; box-sizing: border-box; padding-right: 1.8rem; background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.25); }
.est-pct-in input:disabled { background: rgba(255,255,255,.06); -webkit-text-fill-color: #fff; color: #fff; }
.est-pct-in i { position: absolute; right: .7rem; top: 50%; transform: translateY(-50%); font-style: normal; opacity: .7; }
.est-sum { margin: 0; display: grid; gap: .3rem; }
.est-sum div { display: flex; justify-content: space-between; gap: 1rem; }
.est-sum dt { opacity: .8; } .est-sum dd { margin: 0; font-variant-numeric: tabular-nums; }
.est-sum .grand { border-top: 1px solid rgba(255,255,255,.2); padding-top: .5rem; margin-top: .25rem; font-size: 1.3rem; font-weight: 800; }
.est-sum .grand dt { opacity: 1; }
.est-foot { justify-content: space-between; flex-wrap: wrap; margin: .4rem 0 1.5rem; }
.est-problems { padding-left: 1.2rem; }
.est-convert-list { padding-left: 1.1rem; display: grid; gap: .3rem; }
.co-logo-row { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.co-logo-prev { display: flex; align-items: center; gap: .5rem; }
.co-logo-prev img { max-height: 56px; max-width: 160px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }

/* ---------- proposal document (client page + Print / PDF) ---------- */
.pr-page { padding: calc(.8rem + env(safe-area-inset-top, 0px)) .9rem calc(2rem + env(safe-area-inset-bottom, 0px)); color: var(--ink); }
.pr-toolbar { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .8rem; color: var(--muted); font-weight: 650; font-size: .92rem; }
.pr-toolbar .ap-btn.small { width: auto; min-height: 44px; font-size: .95rem; padding: .4rem .9rem; background: var(--surface); color: var(--ink); border: 1.5px solid var(--line-2); }
.pr-doc { background: #fff; color: #17233a; border-radius: 18px; padding: 1.25rem 1.1rem; box-shadow: 0 2px 14px rgba(23,35,58,.09); font-size: 16px; line-height: 1.45; }
.pr-head { display: flex; align-items: flex-start; gap: .8rem; padding-bottom: 1rem; border-bottom: 3px solid #c65d3b; }
.pr-logo { max-height: 56px; max-width: 110px; object-fit: contain; }
.pr-co { flex: 1; display: flex; flex-direction: column; font-size: .85rem; color: #4b5568; min-width: 0; }
.pr-co b { font-size: 1.08rem; color: #17233a; }
.pr-num { text-align: right; font-size: .78rem; color: #6a6f7a; text-transform: uppercase; letter-spacing: .06em; }
.pr-num b { display: block; font-size: 1.1rem; color: #17233a; letter-spacing: 0; }
.pr-title { font-size: 1.45rem; margin: 1rem 0 .6rem; color: #17233a; }
.pr-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin: 0 0 1rem; }
.pr-meta dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #6a6f7a; font-weight: 700; }
.pr-meta dd { margin: .1rem 0 0; font-weight: 650; }
.pr-meta dd small { display: block; font-weight: 400; color: #4b5568; }
.pr-doc h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: #6a6f7a; margin: 1.1rem 0 .35rem; }
.pr-notes p, .pr-terms p { margin: 0; white-space: pre-wrap; }
.pr-terms p { font-size: .88rem; color: #4b5568; }
.pr-group h3 { font-size: 1rem; margin: 1rem 0 .3rem; color: #c65d3b; }
.pr-lines { list-style: none; margin: 0; padding: 0; }
.pr-lines li { padding: .55rem 0; border-bottom: 1px solid #ece6db; }
.pr-l-main { display: flex; justify-content: space-between; gap: 1rem; }
.pr-l-desc { font-weight: 600; } .pr-l-total { white-space: nowrap; font-variant-numeric: tabular-nums; }
.pr-l-qty { color: #6a6f7a; }
.pr-totals { margin: .9rem 0 0 auto; max-width: 320px; display: grid; gap: .25rem; }
.pr-totals div { display: flex; justify-content: space-between; gap: 1rem; font-variant-numeric: tabular-nums; }
.pr-totals dt { color: #4b5568; } .pr-totals dd { margin: 0; }
.pr-totals .grand { border-top: 2px solid #17233a; padding-top: .45rem; margin-top: .2rem; font-size: 1.3rem; font-weight: 800; }
.pr-totals .grand dt { color: #17233a; }
.pr-signed { margin-top: 1.2rem; padding: .9rem 1rem; border-radius: 12px; background: #eef7f1; }
.pr-signed.declined { background: #fdeceb; }
.pr-signed h2 { margin-top: 0; color: #23724a; } .pr-signed.declined h2 { color: #b3372a; }
.pr-sig-img { display: block; max-width: 260px; width: 100%; height: auto; background: #fff; border-radius: 8px; border: 1px solid #d6ccbb; }
.pr-signed p { margin: .4rem 0 0; }
.pr-paper-sig { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; margin-top: 2.5rem; font-size: .85rem; color: #4b5568; }
.pr-sig-line { border-bottom: 1.5px solid #17233a; height: 2.2rem; }
.print-only { display: none; }
.pr-sign { background: var(--surface); border-radius: 18px; padding: 1.1rem; margin-top: 1rem; box-shadow: 0 2px 12px rgba(0,0,0,.07); font-size: 17px; }
.pr-sign h2 { margin: 0 0 .7rem; font-size: 1.25rem; }
.pr-sign label { display: block; font-weight: 700; margin-bottom: .3rem; }
.pr-sign input, .pr-sign textarea { width: 100%; box-sizing: border-box; font: inherit; font-size: 1.15rem; padding: .75rem; border: 2px solid var(--line-2); border-radius: 12px; background: var(--surface); color: var(--ink); }
.pr-sign textarea { margin-top: .6rem; }
.pr-pad-head { display: flex; justify-content: space-between; align-items: center; margin: .9rem 0 .3rem; font-weight: 700; }
.pr-clear { font: inherit; font-size: .95rem; border: 0; background: none; color: var(--info); min-height: 44px; padding: 0 .4rem; cursor: pointer; }
.pr-pad { display: block; width: 100%; height: 170px; background: #fff; border: 2px dashed var(--line-2); border-radius: 14px; touch-action: none; cursor: crosshair;
  background-image: linear-gradient(transparent calc(100% - 46px), #d6ccbb calc(100% - 46px), #d6ccbb calc(100% - 45px), transparent calc(100% - 45px)); }
.pr-powered { text-align: center; }
.ap-banner.revoked, .ap-banner.expired { background: var(--warn-bg); color: var(--warn); }
.pr-print { max-width: 760px; margin: 0 auto; }
.pr-wrap { position: relative; margin-top: .8rem; }
@media (min-width: 640px) { .pr-doc { padding: 2rem 2.2rem; } .pr-sign { padding: 1.5rem; } }
@media print {
  body.approve-mode > main, .pr-page { padding: 0 !important; max-width: none !important; }
  .pr-doc { box-shadow: none; border-radius: 0; padding: 0; }
  .print-only { display: grid; }
  .pr-lines li, .pr-signed, .pr-totals { break-inside: avoid; }
  .ap-banner { display: none; }
  .home-tabs { display: none; }
}
@media (max-width: 380px) { .est-l-nums { grid-template-columns: 1fr 1fr; } .home-tab { font-size: .9rem; gap: .3rem; } }
