/* R&D Contracting CRM — Rori & Dad brand system
   Mobile-first. Big touch targets (min 52px). Playful, never corporate. */

:root {
    --pink: #E63E8C;
    --blue: #2F9BE8;
    --teal: #1A9E9E;
    --yellow: #FFC93C;
    --ink: #22304A;
    --cream: #FFF6E9;
    --white: #FFFFFF;
    --red: #E14B4B;
    --green: #2FA968;
    --radius: 18px;
    --shadow: 0 4px 0 rgba(34, 48, 74, 0.12);
}

* { box-sizing: border-box; }

/* Ashanti asked for everything a bit bigger — base zoom for readability. */
html { font-size: 175%; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--cream);
    color: var(--ink);
    font-size: 1.15rem;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

.hand, h1.hand, h2.hand {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-weight: 700;
    margin: 0 0 .5rem;
    line-height: 1.1;
}
h1.hand { font-size: 2.4rem; }
h2.hand { font-size: 1.9rem; }

.muted { color: #5A6B8C; }
.small { font-size: .95rem; }
.center { text-align: center; }

/* ---------- top bar ---------- */
.topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "brand search menu" "userchip userchip userchip";
    gap: .5rem .75rem; padding: .7rem 1rem;
    background: var(--ink); color: #fff;
    position: sticky; top: 0; z-index: 50;
    align-items: center;
}
.brand { grid-area: brand; display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; }
.brand-logo {
    width: 44px; height: 44px; border-radius: 50%;
    background: #fff;
    object-fit: cover; flex: 0 0 auto;
}
.brand-mark { font-size: 1.8rem; }
.brand-text { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 1.15rem; font-weight: 700; line-height: 1.1; }
.brand-text em { font-style: normal; color: var(--yellow); }

.userchip { grid-area: userchip; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-start; }
.userchip-name { font-size: 1rem; }

