:root {
    --bg: #0d0f13;
    --panel: #11141a;
    --panel-2: #0b0d11;
    --line: #232833;
    --line-soft: #1b2029;
    --txt: #f3f4f6;
    --muted: #9aa4b2;
    --input-bg: #0f1319;
    --chip: #171b23;
    --accent: #ffffff;
    --accent-dark: #111111;
    --primary: #1f6feb;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);

    --fs-ui-2xs: 0.72rem;
    --fs-ui-xs: 0.76rem;
    --fs-ui-sm: 0.8rem;
    --fs-ui-md: 0.84rem;
    --fs-ui-base: 0.88rem;
    --fs-ui-title-sm: 0.92rem;
    --fs-ui-lg: 0.94rem;
    --fs-ui-xl: 0.98rem;
    --fs-ui-2xl: 1.06rem;

    --doc-bg: #fff;
    --doc-txt: #111;
    --doc-line: #1c1c1c;
    --doc-soft: #666;
}

html[data-theme="light"] {
    --bg: #f3f5f8;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --line: #d8dee7;
    --line-soft: #e7ebf2;
    --txt: #111827;
    --muted: #5f6b7a;
    --input-bg: #ffffff;
    --chip: #eff3f8;
    --accent: #111111;
    --accent-dark: #ffffff;
    --primary: #1f6feb;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.09);
}

html,
body {
    background: var(--bg);
    color: var(--txt);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100%;
    height: 100%;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow: hidden;
}

.app-shell {
    max-width: 1700px;
    height: calc(100vh - 28px);
    margin: 14px auto;
    padding: 0 10px;
}

.workspace {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow);
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: #06070a;
}

html[data-theme="light"] .topbar {
    background: #ffffff;
}

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

.topbar-right {
    min-width: 0;
}

.topbar-logo {
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--chip);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--txt);
    flex: 0 0 auto;
}

.topbar-logo-icon {
    display: block;
    font-size: 1.2rem;
    line-height: 1;
    transform: rotate(45deg);
    transform-origin: center;
}

.topbar-copy {
    min-width: 0;
}

.topbar-title {
    font-size: var(--fs-ui-lg);
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.topbar-sub {
    font-size: var(--fs-ui-xs);
    color: var(--muted);
    margin: 0;
    line-height: 1.2;
}

.icon-btn,
.ghost-btn,
.primary-btn {
    border-radius: 8px;
    min-height: 36px;
    font-weight: 600;
    font-size: var(--fs-ui-base);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: .2s ease;
    line-height: 1.2;
    touch-action: manipulation;
}

.icon-btn {
    width: 36px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--txt);
}

.mobile-menu-btn {
    display: none;
}

.ghost-btn {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--txt);
    padding: 0 12px;
}

.ghost-btn:hover,
.icon-btn:hover {
    background: var(--chip);
}

.primary-btn {
    border: 0;
    background: #fff;
    color: #111;
    padding: 0 14px;
}

html[data-theme="light"] .primary-btn {
    background: #111;
    color: #fff;
}

.main-grid {
    display: grid;
    grid-template-columns: 18rem minmax(0, 1fr) minmax(0, 1fr);
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

body.preview-hidden .main-grid {
    grid-template-columns: 18rem minmax(0, 1fr);
}

.app-footer {
    border-top: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--muted);
    font-size: var(--fs-ui-xs);
    line-height: 1.4;
    text-align: left;
    padding: 10px 16px;
}

.mobile-actionbar {
    display: none;
}

.sidebar {
    background: #07090c;
    border-right: 1px solid var(--line);
    padding: 14px 12px;
    overflow: hidden;
}

html[data-theme="light"] .sidebar {
    background: #fbfcfe;
}

.step-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.step-btn {
    width: 100%;
    min-width: 0;
    padding: 10px 10px;
    border-radius: 8px;
    border: 1px solid var(--line-soft);
    background: transparent;
    color: var(--txt);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    text-align: left;
    font-size: var(--fs-ui-base);
}

.step-btn.active {
    background: var(--chip);
    border-color: var(--line);
}

.step-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
}

