/* OmRoots Salesman Portal — DigiWire-style mobile UI */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body.omroots-portal {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f4f8;
    color: #1a202c;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Login ── */
.portal-login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: linear-gradient(135deg, #e8eef5 0%, #f0f4f8 100%);
}
.portal-login-card {
    display: flex;
    width: 100%;
    max-width: 900px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.12);
    min-height: 520px;
}
.portal-login-brand {
    flex: 1;
    background: linear-gradient(160deg, #1e3a5f 0%, #2d5a8e 100%);
    color: #fff;
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.portal-logo { font-size: 28px; font-weight: 800; margin-bottom: 24px; letter-spacing: -1px; }
.portal-login-brand h1 { font-size: 28px; font-weight: 700; line-height: 1.3; margin-bottom: 12px; }
.portal-login-brand p { color: rgba(255,255,255,.7); font-size: 15px; line-height: 1.6; }
.portal-login-stats { display: flex; gap: 16px; margin-top: 40px; }
.portal-login-stats div { background: rgba(255,255,255,.1); border-radius: 10px; padding: 16px; flex: 1; text-align: center; }
.portal-login-stats span { display: block; font-size: 24px; font-weight: 700; }
.portal-login-stats small { color: rgba(255,255,255,.6); font-size: 12px; }
.portal-login-form { flex: 1; background: #fff; padding: 48px 40px; display: flex; flex-direction: column; justify-content: center; }
.portal-login-form h2 { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.portal-login-form .subtitle { color: #718096; margin-bottom: 28px; font-size: 14px; }
.portal-login-form label { display: block; font-size: 13px; font-weight: 600; color: #4a5568; margin-bottom: 6px; margin-top: 16px; }
.portal-login-form input[type=text],
.portal-login-form input[type=password],
.portal-login-form input[type=email],
.portal-login-form input[type=tel] {
    width: 100%; padding: 12px 14px; border: 1.5px solid #e2e8f0; border-radius: 8px;
    font-size: 15px; outline: none; transition: border .2s;
}
.portal-login-form input:focus { border-color: #3182ce; }
.portal-login-form .remember { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-top: 12px; }
.btn-primary {
    background: #3182ce; color: #fff; border: none; border-radius: 8px;
    padding: 14px; font-size: 16px; font-weight: 600; cursor: pointer; margin-top: 24px;
    width: 100%; transition: background .2s;
}
.btn-primary:hover { background: #2b6cb0; }
.btn-block { margin-top: 16px; }
.portal-alert.error { background: #fed7d7; color: #c53030; padding: 12px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; }
.portal-footer-text { text-align: center; color: #a0aec0; font-size: 12px; margin-top: 24px; }

@media (max-width: 640px) {
    .portal-login-card { flex-direction: column; }
    .portal-login-brand { padding: 32px 24px; }
    .portal-login-form { padding: 32px 24px; }
    .portal-login-stats { display: none; }
}

/* ── Header ── */
.portal-header {
    background: linear-gradient(135deg, #1e3a5f, #2d5a8e);
    color: #fff; padding: 14px 16px;
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 100;
}
.portal-header-title { flex: 1; font-weight: 600; font-size: 16px; }
.back-btn { color: #fff; text-decoration: none; font-size: 20px; padding: 4px 8px; }
.hdr-btn {
    background: rgba(255,255,255,.15); color: #fff; border: none;
    padding: 6px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; text-decoration: none;
}
.hdr-btn.logout { background: rgba(255,255,255,.1); }

/* ── Content ── */
.portal-content { padding: 16px; padding-bottom: 90px; max-width: 600px; margin: 0 auto; }
.portal-greeting h1 { font-size: 20px; font-weight: 700; margin-bottom: 16px; }

/* Quick stats */
.portal-quick-stats { display: flex; gap: 10px; margin-bottom: 16px; }
.qstat { flex: 1; background: #fff; border-radius: 12px; padding: 14px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.qstat .num { display: block; font-size: 24px; font-weight: 800; color: #1e3a5f; }
.qstat small { color: #718096; font-size: 11px; }

/* Stat cards */
.portal-stat-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: 12px; padding: 16px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.06); border-top: 3px solid; }
.stat-card.blue { border-color: #3182ce; }
.stat-card.green { border-color: #38a169; }
.stat-card.purple { border-color: #805ad5; }
.stat-card.orange { border-color: #dd6b20; }
.stat-card .num { display: block; font-size: 28px; font-weight: 800; }
.stat-card small { color: #718096; font-size: 11px; font-weight: 600; letter-spacing: .5px; }

/* Targets */
.portal-section { margin-bottom: 20px; }
.portal-section h3 { font-size: 14px; font-weight: 700; color: #4a5568; margin-bottom: 12px; }
.target-rings { display: flex; gap: 12px; justify-content: space-around; }
.ring-item { text-align: center; }
.ring { width: 72px; height: 72px; border-radius: 50%; border: 4px solid #e2e8f0; display: flex; align-items: center; justify-content: center; margin: 0 auto 6px; font-size: 11px; font-weight: 700; color: #4a5568; }
.ring-item small { font-size: 10px; color: #718096; font-weight: 600; }

/* Actions */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-btn {
    background: #fff; border-radius: 12px; padding: 16px; text-align: center;
    text-decoration: none; color: #2d3748; font-size: 13px; font-weight: 600;
    box-shadow: 0 1px 4px rgba(0,0,0,.06); display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.action-btn svg { width: 24px; height: 24px; color: #3182ce; }

/* ── Form ── */
.portal-form .form-section { background: #fff; border-radius: 12px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.portal-form h3 { font-size: 13px; font-weight: 700; color: #4a5568; margin-bottom: 12px; text-transform: uppercase; letter-spacing: .5px; }
.portal-form label { display: block; font-size: 12px; font-weight: 600; color: #718096; margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .3px; }
.portal-form input, .portal-form textarea, .portal-form select {
    width: 100%; padding: 11px 12px; border: 1.5px solid #e2e8f0; border-radius: 8px;
    font-size: 15px; outline: none; font-family: inherit;
}
.portal-form input:focus, .portal-form textarea:focus { border-color: #3182ce; }
.gps-box { background: #f7fafc; border: 1.5px dashed #cbd5e0; border-radius: 8px; padding: 14px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.gps-box.ok { border-color: #38a169; background: #f0fff4; }
.btn-sm { background: #3182ce; color: #fff; border: none; padding: 8px 14px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.outcome-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.outcome-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px; border: 2px solid #e2e8f0; border-radius: 10px; cursor: pointer; font-size: 12px; font-weight: 600; text-align: center; }
.outcome-btn input { display: none; }
.outcome-btn:has(input:checked) { border-color: #3182ce; background: #ebf8ff; color: #2b6cb0; }
.outcome-btn .icon { font-size: 20px; }

/* Deal / Order section */
#deal-order-wrap { margin-top: 12px; padding-top: 12px; border-top: 1.5px dashed #e2e8f0; }
.deal-title { font-size: 14px; font-weight: 700; color: #2d3748; margin-bottom: 4px; text-transform: none; letter-spacing: 0; }
.deal-hint { font-size: 12px; color: #718096; margin-bottom: 12px; }
.order-item-row { background: #f7fafc; border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.order-item-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 8px; }
.order-item-grid.fmcg-grid { grid-template-columns: 1fr 1fr 1fr; }
@media (min-width: 480px) {
    .order-item-grid.fmcg-grid { grid-template-columns: repeat(3, 1fr); }
}
.btn-add-item { width: 100%; margin: 4px 0 14px; background: #edf2f7; color: #2d3748; }
.order-summary { background: #ebf8ff; border-radius: 10px; padding: 14px; }
.summary-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 14px; }
.summary-row.total strong, .summary-row.due strong { font-size: 18px; color: #2b6cb0; }
.summary-row.due strong { color: #c05621; }
.order-summary label { margin-top: 8px; }
.schedule-row {
    display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 8px; margin-top: 4px;
}
.schedule-row label { margin-top: 8px; }

.task-list .task-card {
    background: #fff; border-radius: 10px; padding: 14px; margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06); border-left: 3px solid #3182ce;
}
.task-card h4 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.task-card p { font-size: 13px; color: #718096; }
.task-card .task-due { color: #c05621; font-weight: 600; margin-top: 4px; }

/* ── Lists ── */
.list-cards .card, .visits-list .visit-card {
    background: #fff; border-radius: 10px; padding: 14px; margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.card h4, .visit-card h4 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.card p, .visit-card p { font-size: 13px; color: #718096; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.green { background: #c6f6d5; color: #276749; }
.badge.red { background: #fed7d7; color: #c53030; }
.badge.blue { background: #bee3f8; color: #2b6cb0; }
.loading { text-align: center; color: #a0aec0; padding: 32px; }
.portal-search input { width: 100%; padding: 12px; border: 1.5px solid #e2e8f0; border-radius: 8px; margin-bottom: 12px; font-size: 15px; }
.portal-info { color: #718096; font-size: 14px; margin-bottom: 12px; }

/* ── Bottom Nav ── */
.portal-bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff; border-top: 1px solid #e2e8f0;
    display: flex; justify-content: space-around;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 200; box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.portal-bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    text-decoration: none; color: #a0aec0; font-size: 10px; font-weight: 600;
    padding: 4px 8px; min-width: 56px;
}
.portal-bottom-nav a svg { width: 22px; height: 22px; }
.portal-bottom-nav a.active { color: #3182ce; }

/* Order search + detail sheet */
.portal-search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.portal-search-row .portal-input { flex: 1; margin: 0; }
.portal-input {
    width: 100%; padding: 11px 12px; border: 1.5px solid #e2e8f0; border-radius: 8px;
    font-size: 15px; outline: none; font-family: inherit; box-sizing: border-box;
}
.portal-label { display: block; font-size: 12px; font-weight: 600; color: #718096; margin: 10px 0 4px; }
.btn-ghost { background: #edf2f7; color: #2d3748; border: none; padding: 10px 14px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.portal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.card-actions { display: flex; gap: 8px; margin-top: 10px; }
.card-actions .btn,
.card-actions .btn-card-primary,
.card-actions .btn-card-ghost {
    flex: 1; text-align: center; padding: 10px 8px; font-size: 14px; font-weight: 600;
    border-radius: 8px; cursor: pointer; border: none; margin: 0; width: auto;
}
.btn-card-primary { background: #3182ce; color: #fff; }
.btn-card-primary:hover { background: #2b6cb0; }
.btn-card-ghost { background: #edf2f7; color: #2d3748; }
.btn-map {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    flex: 1; text-align: center; padding: 10px 12px; font-size: 14px; font-weight: 700;
    border-radius: 8px; text-decoration: none; border: none; cursor: pointer;
    background: #0f766e; color: #fff;
}
.btn-map:hover { background: #0d9488; color: #fff; }
.btn-map-full { width: 100%; display: block; padding: 14px; font-size: 15px; box-sizing: border-box; }
.btn-edit-full {
    width: 100%; margin-top: 12px; padding: 14px; border: none; border-radius: 10px;
    background: #3182ce; color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
}

.portal-sheet[hidden] { display: none !important; }
.portal-sheet { position: fixed; inset: 0; z-index: 300; }
.portal-sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.portal-sheet-panel {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto;
    background: #fff; border-radius: 16px 16px 0 0; padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 30px rgba(0,0,0,.15);
}
.portal-sheet-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; gap: 12px; }
.portal-sheet-head h3 { font-size: 17px; font-weight: 700; margin: 0; }
.portal-sheet-head .muted, .muted { color: #718096; font-size: 13px; margin: 2px 0 0; }
.portal-sheet-close { background: #edf2f7; border: none; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 16px; }
.od-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.od-kpis > div { background: #f7fafc; border-radius: 10px; padding: 10px 12px; }
.od-kpis span { display: block; font-size: 11px; color: #718096; text-transform: uppercase; font-weight: 600; }
.od-kpis strong { font-size: 16px; color: #2d3748; }
.od-kpis strong.ok { color: #276749; }
.od-kpis strong.warn { color: #c05621; }
.od-items { background: #f7fafc; border-radius: 10px; overflow: hidden; }
.od-item-row { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid #e2e8f0; font-size: 13px; }
.od-item-row:last-child { border-bottom: none; }
.od-edit-row { background: #f7fafc; border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.od-edit-row .row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }

/* Hide WP chrome on portal */
body.omroots-portal #wpadminbar { display: none !important; }
