/* =========================================
   KALKULATOR SHOPEE STAR+ — MOBILE
   Native Android app-style interface
   ========================================= */

:root {
    --bg: #F4F1EC;
    --card: #FFFFFF;
    --card-alt: #FBF8F3;
    --text: #1B1B2F;
    --text-mute: #71717A;
    --text-light: #A1A1AA;
    --border: #E8E5DF;
    --border-soft: #F1EEE8;

    --primary: #EE4D2D;
    --primary-dark: #D63A1F;
    --primary-soft: #FEF1ED;

    --accent: #F59E0B;
    --accent-soft: #FEF3C7;

    --success: #15A34A;
    --success-soft: #DCFCE7;
    --warning: #EA8C0B;
    --warning-soft: #FEF3C7;
    --danger: #DC2626;
    --danger-soft: #FEE2E2;
    --info: #2563EB;
    --info-soft: #DBEAFE;

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;

    --shadow-sm: 0 1px 3px rgba(27,27,47,0.06);
    --shadow-md: 0 4px 16px rgba(27,27,47,0.08);
    --shadow-lg: 0 -4px 24px rgba(27,27,47,0.12);
    --shadow-primary: 0 6px 20px rgba(238,77,45,0.32);

    --nav-height: 64px;
    --topbar-height: 60px;

    --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Roboto', sans-serif;
    --mono: 'JetBrains Mono', 'Roboto Mono', monospace;

    --t: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

input, select, button, textarea {
    font-family: inherit;
}

/* =========================================
   APP SHELL
   ========================================= */
.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    background: var(--bg);
}

.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: var(--nav-height);
}

.screen.active {
    display: flex;
    animation: screenIn 0.25s ease;
}

@keyframes screenIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   TOPBAR
   ========================================= */
.topbar {
    height: var(--topbar-height);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.topbar-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: var(--shadow-primary);
}

.topbar-title h1 {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.topbar-badge {
    font-size: 11px;
    color: var(--text-mute);
    font-weight: 600;
}

.icon-action {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-alt);
    color: var(--text-mute);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--t);
}

.icon-action:active {
    background: var(--primary-soft);
    color: var(--primary);
    transform: scale(0.92);
}

/* =========================================
   SCREEN BODY
   ========================================= */
.screen-body {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
}

.m-spacer { height: 20px; }

/* =========================================
   RESULT HERO (sticky-ish)
   ========================================= */
.result-hero {
    background: linear-gradient(135deg, var(--text) 0%, #2E2E48 100%);
    border-radius: var(--r-lg);
    padding: 22px 20px;
    text-align: center;
    margin-bottom: 14px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.result-hero::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    opacity: 0.45;
}

.result-hero-label {
    font-size: 12px;
    color: rgba(255,255,255,0.65);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    position: relative;
}

.result-hero-price {
    font-family: var(--mono);
    font-size: 40px;
    font-weight: 800;
    color: #FFB85C;
    letter-spacing: -0.03em;
    margin: 6px 0 10px;
    line-height: 1;
    position: relative;
}

.result-hero-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    position: relative;
}

.rh-coret {
    font-size: 13px;
    color: rgba(255,255,255,0.6);
    font-family: var(--mono);
    text-decoration: line-through;
}

.rh-badge {
    font-size: 12px;
    font-weight: 700;
    background: rgba(255,255,255,0.15);
    color: white;
    padding: 4px 12px;
    border-radius: 999px;
}

.rh-badge.danger { background: var(--danger); }
.rh-badge.warning { background: var(--warning); }
.rh-badge.success { background: var(--success); }

/* =========================================
   CARDS
   ========================================= */
.m-card {
    background: var(--card);
    border-radius: var(--r-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-soft);
}

.m-card.info {
    background: var(--info-soft);
    border-color: transparent;
}

.m-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.m-card-head h2 {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.01em;
    flex: 1;
}