.step-no {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--line);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-ui-2xs);
    flex: 0 0 auto;
}

.step-label {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
    font-size: var(--fs-ui-md);
    line-height: 1.3;
}

.step-check {
    color: #22c55e;
    opacity: 0;
    transition: opacity .2s ease;
}

.step-btn.active .step-check {
    opacity: 1;
}

.step-note {
    color: var(--muted);
    font-size: var(--fs-ui-xs);
    margin-top: 12px;
    line-height: 1.45;
    max-width: 100%;
}

.form-panel,
.preview-panel {
    padding: 16px 16px 18px;
    min-height: 0;
}

.form-panel {
    border-right: 1px solid var(--line);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

.preview-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

body.preview-hidden .preview-panel {
    display: none;
}

.form-header {
    margin-bottom: 16px;
}

.form-title {
    font-size: var(--fs-ui-2xl);
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 3px;
}

.form-desc {
    color: var(--muted);
    margin: 0;
    font-size: var(--fs-ui-md);
    line-height: 1.45;
}

.section-card {
    border: 1px solid var(--line-soft);
    background: transparent;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
}

.section-card-title {
    font-size: var(--fs-ui-title-sm);
    font-weight: 800;
    margin-bottom: 3px;
    line-height: 1.3;
}

.section-card-desc {
    color: var(--muted);
    font-size: var(--fs-ui-sm);
    line-height: 1.45;
    margin-bottom: 12px;
}

.form-label {
    font-size: var(--fs-ui-sm);
    font-weight: 700;
    margin-bottom: 6px;
}

.form-control,
.form-select,
.form-control:focus,
.form-select:focus,
textarea.form-control {
    background: var(--input-bg);
    color: var(--txt);
    border-color: var(--line);
    border-radius: 8px;
    box-shadow: none;
}

.form-control,
.form-select {
    min-height: 40px;
    font-size: var(--fs-ui-base);
}

input[type="date"].form-control {
    color-scheme: dark;
}

input[type="date"].form-control::-webkit-calendar-picker-indicator {
    cursor: pointer;
    -webkit-filter: brightness(0) invert(1);
    filter: brightness(0) invert(1);
    opacity: 1;
}

html[data-theme="light"] input[type="date"].form-control {
    color-scheme: light;
}

html[data-theme="light"] input[type="date"].form-control::-webkit-calendar-picker-indicator {
    -webkit-filter: none;
    filter: none;
    opacity: .8;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 .2rem rgba(31, 111, 235, .14);
}

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.editor-toolbar-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.cost-collapse-btn {
    display: none;
}

.summary-realisasi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.summary-stat {
    min-width: 0;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--panel-2);
    padding: 10px;
}

.summary-stat-label {
    display: block;
    color: var(--muted);
    font-size: var(--fs-ui-xs);
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 5px;
}

.summary-stat-value {
    display: block;
    color: var(--txt);
    font-size: var(--fs-ui-lg);
    font-weight: 800;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.summary-stat-value.is-negative {
    color: #fca5a5;
}

.summary-stat-value.is-positive {
    color: #86efac;
}

.mini-btn {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--txt);
    border-radius: 8px;
    min-height: 34px;
    padding: 0 10px;
    font-weight: 600;
    font-size: var(--fs-ui-sm);
}

.mini-btn:hover {
    background: var(--chip);
}

.danger-btn {
    border-color: rgba(239, 68, 68, .55);
    color: #fca5a5;
}

.danger-btn:hover {
    background: rgba(239, 68, 68, .12);
}

.cost-editor-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.cost-editor-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.cost-editor-table th,
.cost-editor-table td {
    border-bottom: 1px solid var(--line-soft);
    padding: 8px;
    vertical-align: top;
    background: transparent;
}

.cost-editor-table th {
    font-size: var(--fs-ui-xs);
    font-weight: 800;
    color: var(--muted);
    background: rgba(255, 255, 255, .01);
}

.cost-editor-table tr:last-child td {
    border-bottom: 0;
}

.table-scroll {
    overflow-x: auto;
}

