:root {
    color-scheme: light;
    --ink: #17201d;
    --muted: #66716d;
    --line: #dde3df;
    --paper: #ffffff;
    --canvas: #f3f5f2;
    --forest: #17365e;
    --forest-2: #244d7e;
    --mint: #e7eef7;
    --accent: #204a7d;
    --accent-dark: #16375e;
    --amber: #f6c86d;
    --danger: #bc3f3f;
    --shadow: 0 18px 50px rgba(23, 32, 29, .09);
    --radius: 16px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); font-size: 16px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(239, 108, 77, .28); outline-offset: 2px; }

.boot-screen, .login-page { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 14px; padding: 24px; }
.boot-screen p { color: var(--muted); }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; overflow: hidden; border-radius: 14px; background: white; }
.brand-mark img { width: 88%; height: 88%; object-fit: contain; }

.login-shell { width: min(100%, 920px); min-height: 560px; display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; border-radius: 24px; background: var(--paper); box-shadow: var(--shadow); }
.login-art { position: relative; overflow: hidden; padding: 48px; background: var(--forest); color: white; display: flex; flex-direction: column; justify-content: space-between; }
.login-art::after { content: ""; position: absolute; width: 360px; height: 360px; right: -150px; bottom: -150px; border: 70px solid rgba(223, 245, 233, .1); border-radius: 50%; }
.login-art .eyebrow { color: #9edbbd; }
.login-art h1 { max-width: 420px; margin: 16px 0; font-size: clamp(2rem, 5vw, 3.4rem); line-height: .98; letter-spacing: -.055em; }
.login-art p { max-width: 400px; color: #c8d7d1; line-height: 1.6; }
.login-content { padding: 48px; display: flex; flex-direction: column; justify-content: center; }
.login-company-logo { width: min(100%, 300px); max-height: 118px; margin: 0 auto 24px; object-fit: contain; }
.login-content h2 { margin: 0 0 10px; font-size: 1.7rem; letter-spacing: -.03em; }
.login-content > p { margin: 0 0 28px; color: var(--muted); line-height: 1.55; }
.demo-box { margin-top: 22px; padding: 18px; border-radius: 14px; background: #f6f8f6; border: 1px solid var(--line); }
.demo-box strong { display: block; margin-bottom: 12px; }
.demo-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.demo-sales-button { width: 100%; margin-top: 10px; }
.login-divider { position: relative; margin: 28px 0 20px; color: var(--muted); font-size: .8rem; text-align: center; }
.login-divider::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.login-divider span { position: relative; padding: 0 12px; background: white; }
.admin-login-form { display: grid; gap: 14px; }
.admin-login-form .field-error { min-height: 1.2em; margin: 0; }
.login-error { margin: 0 0 18px; padding: 12px 14px; border-radius: 10px; color: #862f2f; background: #fff0ef; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 18px; background: var(--forest); color: white; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 8px 30px; }
.brand strong { display: block; letter-spacing: -.02em; }
.brand small { color: #9fb1aa; }
.sidebar .brand-mark { width: 42px; height: 42px; border-radius: 12px; }
.nav { display: grid; gap: 7px; }
.nav-button { width: 100%; min-height: 44px; padding: 10px 12px; display: flex; gap: 11px; align-items: center; border: 0; border-radius: 11px; background: transparent; color: #b8c6c1; text-align: left; }
.nav-button svg { width: 20px; height: 20px; flex: 0 0 20px; }
.nav-button:hover { background: rgba(255,255,255,.06); color: white; }
.nav-button.active { color: white; background: var(--forest-2); }
.sidebar-bottom { margin-top: auto; }
.profile-card { padding: 14px; border-top: 1px solid rgba(255,255,255,.1); }
.profile-card strong, .profile-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-card small { margin-top: 3px; color: #93a7a0; }
.logout-button { margin-top: 12px; padding: 8px 0; border: 0; background: transparent; color: #f1b0a2; }

.main { min-width: 0; }
.topbar { height: 74px; padding: 0 34px; background: rgba(255,255,255,.86); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 8; }
.topbar h1 { margin: 0; font-size: 1.18rem; letter-spacing: -.02em; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.role-pill, .status-pill { display: inline-flex; align-items: center; min-height: 28px; padding: 5px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.role-pill { background: var(--mint); color: #226345; }
.content { max-width: 1440px; margin: auto; padding: 32px 34px 60px; }
.page-heading { margin-bottom: 25px; display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; }
.eyebrow { margin: 0 0 8px; color: var(--accent-dark); font-size: .76rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.page-heading h2 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.4rem); line-height: 1.05; letter-spacing: -.045em; }
.page-heading .description { max-width: 640px; margin: 10px 0 0; color: var(--muted); line-height: 1.55; }

.button { min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; text-decoration: none; transition: transform .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--accent); color: white; }
.button-primary:hover { background: var(--accent-dark); }
.button-secondary { background: white; border-color: var(--line); color: var(--ink); }
.button-ghost { background: #edf1ee; color: var(--ink); }
.button-danger { color: var(--danger); background: #fff0ef; }
.button-small { min-height: 36px; padding: 7px 11px; font-size: .86rem; }
.button svg { width: 18px; height: 18px; }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.heading-actions, .table-actions, .card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.table-actions { min-width: 240px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { padding: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.stat-card .stat-label { color: var(--muted); font-size: .88rem; }
.stat-card strong { display: block; margin-top: 10px; font-size: 2rem; letter-spacing: -.05em; }
.stat-card.accent { background: var(--forest); color: white; border-color: var(--forest); }
.stat-card.accent .stat-label { color: #aebfb8; }
.progress { height: 7px; margin-top: 14px; overflow: hidden; border-radius: 999px; background: #e3e9e5; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

.panel { overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.toolbar { padding: 15px; display: grid; grid-template-columns: minmax(240px, 1fr) 190px 180px auto; gap: 10px; border-bottom: 1px solid var(--line); }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 13px; top: 50%; width: 18px; height: 18px; color: var(--muted); transform: translateY(-50%); }
.input, .select { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid #ccd5d0; border-radius: 10px; background: white; color: var(--ink); }
.search-box .input { padding-left: 40px; }
.select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, #66716d 50%), linear-gradient(135deg, #66716d 50%, transparent 50%); background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.field { display: grid; gap: 7px; }
.field label { font-size: .88rem; font-weight: 700; }
.field-hint { color: var(--muted); font-size: .8rem; line-height: 1.4; }
.field-error { color: var(--danger); font-size: .8rem; }
.input-large, .select-large { min-height: 52px; font-size: 1rem; }

.entry-card { padding: 24px; margin-bottom: 28px; border: 1px solid var(--line); border-radius: 20px; background: white; box-shadow: 0 12px 35px rgba(23, 32, 29, .05); }
.entry-card-header { margin-bottom: 22px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.entry-card-header h3 { margin: 8px 0 0; font-size: 1.35rem; letter-spacing: -.025em; }
.step-badge { display: inline-flex; padding: 5px 9px; border-radius: 7px; background: var(--mint); color: #276746; font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.pending-count { color: var(--accent-dark); font-weight: 750; }
.sales-contact-form { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field-wide { grid-column: 1 / -1; }
.selected-customer-info { grid-column: 1 / -1; padding: 13px 15px; border-left: 4px solid var(--accent); border-radius: 0 10px 10px 0; background: #fff7f4; }
.selected-customer-info strong, .selected-customer-info span { display: block; }
.selected-customer-info span { margin-top: 4px; color: var(--muted); font-size: .86rem; }
.save-contact-button { width: 100%; min-height: 50px; }
.all-complete { padding: 34px 20px; border-radius: 14px; background: var(--mint); text-align: center; }
.all-complete strong { font-size: 1.15rem; }
.all-complete p { margin: 7px 0 0; color: #37624d; }
.completed-section { margin-top: 10px; }
.completed-heading { margin-bottom: 16px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.completed-heading h3 { margin: 0; font-size: 1.35rem; letter-spacing: -.025em; }
.completed-search { width: min(100%, 330px); }
.completed-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.completed-card { padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.completed-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.completed-card h4 { margin: 0; font-size: 1rem; line-height: 1.35; }
.completed-card-top p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; }
.completed-contact { margin: 15px 0; padding: 13px; border-radius: 10px; background: #f5f7f5; }
.completed-contact strong, .completed-contact span, .completed-contact a { display: block; }
.completed-contact span { margin-top: 4px; color: var(--muted); font-size: .86rem; }
.completed-contact a { margin-top: 8px; color: #24734e; font-weight: 750; text-decoration: none; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 16px; background: #f7f9f7; color: var(--muted); font-size: .76rem; letter-spacing: .045em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 15px 16px; border-top: 1px solid #edf0ee; vertical-align: middle; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: #fafcfb; }
.company-cell { min-width: 240px; }
.company-cell strong { display: block; margin-bottom: 4px; }
.company-cell small, .muted { color: var(--muted); }
.pic-cell { min-width: 190px; }
.pic-cell strong, .pic-cell small { display: block; }
.pic-cell small { margin-top: 4px; color: var(--muted); }
.status-pill.complete { background: var(--mint); color: #276746; }
.status-pill.pending { background: #fff3d9; color: #8a5d12; }
.empty-state { padding: 65px 24px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 7px; color: var(--ink); font-size: 1.1rem; }
.customer-cards { display: none; }

.sales-breakdown { margin-top: 24px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.sales-card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.sales-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sales-card-header strong { font-size: 1rem; }
.sales-card p { margin: 7px 0 0; color: var(--muted); font-size: .86rem; }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; padding: 20px; background: rgba(14, 24, 20, .54); display: grid; place-items: center; animation: fade-in .16s ease-out; }
.modal { width: min(100%, 560px); max-height: calc(100vh - 40px); overflow: auto; background: white; border-radius: 20px; box-shadow: 0 30px 80px rgba(0,0,0,.23); }
.modal-header { padding: 22px 24px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; }
.modal-header h3 { margin: 0; font-size: 1.25rem; letter-spacing: -.025em; }
.modal-header p { margin: 6px 0 0; color: var(--muted); font-size: .88rem; }
.icon-button { width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center; border: 0; border-radius: 10px; background: #edf1ee; color: var(--ink); }
.icon-button svg { width: 19px; height: 19px; }
.modal-body { padding: 24px; display: grid; gap: 17px; }
.modal-actions { padding: 18px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.danger-zone { margin-right: auto; }
#admin-credentials-field { display: grid; gap: 17px; }
.admin-password-field { margin-top: 0; }
.multi-sales-list { max-height: 220px; overflow: auto; padding: 8px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; border: 1px solid #ccd5d0; border-radius: 10px; background: #fafcfb; }
.multi-sales-option { min-width: 0; padding: 9px 10px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 9px; background: white; cursor: pointer; font-weight: 600; }
.multi-sales-option input { width: 17px; height: 17px; flex: 0 0 17px; accent-color: var(--accent); }
.multi-sales-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-picker { padding: 14px; border: 1px dashed #bdc9c2; border-radius: 12px; background: #f6faf7; }
.contact-picker p { margin: 0 0 10px; color: var(--muted); font-size: .84rem; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.users-list { display: grid; }
.user-row { padding: 16px 18px; display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(130px, .6fr) minmax(150px, .7fr) auto; align-items: center; gap: 14px; border-top: 1px solid var(--line); }
.user-row:first-child { border-top: 0; }
.user-identity strong, .user-identity small { display: block; }
.user-identity small { margin-top: 4px; color: var(--muted); }
.active-dot { width: 8px; height: 8px; margin-right: 6px; display: inline-block; border-radius: 50%; background: #34a267; }
.active-dot.off { background: #9aa19e; }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: grid; gap: 10px; }
.toast { width: min(360px, calc(100vw - 40px)); padding: 14px 16px; border-radius: 12px; background: var(--forest); color: white; box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast.error { background: #8b3030; }
.mobile-menu { display: none; }
.mobile-bottom-nav { display: none; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .toolbar { grid-template-columns: 1fr 1fr; }
    .search-box { grid-column: 1 / -1; }
    .sales-breakdown { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 780px) {
    .login-shell { grid-template-columns: 1fr; min-height: auto; }
    .login-art { min-height: 260px; padding: 32px; }
    .login-art h1 { font-size: 2.3rem; }
    .login-content { padding: 32px; }
    .app-shell { display: block; }
    .sidebar { display: none; }
    .topbar { height: 64px; padding: 0 18px; }
    .mobile-menu { display: grid; }
    .topbar .role-pill { display: none; }
    .content { padding: 24px 16px 92px; }
    .entry-card { padding: 18px; border-radius: 16px; }
    .entry-card-header { align-items: flex-start; }
    .sales-contact-form { grid-template-columns: 1fr; gap: 15px; }
    .field-wide { grid-column: auto; }
    .selected-customer-info { grid-column: auto; }
    .completed-heading { align-items: stretch; flex-direction: column; }
    .completed-search { width: 100%; }
    .completed-grid { grid-template-columns: 1fr; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .page-heading > .button, .page-heading > a.button, .heading-actions { width: 100%; }
    .heading-actions .button { flex: 1 1 180px; }
    .stats-grid { gap: 10px; }
    .stat-card { padding: 16px; }
    .stat-card strong { font-size: 1.65rem; }
    .toolbar { grid-template-columns: 1fr; }
    .search-box { grid-column: auto; }
    .table-scroll { display: none; }
    .customer-cards { display: grid; gap: 12px; padding: 12px; }
    .customer-card { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: white; }
    .customer-card-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
    .customer-card h3 { margin: 0; font-size: 1rem; line-height: 1.35; }
    .customer-card-meta { margin: 8px 0 14px; color: var(--muted); font-size: .82rem; }
    .customer-card-contact { padding: 12px; margin-bottom: 12px; background: #f6f8f6; border-radius: 10px; }
    .customer-card-contact strong, .customer-card-contact small { display: block; }
    .customer-card-contact small { margin-top: 4px; color: var(--muted); }
    .customer-card .button { width: 100%; }
    .table-actions { min-width: 0; }
    .sales-breakdown { grid-template-columns: 1fr; }
    .user-row { grid-template-columns: 1fr auto; }
    .user-row > :nth-child(2), .user-row > :nth-child(3) { grid-column: 1; }
    .mobile-bottom-nav { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 12; padding: 7px; display: flex; justify-content: space-around; gap: 6px; border: 1px solid rgba(255,255,255,.08); border-radius: 15px; background: rgba(24,43,36,.96); box-shadow: var(--shadow); }
    .mobile-bottom-nav .nav-button { justify-content: center; min-height: 46px; padding: 8px; }
    .mobile-bottom-nav .nav-button span { display: none; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card.accent { grid-column: 1 / -1; }
    .demo-actions { grid-template-columns: 1fr; }
    .login-art { min-height: 220px; padding: 26px; }
    .login-content { padding: 26px 22px; }
    .modal-backdrop { padding: 0; align-items: end; }
    .modal { width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; }
    .modal-actions { flex-wrap: wrap; }
    .modal-actions .danger-zone { width: 100%; margin-right: 0; order: 3; }
    .contact-actions .button { width: 100%; }
    .multi-sales-list { grid-template-columns: 1fr; }
}