.m-card > h2 {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

.m-card.info > h2 { color: var(--info); }

.m-step {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0;
}

.m-card-head.collapsible {
    cursor: pointer;
    margin-bottom: 0;
    user-select: none;
}

.m-card-head.collapsible.expanded {
    margin-bottom: 14px;
}

.chevron {
    color: var(--text-mute);
    transition: transform var(--t);
}

.m-card-head.collapsible.expanded .chevron {
    transform: rotate(180deg);
}

.m-collapse-body {
    display: none;
}

.m-collapse-body.show {
    display: block;
    animation: collapseIn 0.25s ease;
}

@keyframes collapseIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.m-subhead {
    font-size: 14px;
    font-weight: 700;
    margin: 16px 0 10px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
}

/* =========================================
   FORM FIELDS
   ========================================= */
.m-field {
    margin-bottom: 14px;
}

.m-field:last-child { margin-bottom: 0; }

.m-field.hidden { display: none; }

.m-field label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
}

.m-field input[type="text"],
.m-field input[type="number"],
.m-field select {
    width: 100%;
    height: 50px;
    padding: 0 16px;
    background: var(--card-alt);
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    font-size: 16px; /* 16px prevents zoom on iOS/Android */
    font-weight: 600;
    color: var(--text);
    transition: var(--t);
    appearance: none;
    -webkit-appearance: none;
}

.m-field input[type="number"] {
    font-family: var(--mono);
}

.m-field select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9' fill='none'%3e%3cpath d='M1 1.5L7 7.5L13 1.5' stroke='%231B1B2F' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 42px;
}

.m-field input:focus,
.m-field select:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--card);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.m-hint {
    font-size: 12px;
    color: var(--text-mute);
    margin-top: 6px;
    line-height: 1.4;
}

/* Segment control */
.m-segment {
    display: flex;
    background: var(--card-alt);
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    padding: 4px;
    gap: 4px;
}

.m-segment button {
    flex: 1;
    height: 42px;
    background: transparent;
    border: none;
    border-radius: calc(var(--r-md) - 4px);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-mute);
    cursor: pointer;
    transition: var(--t);
}

.m-segment button.active {
    background: var(--text);
    color: white;
    box-shadow: var(--shadow-sm);
}

.m-segment button:active {
    transform: scale(0.96);
}

/* Suggest button */
.m-suggest-btn {
    width: 100%;
    margin-top: 8px;
    padding: 12px;
    background: var(--accent-soft);
    border: 1.5px dashed var(--accent);
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 600;
    color: #B45309;
    cursor: pointer;
    transition: var(--t);
}

.m-suggest-btn strong {
    font-family: var(--mono);
    font-weight: 800;
}

.m-suggest-btn:active {
    background: var(--accent);
    color: white;
    transform: scale(0.98);
}

/* =========================================
   RATES
   ========================================= */
.m-rates {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--card-alt);
    border-radius: var(--r-md);
    padding: 6px;
}

.m-rate {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 12px;
    font-size: 14px;
}

.m-rate span { color: var(--text-mute); font-weight: 500; }

.m-rate strong {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 15px;
}

.m-rate.total {
    background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft));
    border-radius: var(--r-sm);
    margin-top: 4px;
}

.m-rate.total span { color: var(--text); font-weight: 700; }
.m-rate.total strong { color: var(--primary); font-size: 17px; }

/* =========================================
   BREAKDOWN
   ========================================= */
.m-breakdown {
    background: var(--card-alt);
    border-radius: var(--r-md);
    padding: 6px;
    margin-bottom: 12px;
}

.m-bd-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    font-size: 14px;
}

.m-bd-row span:first-child { color: var(--text); }

.m-bd-row span:last-child {
    font-family: var(--mono);
    font-weight: 700;
}

.m-bd-row .pos { color: var(--success); }
.m-bd-row .neg { color: var(--danger); }

.m-bd-row.sub {
    background: var(--card);
    border-radius: var(--r-sm);
    margin: 3px 0;
    border-top: 1px dashed var(--border);
    border-bottom: 1px dashed var(--border);
}

.m-bd-row.sub span { color: var(--info) !important; font-weight: 700; }

