:root {
    --bg-dark: #f1eddf;
    --card-bg: #fffdf5;
    --card-strong: #eae5d8;
    --card-border: #d9d4c7;
    --card-border-hover: #928876;
    --text-main: #252520;
    --text-muted: #59594f;
    --text-dim: #666256;
    --accent: #39392f;
    --color-paid: #305d46;
    --color-paid-bg: #e2ecdc;
    --color-unpaid: #814637;
    --color-unpaid-bg: #f9ded1;
    --color-profit: #4e3a68;
    --font-mono: var(--font-sora);
}
html { scroll-behavior: smooth; }
.invoice-tools { display:flex; gap:10px; margin:0 0 22px; align-items:center; flex-wrap:wrap; }
.invoice-sync-state { color:#625d50; font-size:11px; max-width:440px; line-height:1.6; }
.invoice-manager-dialog > .invoice-sync-state:not(:empty) { margin-bottom:16px; }
.create-invoice-btn { background:#30352b; color:#fffdf3; border:0; border-radius:8px; padding:12px 18px; cursor:pointer; text-decoration:none; display:inline-block; font-size:12px; }
.create-invoice-btn:hover { background:#4c5542; }
.delete-invoice-btn { border:0; background:none; color:#814637; cursor:pointer; font-size:11px; padding:9px 0; text-align:left; }
.invoice-manager-dialog { border:1px solid #d9d1bf; border-radius:18px; background:#faf8ee; color:#292923; width:min(760px,calc(100vw - 28px)); max-height:90dvh; padding:26px; margin:auto; font:13px/1.7 var(--font-sora); }
.invoice-manager-dialog::backdrop { background:#29292370; }
.manager-heading { display:flex; justify-content:space-between; align-items:center; gap:15px; margin-bottom:20px; }
.manager-heading h2 { font-size:23px; font-weight:500; }
.manager-heading button { background:#eee8d9; border:0; border-radius:8px; width:40px; height:40px; cursor:pointer; font-size:24px; }
.manager-content p { margin-bottom:18px; }
.manager-content label { display:block; font-size:12px; }
.manager-content input,.manager-content textarea { width:100%; min-width:0; font:inherit; color:#292923; background:#fffdf6; border:1px solid #bdb3a0; padding:11px; border-radius:8px; margin:6px 0 12px; }
.manager-content textarea { resize:vertical; }
.draft-fields { display:grid; grid-template-columns:1fr 1fr; gap:4px 16px; }
.wide-field { grid-column:1/-1; }
.draft-hint { color:#625d50; font-size:11px; margin-top:12px; }
.draft-error { color:#9c3529; }
.trash-row { display:flex; justify-content:space-between; align-items:center; gap:20px; padding:14px 0; border-bottom:1px solid #ddd4c0; }
.document-actions { display:flex; flex-wrap:wrap; gap:12px; margin-bottom:18px; }
.document-actions a { text-decoration:none; }
.invoice-preview { width:100%; height:500px; border:1px solid #d9d1bf; border-radius:10px; background:white; }
@media(max-width:600px) { .draft-fields{grid-template-columns:1fr}.invoice-manager-dialog{padding:20px}.delete-invoice-btn{min-height:40px} }
body { background: #f1eddf; padding: 32px 32px 48px 246px; font-size: 13px; }
button, input { font: inherit; }
button, a { transition: background .18s ease, color .18s ease; }
button:active { transform: translateY(1px); }
:focus-visible { outline: 2px solid #584272 !important; outline-offset: 4px; }
.workspace-sidebar { position: fixed; inset: 16px auto 16px 16px; width: 202px; background: #faf9f3; border-radius: 18px; padding: 28px 16px 18px; display: flex; flex-direction: column; z-index: 10; }
.workspace-sidebar-top { display: flex; flex-direction: column; }
.mobile-lock-btn { display: none; }
.workspace-brand { display: flex; align-items: baseline; gap: 7px; color: #24241f; text-decoration: none; font-size: 25px; font-weight: 700; letter-spacing: -1.3px; padding: 0 12px 40px; }
.workspace-brand span { font-size: 13px; font-weight: 400; letter-spacing: -.3px; }
.sidebar-caption { padding: 0 12px 12px; color: #686458; font-size: 11px; }
.sidebar-link { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; color: #514f45; border-radius: 8px; padding: 12px; text-align: left; margin-bottom: 5px; cursor: pointer; font-size: 12px; }
.sidebar-link span { font-size: 19px; }
.sidebar-link.active { background: #eae6da; color: #24241f; font-weight: 600; }
.sidebar-link:hover { background: #eeece3; }
.mobile-lock { display: none; }
.sidebar-note { margin: 38px 12px; padding-top: 20px; border-top: 1px solid #dedbd0; font-size: 11px; line-height: 1.8; color: #676356; }
.sidebar-note > span { color: #36362e; font-weight: 500; }
.sidebar-note p { margin-top: 10px; }
.sidebar-account { margin-top: auto; padding: 14px 12px 0; border-top: 1px solid #dedbd0; display: grid; gap: 7px; font-size: 12px; }
.sidebar-account > span { color: #666256; font-size: 10px; }
.sidebar-account button { background: transparent; border: 0; text-align: left; padding: 16px 0 0; cursor: pointer; color: #514d42; font-size: 11px; }
.portal-container { max-width: 1600px; margin: auto; }
.portal-header { text-align: left; margin: 0 0 26px; padding: 0; border: 0; background: none; box-shadow: none; }
.portal-badge { border: 0; background: none; padding: 0; margin: 0 0 10px; font-size: 10px; color: #666256; letter-spacing: 0; box-shadow: none; }
.portal-title { color: #24241f; font-size: 30px; letter-spacing: -1.3px; font-weight: 500; line-height: 1.25; margin-bottom: 8px; text-transform: none; text-shadow: none; }
.portal-subtitle { color: #666256; font-size: 12px; max-width: none; margin: 0; }
.stats-bar { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 20px; min-height: 152px; border: 0; border-radius: 17px; box-shadow: none; position: relative; }
.stat-card::before, .invoice-card::before { display: none; }
.stat-card:hover { transform: none; box-shadow: none; }
.stat-card.profit-stat { background: #d0b4e9; }
.stat-card.paid-stat { background: #ffb99f; }
.stat-card.unpaid-stat { background: #adc6ed; }
.stat-card.total-stat { background: #e3e6c7; }
.stat-card.profit-stat, .stat-card.paid-stat, .stat-card.unpaid-stat, .stat-card.total-stat { border: 0; }
.stat-icon { height: 27px; width: 27px; background: #272722; border: 0 !important; color: #fff !important; border-radius: 50%; }
.stat-icon svg { width: 14px; height: 14px; }
.stat-info-title { color: #34332f; font-size: 10px; font-weight: 400; letter-spacing: 0; margin-bottom: 8px; }
.stat-info-val { color: #272722 !important; font-size: clamp(17px,1.65vw,29px); letter-spacing: -1px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Monthly Goal Tracker - Harmonized with Dashboard Pastel/Bento Theme */
.goal-tracker-card {
    background: #fffdf5;
    border: 1px solid #d9d4c7;
    border-radius: 17px;
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: none;
    position: relative;
    transition: background .18s ease, border-color .18s ease;
}
.goal-tracker-card:hover {
    border-color: #c7bda8;
    background: #fffdf5;
}
.goal-tracker-card.goal-achieved {
    border-color: #b8d9c2;
    background: #fdfefb;
}
.goal-tracker-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}
.goal-header-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.goal-icon-badge {
    height: 27px;
    width: 27px;
    background: #272722;
    color: #fff !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}
.goal-icon-badge svg {
    width: 14px;
    height: 14px;
}
.goal-tracker-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #666256;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: uppercase;
    margin-bottom: 4px;
    background: transparent;
    border: 0;
    padding: 0;
}
.goal-tracker-badge .badge-dot {
    width: 6px;
    height: 6px;
    background-color: #305d46;
    border-radius: 50%;
    display: inline-block;
}
.goal-tracker-title {
    font-size: 16px;
    font-weight: 600;
    color: #24241f;
    letter-spacing: -0.5px;
    margin: 0 0 4px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}
.goal-tracker-title span {
    color: #666256;
    font-weight: 400;
    font-size: 13px;
}
.goal-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 12px 0 6px;
    padding-top: 14px;
    border-top: 1px solid #eee8da;
}
.goal-control-col {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.goal-control-label {
    font-size: 10px;
    font-weight: 500;
    color: #666256;
    letter-spacing: 0;
    text-transform: uppercase;
}
.goal-month-pills {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}
.goal-month-pill-btn {
    background: transparent;
    border: 1px solid #d7d1c2;
    color: #514f43;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0;
    padding: 6px 12px;
    cursor: pointer;
    box-shadow: none;
    transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.goal-month-pill-btn:hover {
    background: #e3ddce;
    color: #272722;
}
.goal-month-pill-btn.active {
    color: #fffdf5;
    background: #292a24;
    border-color: #292a24;
    font-weight: 500;
}
.goal-tiers-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.goal-tier-btn {
    background: transparent;
    border: 1px solid #d7d1c2;
    color: #514f43;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0;
    padding: 7px 13px;
    cursor: pointer;
    box-shadow: none;
    transition: background .18s ease, color .18s ease, border-color .18s ease;
    text-transform: none;
}
.goal-tier-btn:hover {
    background: #e3ddce;
    color: #272722;
}
.goal-tier-btn.active {
    color: #fffdf5;
    background: #292a24;
    border-color: #292a24;
    font-weight: 500;
    box-shadow: none;
}
.goal-metrics-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin: 14px 0 10px;
    flex-wrap: wrap;
    gap: 12px;
}
.goal-metrics-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.goal-label-mini {
    color: #34332f;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: uppercase;
}
.goal-numbers {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}
.goal-numbers strong {
    color: #272722;
    font-size: clamp(20px, 2vw, 29px);
    letter-spacing: -1px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    line-height: 1.2;
}
.goal-numbers .target-divider {
    color: #8c877a;
    font-size: 15px;
    font-weight: 400;
}
.goal-numbers .target-num {
    color: #666256;
    font-size: 12px;
    font-weight: 400;
}
.goal-pct-pill {
    background: #eedfa9;
    color: #4a3b10;
    border: 0;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0;
    padding: 6px 13px;
    border-radius: 20px;
    box-shadow: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.goal-pct-pill.achieved {
    background: #d0b4e9;
    color: #38204d;
    box-shadow: none;
}
.goal-progress-track {
    background: #eae5d8;
    border: 0;
    height: 8px;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    margin-bottom: 16px;
}
.goal-progress-fill {
    height: 100%;
    width: 0%;
    background: #272722;
    border-radius: 20px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}
.goal-progress-fill.achieved {
    background: #305d46;
    box-shadow: none;
}
.goal-affirmation-box {
    background: #f4f0e4;
    border: 1px solid #ded6c5;
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.goal-affirmation-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
    min-width: 240px;
}
.goal-affirmation-icon {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}
.goal-affirmation-label {
    font-size: 10px;
    color: #666256;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.goal-affirmation-text {
    font-size: 12px;
    color: #272722;
    line-height: 1.55;
    font-style: italic;
    font-weight: 500;
}
.goal-actions-group {
    display: flex;
    gap: 8px;
    align-items: center;
}
.goal-action-btn {
    background: #fffdf6;
    border: 1px solid #d5cebe;
    color: #403b30;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0;
    padding: 7px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: background .18s ease, color .18s ease;
    text-transform: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: none;
}
.goal-action-btn:hover {
    background: #eae4d4;
    color: #24241f;
}
.goal-celebrate-btn {
    background: #30352b;
    color: #fffdf3;
    border-color: #30352b;
    font-weight: 500;
}
.goal-celebrate-btn:hover {
    background: #474f3f;
    color: #ffffff;
}

.filter-section { background: none; border: 0; box-shadow: none; padding: 0; margin-bottom: 24px; }
.filter-row-top { gap: 16px; padding: 0; margin: 0 0 14px; border: 0; justify-content: flex-start; }
.filter-title { font-size: 10px; color: #666256; letter-spacing: 0; text-transform: none; }
.month-pills-group { gap: 6px; flex-wrap: wrap; }
.month-pill-btn { background: transparent; border: 1px solid #d7d1c2; color: #514f43; border-radius: 20px; font-size: 10px; font-weight: 400; letter-spacing: 0; padding: 9px 14px; box-shadow: none; }
.month-pill-btn.active { color: #fffdf5; background: #292a24; border-color: #292a24; box-shadow: none; }
.month-pill-btn:hover { background: #e3ddce; color: #272722; transform: none; }
.filter-subrow { display: block; }
.filter-subrow .filter-title { display: none; }
.search-box { width: 100%; max-width: none; }
.search-input { background: transparent; color: #272722; border: 1px solid #d4cebe; border-radius: 9px; padding: 12px 16px 12px 40px; font-size: 12px; box-shadow: none; }
.search-input:focus { background: #faf7ec; border-color: #77705f; }
.search-input::placeholder { color: #666256; }
.revenue-report-box { display: none; background: #fffdf5; border: 1px solid #ded7c8; border-radius: 14px; padding: 24px; box-shadow: none; overflow-x: auto; }
body[data-view="report"] .revenue-report-box { display: block; }
body[data-view="report"] .invoice-grid, body[data-view="report"] .filter-subrow { display: none; }
.revenue-report-title { color: #323229; font-size: 13px; letter-spacing: 0; text-transform: none; }
.revenue-table { min-width: 670px; }
.revenue-table th { color: #605c50; background: #efebdf; letter-spacing: 0; font-size: 10px; }
.revenue-table td { color: #36362d !important; border-color: #e5dfd0; font-size: 12px; }
.revenue-table .grand-row { background: #e6ead7; }
.invoice-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); align-items: start; gap: 16px; }
.board-column { min-width: 0; }
.board-heading { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500; padding: 0 3px 14px; }
.board-count { font-size: 10px; border: 1px solid #d3ccbc; padding: 2px 6px; border-radius: 5px; color: #5c584c; }
.board-cards { display: grid; gap: 12px; }
.board-empty { padding: 25px 18px; border: 1px dashed #bfb6a4; border-radius: 12px; color: #686050; font-size: 12px; line-height: 1.7; }
.invoice-card { background: #fffdf3; border: 1px solid transparent; border-radius: 14px; padding: 18px; box-shadow: none; min-width: 0; gap: 14px; }
.invoice-card:hover { transform: none; box-shadow: none; border-color: #c7bda8; }
.card-top { flex-direction: column-reverse; align-items: flex-start; gap: 13px; margin-bottom: 10px; }
.client-title { color: #282821; font-size: 13px; line-height: 1.5; font-weight: 600; letter-spacing: -.2px; }
.status-badge-group { display: flex; flex-wrap: wrap; gap: 6px; }
.invoice-card .status-badge-group { flex-direction: row; align-items: center; }
.payment-status-pill { padding: 5px 8px; border: 0 !important; font-size: 9px; font-weight: 500; letter-spacing: 0; border-radius: 6px; }
.payment-status-pill.status-dp { background: #e5d5f2; color: #57376a; }
.payment-status-pill.status-dp:hover { background: #d6bce9; color: #422254; }
.status-dot { width: 5px; height: 5px; box-shadow: none; }
.dp-status-action { background: transparent; border: 1px solid #d5cebe; color: #605442; border-radius: 6px; font-size: 9px; letter-spacing: 0; padding: 5px 7px; }
.dp-status-action:hover { background: #eee5d2; color: #403b30; }
.ref-code { color: #666256; font-size: 9px; flex-wrap: wrap; gap: 6px; letter-spacing: 0; font-weight: 400; }
.month-tag { background: #efece1; color: #5c594f; border: 0; border-radius: 4px; font-size: 9px; }
.project-desc { color: #555247; font-size: 11px; line-height: 1.7; margin-bottom: 14px; }
.slug-box { background: none; border: 0; padding: 0; box-shadow: none; margin: 0 0 15px; }
.slug-url { display: none; }
.btn-row-flex { gap: 6px; flex-wrap: wrap; }
.slug-copy-btn { color: #514d42 !important; background: transparent !important; border: 1px solid #d6d0c0; border-radius: 6px; font-size: 9px; padding: 7px 9px; letter-spacing: 0; box-shadow: none; }
.slug-copy-btn:hover { background: #ede8da !important; transform: none; }
.financial-breakdown-box { background: none; border: 0; border-top: 1px solid #e4ddcd; padding: 12px 0 0; border-radius: 0; margin: 0; }
.fin-row { gap: 8px; align-items: baseline; margin-bottom: 7px; }
.fin-label { font-size: 9px; color: #6b6557; letter-spacing: 0; }
.fin-val { color: #37372e !important; font-size: 11px; white-space: nowrap; }
.net-profit-row { border-top: 0; padding-top: 2px; margin-top: 5px; }
.net-profit-flex { gap: 6px; flex-wrap: wrap; }
.net-profit-val { color: #315b42; font-size: 12px; white-space: nowrap; }
.edit-profit-btn { color: #5b5344; background: none; border: 0; font-size: 9px; padding: 4px; }
.action-btn { background: #efebdd; color: #3c3b30; border: 0; border-radius: 7px; padding: 10px; font-size: 10px; font-weight: 500; letter-spacing: 0; text-transform: none; box-shadow: none; }
.action-btn:hover { background: #e2dccb; color: #24241f; transform: none; box-shadow: none; }
.dev-footer-card { background: none; border: 0; border-top: 1px solid #d9d2c2; padding: 24px 0 0; margin-top: 32px; box-shadow: none; }
.dev-avatar { background: #ddd5c2; color: #3f3a2f; border: 0; box-shadow: none; }
.dev-name { color: #3c392f; font-size: 11px; }
.dev-title { color: #666256; font-size: 10px; }
.dev-contact-btn { background: transparent; color: #4c493e; border-color: #c6bcaa; font-size: 10px; box-shadow: none; }
.cover-overlay { background: #eae5d8; height: 100dvh; }
.cover-card { background: #faf8ee; color: #292923; border: 1px solid #ddd5c5; padding: 44px; border-radius: 22px; box-shadow: 0 22px 80px #65583b18; text-align: left; }
.cover-top-barcode { color: #666256; font-size: 11px; letter-spacing: 0; margin-bottom: 35px; }
.classified-stamp { transform: none; box-shadow: none; border: 0; background: #dbc4ee; color: #513862; padding: 7px 10px; letter-spacing: 0; text-transform: none; font-size: 10px; border-radius: 6px; margin-bottom: 20px; }
.cover-title { color: #292923; font-size: 32px; font-weight: 500; text-transform: none; letter-spacing: -1.4px; line-height: 1.25; margin-bottom: 16px; }
.cover-subtitle { color: #625d50; font-style: normal; font-size: 12px; line-height: 1.8; }
.classified-line-divider { border-color: #d9d1c0; border-top-style: solid; }
.passcode-label { display: block; color: #5c574a; font-size: 11px; text-transform: none; letter-spacing: 0; margin-bottom: 10px; }
.passcode-input, .passcode-input:focus { color: #252520; background: #fffdf6; border: 1px solid #bdb3a0; border-radius: 8px; box-shadow: none; font-size: 16px; text-align: left; letter-spacing: 2px; }
.passcode-input::placeholder { font-size: 12px; letter-spacing: 0; }
.passcode-error { color: #9c3529; font-size: 11px; letter-spacing: 0; }
.cover-open-btn { background: #292b24; color: #fffdf3; border: 0; border-radius: 8px; box-shadow: none; font-size: 12px; text-transform: none; letter-spacing: 0; width: 100%; }
.cover-open-btn:hover { background: #43473b; color: #fffdf3; box-shadow: none; transform: none; }
.modal-overlay { background: #25251f66; }
.modal-card { background: #faf8ef; color: #252520; border: 1px solid #d4cbb8; border-radius: 16px; box-shadow: 0 20px 60px #29251a22; }
.modal-title, .modal-input-label { color: #39362c; }
.modal-subtitle { color: #666256; }
.modal-input { background: #fffdf5; border: 1px solid #b9af9b; color: #252520; box-shadow: none; border-radius: 8px; }
.modal-btn { border-radius: 8px; box-shadow: none; }
.modal-btn-cancel { background: #e8e2d4; color: #37342b; border: 0; }
.modal-btn-confirm { background: #30352b; color: #fff; border: 0; }
.toast { background: #30342b; color: #fffdf3; border: 0; border-radius: 10px; font-size: 11px; letter-spacing: 0; max-width: calc(100vw - 32px); }
/* ========================================================
   RESPONSIVE DESIGN SYSTEM (MOBILE, TABLET, DESKTOP)
   ======================================================== */

@media (min-width: 1600px) { body { padding-right: 48px; } }

@media (max-width: 1150px) {
    body { padding: 24px 20px 40px 214px; }
    .workspace-sidebar { width: 178px; padding-inline: 10px; }
    .stats-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-card { min-height: 125px; }
    .stat-info-val { font-size: 24px; }
    .invoice-grid { gap: 12px; }
    .invoice-card { padding: 15px; }
    .fin-row { flex-wrap: wrap; }
}

@media (max-width: 850px) {
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    body {
        padding: 16px 16px 48px;
    }
    .workspace-sidebar {
        position: static;
        width: 100%;
        padding: 14px 16px;
        margin-bottom: 20px;
        border-radius: 14px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }
    .workspace-sidebar-top {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .workspace-brand {
        padding: 0;
        font-size: 20px;
    }
    .workspace-sidebar nav {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .workspace-sidebar nav::-webkit-scrollbar {
        display: none;
    }
    .sidebar-link {
        padding: 8px 12px;
        margin: 0;
        width: auto;
        font-size: 11px;
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 36px;
        border-radius: 20px;
    }
    .sidebar-link span {
        display: inline-block;
        font-size: 13px;
    }
    .sidebar-caption, .sidebar-note, .sidebar-account {
        display: none;
    }
    .sidebar-link.mobile-lock {
        display: none;
    }
    .mobile-lock-btn {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        padding: 6px 12px;
        font-size: 11px;
        font-weight: 600;
        color: #403d32;
        background: #eee8d8;
        border: 1px solid #ddd7c6;
        border-radius: 8px;
        cursor: pointer;
    }
    .stats-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
    .stat-card {
        padding: 16px 14px;
        min-height: 105px;
    }
    .stat-info-val {
        font-size: clamp(16px, 2.5vw, 22px);
    }
    .invoice-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .debt-stats-bar {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .debt-item-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .debt-amount-col {
        text-align: left;
    }
    .debt-item-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 600px) {
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    body {
        padding: 12px 12px 50px;
    }

    /* --- Sidebar / Header Mobile App Layout --- */
    .workspace-sidebar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 14px 10px;
        margin-bottom: 16px;
        border-radius: 14px;
        gap: 10px;
        background: #faf9f3;
        border: 1px solid #ded7c6;
    }
    .workspace-sidebar-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    .workspace-brand {
        padding: 0;
        font-size: 19px;
        display: flex;
        align-items: baseline;
        gap: 5px;
    }
    .workspace-brand span {
        display: inline !important;
        font-size: 11px;
        color: #666256;
    }
    .mobile-lock-btn {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 5px 11px;
        font-size: 11px;
        font-weight: 600;
        color: #433f33;
        background: #eae4d5;
        border: 1px solid #dcd4c2;
        border-radius: 7px;
    }
    .workspace-sidebar nav {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        width: 100%;
        padding-bottom: 2px;
    }
    .workspace-sidebar nav::-webkit-scrollbar {
        display: none;
    }
    .sidebar-link {
        padding: 7px 12px;
        font-size: 11px;
        font-weight: 500;
        border-radius: 20px;
        white-space: nowrap;
        flex-shrink: 0;
        min-height: 34px;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: #eae5d8;
        color: #454238;
        border: 1px solid transparent;
    }
    .sidebar-link span {
        display: inline-block !important;
        font-size: 12px;
    }
    .sidebar-link.active {
        background: #272722;
        color: #fffdf5;
        border-color: #272722;
        font-weight: 600;
    }
    .sidebar-link.mobile-lock {
        display: none;
    }

    /* --- Portal Title & Header --- */
    .portal-header {
        margin: 0 0 14px;
        padding: 0;
    }
    .portal-badge {
        font-size: 9px;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        margin-bottom: 4px;
    }
    .portal-title {
        font-size: 22px;
        font-weight: 600;
        letter-spacing: -0.7px;
        line-height: 1.2;
        margin-bottom: 4px;
    }
    .portal-subtitle {
        font-size: 11.5px;
        line-height: 1.45;
        color: #666256;
    }
    .portal-header-action {
        display: none !important;
    }

    /* --- Invoice Tools Toolbar --- */
    .invoice-tools {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin: 0 0 16px;
        align-items: stretch;
        width: 100%;
    }
    .invoice-tools .create-invoice-btn {
        flex: 1 1 auto;
        text-align: center;
        justify-content: center;
        min-height: 38px;
        padding: 9px 12px;
        font-size: 11.5px;
        font-weight: 600;
        border-radius: 8px;
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }
    .invoice-tools .month-pill-btn {
        padding: 9px 12px;
        font-size: 11px;
        min-height: 38px;
        border-radius: 8px;
        flex: 0 0 auto;
    }
    .invoice-sync-state {
        width: 100%;
        max-width: 100%;
        font-size: 10.5px;
        padding-top: 2px;
        line-height: 1.4;
    }

    /* --- Executive KPI Stats Bar --- */
    .stats-bar {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 16px;
    }
    .stat-card {
        padding: 12px 11px;
        min-height: 92px;
        border-radius: 13px;
        gap: 6px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    .stat-icon {
        height: 24px;
        width: 24px;
        min-height: 24px;
        min-width: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .stat-icon svg {
        width: 12px;
        height: 12px;
    }
    .stat-info-title {
        font-size: 9.5px;
        font-weight: 500;
        margin-bottom: 2px;
        line-height: 1.25;
    }
    .stat-info-val {
        font-size: clamp(12.5px, 3.8vw, 16px) !important;
        font-weight: 700;
        letter-spacing: -0.5px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.2;
    }

    /* --- Monthly Goal Tracker --- */
    .goal-tracker-card {
        padding: 14px 13px;
        border-radius: 14px;
        margin-bottom: 16px;
    }
    .goal-tracker-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-bottom: 10px;
    }
    .goal-header-left {
        gap: 9px;
    }
    .goal-icon-badge {
        height: 23px;
        width: 23px;
        min-width: 23px;
        margin-top: 2px;
    }
    .goal-icon-badge svg {
        width: 11px;
        height: 11px;
    }
    .goal-tracker-title {
        font-size: 14.5px;
        font-weight: 600;
        letter-spacing: -0.3px;
        margin-bottom: 2px;
    }
    .goal-tracker-sub {
        font-size: 10.5px;
        line-height: 1.45;
    }

    .goal-controls-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-bottom: 12px;
    }
    .goal-control-col {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }
    .goal-control-label {
        font-size: 9.5px;
        font-weight: 600;
        text-transform: uppercase;
        color: #514f43;
    }
    .goal-month-pills {
        display: flex;
        overflow-x: auto;
        flex-wrap: nowrap;
        gap: 5px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        width: 100%;
        padding-bottom: 2px;
    }
    .goal-month-pills::-webkit-scrollbar {
        display: none;
    }
    .goal-month-pill-btn {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 6px 10px;
        font-size: 9.5px;
        font-weight: 500;
        border-radius: 16px;
        min-height: 30px;
    }
    .goal-tiers-group {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
        width: 100%;
    }
    .goal-tier-btn {
        padding: 6px 2px;
        font-size: 9.5px;
        font-weight: 600;
        text-align: center;
        border-radius: 7px;
        min-height: 30px;
    }

    .goal-metrics-row {
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        gap: 6px;
        margin-bottom: 6px;
    }
    .goal-label-mini {
        font-size: 9px;
        margin-bottom: 2px;
    }
    .goal-numbers {
        display: flex;
        align-items: baseline;
        gap: 4px;
        flex-wrap: wrap;
    }
    .goal-numbers strong {
        font-size: 16px;
        font-weight: 700;
    }
    .target-divider {
        font-size: 11px;
    }
    .target-num {
        font-size: 10.5px;
    }
    .goal-pct-pill {
        font-size: 9.5px;
        padding: 3px 7px;
        border-radius: 5px;
        white-space: nowrap;
    }

    .goal-progress-track {
        height: 7px;
        border-radius: 5px;
        margin-bottom: 10px;
    }

    .goal-affirmation-box {
        padding: 9px 11px;
        border-radius: 9px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .goal-affirmation-content {
        gap: 8px;
    }
    .goal-affirmation-icon {
        font-size: 13px;
    }
    .goal-affirmation-label {
        font-size: 8.5px;
        margin-bottom: 1px;
    }
    .goal-affirmation-text {
        font-size: 10.5px;
        line-height: 1.45;
    }
    .goal-actions-group {
        justify-content: flex-end;
        gap: 5px;
        width: 100%;
    }
    .goal-action-btn {
        font-size: 9.5px;
        padding: 5px 9px;
        border-radius: 6px;
        min-height: 28px;
    }

    /* --- Filter & Search Section --- */
    .filter-section {
        margin-bottom: 16px;
        padding: 0;
    }
    .filter-row-top {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        margin-bottom: 10px;
    }
    .filter-title {
        font-size: 9.5px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }
    .month-pills-group {
        display: flex;
        overflow-x: auto;
        flex-wrap: nowrap;
        gap: 6px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        width: 100%;
        padding-bottom: 3px;
    }
    .month-pills-group::-webkit-scrollbar {
        display: none;
    }
    .month-pill-btn {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 7px 13px;
        font-size: 10px;
        font-weight: 500;
        border-radius: 20px;
        min-height: 34px;
    }

    .filter-subrow {
        width: 100%;
    }
    .search-box {
        width: 100%;
        position: relative;
    }
    .search-input {
        width: 100%;
        font-size: 13px;
        padding: 11px 12px 11px 36px;
        border-radius: 9px;
        min-height: 42px;
    }
    .search-icon {
        left: 12px;
        width: 14px;
        height: 14px;
    }

    /* --- Invoice Grid & Cards --- */
    .invoice-grid {
        grid-template-columns: 1fr;
        gap: 18px;
        width: 100%;
    }
    .board-column {
        width: 100%;
    }
    .board-heading {
        font-size: 12.5px;
        font-weight: 600;
        padding: 0 0 8px;
        margin-bottom: 4px;
        display: flex;
        align-items: center;
        gap: 6px;
        border-bottom: 1px solid #ded8c8;
        color: #2e2c24;
    }
    .board-count {
        font-size: 10px;
        padding: 2px 6px;
        border-radius: 8px;
    }
    .board-cards {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 8px;
    }

    .invoice-card {
        padding: 14px 13px;
        border-radius: 13px;
        gap: 10px;
        border: 1px solid #ded7c6;
        background: #fffdf5;
        box-shadow: 0 1px 4px rgba(0,0,0,0.02);
        width: 100%;
    }
    .card-top {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        gap: 8px;
        margin-bottom: 6px;
    }
    .client-title {
        font-size: 13.5px;
        font-weight: 700;
        line-height: 1.35;
        color: #24241f;
        flex: 1;
        word-break: break-word;
    }
    .status-badge-group {
        flex-shrink: 0;
        display: flex;
        gap: 4px;
        align-items: center;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    .payment-status-pill {
        font-size: 9px;
        font-weight: 600;
        padding: 4px 7px;
        border-radius: 5px;
        min-height: 26px;
    }
    .dp-history-badge {
        font-size: 8.5px;
        padding: 3px 6px;
    }

    .ref-code {
        font-size: 9.5px;
        color: #666256;
        margin-bottom: 6px;
        display: flex;
        align-items: center;
        gap: 5px;
        flex-wrap: wrap;
    }
    .month-tag {
        font-size: 9px;
        padding: 2px 5px;
    }
    .project-desc {
        font-size: 11px;
        line-height: 1.55;
        color: #514d41;
        margin-bottom: 8px;
    }

    .slug-box {
        margin: 0 0 8px;
        width: 100%;
    }
    .btn-row-flex {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        width: 100%;
    }
    .slug-copy-btn {
        width: 100%;
        min-height: 36px;
        font-size: 10px;
        font-weight: 600;
        border-radius: 6px;
        padding: 7px 8px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        background: #faf7eb !important;
        color: #454032 !important;
        border: 1px solid #d7d0c0;
    }

    .financial-breakdown-box {
        padding-top: 8px;
        margin-top: 2px;
        border-top: 1px solid #eae4d4;
        display: flex;
        flex-direction: column;
        gap: 5px;
    }
    .fin-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0;
    }
    .fin-label {
        font-size: 9.5px;
        font-weight: 500;
        color: #6d6759;
        text-transform: uppercase;
        letter-spacing: 0.02em;
    }
    .fin-val {
        font-size: 11.5px;
        font-weight: 600;
        color: #24241f;
    }
    .net-profit-flex {
        display: flex;
        align-items: center;
        gap: 6px;
    }
    .net-profit-val {
        font-size: 12.5px;
        font-weight: 700;
        color: #305d46;
    }
    .edit-profit-btn {
        font-size: 9.5px;
        padding: 3px 6px;
        background: #ede6d7;
        border-radius: 4px;
    }

    .card-action-bar {
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-top: 8px;
        width: 100%;
    }
    .action-btn,
    .mark-pelunasan-btn {
        width: 100%;
        min-height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 11px;
        font-weight: 600;
        border-radius: 7px;
        padding: 9px;
        text-decoration: none;
        text-align: center;
    }

    /* --- Debt & Receivables Section --- */
    .debt-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-bottom: 14px;
    }
    .debt-toolbar .create-invoice-btn {
        width: 100%;
        min-height: 38px;
        font-size: 11.5px;
        justify-content: center;
    }
    .debt-filter-pills {
        display: flex;
        overflow-x: auto;
        flex-wrap: nowrap;
        gap: 5px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        width: 100%;
        padding-bottom: 2px;
    }
    .debt-filter-pills::-webkit-scrollbar {
        display: none;
    }
    .debt-filter-pills .month-pill-btn {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 7px 11px;
        font-size: 10px;
        border-radius: 18px;
        min-height: 32px;
    }
    .debt-search-box {
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .debt-stats-bar {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 16px;
    }
    .debt-stats-bar .stat-card {
        padding: 12px 11px;
        min-height: 92px;
        border-radius: 13px;
        gap: 6px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    .debt-stats-bar .stat-info-val {
        font-size: clamp(12.5px, 3.8vw, 16px) !important;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .debt-item-card {
        padding: 13px 12px;
        border-radius: 11px;
        gap: 8px;
    }
    .debt-item-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 5px;
    }
    .debt-action-btn {
        min-height: 34px;
        padding: 6px 10px;
        font-size: 10.5px;
    }

    /* --- Laporan Keuangan Section --- */
    .revenue-report-box {
        padding: 14px 10px;
        border-radius: 12px;
        margin-bottom: 18px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .revenue-table {
        min-width: 540px;
        font-size: 10.5px;
    }
    .revenue-table th,
    .revenue-table td {
        padding: 9px 8px;
    }

    /* --- Dev Footer Card --- */
    .dev-footer-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 18px 12px;
        margin-top: 24px;
        gap: 10px;
    }
    .dev-info-left {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 6px;
    }
    .dev-contact-btn {
        width: 100%;
        min-height: 38px;
        justify-content: center;
        font-size: 10.5px;
    }

    /* --- Modals & Cover Card --- */
    .cover-card {
        padding: 24px 18px;
        border-radius: 16px;
        max-width: 92vw;
    }
    .cover-title {
        font-size: 24px;
        letter-spacing: -1px;
        margin-bottom: 12px;
    }
    .cover-open-btn {
        min-height: 42px;
        font-size: 12px;
    }

    .modal-card {
        max-width: 92vw;
        padding: 20px 16px;
        border-radius: 14px;
    }
    .modal-title {
        font-size: 14px;
    }

    .toast {
        left: 12px;
        right: 12px;
        bottom: 14px;
        font-size: 10.5px;
        padding: 11px 14px;
        text-align: center;
    }
}

@media (max-width: 380px) {
    body {
        padding: 10px 8px 44px;
    }
    .portal-title {
        font-size: 20px;
    }
    .stat-card {
        padding: 10px 8px;
    }
    .stat-info-val {
        font-size: 12px !important;
    }
    .goal-tier-btn {
        font-size: 8.5px;
        padding: 5px 1px;
    }
    .btn-row-flex {
        grid-template-columns: 1fr;
    }
}

/* ========================================================
   MOBILE POLISH — readable type, 44px touch targets,
   sticky nav, tighter toolbar (phones only)
   ======================================================== */
@media (max-width: 600px) {
    body { padding: 10px 14px calc(56px + env(safe-area-inset-bottom)); }

    /* Compact header (scrolls with the page) */
    .workspace-sidebar {
        position: static;
        inset: auto;
        width: 100%;
        z-index: 40;
        margin-bottom: 14px;
        padding: 10px 12px 8px;
        gap: 8px;
        box-shadow: 0 6px 18px rgba(40, 36, 20, 0.08);
    }
    .workspace-brand { font-size: 20px; }
    .workspace-brand span { font-size: 12px !important; }
    .mobile-lock-btn { min-height: 34px; padding: 6px 12px; font-size: 12px; border-radius: 9px; }
    .sidebar-link { min-height: 40px; padding: 8px 14px; font-size: 12.5px; }
    .sidebar-link span { font-size: 13px !important; }
    .workspace-sidebar-top { flex-direction: row; justify-content: space-between; align-items: center; }
    .workspace-brand { padding: 0 !important; }
    .workspace-sidebar nav { scroll-snap-type: x proximity; margin-inline: -4px; padding-inline: 4px; }
    .sidebar-link { scroll-snap-align: start; }

    /* Header */
    .portal-header { margin-bottom: 14px; }
    .portal-badge { font-size: 10.5px; }
    .portal-title { font-size: 26px; }
    .portal-subtitle { font-size: 13px; }

    /* Toolbar: primary action full width, secondary in pairs */
    .invoice-tools {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .invoice-tools .create-invoice-btn,
    .invoice-tools .month-pill-btn {
        min-height: 46px;
        font-size: 13px;
        border-radius: 12px;
        justify-content: center;
        width: 100%;
    }
    .invoice-tools .create-invoice-btn[onclick] { grid-column: 1 / -1; order: 1; }
    .invoice-tools a.create-invoice-btn { order: 2; }
    .invoice-tools .month-pill-btn[onclick*="Trash"] { order: 3; }
    .invoice-tools .month-pill-btn[onclick*="persist"] { order: 4; grid-column: 1 / -1; }
    .invoice-tools .invoice-sync-state { order: 5; grid-column: 1 / -1; font-size: 12px; padding: 0; }
    .invoice-tools .invoice-sync-state:empty { display: none; }

    /* KPI cards */
    .stats-bar { gap: 10px; }
    .stat-card { padding: 14px 13px; min-height: 104px; border-radius: 16px; }
    .stat-icon { height: 28px; width: 28px; min-height: 28px; min-width: 28px; }
    .stat-icon svg { width: 14px; height: 14px; }
    .stat-info-title { font-size: 11px; letter-spacing: 0.02em; }
    .stat-info-val { font-size: clamp(15px, 4.6vw, 19px) !important; }

    /* Goal tracker */
    .goal-tracker-card { padding: 16px 14px; border-radius: 16px; }
    .goal-tracker-card, .goal-controls-row, .goal-control-col, .goal-tiers-group { min-width: 0; max-width: 100%; }
    .goal-tracker-title { font-size: 16px; }
    .goal-tracker-sub { font-size: 12.5px; }
    .goal-control-label { font-size: 11px; }
    .goal-month-pills { margin-inline: -14px; padding-inline: 14px; }
    .goal-month-pill-btn { font-size: 12px; min-height: 38px; padding: 8px 14px; border-radius: 20px; }
    .goal-tiers-group { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
    .goal-tier-btn { font-size: 12px; min-height: 40px; border-radius: 10px; }
    .goal-label-mini { font-size: 11px; }
    .goal-numbers strong { font-size: 19px; }
    .target-num { font-size: 12.5px; }
    .goal-pct-pill { font-size: 11.5px; padding: 4px 9px; }
    .goal-progress-track { height: 9px; }
    .goal-affirmation-box { padding: 12px 13px; border-radius: 12px; }
    .goal-affirmation-label { font-size: 10.5px; }
    .goal-affirmation-text { font-size: 12.5px; }
    .goal-actions-group { justify-content: stretch; }
    .goal-action-btn { flex: 1; font-size: 12px; min-height: 38px; border-radius: 9px; }

    /* Filters */
    .filter-title { font-size: 11px; }
    .month-pills-group { margin-inline: -14px; padding-inline: 14px; }
    .month-pill-btn { font-size: 12.5px; min-height: 40px; padding: 8px 15px; }
    .search-input { font-size: 16px; min-height: 46px; border-radius: 12px; } /* 16px stops iOS zoom */

    /* Invoice cards */
    .board-heading { font-size: 15px; }
    .board-count { font-size: 11.5px; }
    .invoice-card { padding: 16px 14px; border-radius: 16px; gap: 12px; }
    .card-top { flex-direction: column !important; align-items: stretch !important; gap: 8px; }
    .client-title { font-size: 15.5px; min-width: 0; width: 100%; overflow-wrap: anywhere; word-break: normal; }
    .status-badge-group { justify-content: flex-start; flex-wrap: wrap; min-width: 0; max-width: 100%; }
    .status-badge-group > * { max-width: 100%; }
    .payment-status-pill { font-size: 10.5px; padding: 5px 9px; min-height: 28px; }
    .dp-history-badge { font-size: 10.5px; padding: 4px 8px; }
    .ref-code { font-size: 11.5px; }
    .month-tag { font-size: 10.5px; padding: 3px 7px; }
    .project-desc { font-size: 13px; line-height: 1.6; }
    .btn-row-flex { grid-template-columns: 1fr 1fr; gap: 8px; }
    .slug-copy-btn { min-height: 44px; font-size: 12px; border-radius: 10px; }
    .financial-breakdown-box { gap: 7px; padding-top: 12px; }
    .fin-label { font-size: 11px; }
    .fin-val { font-size: 13.5px; }
    .net-profit-val { font-size: 14.5px; }
    .edit-profit-btn { font-size: 11px; padding: 5px 9px; min-height: 28px; }
    .card-action-bar { gap: 8px; }
    .action-btn, .mark-pelunasan-btn { flex: 0 0 auto; min-height: 46px; font-size: 13px; border-radius: 11px; }

    /* Hutang & piutang */
    .debt-toolbar .create-invoice-btn { min-height: 46px; font-size: 13px; border-radius: 12px; }
    .debt-filter-pills { margin-inline: -14px; padding-inline: 14px; }
    .debt-filter-pills .month-pill-btn { font-size: 12.5px; min-height: 40px; }
    .debt-action-btn { min-height: 40px; font-size: 12px; padding: 8px 13px; }
    .debt-stats-bar .stat-card { min-height: 104px; padding: 14px 13px; border-radius: 16px; }
    .debt-stats-bar .stat-info-val { font-size: clamp(15px, 4.6vw, 19px) !important; }
    .debt-item-card { padding: 15px 14px; border-radius: 14px; }

    /* Report */
    .revenue-table { font-size: 12px; }

    /* Footer / overlays */
    .dev-contact-btn { min-height: 46px; font-size: 12.5px; }
    .modal-card { max-width: 94vw; max-height: 90vh; overflow-y: auto; }
    .modal-title { font-size: 16px; }
    .toast { font-size: 12.5px; bottom: calc(14px + env(safe-area-inset-bottom)); }
}

@media (max-width: 380px) {
    body { padding-inline: 10px; }
    .goal-tier-btn { font-size: 11px; }
    .portal-title { font-size: 23px; }
    .btn-row-flex { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ========================================================
   DEBT & RECEIVABLE (HUTANG & PIUTANG) MODULE STYLES
   ======================================================== */
#debtSection { display: none; }
body[data-view="debt"] #debtSection { display: block; }
body[data-view="debt"] .invoice-grid,
body[data-view="debt"] .revenue-report-box,
body[data-view="debt"] .filter-section,
body[data-view="debt"] .invoice-tools,
body[data-view="debt"] .stats-bar {
    display: none !important;
}

.debt-stats-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.stat-card.debt-piutang-stat { background: #d4eedb; }
.stat-card.debt-hutang-stat { background: #fcdbd3; }
.stat-card.debt-net-stat { background: #dce7f9; }
.stat-card.debt-done-stat { background: #ede8d8; }

.debt-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.debt-filter-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.debt-search-box {
    flex: 1;
    min-width: 240px;
    max-width: 380px;
    position: relative;
}
.debt-search-box .search-input {
    width: 100%;
}

.debt-card-list {
    display: grid;
    gap: 10px;
}
.debt-empty-state {
    padding: 38px 20px;
    text-align: center;
    background: #fffdf6;
    border: 1px dashed #cfc7b4;
    border-radius: 12px;
    color: #686150;
    font-size: 12px;
    line-height: 1.7;
}
.debt-item-card {
    background: #fffdf8;
    border: 1px solid #ded8cb;
    border-radius: 12px;
    padding: 15px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    transition: border-color .15s ease;
}
.debt-item-card:hover {
    border-color: #c4bdae;
}
.debt-item-card.type-piutang {
    border-left: 3px solid #2e7343;
}
.debt-item-card.type-hutang {
    border-left: 3px solid #b3392d;
}

.debt-item-main {
    flex: 1;
    min-width: 240px;
}
.debt-header-badges {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 5px;
}
.debt-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    padding: 2.5px 7px;
    border-radius: 4px;
    letter-spacing: 0.3px;
}
.badge-piutang {
    background: #eef7f0;
    color: #246838;
    border: 1px solid #d2ebd7;
}
.badge-hutang {
    background: #fdf0ee;
    color: #9e2d22;
    border: 1px solid #f6d8d3;
}

.debt-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 9px;
    font-weight: 400;
    padding: 2.5px 7px;
    border-radius: 4px;
}
.debt-status-unpaid {
    background: #fdf2f1;
    color: #9e2d22;
    border: 1px solid #f7dcd8;
}
.debt-status-partial {
    background: #fef8eb;
    color: #8a5316;
    border: 1px solid #f6e6c4;
}
.debt-status-settled {
    background: #eef7f0;
    color: #246838;
    border: 1px solid #d2ebd7;
}

.debt-person-name {
    font-size: 14px;
    font-weight: 500;
    color: #24241f;
    margin: 1px 0 3px;
    letter-spacing: -0.2px;
}
.debt-notes {
    font-size: 12px;
    font-weight: 400;
    color: #5c584c;
    margin-bottom: 5px;
    line-height: 1.5;
}
.debt-meta-tags {
    display: flex;
    gap: 12px;
    font-size: 10px;
    font-weight: 400;
    color: #797466;
    flex-wrap: wrap;
}
.debt-meta-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.debt-meta-tag svg {
    opacity: 0.75;
}
.debt-meta-tag.overdue {
    color: #b3392d;
    font-weight: 500;
}

.debt-amount-col {
    text-align: right;
    min-width: 150px;
}
.debt-amount-label {
    font-size: 9px;
    color: #7a7567;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 1px;
    font-weight: 400;
}
.debt-amount-total {
    font-size: 15px;
    font-weight: 500;
    color: #24241f;
    font-variant-numeric: tabular-nums;
}
.debt-amount-remaining {
    font-size: 11px;
    font-weight: 400;
    margin-top: 2px;
    color: #6a6557;
}
.debt-amount-remaining span {
    font-weight: 500;
}

.debt-item-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}
.debt-action-btn {
    padding: 6px 10px;
    font-size: 10px;
    font-weight: 400;
    border-radius: 6px;
    border: 1px solid #ded7c9;
    background: #fffdf8;
    color: #4a473d;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.debt-action-btn svg {
    stroke-width: 1.6;
    color: currentColor;
}
.debt-action-btn:hover {
    background: #f1ede3;
    color: #24241f;
    border-color: #c8c1b2;
}
.debt-action-btn.btn-pay {
    background: #2b2a24;
    color: #fffdf6;
    border-color: #2b2a24;
}
.debt-action-btn.btn-pay:hover {
    background: #3f3e35;
}
.debt-action-btn.btn-settle {
    background: #f2f8f3;
    color: #205c31;
    border-color: #cae3cf;
}
.debt-action-btn.btn-settle:hover {
    background: #e3f2e6;
    border-color: #b5dabf;
}
.debt-action-btn.btn-wa {
    background: #f2f8f4;
    color: #176d33;
    border-color: #c8e3d0;
}
.debt-action-btn.btn-wa:hover {
    background: #e1f2e5;
    border-color: #b3dbbf;
}
.debt-action-btn.btn-delete {
    color: #8c2e24;
    border-color: transparent;
    background: transparent;
    padding: 6px 8px;
}
.debt-action-btn.btn-delete:hover {
    background: #fbebea;
    border-color: #f7d2cd;
}

.type-selector-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 6px 0 14px;
}
.type-selector-card {
    border: 1px solid #d9d2c2;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    background: #fff;
    text-align: center;
    transition: all .15s ease;
}
.type-selector-card input[type="radio"] {
    display: none;
}
.type-selector-card.selected-piutang {
    border-color: #2e7343;
    background: #f1f8f3;
    color: #1e5a30;
    font-weight: 500;
}
.type-selector-card.selected-hutang {
    border-color: #b3392d;
    background: #fdf2f0;
    color: #8e2b20;
    font-weight: 500;
}

/* Debt responsive styles are consolidated in the main responsive section */

/* DP History & Pelunasan Features - Harmonized with Pastel / Cream Dashboard Theme */
.dp-history-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 8px;
    background: #e2ecdc;
    color: #305d46;
    border-radius: 6px;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: uppercase;
    border: 0 !important;
}

.dp-history-banner {
    background: #edf4ea;
    border: 1px solid #cce0c7;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 12px 0 14px 0;
    font-size: 11px;
    line-height: 1.6;
    color: #264a34 !important;
}

.dp-banner-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 700;
    color: #20442e !important;
    letter-spacing: 0.02em;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.dp-banner-body {
    color: #264a34 !important;
}

.card-action-bar {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.mark-pelunasan-btn {
    flex: 1 1 180px;
    background: #30352b !important;
    color: #fffdf3 !important;
    border: 0 !important;
    border-radius: 7px;
    padding: 9px 13px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    letter-spacing: 0;
    text-transform: none;
    box-shadow: none !important;
    transition: background 0.18s ease, color 0.18s ease;
}

.mark-pelunasan-btn:hover {
    background: #474f40 !important;
    color: #ffffff !important;
    transform: none !important;
}

.mark-pelunasan-btn.is-paid {
    background: #e2ecdc !important;
    color: #305d46 !important;
    border: 1px solid #bedbb4 !important;
}

.mark-pelunasan-btn.is-paid:hover {
    background: #f9ded1 !important;
    color: #814637 !important;
    border-color: #e5b3a1 !important;
}

.card-action-bar .action-btn {
    flex: 1 1 120px;
    margin-top: 0;
}


/* Mobile: debt stat cards must stay 2-up (base rule above is declared after the earlier media blocks) */
@media (max-width: 850px) {
    .debt-stats-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}
@media (max-width: 600px) {
    .debt-stats-bar .stat-info-title { font-size: 11px; line-height: 1.3; overflow-wrap: anywhere; }
    .debt-stats-bar .stat-info-val { font-size: clamp(14px, 4.2vw, 18px) !important; }
}

/* Mobile: hutang & piutang cards — stack cleanly, full-width children */
@media (max-width: 850px) {
    .debt-item-card {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        flex-wrap: nowrap;
        gap: 12px;
    }
    .debt-item-main { flex: 0 0 auto; min-width: 0; width: 100%; }
    .debt-amount-col {
        width: 100%;
        min-width: 0;
        text-align: left;
        padding: 10px 12px;
        border-radius: 10px;
        background: #f6f2e6;
    }
    .debt-item-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .debt-action-btn { justify-content: center; min-height: 42px; font-size: 12px; padding: 8px 10px; border-radius: 10px; }
    .debt-action-btn.btn-pay { grid-column: 1 / -1; }
    .debt-action-btn.btn-delete { border-color: #e4cfcb; background: #fff8f6; }
}
@media (max-width: 600px) {
    .debt-amount-label { font-size: 11px; }
    .debt-amount-total { font-size: 18px; font-weight: 600; }
    .debt-amount-remaining { font-size: 13px; }
}

/* Mobile: nav as a 4-up tab grid so every section is visible without sideways scrolling */
@media (max-width: 600px) {
    .workspace-sidebar nav {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
        overflow: visible;
        margin-inline: 0;
        padding: 0;
    }
    .workspace-sidebar nav .sidebar-link {
        flex-direction: column;
        justify-content: center;
        gap: 3px;
        min-height: 54px;
        padding: 7px 4px;
        border-radius: 12px;
        font-size: 11px;
        line-height: 1.15;
        text-align: center;
        white-space: normal;
        width: auto;
    }
    .workspace-sidebar nav .sidebar-link span { font-size: 16px !important; line-height: 1; }
}

/* Mobile: monthly report table becomes one card per month (no sideways scrolling) */
@media (max-width: 600px) {
    .revenue-report-box { overflow: visible; padding: 16px 14px; }
    .revenue-table { min-width: 0 !important; width: 100%; display: block; font-size: 13px; }
    .revenue-table thead { display: none; }
    .revenue-table tbody { display: grid; gap: 10px; }
    .revenue-table tr {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0;
        border: 1px solid #e2dccb;
        border-radius: 14px;
        background: #fffdf5;
        overflow: hidden;
    }
    .revenue-table td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 12px;
        padding: 9px 14px !important;
        border: 0 !important;
        border-top: 1px solid #efe9d9 !important;
        text-align: right !important;
        font-size: 13px;
        white-space: normal;
    }
    .revenue-table td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        color: #6d6759;
        text-align: left;
    }
    .revenue-table td:first-child {
        border-top: 0 !important;
        background: #f1ecdc;
        font-weight: 700;
        font-size: 14px;
        text-align: left !important;
    }
    .revenue-table td:first-child::before { display: none; }
    .revenue-table tr.grand-row td { font-size: 14px; }
    .revenue-table tr.grand-row td:first-child { font-size: 13px; letter-spacing: 0.02em; }
}

/* Mobile: give dense sections room to breathe */
@media (max-width: 600px) {
    /* the profit-target card is about invoices, not hutang/piutang: don't stack it above the debt list */
    body[data-view="debt"] .goal-tracker-card { display: none; }

    /* "2 Catatan (Rp 395.000)" must wrap instead of being cut off */
    .debt-stats-bar .stat-info-val {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    /* goal card: more air between its blocks */
    .goal-tracker-header { gap: 12px; margin-bottom: 14px; padding-bottom: 14px; }
    .goal-controls-row { gap: 16px; margin-bottom: 18px; }
    .goal-control-col { gap: 8px; }
    .goal-metrics-row { margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }
    .goal-progress-track { margin-bottom: 16px; }
    .goal-affirmation-box { gap: 12px; }
    .goal-tracker-sub { line-height: 1.55; }

    /* gaps between stacked blocks across views */
    .stats-bar, .debt-stats-bar { margin-bottom: 20px; }
    .goal-tracker-card { margin-bottom: 20px; }
    .debt-toolbar { gap: 12px; margin-bottom: 18px; }
    .debt-item-card { gap: 14px; }
    #debtCardList, .debt-card-list { gap: 14px; }
}

/* Outline nav icons (inherit text color) */
.sidebar-link .nav-icon { display: block; flex-shrink: 0; }
.sidebar-link span { display: inline-flex; align-items: center; line-height: 0; }
@media (max-width: 600px) {
    .workspace-sidebar nav .sidebar-link span { display: inline-flex !important; }
    .workspace-sidebar nav .sidebar-link .nav-icon { width: 20px; height: 20px; }
}

/* Mobile: action buttons sit in a column, so flex-basis must not turn into height (declared last to beat the base rules above) */
@media (max-width: 600px) {
    .card-action-bar { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 8px; margin-top: 12px; }
    .card-action-bar .mark-pelunasan-btn,
    .card-action-bar .action-btn {
        flex: 0 0 auto;
        width: 100%;
        height: auto;
        min-height: 40px;
        padding: 9px 12px;
        font-size: 12.5px;
        border-radius: 10px;
        line-height: 1.25;
    }
}

/* Mobile status tabs: Semua / Belum lunas / DP / Lunas */
.board-tabs { display: none; }
@media (max-width: 600px) {
    .board-tabs {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 4px;
        padding: 4px;
        margin: 0 0 14px;
        background: #ece7d8;
        border: 1px solid #ddd6c4;
        border-radius: 14px;
        box-shadow: 0 6px 14px rgba(40, 36, 20, 0.07);
    }
    .board-tabs button {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px;
        min-height: 46px;
        padding: 5px 2px;
        border: 0;
        border-radius: 10px;
        background: transparent;
        color: #514d41;
        font-size: 11.5px;
        font-weight: 500;
        line-height: 1.15;
        cursor: pointer;
    }
    .board-tabs button b { font-size: 14px; font-weight: 700; }
    .board-tabs button.active { background: #272722; color: #fffdf5; }
    body[data-view="report"] .board-tabs,
    body[data-view="debt"] .board-tabs { display: none; }

    .invoice-grid { scroll-margin-top: 70px; }
    .invoice-grid[data-tab="UNPAID"] #column-DP,
    .invoice-grid[data-tab="UNPAID"] #column-PAID,
    .invoice-grid[data-tab="DP"] #column-UNPAID,
    .invoice-grid[data-tab="DP"] #column-PAID,
    .invoice-grid[data-tab="PAID"] #column-UNPAID,
    .invoice-grid[data-tab="PAID"] #column-DP { display: none; }
}

/* overflow-x:hidden on html/body turns body into a scroll container and silently breaks position:sticky; clip does not */
@supports (overflow: clip) {
    @media (max-width: 850px) {
        html, body { overflow-x: clip; }
    }
}

/* no pinch / double-tap zoom on phones */
html, body { touch-action: manipulation; }

/* Mobile audit pass: readable badges, finger-sized secondary buttons, 16px form fields (no iOS focus zoom) */
@media (max-width: 600px) {
    .dp-status-action { font-size: 11px; min-height: 32px; padding: 6px 10px; border-radius: 8px; }
    .edit-profit-btn { font-size: 11.5px; min-height: 34px; padding: 6px 11px; border-radius: 8px; }
    .dp-history-badge, .dp-banner-header { font-size: 11px; }
    .payment-status-pill { font-size: 11px; }
    .debt-type-badge, .debt-status-pill { font-size: 11px; padding: 4px 8px; }
    .debt-meta-tag { font-size: 11.5px; }
    .portal-badge, .goal-affirmation-label, .dev-title { font-size: 11px; }

    dialog input:not([type="radio"]):not([type="checkbox"]),
    dialog textarea, dialog select,
    .modal-card input, .modal-card textarea,
    #profitModalInput { font-size: 16px !important; min-height: 44px; }
    dialog textarea, .modal-card textarea { min-height: 88px; }
    .modal-input-label, dialog label { font-size: 12px; }
    dialog { max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain; }
}
@media (max-width: 600px) {
    .goal-tracker-header span, .month-tag { font-size: 11px; }
}

/* Trash: restore / permanent delete */
.trash-name { min-width: 0; overflow-wrap: anywhere; }
.trash-actions { display: flex; gap: 8px; flex-shrink: 0; }
.purge-invoice-btn { color: #8c2e24 !important; border-color: #e4c4be !important; background: #fff8f6 !important; }
.purge-invoice-btn:hover { background: #fbebea !important; }
.purge-all-btn { margin-top: 18px; width: 100%; justify-content: center; background: #8c2e24 !important; color: #fffdf6 !important; }
@media (max-width: 600px) {
    .trash-row { flex-direction: column; align-items: stretch; gap: 10px; }
    .trash-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .trash-actions button { min-height: 42px; font-size: 12.5px; justify-content: center; }
    .purge-all-btn { min-height: 46px; }
}