/* ---------- nav (hamburger dropdown, top-right) ---------- */
.menu-btn {
    grid-area: menu; align-self: center;
    font-size: 1.7rem; line-height: 1;
    background: var(--yellow); color: var(--ink);
    border: 3px solid var(--ink); border-radius: 14px;
    min-width: 58px; min-height: 58px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: var(--shadow);
}
.menu-btn:active { transform: scale(.94); }
/* Walmart-style: search bar shares the top row with the menu button. */
.topbar-search { grid-area: search; position: relative; margin: 0; max-width: none; min-width: 0; }
.topbar-search .search-input {
    width: 100%; min-width: 0; padding: .55rem 1rem; font-size: 1rem;
    border-radius: 999px; border: 3px solid var(--ink);
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.mainnav {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 60;
    display: flex; flex-direction: column; gap: .35rem;
    background: #fff; border-bottom: 3px solid var(--ink);
    padding: .8rem 1rem 1rem;
    box-shadow: 0 10px 18px rgba(0,0,0,.18);
    max-height: 70vh; overflow-y: auto;
}
.mainnav[hidden] { display: none; }
.navlink {
    text-decoration: none; color: var(--ink); font-size: 1.35rem; font-weight: 600;
    padding: .9rem 1rem; border-radius: 14px; white-space: nowrap;
    border: 2px solid transparent; min-height: 56px;
    display: flex; align-items: center;
}
.navlink:active { background: var(--yellow); border-color: var(--ink); }

/* ---------- page & cards ---------- */
.page { max-width: 44rem; margin: 0 auto; padding: 1.25rem 1rem 4rem; }

.card {
    background: var(--white);
    border: 3px solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.page-head {
    display: flex; justify-content: space-between; align-items: center;
    gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.page-head h1 { margin: 0; }

.grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid { grid-template-columns: 1fr 1fr; } }

.stack { display: grid; gap: 1rem; }

.link-card { text-decoration: none; color: inherit; display: block; }
.link-card:active { transform: translateY(2px); box-shadow: none; }
.link-card-emoji { font-size: 2.4rem; }

/* ---------- stickers / badges ---------- */
.sticker {
    display: inline-block; font-size: .9rem; line-height: 1;
    padding: .35rem .7rem; border-radius: 999px;
    border: 2px solid var(--ink); font-weight: bold;
    transform: rotate(-2deg); vertical-align: middle;
    white-space: nowrap;
}
.sticker-owner  { background: var(--yellow); }
.sticker-office { background: var(--blue); color: #fff; }
.sticker-field  { background: var(--teal); color: #fff; }
.sticker-soon   { background: #E8EAF2; color: #5A6B8C; }
.sticker-off    { background: var(--red); color: #fff; }

/* ---------- buttons (min 52px touch targets) ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: .4rem; min-height: 52px; padding: .7rem 1.4rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 1.2rem;
    border: 3px solid var(--ink); border-radius: 999px;
    background: #fff; color: var(--ink); cursor: pointer;
    text-decoration: none; box-shadow: var(--shadow);
    -webkit-appearance: none; appearance: none;
}
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn-primary { background: var(--pink); color: #fff; }
.btn-secondary { background: var(--yellow); }
.btn-ghost { box-shadow: none; border-color: #9AA7C4; color: #5A6B8C; }
.btn-sm { min-height: 44px; font-size: 1.05rem; padding: .45rem 1rem; }
.btn-lg { font-size: 1.35rem; }
.btn-block { width: 100%; }

.inline-form { display: inline; }

/* ---------- forms ---------- */
.form { display: grid; gap: 1.1rem; }
.field { display: grid; gap: .35rem; }
.field-label { font-size: 1.15rem; font-weight: bold; }

.input {
    width: 100%; min-height: 56px; font-size: 1.25rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; color: var(--ink);
    border: 3px solid var(--ink); border-radius: 14px;
    padding: .6rem 1rem; background: #FFFDF7;
}
.input:focus { outline: 3px solid var(--blue); outline-offset: 1px; background: #fff; }

.check {
    display: flex; align-items: center; gap: .7rem;
    min-height: 52px; font-size: 1.1rem; cursor: pointer;
}
.check input { width: 28px; height: 28px; accent-color: var(--pink); flex: none; }

.radio-cards { display: grid; gap: .75rem; margin-bottom: .5rem; }
.radio-card {
    display: flex; align-items: center; gap: .75rem;
    border: 3px solid var(--ink); border-radius: 14px;
    padding: .8rem 1rem; min-height: 60px; cursor: pointer; background: #FFFDF7;
}
.radio-card input { width: 26px; height: 26px; accent-color: var(--pink); flex: none; }
.radio-card.is-checked { background: #FFF3D6; border-color: var(--pink); }

/* ---------- flash messages ---------- */
.flash {
    border: 3px solid var(--ink); border-radius: 14px;
    padding: .9rem 1.1rem; margin-bottom: 1.25rem; font-size: 1.15rem;
    box-shadow: var(--shadow);
}
.flash-ok   { background: #DFF7E8; }
.flash-err  { background: #FFE1E1; }
.flash-warn { background: #FFF3D6; }
.flash-info { background: #DFF1FD; }

/* ---------- auth pages ---------- */
.auth-wrap { display: flex; justify-content: center; padding-top: 1rem; }
.auth-card { width: 100%; max-width: 28rem; text-align: left; }
.auth-hero { font-size: 3rem; text-align: center; }

/* ---------- team ---------- */
.user-card.is-disabled { opacity: .75; background: #F4F5FA; }
.user-card-main { display: flex; gap: .9rem; align-items: flex-start; margin-bottom: .9rem; }
.user-card-emoji { font-size: 2.2rem; }
.user-card-name { font-size: 1.3rem; margin-right: .4rem; }
.user-card-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.creds-card { background: #FFF3D6; border-color: var(--pink); }
.creds-box {
    display: grid; gap: .75rem; background: #fff;
    border: 2px dashed var(--ink); border-radius: 12px;
    padding: 1rem; margin: 1rem 0;
}
.creds-value { font-size: 1.5rem; letter-spacing: .03em; }

/* ---------- footer ---------- */
.footer { text-align: center; color: #5A6B8C; padding: 1rem; font-size: 1rem; }

/* ---------- Phase 2: customers ---------- */
select.input { appearance: auto; }
.textarea { min-height: 110px; resize: vertical; font-size: 1.2rem; }
.file-input { padding: .8rem 1rem; }

.filter-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip {
    display: inline-flex; align-items: center; min-height: 48px;
    padding: .45rem 1rem; border: 3px solid var(--ink); border-radius: 999px;
    background: #fff; color: var(--ink); text-decoration: none; font-size: 1.05rem;
}
.chip.is-active { background: var(--yellow); }

.card.is-archived, .media-card.is-archived { opacity: .8; background: #F4F5FA; }
.mini-card { margin-bottom: 0; padding: .9rem 1.1rem; }
.mini-card strong { font-size: 1.2rem; margin-right: .4rem; }

.contact-row { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1rem 0; }
.contact-row .btn { flex: 1 1 0; min-width: 140px; }

.detail-list { display: grid; gap: .7rem; margin: 1rem 0 0; }
.detail-list > div { display: grid; gap: .15rem; }
.detail-list dt { font-weight: bold; font-size: 1.05rem; }
.detail-list dd { margin: 0; }
.detail-list .notes { white-space: pre-wrap; }

.upload-form { margin-bottom: 1.25rem; }

.gallery { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
@media (min-width: 560px) { .gallery { grid-template-columns: 1fr 1fr 1fr; } }
.media-card {
    margin: 0; border: 3px solid var(--ink); border-radius: 14px;
    overflow: hidden; background: #fff; box-shadow: var(--shadow);
}
.media-card img, .media-card video {
    width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; background: #222;
}
.media-card video { background: #111; }
.media-download {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .3rem; aspect-ratio: 1 / 1; text-decoration: none; color: var(--ink);
    background: #FFF3D6;
}
.media-download-emoji { font-size: 2.6rem; }
.media-card figcaption { padding: .6rem .7rem; font-size: 1rem; display: grid; gap: .3rem; }

/* ---------- Phase 3: estimates, change orders, receipts ---------- */
.nudge-card { border-color: var(--pink); background: #FFF9FB; }

.pipeline {
    list-style: none; margin: 0 0 1.25rem; padding: 0;
    display: flex; gap: .4rem;
}
.pipeline .step { flex: 1; text-align: center; }
.step-dot {
    display: flex; align-items: center; justify-content: center;
    width: 52px; height: 52px; margin: 0 auto .35rem;
    border: 3px solid var(--ink); border-radius: 50%;
    background: #fff; font-size: 1.3rem; font-weight: bold;
}
.step-label { font-size: .95rem; line-height: 1.2; display: block; }
.step.is-done .step-dot { background: var(--teal); color: #fff; }
.step.is-current .step-dot { background: var(--yellow); transform: scale(1.12); }
.step.is-current .step-label { font-weight: bold; }

/* Branded estimate document — professional type for customer-facing docs */
.doc-brand { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
.doc-brand em { font-style: normal; color: var(--pink); }
.doc-tagline { color: #5A6B8C; }
.doc-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 1rem; margin-bottom: 1rem;
    border-bottom: 3px dashed var(--ink); padding-bottom: 1rem;
}
.doc-estno { text-align: right; }
.doc-estno-label { font-size: 1rem; letter-spacing: .15em; color: #5A6B8C; }
.doc-estno-num { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; font-size: 2rem; font-weight: 800; }
.doc-parties {
    display: grid; gap: 1rem; grid-template-columns: 1fr 1fr;
    margin: 1rem 0; padding: 1rem;
    background: #FFFDF7; border: 2px dashed var(--ink); border-radius: 12px;
}
.doc-notes { margin-top: 1rem; }
.doc-thanks { margin-top: 1.5rem; }

/* Line-item tables */
.items-scroll { overflow-x: auto; margin: 0 -.25rem; padding: 0 .25rem; }
.items-table { width: 100%; border-collapse: collapse; font-size: 1.05rem; }
.items-table th, .items-table td { padding: .5rem .4rem; text-align: left; vertical-align: middle; }
.items-table th.num, .items-table td.num { text-align: right; }
.items-table thead th { border-bottom: 3px solid var(--ink); }
.items-table tbody td { border-bottom: 2px solid #E8EAF2; }
.items-table .input { min-height: 52px; font-size: 1.1rem; padding: .5rem .7rem; }
.items-table .input.num { text-align: right; }
.doc-table { margin-top: 1rem; }
.doc-table tbody td { font-size: 1.15rem; }

.total-line {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 1.4rem; margin-top: .75rem; padding: .75rem 1rem;
    background: var(--yellow); border: 3px solid var(--ink); border-radius: 14px;
}
.total-box { margin-top: 1rem; display: grid; gap: .4rem; }
.total-row {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 1.2rem; padding: .4rem .2rem;
}
.total-row.grand {
    font-size: 1.5rem; border-top: 3px solid var(--ink); padding-top: .7rem;
}

/* Money picture + budget bar */
.money-list .grand dt, .money-list .grand dd { font-size: 1.35rem; }
.progress {
    height: 26px; border: 3px solid var(--ink); border-radius: 999px;
    background: #fff; overflow: hidden; margin-top: 1rem;
}
.progress-fill {
    height: 100%; background: var(--teal); border-radius: 999px;
    transition: width .4s;
}

/* Receipt rows */
.receipt-row { display: flex; gap: .9rem; align-items: flex-start; }
.receipt-thumb { flex: none; width: 84px; height: 84px; }
.receipt-thumb img {
    width: 84px; height: 84px; object-fit: cover; display: block;
    border: 3px solid var(--ink); border-radius: 12px; background: #222;
}

/* ---------- print: the estimate document prints clean ---------- */
@media print {
    .topbar, .mainnav, .footer, .no-print { display: none !important; }
    body { background: #fff; font-size: 1rem; }
    .page { max-width: none; padding: 0; }
    .card { box-shadow: none; margin-bottom: 1rem; }
    .doc { border: 2px solid #000; }
}

/* ------------------------------------------------------------------ Phase 6 */

/* Global search bar + autocomplete dropdown */
.searchbar-wrap { padding: .6rem 1rem 0; }
.searchbar { position: relative; max-width: 640px; margin: 0 auto; }
.search-input {
    width: 100%; padding-left: 1rem; font-size: 1.05rem;
    border-radius: 999px; box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.search-suggest {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0;
    background: #fff; border-radius: 12px; z-index: 200;
    box-shadow: 0 10px 30px rgba(0,0,0,.18); overflow: hidden;
    max-height: 60vh; overflow-y: auto;
}
.suggest-row {
    display: flex; align-items: center; gap: .6rem;
    padding: .7rem .9rem; text-decoration: none; color: inherit;
    border-bottom: 1px solid #f0f0f0; min-height: 52px;
}
.suggest-row:last-child { border-bottom: none; }
.suggest-row:active { background: #f7f3ff; }
.suggest-icon { font-size: 1.3rem; flex-shrink: 0; }
.suggest-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.suggest-label { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-detail { font-size: .85rem; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-empty { padding: 1rem; color: #666; text-align: center; }

/* Ask Kavi corner */
.kavi-panel {
    position: fixed; right: .8rem; top: 4.2rem; z-index: 300;
    width: min(22rem, calc(100vw - 1.6rem));
    background: #fffdf5; border: 3px solid #7c5cbf; border-radius: 16px;
    box-shadow: 0 14px 40px rgba(0,0,0,.25); padding: .9rem;
}
.kavi-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.kavi-title { font-size: 1.25rem; font-weight: 800; }
.kavi-questions { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.kavi-answer { max-height: 50vh; overflow-y: auto; }
.kavi-headline { font-weight: 700; font-size: 1.05rem; margin-bottom: .5rem; }

/* Calendar */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; }
.cal-nav { display: flex; gap: .4rem; }
.cal-toggle { display: flex; gap: .4rem; margin-bottom: .8rem; }
.cal-toggle .btn[aria-current="page"] { box-shadow: inset 0 0 0 2px #7c5cbf; }
.cal-title { margin: 0; font-size: 1.4rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; background: #e8e2f4; border-radius: 12px; overflow: hidden; }
.cal-dow { background: #7c5cbf; color: #fff; text-align: center; font-weight: 700; padding: .4rem 0; font-size: .85rem; }
.cal-cell { background: #fff; min-height: 4.4rem; padding: .25rem; font-size: .8rem; }
.cal-cell.dim { background: #f7f5fc; color: #aaa; }
.cal-cell.today { box-shadow: inset 0 0 0 3px #7c5cbf; }
.cal-daynum { font-weight: 700; font-size: .95rem; }
.cal-items { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.cal-item {
    display: block; text-decoration: none; color: inherit; font-size: .72rem;
    line-height: 1.2; padding: 2px 4px; border-radius: 6px; background: #f0ebff;
    border-left: 3px solid #7c5cbf; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    min-height: 28px;
}
.cal-job { background: #e3f2fd; border-color: #2196f3; }
.cal-task { background: #fff8e1; border-color: #ffb300; }
.cal-task.done { opacity: .55; text-decoration: line-through; }
.cal-followup { background: #fce4ec; border-color: #e91e63; }
.cal-sub { background: #e8f5e9; border-color: #4caf50; }
.cal-more { font-size: .7rem; color: #666; padding: 0 4px; }
.cal-day-detail { margin-top: 1rem; }

/* Week view */
.cal-week { display: flex; flex-direction: column; gap: .4rem; }
.cal-week-day { background: #fff; border-radius: 12px; padding: .6rem .8rem; }
.cal-week-day.today { box-shadow: 0 0 0 3px #7c5cbf; }
.cal-week-day h3 { margin: 0 0 .4rem; font-size: 1.05rem; }

/* Signature pad */
.sig-pad { width: 100%; height: 160px; border: 2px dashed #7c5cbf; border-radius: 12px; background: #fff; touch-action: none; cursor: crosshair; }
.sig-img { max-width: 100%; border: 1px solid #ddd; border-radius: 8px; background: #fff; }

/* Option blocks on the estimate page */
.opt-block { border: 2px solid #e0d6f5; border-radius: 12px; padding: .8rem; margin-bottom: .8rem; }
.opt-block.accepted { border-color: #4caf50; background: #f6fff6; }

/* Nudge card highlight */
.nudge-card { border: 3px dashed #7c5cbf; background: #fffdf5; }

/* Review/settings helpers */
.review-qr { max-width: 220px; border-radius: 12px; }

/* Big tap targets for the "log it" buttons */
@media (max-width: 640px) {
    .kavi-panel { top: 3.6rem; }
    .cal-cell { min-height: 3.6rem; }
}

/* Checkbox rows (invoice tax picker) — big 52px touch targets */
.check-row {
    display: flex; align-items: center; gap: .7rem;
    min-height: 52px; padding: .5rem .7rem;
    background: #f9f7ff; border-radius: 10px; cursor: pointer;
}
.check-row input[type="checkbox"] { width: 28px; height: 28px; accent-color: #7c5cbf; flex: none; }
.check-row span { font-weight: 600; }