.row-type-badge {
    min-width: max-content;
    width: max-content;
    padding-left: 6px;
    padding-right: 22px;
}

.signature-uploader {
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 10px;
    background: transparent;
}

.signature-preview-mini {
    width: 100%;
    max-width: 160px;
    height: 60px;
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--line-soft);
    padding: 5px;
    display: block;
}

.delete-sign-btn {
    width: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.preview-head {
    margin-bottom: 12px;
}

.preview-head > div {
    min-width: 0;
}

.preview-head h4 {
    font-weight: 800;
    margin: 0 0 4px;
    font-size: var(--fs-ui-xl);
    line-height: 1.25;
}

.preview-head p {
    color: var(--muted);
    margin: 0;
    font-size: var(--fs-ui-sm);
    line-height: 1.4;
}

.preview-back-btn {
    display: none;
}

.preview-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    border-radius: 8px;
    padding: 4px;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.preview-stage {
    position: relative;
    width: 794px;
    height: 1123px;
    min-height: 0;
    margin: 0 auto;
    flex: 0 0 auto;
}

.preview-stage .doc-page {
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    transform-origin: top left;
    transform: scale(var(--preview-scale, 1));
}

.doc-page {
    width: 794px;
    min-height: 1123px;
    background: var(--doc-bg);
    color: var(--doc-txt);
    margin: 0 auto;
    padding: 26px 34px 28px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .18);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.28;
    display: flex;
    flex-direction: column;
}

.doc-top {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 12px;
    margin-bottom: 38px;
}

.doc-company {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: .2px;
}

.doc-date {
    font-size: 14px;
    margin-top: 18px;
}

.doc-title {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: .3px;
    margin-bottom: 18px;
    text-transform: uppercase;
}

.doc-info {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}

.doc-info td {
    padding: 1px 0;
    vertical-align: top;
    font-size: 13px;
}

.doc-info .label {
    width: 195px;
    font-weight: 700;
    text-transform: uppercase;
}

.doc-info .colon {
    width: 16px;
    text-align: center;
    font-weight: 700;
}

.doc-cost {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin: 8px 0 14px;
    font-size: 13px;
}

.doc-cost td,
.doc-cost th {
    border: 0.7px solid var(--doc-line);
    padding: 3px 5px;
    vertical-align: top;
}

.doc-cost thead th {
    text-align: center;
    font-weight: 700;
    vertical-align: middle;
}

.doc-cost .no-col {
    width: 34px;
    text-align: center;
}

.doc-cost .desc-col {
    width: auto;
}

.doc-cost .rp-col,
.doc-cost .usd-col {
    width: 132px;
    text-align: right;
    white-space: nowrap;
}

.doc-cost .center {
    text-align: center;
}

.doc-cost .total-label {
    font-weight: 700;
    text-align: center;
}

.doc-cost .total-value {
    font-weight: 700;
}

.doc-note-title {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 13px;
}

.doc-note-lines {
    font-size: 13px;
    line-height: 1.35;
    margin-bottom: 18px;
    white-space: pre-line;
}

.doc-summary {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    margin: 8px 0 18px;
    font-size: 13px;
}

.doc-summary.active {
    display: grid;
}

.summary-col .summary-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: end;
    margin-bottom: 6px;
}

.summary-col-usd .summary-row > span:first-child {
    padding-left: 28px;
}

.summary-value {
    min-width: 110px;
    border-bottom: 1px solid #111;
    text-align: right;
    font-weight: 700;
    padding-bottom: 2px;
}

.doc-signatures {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 36px;
    margin-top: 34px;
    text-align: center;
}

.doc-sign-role {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 24px;
}

.doc-sign-image-wrap {
    height: 62px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: 8px;
}

.doc-sign-image {
    max-width: 150px;
    max-height: 54px;
    object-fit: contain;
    display: none;
}

.doc-sign-image.has-image {
    display: block;
}

.doc-sign-name {
    display: inline-block;
    min-width: 160px;
    padding-top: 6px;
    border-top: 1px solid #111;
    font-size: 13px;
}