.m-bd-row.total {
    background: linear-gradient(135deg, var(--success-soft), var(--card));
    border-radius: var(--r-sm);
    margin-top: 3px;
    padding: 13px 12px;
}

.m-bd-row.total span {
    color: var(--success) !important;
    font-weight: 800;
    font-size: 15px;
}

.m-bd-row.total span:last-child { font-size: 17px; }

.m-bd-row.total.danger {
    background: linear-gradient(135deg, var(--danger-soft), var(--card));
}

.m-bd-row.total.danger span { color: var(--danger) !important; }

/* Status */
.m-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--success-soft);
    border-radius: var(--r-md);
    border-left: 4px solid var(--success);
    margin-bottom: 12px;
}

.m-status:last-child { margin-bottom: 0; }

.m-status.warning { background: var(--warning-soft); border-left-color: var(--warning); }
.m-status.danger { background: var(--danger-soft); border-left-color: var(--danger); }
.m-status.info { background: var(--info-soft); border-left-color: var(--info); }

.m-status-icon { font-size: 20px; flex-shrink: 0; }

.m-status-text {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
}

/* Extra prices */
.m-extra-prices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.m-extra {
    background: var(--card-alt);
    border-radius: var(--r-md);
    padding: 12px;
    text-align: center;
}

.m-extra span {
    display: block;
    font-size: 11px;
    color: var(--text-mute);
    font-weight: 600;
    margin-bottom: 4px;
}

.m-extra strong {
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 700;
}

/* =========================================
   ROAS GRID
   ========================================= */
.m-roas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.m-roas-item {
    background: var(--card-alt);
    border-radius: var(--r-md);
    padding: 13px;
    text-align: center;
}

.m-roas-item.highlight {
    background: linear-gradient(135deg, var(--success-soft), var(--card));
    border: 1.5px solid var(--success);
}

.m-roas-item span {
    display: block;
    font-size: 11px;
    color: var(--text-mute);
    font-weight: 600;
    margin-bottom: 4px;
}

.m-roas-item strong {
    font-family: var(--mono);
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
}

.m-roas-item.highlight strong { color: var(--success); }

.m-roas-item small {
    display: block;
    font-size: 10px;
    color: var(--text-light);
    margin-top: 2px;
}

/* =========================================
   MULTI-PRODUK
   ========================================= */
.m-summary-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.m-summary-item {
    background: linear-gradient(135deg, var(--success-soft), var(--card));
    border: 1.5px solid var(--success);
    border-radius: var(--r-md);
    padding: 14px;
    text-align: center;
}

.m-summary-item span {
    display: block;
    font-size: 11px;
    color: var(--text-mute);
    font-weight: 600;
    margin-bottom: 4px;
}

.m-summary-item strong {
    font-family: var(--mono);
    font-size: 18px;
    font-weight: 800;
    color: var(--success);
}

/* Product Card */
.product-card {
    background: var(--card);
    border-radius: var(--r-lg);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-soft);
    cursor: pointer;
    transition: var(--t);
}

.product-card:active {
    transform: scale(0.99);
    background: var(--card-alt);
}

.pc-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.pc-name {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    flex: 1;
}

.pc-num {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--card-alt);
    color: var(--text-mute);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.pc-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.pc-stat {
    background: var(--card-alt);
    border-radius: var(--r-sm);
    padding: 8px 6px;
    text-align: center;
}

.pc-stat span {
    display: block;
    font-size: 10px;
    color: var(--text-mute);
    font-weight: 600;
    margin-bottom: 2px;
}

.pc-stat strong {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
}

.pc-stat.price strong { color: var(--primary); }
.pc-stat.profit strong { color: var(--success); }
.pc-stat.profit.neg strong { color: var(--danger); }
.pc-stat.margin strong { color: var(--text); }

.pc-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-mute);
}

.pc-empty-icon { font-size: 40px; margin-bottom: 8px; }

/* =========================================
   FAB
   ========================================= */
.fab {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    right: calc(50% - 240px + 16px);
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-primary);
    z-index: 25;
    transition: var(--t);
}

