/* AD Gupta CRM - mobile-first admin */
:root {
    --navy: #0E2440;
    --navy-deep: #081727;
    --gold: #C9A24B;
    --gold-dark: #A9853A;
    --bg: #F5F4F0;
    --card: #FFFFFF;
    --ink: #1C2733;
    --muted: #6B7684;
    --line: #E5E2DA;
    --green: #2E8B57;
    --red: #C0392B;
    --nav-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 16px;
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

/* ---------- top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: var(--navy);
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px;
}
.topbar-brand img { height: 30px; background: #FAF7F0; border-radius: 6px; padding: 4px 10px; display: block; }
.topbar-logout { color: var(--gold); font-size: 14px; text-decoration: none; font-weight: 600; }

/* ---------- layout ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin-bottom: 14px; color: var(--navy); }
h2 { font-size: 16px; margin: 22px 0 10px; color: var(--navy); text-transform: uppercase; letter-spacing: .08em; }

/* ---------- cards ---------- */
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(14, 36, 64, .05);
}
a.card { display: block; text-decoration: none; color: inherit; }
a.card:active { background: #FBF8F0; }

.card-title { font-weight: 700; font-size: 16px; }
.card-sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 6px; }
.stat {
    background: var(--card); border: 1px solid var(--line); border-radius: 12px;
    padding: 14px; text-align: center;
}
.stat b { display: block; font-size: 26px; color: var(--navy); }
.stat span { font-size: 13px; color: var(--muted); }
.stat.gold { background: var(--navy); border-color: var(--navy); }
.stat.gold b { color: var(--gold); }
.stat.gold span { color: #C7D2E0; }

/* ---------- badges ---------- */
.badge {
    display: inline-block; font-size: 12px; font-weight: 700;
    padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.badge-New         { background: #E8F0FB; color: #2A5DA8; }
.badge-Active      { background: #FFF4DC; color: var(--gold-dark); }
.badge-Viewing     { background: #EDE6FA; color: #6C3FC5; }
.badge-Negotiation { background: #FDEBD9; color: #B4610E; }
.badge-Won         { background: #E3F4E9; color: var(--green); }
.badge-Lost        { background: #FBE9E7; color: var(--red); }
.badge-Scheduled   { background: #E8F0FB; color: #2A5DA8; }
.badge-Done        { background: #E3F4E9; color: var(--green); }
.badge-Cancelled   { background: #FBE9E7; color: var(--red); }

/* ---------- forms ---------- */
label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 5px; color: var(--navy); }
input[type=text], input[type=tel], input[type=email], input[type=password],
input[type=date], input[type=time], input[type=datetime-local],
select, textarea {
    width: 100%; font-size: 16px;               /* 16px stops iOS zoom */
    padding: 12px; border: 1px solid var(--line); border-radius: 10px;
    background: #fff; color: var(--ink); -webkit-appearance: none; appearance: none;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold);
}
.check { display: flex; align-items: center; gap: 10px; margin: 14px 0; font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--gold-dark); }

.btn {
    display: inline-block; width: 100%; text-align: center;
    background: var(--navy); color: #fff; font-size: 16px; font-weight: 700;
    padding: 14px; border: 0; border-radius: 10px; cursor: pointer;
    margin-top: 18px; text-decoration: none;
}
.btn:active { background: var(--navy-deep); }
.btn-gold { background: var(--gold-dark); }
.btn-outline {
    background: transparent; color: var(--navy);
    border: 1.5px solid var(--navy);
}
.btn-sm { width: auto; padding: 8px 14px; font-size: 14px; margin-top: 0; }
.btn-danger { background: var(--red); }

.inline-form { display: inline; }

/* ---------- filter bar ---------- */
.filterbar { display: flex; gap: 8px; margin-bottom: 14px; }
.filterbar input { flex: 1; }
.filterbar select { width: 128px; }
.filterbar .btn { width: auto; margin-top: 0; padding: 12px 16px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; -webkit-overflow-scrolling: touch; }
.chips a {
    flex: 0 0 auto; font-size: 13px; font-weight: 600; text-decoration: none;
    padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
    background: #fff; color: var(--muted);
}
.chips a.on { background: var(--navy); border-color: var(--navy); color: var(--gold); }

/* ---------- calendar ---------- */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-nav a {
    text-decoration: none; color: var(--navy); font-weight: 700;
    padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.cal-nav b { font-size: 16px; color: var(--navy); }
.day-head {
    font-size: 14px; font-weight: 700; color: var(--navy);
    margin: 18px 0 8px; padding-bottom: 5px; border-bottom: 2px solid var(--gold);
}
.day-head.today { color: var(--gold-dark); }
.time { font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); font-size: 14px; padding: 20px 0; text-align: center; }

/* ---------- notes ---------- */
.note { border-left: 3px solid var(--gold); }
.note.done { opacity: .55; border-left-color: var(--line); }
.note-next { margin-top: 8px; font-size: 14px; background: #FFF8E8; border-radius: 8px; padding: 8px 10px; }
.note-next b { color: var(--gold-dark); }
.note-date { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* project like heart */
.likes { font-size: 14px; font-weight: 700; }
.likes.yes { color: var(--green); }
.likes.no { color: var(--muted); }

/* quick actions on lead */
.quick { display: flex; gap: 8px; margin: 10px 0 4px; }
.quick a {
    flex: 1; text-align: center; font-size: 14px; font-weight: 700; text-decoration: none;
    padding: 10px; border-radius: 10px; background: var(--navy); color: var(--gold);
}

/* alerts */
.alert { border-radius: 10px; padding: 12px 14px; font-size: 14px; margin-bottom: 14px; }
.alert-err { background: #FBE9E7; color: var(--red); }
.alert-ok  { background: #E3F4E9; color: var(--green); }

/* ---------- bottom nav ---------- */
.bottomnav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--navy);
    display: flex; align-items: stretch;
    box-shadow: 0 -4px 16px rgba(8, 23, 39, .25);
}
.bottomnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; color: #8FA3BB; text-decoration: none; font-size: 11px; font-weight: 600;
}
.bottomnav a .ico { font-size: 20px; line-height: 1; }
.bottomnav a.active { color: var(--gold); }
.nav-add { position: relative; }

/* The gold circle is lifted 20px clear of the bar, which left the top of it
   outside the link's own box - pressing there did nothing at all. This puts
   an invisible extension over the raised part so the whole circle answers. */
.nav-add::before {
    content: ""; position: absolute; left: 0; right: 0; top: -22px; height: 22px;
}

.add-circle {
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--gold); color: var(--navy);
    display: flex; align-items: center; justify-content: center;
    font-size: 30px; font-weight: 700; line-height: 1;
    margin-top: -20px; box-shadow: 0 4px 12px rgba(0,0,0,.3);
}

/* ---------- login ---------- */
.login-wrap {
    min-height: calc(100vh - 0px); display: flex; align-items: center; justify-content: center;
    background: var(--navy); padding: 24px;
}
.login-card {
    width: 100%; max-width: 380px; background: #fff; border-radius: 16px;
    padding: 28px 24px; box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-card img { width: 100%; margin-bottom: 8px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; letter-spacing: .2em; text-transform: uppercase; margin-bottom: 8px; }

/* ---------- desktop (>= 900px) ----------
   Mobile stays untouched. On desktop the layout is restructured:
   header on top, the nav becomes a horizontal menu bar directly
   under the header, and content gets proper desktop widths.     */
@media (min-width: 900px) {
    /* The nav moves to the top here, so nothing is reserved at the bottom of
       the window any more. Anything positioned above the nav - the recipient
       selection bar - has to come back down, or it floats over the page with
       an empty gap beneath it and swallows the clicks underneath. */
    :root { --nav-h: 0px; }

    body {
        display: flex; flex-direction: column;
        min-height: 100vh; padding-bottom: 0;
    }

    /* reorder: header -> nav -> content */
    .topbar    { order: 0; padding: 12px 40px; }
    .bottomnav { order: 1; }
    .page      { order: 2; }

    .topbar-brand img { height: 38px; }
    .topbar-logout { font-size: 15px; }

    /* nav bar under the header */
    .bottomnav {
        position: static; height: auto; padding: 0;
        justify-content: center; gap: 4px;
        background: var(--navy-deep);
        border-top: 1px solid rgba(255, 255, 255, .08);
        box-shadow: 0 4px 14px rgba(8, 23, 39, .18);
    }
    .bottomnav a {
        flex: 0 0 auto; flex-direction: row; gap: 8px;
        padding: 14px 26px; font-size: 15px;
    }
    .bottomnav a:hover { color: var(--gold-soft); }
    .bottomnav a.active {
        color: var(--gold);
        box-shadow: inset 0 -3px 0 var(--gold);
    }
    .bottomnav a .ico { font-size: 18px; }
    .nav-add { padding: 8px 14px !important; }
    /* the circle is not raised here, so there is nothing to reach over */
    .nav-add::before { display: none; }
    .add-circle {
        width: 36px; height: 36px; margin-top: 0; font-size: 24px;
        box-shadow: none; transition: transform .15s ease;
    }
    .nav-add:hover .add-circle { transform: scale(1.08); }

    /* content area */
    .page { width: 100%; max-width: 1080px; margin: 0 auto; padding: 32px 40px 60px; }
    h1 { font-size: 26px; }

    .stats { grid-template-columns: repeat(4, 1fr); gap: 14px; }
    .stat b { font-size: 30px; }

    /* forms: comfortable reading width, not full screen */
    form { max-width: 620px; }
    .card form { max-width: none; }
    .card { padding: 18px 22px; }
    .btn { width: auto; min-width: 180px; padding: 13px 32px; }
    .btn:hover { opacity: .92; }
    a.card:hover { border-color: var(--gold); box-shadow: 0 3px 10px rgba(14,36,64,.08); }

    .filterbar { max-width: 620px; }
    .quick { max-width: 480px; }
    .quick a:hover { background: var(--navy-deep); }
    .cal-nav a:hover { border-color: var(--gold); color: var(--gold-dark); }
}

/* wide desktop: two-column dashboard feel via wider cards grid */
@media (min-width: 1200px) {
    .page { max-width: 1180px; }
}

/* ---------- v2: topbar links ---------- */
.topbar-links { display: flex; align-items: center; gap: 16px; }
.topbar-links a { color: var(--gold); font-size: 14px; text-decoration: none; font-weight: 600; }
.topbar-links a[title="Settings"] { font-size: 20px; line-height: 1; }

/* ---------- v2: quick-add action sheet ---------- */
.sheet-backdrop {
    position: fixed; inset: 0; z-index: 60; background: rgba(8, 23, 39, .55);
    display: none; align-items: flex-end; justify-content: center;
}
.sheet-backdrop.open { display: flex; }
.sheet {
    width: 100%; max-width: 480px; background: #fff;
    border-radius: 18px 18px 0 0; padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
    animation: sheetUp .22s ease;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 44px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 12px; }
.sheet-item {
    display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink);
    padding: 14px 10px; border-radius: 12px;
}
.sheet-item:active, .sheet-item:hover { background: #FBF8F0; }
.sheet-item b { display: block; font-size: 16px; color: var(--navy); }
.sheet-item small { color: var(--muted); font-size: 13px; }
.sheet-ico {
    flex: 0 0 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    background: var(--navy); color: var(--gold); font-size: 20px; border-radius: 12px;
}
.sheet-cancel {
    width: 100%; margin-top: 8px; padding: 13px; font-size: 15px; font-weight: 700;
    background: var(--bg); color: var(--muted); border: 0; border-radius: 12px; cursor: pointer;
}
@media (min-width: 900px) {
    .sheet-backdrop { align-items: center; }
    .sheet { border-radius: 18px; padding-bottom: 16px; }
}

/* ---------- v2: live search autocomplete ---------- */
.livesearch { position: relative; }
.ls-results {
    position: absolute; left: 0; right: 0; top: 100%; z-index: 40;
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    margin-top: 4px; max-height: 280px; overflow-y: auto;
    box-shadow: 0 10px 26px rgba(14, 36, 64, .16); display: none;
}
.ls-results.open { display: block; }
.ls-item { padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--line); }
.ls-item:last-child { border-bottom: 0; }
.ls-item:hover, .ls-item.hl { background: #FBF8F0; }
.ls-item b { color: var(--navy); }
.ls-item small { display: block; color: var(--muted); }
.ls-empty { padding: 12px 14px; color: var(--muted); font-size: 14px; }

.picked {
    display: flex; align-items: center; justify-content: space-between;
    background: #FFF8E8; border: 1px solid var(--gold); border-radius: 10px;
    padding: 12px 14px; margin-top: 8px;
}
.picked b { color: var(--navy); }
.picked small { display: block; color: var(--muted); }
.picked button {
    background: none; border: 0; color: var(--red); font-weight: 700; cursor: pointer; font-size: 14px;
}

.toggle-row { display: flex; gap: 8px; margin: 10px 0; }
.toggle-row button {
    flex: 1; padding: 11px; font-size: 14px; font-weight: 700; cursor: pointer;
    border: 1.5px solid var(--line); background: #fff; color: var(--muted); border-radius: 10px;
}
.toggle-row button.on { border-color: var(--navy); background: var(--navy); color: var(--gold); }

/* ---------- v2: reminders ---------- */
.rem { border-left: 3px solid #2A5DA8; }
.rem.overdue { border-left-color: var(--red); }
.rem-date { font-size: 12px; font-weight: 700; color: #2A5DA8; }
.rem.overdue .rem-date { color: var(--red); }

.warn { border-left: 3px solid var(--red); background: #FFF7F5; }