.doc-footer {
    margin-top: auto;
    padding-top: 18px;
    color: #777;
    font-size: 10px;
    text-align: center;
}

.draft-modal[hidden] {
    display: none;
}

.draft-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 18px;
}

.draft-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .62);
}

.draft-modal-panel {
    position: relative;
    width: min(760px, 100%);
    max-height: min(760px, calc(100vh - 36px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--txt);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .36);
}

.draft-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.draft-modal-title {
    font-size: var(--fs-ui-2xl);
    font-weight: 800;
    line-height: 1.2;
}

.draft-modal-desc {
    color: var(--muted);
    font-size: var(--fs-ui-sm);
    margin-top: 2px;
}

.draft-list {
    overflow: auto;
    padding: 14px;
}

.draft-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--panel-2);
}

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

.draft-item-main {
    min-width: 0;
}

.draft-item-title {
    font-size: var(--fs-ui-lg);
    font-weight: 800;
    margin-bottom: 4px;
}

.draft-item-meta {
    color: var(--muted);
    font-size: var(--fs-ui-sm);
    line-height: 1.45;
}

.draft-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.empty-draft-state {
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    padding: 18px;
    text-align: center;
}

.toast-region {
    position: fixed;
    left: 50%;
    bottom: 20px;
    z-index: 1400;
    width: min(420px, calc(100vw - 24px));
    display: grid;
    gap: 8px;
    pointer-events: none;
    transform: translateX(-50%);
}

.app-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--txt);
    box-shadow: 0 18px 42px rgba(0, 0, 0, .34);
    padding: 12px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .18s ease, transform .18s ease;
}

.app-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.app-toast i {
    flex: 0 0 auto;
    line-height: 1.25;
}

.app-toast-message {
    min-width: 0;
    font-size: var(--fs-ui-sm);
    font-weight: 700;
    line-height: 1.35;
}

.app-toast-success i {
    color: #22c55e;
}

.app-toast-error i,
.app-toast-danger i {
    color: #ef4444;
}

.app-toast-warning i {
    color: #f59e0b;
}

.confirm-dialog[hidden] {
    display: none;
}

.confirm-dialog {
    position: fixed;
    inset: 0;
    z-index: 1300;
    display: grid;
    place-items: center;
    padding: 18px;
}

.confirm-dialog-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .64);
}

.confirm-dialog-panel {
    position: relative;
    width: min(420px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--txt);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .38);
    padding: 16px;
}

.confirm-dialog-icon {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--chip);
    color: #f59e0b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.confirm-dialog-panel.danger .confirm-dialog-icon {
    color: #ef4444;
}

.confirm-dialog-copy {
    min-width: 0;
}

.confirm-dialog-title {
    font-size: var(--fs-ui-2xl);
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 5px;
}

.confirm-dialog-message {
    color: var(--muted);
    font-size: var(--fs-ui-sm);
    line-height: 1.45;
}

.confirm-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

.text-muted-small {
    color: var(--muted);
    font-size: var(--fs-ui-md);
}

@media (max-width: 1399.98px) {
    .main-grid {
        grid-template-columns: 17rem minmax(0, 1fr) minmax(0, 1fr);
    }

    body.preview-hidden .main-grid {
        grid-template-columns: 17rem minmax(0, 1fr);
    }
}