.fab:active { transform: scale(0.9); }

@media (max-width: 512px) {
    .fab { right: 16px; }
}

/* =========================================
   BOTTOM NAVIGATION
   ========================================= */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: var(--nav-height);
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 40;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    flex: 1;
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    color: var(--text-light);
    transition: var(--t);
    position: relative;
}

.nav-item svg {
    width: 23px;
    height: 23px;
    transition: var(--t);
}

.nav-item span {
    font-size: 10.5px;
    font-weight: 700;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active svg {
    transform: translateY(-1px);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

.nav-item:active { transform: scale(0.92); }

/* =========================================
   PANDUAN MARGIN
   ========================================= */
.m-paragraph {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 8px;
}

.m-bullets {
    list-style: none;
    margin-top: 6px;
}

.m-bullets li {
    font-size: 13.5px;
    line-height: 1.6;
    padding: 5px 0 5px 20px;
    position: relative;
}

.m-bullets li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--info);
    font-weight: 800;
}

.m-card:not(.info) .m-bullets li::before { color: var(--primary); }

.m-bullets.links li::before { content: '🔗'; }

.m-bullets a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* Benchmark item */
.bench-item {
    background: var(--card-alt);
    border-radius: var(--r-md);
    padding: 13px;
    margin-bottom: 8px;
    border-left: 4px solid var(--primary);
}

.bench-item:last-child { margin-bottom: 0; }

.bench-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    gap: 8px;
}

.bench-range {
    font-size: 14px;
    font-weight: 800;
}

.bench-margin {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 800;
    color: var(--primary);
    background: var(--primary-soft);
    padding: 3px 9px;
    border-radius: 999px;
    flex-shrink: 0;
}

.bench-laba {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 5px;
}

.bench-contoh {
    font-size: 12px;
    color: var(--text-mute);
    line-height: 1.45;
}

.bench-strategi {
    display: inline-block;
    margin-top: 7px;
    font-size: 11px;
    font-weight: 700;
    color: #B45309;
    background: var(--accent-soft);
    padding: 3px 9px;
    border-radius: 6px;
}

/* Adjust item */
.adjust-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    background: var(--card-alt);
    border-radius: var(--r-md);
    margin-bottom: 7px;
}

.adjust-row:last-child { margin-bottom: 0; }

.adjust-row.up { border-left: 4px solid var(--success); }
.adjust-row.down { border-left: 4px solid var(--warning); }

.adjust-tag {
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    flex-shrink: 0;
    width: 96px;
}

.adjust-row.up .adjust-tag { color: var(--success); }
.adjust-row.down .adjust-tag { color: var(--warning); }

.adjust-desc {
    font-size: 12.5px;
    color: var(--text-mute);
    line-height: 1.4;
}

/* =========================================
   PANDUAN IKLAN
   ========================================= */
.m-formula {
    background: var(--card-alt);
    border-left: 4px solid var(--primary);
    border-radius: var(--r-sm);
    padding: 12px 14px;
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.5;
}

.m-formula:last-child { margin-bottom: 0; }

.m-formula.danger {
    border-left-color: var(--danger);
    color: var(--danger);
}

.m-formula small {
    font-family: var(--font);
    font-size: 11px;
    font-weight: 700;
}

/* BEP table as list */
.bep-row {
    display: grid;
    grid-template-columns: 52px 1fr 1fr 1fr;
    gap: 6px;
    padding: 9px 10px;
    border-radius: var(--r-sm);
    align-items: center;
    margin-bottom: 4px;
    background: var(--card-alt);
}

.bep-row.head {
    background: var(--text);
    color: white;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.bep-row.head span { text-align: center; }
.bep-row.head span:first-child { text-align: left; }

.bep-margin {
    font-weight: 800;
    font-size: 13px;
}

.bep-val {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 12.5px;
    text-align: center;
}

.bep-val.bep { color: var(--danger); }
.bep-val.aman { color: var(--warning); }
.bep-val.bagus { color: var(--success); }

.bep-note {
    font-size: 11px;
    color: var(--text-mute);
    padding: 2px 10px 8px;
    line-height: 1.4;
}

/* Ad type card */
.adtype {
    background: var(--card-alt);
    border-radius: var(--r-md);
    padding: 13px;
    margin-bottom: 9px;
    border-top: 3px solid var(--primary);
}

.adtype:last-child { margin-bottom: 0; }

.adtype-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
}

