:root {
    --ink: #17211f;
    --muted: #61706b;
    --paper: #f5f2e9;
    --cream: #fffdf7;
    --mint: #c8f169;
    --teal: #0e5b50;
    --teal-dark: #093f37;
    --line: rgba(23, 33, 31, .14);
    --shadow: 0 24px 70px rgba(23, 33, 31, .13);
    --red: #b3452f;
    --amber: #c98a1c;
    --green: #4c8c2b;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: 'Trebuchet MS', Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: Georgia, 'Times New Roman', serif; font-weight: 500; letter-spacing: -.02em; }
.eyebrow { color: var(--teal); font: 800 11px 'Trebuchet MS', Arial, sans-serif; letter-spacing: .14em; text-transform: uppercase; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.mobile-topbar { display: none; }
.sidebar-scrim { display: none; }
.app-sidebar {
    width: 236px; flex-shrink: 0; background: var(--teal-dark); color: #eaf3ef;
    display: flex; flex-direction: column; padding: 22px 18px; position: sticky; top: 0; height: 100vh;
}
.app-brand { display: flex; align-items: center; gap: 10px; font: 800 15px 'Trebuchet MS', Arial, sans-serif; letter-spacing: .02em; color: #fff; }
.app-brand .mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--mint); font-size: 16px; }
.app-portal-tag { margin: 16px 0 22px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.08); font-size: 11px; color: #bcd4cb; line-height: 1.4; }
.app-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.app-nav a { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px; font: 700 13px 'Trebuchet MS', Arial, sans-serif; color: #cfe3db; }
.app-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.app-nav a.active { background: var(--mint); color: var(--ink); }
.nav-ico { font-size: 14px; width: 16px; text-align: center; }
.app-sidebar-foot { display: flex; flex-direction: column; gap: 4px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.14); }
.ghost-link { font-size: 11px; color: #9db8ac; padding: 6px 4px; }
.ghost-link:hover { color: #fff; }

.app-main { flex: 1; min-width: 0; }
.app-topbar { display: flex; align-items: center; justify-content: space-between; padding: 30px 40px 18px; }
.app-title { margin: 6px 0 0; font-size: 30px; }
.app-content { padding: 6px 40px 60px; }

/* ---------- Buttons ---------- */
.button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border-radius: 999px; padding: 11px 18px; font: 800 12px 'Trebuchet MS', Arial, sans-serif;
    border: none; cursor: pointer; white-space: nowrap;
}
.button-primary { background: var(--teal); color: #fff; box-shadow: 0 10px 22px rgba(14,91,80,.22); }
.button-primary:hover { background: var(--teal-dark); }
.button-secondary { background: var(--mint); color: var(--ink); }
.button-secondary:hover { filter: brightness(0.96); }
.button-outline { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.button-outline:hover { background: rgba(23,33,31,.04); }
.button-danger { background: #fbeae5; color: var(--red); }
.button-small { padding: 7px 12px; font-size: 11px; }
.button[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Cards / layout ---------- */
.card { background: var(--cream); border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 1.3fr .7fr; }
@media (max-width: 1080px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .grid-4, .grid-3 { grid-template-columns: 1fr; } }

.stat-card { background: var(--cream); border: 1px solid var(--line); border-top: 3px solid var(--teal); border-radius: 14px; padding: 18px 20px; }
.stat-card .stat-label { font: 800 11px 'Trebuchet MS'; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stat-card .stat-value { font: 500 30px Georgia, serif; margin-top: 8px; }
.stat-card .stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Tables ---------- */
table.data-table { width: 100%; border-collapse: collapse; }
table.data-table th { text-align: left; font: 800 10px 'Trebuchet MS'; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
table.data-table td { padding: 14px 12px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: rgba(23,33,31,.02); }
.row-link { color: var(--teal); font-weight: 700; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font: 800 10px 'Trebuchet MS'; text-transform: uppercase; letter-spacing: .05em; }
.badge-draft { background: #ece9df; color: var(--muted); }
.badge-sent { background: #fdecd2; color: var(--amber); }
.badge-approved { background: #dcecff; color: #2a5fa8; }
.badge-paid { background: #e2f2d6; color: var(--green); }

/* ---------- Forms ---------- */
label { display: block; font: 800 11px 'Trebuchet MS'; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
    font: 13px 'Trebuchet MS', Arial, sans-serif; color: var(--ink);
}
textarea { resize: vertical; font-family: 'Trebuchet MS', Arial, sans-serif; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 11px; color: var(--muted); margin-top: 5px; }
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 13px; }
.flash-error { background: #fbeae5; color: var(--red); border: 1px solid #f0cfc6; }
.flash-ok { background: #eef8f0; color: var(--teal-dark); border: 1px solid var(--teal); }

/* ---------- Modal (native dialog) ---------- */
dialog { border: none; border-radius: 20px; padding: 0; width: min(480px, 92vw); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(23,33,31,.45); }
.modal-body { padding: 26px; }
.modal-title { margin: 0 0 16px; font-size: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Toast ---------- */
.toast-stack { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 900; }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 13px; box-shadow: var(--shadow); max-width: 320px; animation: toast-in .18s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Empty / activity ---------- */
.activity-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); margin-top: 6px; flex-shrink: 0; }
.activity-time { color: var(--muted); font-size: 11px; }

/* ---------- Quote builder ---------- */
.builder-grid { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
@media (max-width: 980px) { .builder-grid { grid-template-columns: 1fr; } }
.line-items { width: 100%; border-collapse: collapse; }
.line-items th { text-align: left; font: 800 10px 'Trebuchet MS'; text-transform: uppercase; color: var(--muted); padding: 0 8px 8px; }
.line-items td { padding: 6px 8px; }
.line-items input { padding: 8px 10px; }
.line-items .amount-cell { text-align: right; font-weight: 700; white-space: nowrap; }
.remove-row { background: none; border: none; color: var(--red); font-size: 16px; cursor: pointer; padding: 4px 8px; }
.totals-box { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.totals-box .row { display: flex; justify-content: space-between; }
.totals-box .total-row { font-size: 20px; font-family: Georgia, serif; padding-top: 8px; border-top: 1px solid var(--line); margin-top: 4px; }

/* Stopwatch */
.stopwatch { text-align: center; }
.stopwatch-display { font: 700 42px/1 'Trebuchet MS', Arial, sans-serif; letter-spacing: .02em; margin: 10px 0 16px; font-variant-numeric: tabular-nums; }
.stopwatch-controls { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.stopwatch-live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-right: 6px; animation: pulse 1.1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* Share link box */
.share-box { display: flex; gap: 8px; align-items: center; background: #fff; border: 1px dashed var(--teal); border-radius: 12px; padding: 10px 12px; }
.share-box input { border: none; background: transparent; font-size: 12px; padding: 4px; }
.live-pill { display: inline-flex; align-items: center; gap: 5px; font: 800 10px 'Trebuchet MS'; color: var(--green); text-transform: uppercase; letter-spacing: .06em; }
.live-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 1.3s infinite; }

/* ---------- Public quote / payment pages ---------- */
.public-wrap { max-width: 760px; margin: 0 auto; padding: 60px 24px 90px; font-family: 'Trebuchet MS', Arial, sans-serif; color: var(--ink); }
.public-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.public-brand { display: flex; align-items: center; gap: 10px; font: 800 15px 'Trebuchet MS'; }
.public-brand .mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: var(--mint); }
.public-card { background: var(--cream); border: 1px solid var(--line); border-radius: 22px; padding: 34px; box-shadow: var(--shadow); }
.public-card h1 { font-size: 30px; margin: 0 0 6px; }
.pay-card { max-width: 420px; margin: 40px auto 0; }
.card-face { background: linear-gradient(135deg, var(--teal), #123f38); color: #fff; border-radius: 16px; padding: 22px; margin-bottom: 20px; font: 700 16px 'Trebuchet MS'; letter-spacing: .08em; }

/* ---------- Tour ---------- */
.tour-backdrop { position: fixed; inset: 0; background: rgba(23,33,31,.5); z-index: 990; }
.tour-highlight { position: fixed; z-index: 991; border-radius: 12px; box-shadow: 0 0 0 4px var(--mint), 0 0 0 9999px rgba(23,33,31,.55); pointer-events: none; transition: all .25s ease; }
.tour-tooltip { position: fixed; z-index: 992; background: #fff; border-radius: 16px; padding: 18px 20px; width: 280px; box-shadow: var(--shadow); transition: all .25s ease; }
.tour-tooltip .eyebrow { font-size: 10px; }
.tour-tooltip h4 { margin: 8px 0 6px; font-size: 17px; }
.tour-tooltip p { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.tour-tooltip .tour-actions { display: flex; justify-content: space-between; align-items: center; }
.tour-skip { font-size: 11px; color: var(--muted); background: none; border: none; cursor: pointer; text-decoration: underline; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.text-right { text-align: right; }
.small { font-size: 12px; }
.divider { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
.pill-toggle { display: flex; align-items: center; gap: 10px; }
.switch { position: relative; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: #d8d4c6; border-radius: 999px; transition: .2s; cursor: pointer; }
.switch .track::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .track { background: var(--teal); }
.switch input:checked + .track::before { transform: translateX(18px); }

/* =======================================================================
   Mobile responsive layer
   ======================================================================= */

/* Scrollable wrapper for wide tables on narrow screens */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table.data-table { min-width: 560px; }

@media (max-width: 880px) {
    /* Off-canvas sidebar */
    .mobile-topbar {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        position: sticky; top: 0; z-index: 500; background: var(--teal-dark);
        padding: 12px 16px; color: #fff;
    }
    .mobile-topbar .app-brand { color: #fff; font-size: 14px; }
    .mobile-topbar .app-brand .mark { width: 26px; height: 26px; font-size: 14px; }
    .hamburger {
        display: flex; flex-direction: column; justify-content: center; gap: 4px;
        width: 34px; height: 34px; padding: 8px; border: none; background: rgba(255,255,255,.1);
        border-radius: 9px; cursor: pointer;
    }
    .hamburger span { display: block; width: 18px; height: 2px; background: #fff; border-radius: 2px; }

    .app-shell { flex-direction: column; }
    .app-sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; z-index: 700;
        transform: translateX(-104%); transition: transform .22s ease-out;
        box-shadow: 0 0 0 rgba(0,0,0,0);
    }
    .app-sidebar.open { transform: translateX(0); box-shadow: 24px 0 60px rgba(0,0,0,.35); }
    .sidebar-scrim {
        display: block; position: fixed; inset: 0; background: rgba(15,20,19,.5);
        z-index: 650; opacity: 0; pointer-events: none; transition: opacity .2s ease;
    }
    .sidebar-scrim.visible { opacity: 1; pointer-events: auto; }

    .app-main { width: 100%; }
    .app-topbar { padding: 20px 18px 12px; flex-wrap: wrap; gap: 10px; }
    .app-title { font-size: 23px; }
    .app-topbar-actions { width: 100%; }
    .app-topbar-actions a[data-tour="nav-new-quote"] { display: none; }
    .app-topbar-actions .button-outline { width: 100%; }
    .app-content { padding: 4px 18px 50px; }

    .grid { gap: 12px; }
    .card { padding: 16px; border-radius: 14px; }
    .stat-card .stat-value { font-size: 25px; }

    .builder-grid { gap: 14px; }
}

@media (max-width: 700px) {
    /* Turn line-item table rows into stacked cards */
    .line-items thead { display: none; }
    .line-items, .line-items tbody, .line-items tr, .line-items td { display: block; width: 100%; }
    .line-items { margin-bottom: 4px; }
    .line-items tr {
        border: 1px solid var(--line); border-radius: 12px; background: #fff;
        padding: 34px 12px 12px; margin-bottom: 10px; position: relative;
    }
    .line-items td { padding: 6px 0; }
    .line-items td[data-label]::before {
        content: attr(data-label); display: block; font: 800 10px 'Trebuchet MS';
        text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px;
    }
    .line-items .amount-cell { text-align: left; font-size: 15px; }
    .line-items td:last-child { position: absolute; top: 6px; right: 8px; padding: 0; }
    .line-items .remove-row { font-size: 20px; width: 28px; height: 28px; border-radius: 50%; background: #fbeae5; }
    .line-items input { font-size: 16px; } /* avoids iOS auto-zoom on focus */

    .stopwatch-controls { flex-wrap: wrap; }
    .stopwatch-display { font-size: 34px; }

    dialog { width: 94vw; max-height: 88vh; overflow-y: auto; }
    .field-row { grid-template-columns: 1fr; gap: 10px; }

    input[type=text], input[type=email], input[type=tel], input[type=number],
    input[type=password], select, textarea { font-size: 16px; } /* avoids iOS auto-zoom */

    .public-wrap { padding: 30px 16px 60px; }
    .public-card { padding: 22px; border-radius: 16px; }
    .public-header { flex-wrap: wrap; gap: 10px; }
    .public-card h1 { font-size: 26px; }
    .totals-box .total-row { font-size: 17px; }

    .tour-tooltip { width: min(280px, calc(100vw - 32px)); }

    .share-box { flex-wrap: wrap; }
    .share-box input { width: 100%; }
}

@media (max-width: 420px) {
    .app-topbar-actions { display: flex; flex-direction: column; }
    table.data-table th, table.data-table td { padding: 10px 8px; font-size: 12.5px; }
}