@media (max-width: 1023.98px) {
    html,
    body {
        height: auto;
    }

    body {
        --mobile-topbar-height: 65px;
        --mobile-tabbar-height: 44px;
        overflow: auto;
        overflow-x: hidden;
        overscroll-behavior-y: none;
    }

    body.mobile-menu-open {
        overflow: hidden;
    }

    body.mobile-menu-open::before {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 55;
        background: rgba(0, 0, 0, .56);
        backdrop-filter: blur(2px);
    }

    html[data-theme="light"] body.mobile-menu-open::before {
        background: rgba(15, 23, 42, .26);
    }

    .app-shell {
        height: auto;
        min-height: 100dvh;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .workspace {
        height: auto;
        min-height: 100dvh;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    .topbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 50;
        flex-wrap: nowrap;
        overflow: visible;
    }

    body.mobile-menu-open .topbar {
        z-index: 70;
    }

    .mobile-menu-btn {
        display: inline-flex;
        width: 44px;
        min-height: 44px;
        flex: 0 0 auto;
        font-size: 1.15rem;
    }

    body.mobile-menu-open .mobile-menu-btn {
        background: var(--chip);
    }

    .topbar-left {
        flex: 1 1 auto;
    }

    .topbar-right {
        position: fixed;
        top: auto;
        left: 50%;
        right: auto;
        bottom: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        z-index: 80;
        display: flex !important;
        flex-direction: column;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: 6px !important;
        width: min(360px, calc(100vw - 24px));
        max-height: min(76dvh, 420px);
        overflow-y: auto;
        padding: 10px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--panel-2);
        box-shadow: 0 18px 42px rgba(0, 0, 0, .36);
        opacity: 0;
        pointer-events: none;
        transform: translate(-50%, 18px);
        visibility: hidden;
        transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
    }

    .topbar-right::before {
        content: "Menu";
        color: var(--muted);
        font-size: var(--fs-ui-xs);
        font-weight: 800;
        line-height: 1.2;
        padding: 2px 4px 5px;
        text-transform: uppercase;
    }

    body.mobile-menu-open .topbar-right {
        opacity: 1;
        pointer-events: auto;
        transform: translate(-50%, 0);
        visibility: visible;
    }

    .topbar-right .ghost-btn,
    .topbar-right .primary-btn {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 44px;
        justify-content: flex-start;
        padding: 0 10px;
        text-align: left;
    }

    .topbar-right .ghost-btn span,
    .topbar-right .primary-btn span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .main-grid {
        grid-template-columns: 1fr;
        align-content: start;
        overflow: visible;
        min-width: 0;
        padding-top: calc(var(--mobile-topbar-height) + var(--mobile-tabbar-height));
        padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px));
    }

    body.preview-hidden .main-grid {
        grid-template-columns: 1fr;
    }

    body.mobile-preview-mode .main-grid {
        padding-top: var(--mobile-topbar-height);
    }

    .sidebar,
    .form-panel {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .sidebar {
        position: static;
        z-index: auto;
        overflow: visible;
        min-width: 0;
        padding: 0;
        border-bottom: 0;
        background: transparent;
    }

    .preview-panel {
        display: none;
        overflow: visible;
        min-width: 0;
        padding-top: 12px;
    }

    body.mobile-preview-mode .sidebar,
    body.mobile-preview-mode .form-panel {
        display: none;
    }

    body.mobile-preview-mode .preview-panel {
        display: block;
        border-bottom: 0;
    }

    .form-panel {
        overflow: visible;
        min-width: 0;
        padding-bottom: 12px;
    }

    .form-panel .tab-pane.active > .section-card:last-child {
        margin-bottom: 0;
    }

    .preview-head h4 {
        margin-top: 0;
    }

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

    .preview-back-btn {
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--chip);
        color: var(--txt);
        min-height: 40px;
        padding: 0 10px;
        align-items: center;
        justify-content: center;
        gap: 6px;
        font-size: var(--fs-ui-sm);
        font-weight: 800;
        line-height: 1.2;
        flex: 0 0 auto;
    }

    body.mobile-preview-mode .preview-back-btn {
        display: inline-flex;
    }

    .preview-scroll {
        max-width: 100%;
        overflow-x: hidden;
        overflow-y: visible;
    }

    .step-list {
        position: fixed;
        top: var(--mobile-topbar-height);
        left: 0;
        right: 0;
        z-index: 44;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        min-width: 0;
        padding: 10px 12px;
        border-bottom: 1px solid var(--line);
        background: var(--panel);
    }

    .step-note {
        display: none;
    }

    .mobile-actionbar {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: 10px;
        bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        z-index: 45;
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 3px;
        padding: 6px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: rgba(11, 13, 17, .94);
        box-shadow: 0 16px 34px rgba(0, 0, 0, .32);
        backdrop-filter: blur(14px);
    }

    html[data-theme="light"] .mobile-actionbar {
        background: rgba(255, 255, 255, .94);
    }

    .mobile-actionbar-btn {
        min-width: 0;
        min-height: 48px;
        border: 1px solid transparent;
        border-radius: 8px;
        background: transparent;
        color: var(--muted);
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        font-size: var(--fs-ui-2xs);
        font-weight: 800;
        line-height: 1.1;
        padding: 4px 2px;
    }

    .mobile-actionbar-btn i {
        font-size: 1rem;
        line-height: 1;
    }

    .mobile-actionbar-btn.active {
        border-color: var(--line);
        background: var(--chip);
        color: var(--txt);
    }

    .app-footer {
        display: none;
    }

}