.adtype-name {
    font-size: 13.5px;
    font-weight: 800;
}

.adtype-roas {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 800;
    background: var(--primary);
    color: white;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
}

.adtype-desc {
    font-size: 12.5px;
    color: var(--text-mute);
    line-height: 1.5;
    margin-bottom: 6px;
}

.adtype-budget {
    font-size: 12px;
    font-weight: 700;
    color: var(--success);
    padding-top: 7px;
    border-top: 1px dashed var(--border);
}

/* Timeline */
.tl-item {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.tl-item:last-child { margin-bottom: 0; }

.tl-marker {
    flex-shrink: 0;
    width: 46px;
    text-align: center;
}

.tl-week {
    background: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 5px 0;
    border-radius: 6px;
    line-height: 1.2;
}

.tl-line {
    width: 2px;
    background: var(--border);
    margin: 4px auto 0;
    height: calc(100% - 30px);
}

.tl-item:last-child .tl-line { display: none; }

.tl-body {
    flex: 1;
    background: var(--card-alt);
    border-radius: var(--r-md);
    padding: 12px;
}

.tl-body h4 {
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 4px;
}

.tl-meta {
    font-size: 11px;
    color: var(--success);
    font-weight: 700;
    margin-bottom: 5px;
}

.tl-body p {
    font-size: 12.5px;
    color: var(--text-mute);
    line-height: 1.5;
}

/* Rules */
.m-rules {
    list-style: none;
    counter-reset: r;
}

.m-rules li {
    counter-increment: r;
    background: var(--card-alt);
    border-radius: var(--r-md);
    padding: 11px 12px 11px 44px;
    margin-bottom: 7px;
    font-size: 12.5px;
    line-height: 1.5;
    position: relative;
}

.m-rules li:last-child { margin-bottom: 0; }

.m-rules li::before {
    content: counter(r);
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-weight: 800;
    font-size: 11px;
}

/* Reference list */
.ref-row {
    background: var(--card-alt);
    border-radius: var(--r-md);
    padding: 12px;
    margin-bottom: 8px;
}

.ref-row:last-child { margin-bottom: 0; }

.ref-name {
    font-size: 13.5px;
    font-weight: 800;
    margin-bottom: 3px;
}

.ref-contoh {
    font-size: 11.5px;
    color: var(--text-mute);
    line-height: 1.4;
    margin-bottom: 8px;
}

.ref-rates {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}

.ref-rate {
    background: var(--card);
    border-radius: var(--r-sm);
    padding: 7px 4px;
    text-align: center;
}

.ref-rate span {
    display: block;
    font-size: 9.5px;
    color: var(--text-mute);
    font-weight: 600;
    margin-bottom: 2px;
}

.ref-rate strong {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 800;
}

.ref-rate.total strong { color: var(--primary); }

/* =========================================
   BOTTOM SHEET
   ========================================= */
.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(27,27,47,0.5);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t);
}

.sheet-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 100%;
    max-width: 480px;
    max-height: 88vh;
    background: var(--card);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    z-index: 51;
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.bottom-sheet.show {
    transform: translateX(-50%) translateY(0);
}

.sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 999px;
    margin: 10px auto 4px;
    flex-shrink: 0;
}

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 12px;
    border-bottom: 1px solid var(--border-soft);
    flex-shrink: 0;
}

.sheet-head h2 {
    font-size: 17px;
    font-weight: 800;
}

.sheet-body {
    padding: 16px;
    overflow-y: auto;
}

.sheet-delete {
    width: 100%;
    margin-top: 8px;
    padding: 14px;
    background: var(--danger-soft);
    color: var(--danger);
    border: none;
    border-radius: var(--r-md);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.sheet-delete:active { transform: scale(0.98); }

/* =========================================
   TOAST
   ========================================= */
.toast {
    position: fixed;
    bottom: calc(var(--nav-height) + 20px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: white;
    padding: 12px 22px;
    border-radius: var(--r-md);
    font-size: 13.5px;
    font-weight: 600;
    z-index: 60;
    opacity: 0;
    transition: var(--t);
    pointer-events: none;
    box-shadow: var(--shadow-md);
    max-width: 88vw;
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success { background: var(--success); }
.toast.warning { background: var(--warning); }
.toast.danger { background: var(--danger); }

.hidden { display: none !important; }

/* ===== Save Button & Riwayat (mobile) ===== */
.m-save-btn {
    width: 100%;
    margin-top: 14px;
    padding: 14px 20px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(16,185,129,0.3);
    -webkit-tap-highlight-color: transparent;
}
.m-save-btn:active { transform: scale(0.98); }

.m-history-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted, #6b7280);
    font-size: 14px;
    line-height: 1.5;
}

.m-history-item {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}

.m-history-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}
.m-history-name {
    font-weight: 700;
    font-size: 14px;
    color: #111827;
    flex: 1;
    line-height: 1.3;
    word-break: break-word;
}
.m-history-del {
    background: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}
.m-history-del:active { background: #fecaca; }

.m-history-date {
    font-size: 11px;
    color: #9ca3af;
    margin-bottom: 10px;
}

.m-history-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}
.m-history-stat {
    background: #f9fafb;
    border-radius: 8px;
    padding: 8px 10px;
}
.m-history-stat-label {
    font-size: 10px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.m-history-stat-value {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
    margin-top: 2px;
}
.m-history-stat-value.profit { color: #ee4d2d; }
.m-history-stat-value.danger { color: #dc2626; }

.m-history-meta {
    font-size: 11px;
    color: #6b7280;
    padding-top: 8px;
    border-top: 1px dashed #e5e7eb;
    line-height: 1.6;
}
.m-history-meta span { display: inline-block; margin-right: 10px; }

/* ===== Auth Panel (Cloud Sync - mobile) ===== */
.m-auth-panel { margin-bottom: 12px; }
.m-auth-not-config, .m-auth-login, .m-auth-status {
    border-radius: 12px; padding: 12px 14px; font-size: 13px;
    line-height: 1.4;
}
.m-auth-not-config {
    background: #f3f4f6; color: #4b5563;
    display: flex; gap: 10px; align-items: flex-start;
    border: 1px dashed #d1d5db;
}
.m-auth-login { background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; }
.m-auth-status { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.m-auth-icon { font-size: 18px; flex-shrink: 0; }
.m-auth-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.m-auth-input {
    width: 100%; padding: 10px 12px; margin-top: 8px;
    border: 1px solid #d1d5db; border-radius: 8px;
    font-size: 14px; background: #fff; box-sizing: border-box;
    -webkit-appearance: none;
}
.m-auth-input:focus { outline: none; border-color: #2563eb; }
.m-auth-btn {
    width: 100%; padding: 11px; margin-top: 8px;
    background: #2563eb; color: white; border: none;
    border-radius: 8px; font-weight: 600; font-size: 14px;
    -webkit-tap-highlight-color: transparent;
}
.m-auth-btn:active { background: #1d4ed8; }
.m-auth-btn:disabled { background: #9ca3af; }
.m-auth-sent {
    margin-top: 8px; padding: 8px 10px; background: #d1fae5;
    border-radius: 6px; font-size: 12px; color: #065f46;
}
.m-auth-status-row { display: flex; gap: 10px; align-items: center; }
.m-auth-email {
    font-size: 11px; color: #047857; word-break: break-all;
    margin-top: 2px;
}
.m-auth-signout-btn {
    padding: 6px 10px; background: #fff; color: #065f46;
    border: 1px solid #a7f3d0; border-radius: 6px;
    font-size: 11px; font-weight: 600;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