@media (max-width: 767.98px) {
    body {
        --mobile-topbar-height: 69px;
        --mobile-tabbar-height: 44px;
    }

    .app-shell {
        margin: 0;
        padding: 0;
    }

    .topbar {
        gap: 8px;
        padding: 12px 10px;
        min-width: 0;
    }

    .topbar-sub {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: var(--fs-ui-xs);
        line-height: 1.2;
        margin-top: 3px;
    }

    .topbar {
        flex-direction: row;
        align-items: center;
    }

    .topbar-left {
        width: auto;
        flex: 1 1 auto;
        min-width: 0;
    }

    .topbar-left > div {
        min-width: 0;
    }

    .topbar-title {
        font-size: var(--fs-ui-xl);
        line-height: 1.15;
    }

    .topbar-right {
        width: min(340px, calc(100vw - 20px));
    }

    .topbar-right .ghost-btn,
    .topbar-right .primary-btn {
        font-size: var(--fs-ui-sm);
    }

    .sidebar,
    .form-panel,
    .preview-panel {
        padding: 12px;
    }

    .form-panel {
        padding-bottom: 12px;
    }

    .preview-panel {
        padding: 14px 12px 12px;
    }

    .step-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .step-btn {
        display: grid;
        grid-template-columns: 22px max-content 16px;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        max-width: 100%;
        padding: 8px 10px;
        column-gap: 7px;
    }

    .step-left {
        display: contents;
    }

    .step-no {
        width: 22px;
        height: 22px;
        font-size: var(--fs-ui-2xs);
    }

    .step-btn.active .step-no {
        border-color: var(--line);
        background: rgba(255, 255, 255, .04);
    }

    .step-label {
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 0;
        line-height: 1;
    }

    .step-label::after {
        content: attr(data-mobile-label);
        font-size: var(--fs-ui-xs);
        line-height: 1.2;
        font-weight: 800;
    }

    .step-check {
        display: inline-flex;
        grid-column: 3;
        justify-self: center;
        color: #22c55e;
        font-size: var(--fs-ui-sm);
    }

    .step-note {
        display: none;
    }

    .form-title {
        font-size: var(--fs-ui-lg);
        line-height: 1.25;
    }

    .form-desc {
        font-size: var(--fs-ui-sm);
        line-height: 1.5;
    }

    .section-card-title {
        font-size: var(--fs-ui-lg);
        line-height: 1.25;
    }

    .section-card-desc {
        font-size: var(--fs-ui-xs);
        line-height: 1.45;
    }

    .section-card {
        padding: 12px;
        margin-bottom: 12px;
        background: rgba(17, 20, 26, .72);
    }

    html[data-theme="light"] .section-card {
        background: rgba(255, 255, 255, .86);
    }

    .section-card.mobile-collapsible .section-card-title {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        cursor: pointer;
        user-select: none;
    }

    .section-card.mobile-collapsible .section-card-title::after {
        content: "-";
        width: 24px;
        height: 24px;
        border: 1px solid var(--line);
        border-radius: 8px;
        color: var(--muted);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: var(--fs-ui-base);
        line-height: 1;
        flex: 0 0 auto;
    }

    .section-card.mobile-collapsible.mobile-section-collapsed .section-card-title::after {
        content: "+";
    }

    .section-card.mobile-collapsible.mobile-section-collapsed > *:not(.section-card-title):not(.section-card-desc) {
        display: none !important;
    }

    .section-card.mobile-collapsible.mobile-section-collapsed .section-card-desc {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-bottom: 0;
    }

    .row.g-3 {
        --bs-gutter-y: .85rem;
    }

    .summary-realisasi-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    .summary-stat {
        display: flex;
        min-height: 58px;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        gap: 4px;
        padding: 8px;
    }

    .summary-stat-label {
        margin-bottom: 0;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .summary-stat-value {
        width: 100%;
        text-align: left;
        font-size: var(--fs-ui-sm);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .summary-realisasi-grid .summary-receipt-rp {
        order: 1;
    }

    .summary-realisasi-grid .summary-expense-rp {
        order: 2;
    }

    .summary-realisasi-grid .summary-difference-rp {
        order: 3;
    }

    .summary-realisasi-grid .summary-receipt-usd {
        order: 4;
    }

    .summary-realisasi-grid .summary-expense-usd {
        order: 5;
    }

    .summary-realisasi-grid .summary-difference-usd {
        order: 6;
    }

    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px;
    }

    textarea.form-control {
        font-size: 16px;
    }

    .editor-toolbar-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    .editor-toolbar-actions .mini-btn {
        width: 100%;
        min-height: 44px;
    }

    .cost-collapse-btn:not([hidden]) {
        display: inline-flex;
        width: 100%;
        min-height: 40px;
        align-items: center;
        justify-content: center;
        gap: 6px;
        margin-top: 8px;
    }

    .table-scroll {
        overflow: visible;
    }

    .cost-editor-wrap {
        border: 0;
        overflow: visible;
    }

    .cost-editor-table {
        display: block;
        min-width: 0;
    }

    .cost-editor-table thead {
        display: none;
    }

    .cost-editor-table tbody {
        display: block;
    }

    .cost-editor-table tr {
        display: block;
        padding: 12px;
        margin-bottom: 10px;
        border: 1px solid var(--line-soft);
        border-radius: 8px;
        background: var(--panel-2);
    }

    .cost-editor-table tr:last-child {
        margin-bottom: 0;
    }

    .cost-editor-wrap.cost-collapsed .cost-editor-table tbody tr:nth-child(n+2) {
        display: none;
    }

    .cost-editor-wrap.cost-collapsed .cost-editor-table tbody tr:first-child {
        margin-bottom: 0;
    }

    .cost-editor-table td {
        display: block;
        padding: 0;
        border-bottom: 0;
    }

    .cost-editor-table td + td {
        margin-top: 10px;
    }

    .cost-editor-table td::before {
        content: attr(data-label);
        display: block;
        color: var(--muted);
        font-size: var(--fs-ui-xs);
        font-weight: 800;
        line-height: 1.2;
        margin-bottom: 6px;
    }

    .cost-editor-table td[data-label="Aksi"]::before {
        display: none;
    }

    .row-type-badge {
        width: 100%;
        min-width: 0;
    }

    .delete-row-btn {
        width: 100%;
        min-height: 44px;
        margin-top: 2px;
    }

    .signature-preview-mini {
        max-width: none;
        height: 72px;
    }

    .delete-sign-btn {
        width: 100%;
        min-height: 44px;
    }

    .preview-head p {
        line-height: 1.45;
    }

    .preview-scroll {
        padding: 0;
    }

    .doc-page {
        width: 794px;
        min-width: 794px;
    }

    .draft-modal {
        padding: 10px;
    }

    .toast-region {
        bottom: calc(82px + env(safe-area-inset-bottom, 0px));
    }

    .confirm-dialog {
        align-items: end;
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .confirm-dialog-panel {
        width: 100%;
    }

    .confirm-dialog-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .confirm-dialog-actions .mini-btn {
        min-height: 44px;
    }

    .draft-item {
        flex-direction: column;
    }

    .draft-item-actions {
        width: 100%;
    }

    .draft-item-actions .mini-btn {
        flex: 1 1 0;
    }

}

@media (max-width: 374.98px) {
    .step-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cost-editor-table td {
        grid-template-columns: 1fr;
    }

    .cost-editor-table td::before {
        margin-bottom: -2px;
    }
}
