:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-muted: #eef2f6;
    --text: #18202a;
    --muted: #687384;
    --line: #d9e0e8;
    --primary: #176b87;
    --primary-dark: #0f4d63;
    --accent: #d89216;
    --danger-bg: #fff0f0;
    --danger-text: #a42323;
    --shadow: 0 18px 45px rgba(24, 32, 42, 0.11);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(23, 107, 135, 0.12), rgba(216, 146, 22, 0.14)),
        var(--bg);
}

.login-panel {
    width: min(100%, 420px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 36px;
}

.login-brand-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin-bottom: 26px;
}

.login-brand-row h1 {
    margin: 0 0 4px;
}

.login-logo {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    object-fit: contain;
}

.brand-mark,
.brand-logo {
    width: 42px;
    height: 42px;
    max-width: 42px;
    max-height: 42px;
}

.brand-mark {
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 700;
}

.brand-logo {
    display: block;
    object-fit: contain;
}

.login-panel h1 {
    margin: 0 0 4px;
    font-size: 30px;
}

.login-subtitle {
    margin: 0;
    color: var(--muted);
}

.alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 6px;
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid #f0c8c8;
    font-size: 14px;
}

.alert.warning {
    background: #fff8e8;
    color: #7a4a00;
    border-color: #efd39a;
}

.alert.success {
    background: #ecfdf3;
    color: #166534;
    border-color: #bbf7d0;
}

.alert.warning p {
    margin: 8px 0 0;
}

.alert.warning ul {
    margin: 8px 0 0;
    padding-left: 18px;
}

.deadline-date--urgent,
td .deadline-date--urgent,
input.deadline-date--urgent {
    color: var(--danger-text) !important;
    font-weight: 700;
}

.login-form {
    display: grid;
    gap: 10px;
}

.login-form label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.login-form input:not([type="checkbox"]) {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 15px;
}

.login-form input:not([type="checkbox"]):focus {
    outline: 3px solid rgba(23, 107, 135, 0.18);
    border-color: var(--primary);
}

.remember-row {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    gap: 7px;
    margin-top: 2px;
    color: var(--muted) !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    line-height: 1.2;
    cursor: pointer;
}

.remember-row input {
    width: 14px;
    height: 14px;
    min-height: 14px;
    margin: 0;
    accent-color: var(--primary);
}

.login-form button {
    margin-top: 12px;
    min-height: 44px;
    border: 0;
    border-radius: 6px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
}

.login-form button:hover {
    background: var(--primary-dark);
}

.app-shell {
    display: grid;
    grid-template-columns: 185px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: #15202b;
    color: #ffffff;
    padding: 18px 10px;
}

.sidebar-brand {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 4px 2px 22px;
    min-width: 0;
}

.sidebar-brand .brand-logo {
    width: 32px;
    height: 32px;
    max-width: 32px;
    max-height: 32px;
    flex: 0 0 32px;
}

.sidebar-brand > div {
    min-width: 0;
}

.sidebar-brand strong,
.sidebar-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-brand span {
    display: block;
    margin-top: 2px;
    color: #aeb9c6;
    font-size: 12px;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
}

.sidebar-nav a {
    min-height: 38px;
    display: flex;
    align-items: center;
    padding: 9px 10px;
    border-radius: 6px;
    color: #dce3ea;
    font-size: 14px;
}

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    white-space: nowrap;
}

.sort-link.active {
    color: var(--primary);
}

.sort-icon {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    width: 7px;
    flex: 0 0 7px;
}

.sort-icon span {
    display: block;
    width: 0;
    height: 0;
    border-left: 3.5px solid transparent;
    border-right: 3.5px solid transparent;
}

.sort-up {
    border-bottom: 4px solid #8997a8;
}

.sort-down {
    border-top: 4px solid #8997a8;
}

.sort-icon.asc .sort-up {
    border-bottom-color: var(--primary);
}

.sort-icon.desc .sort-down {
    border-top-color: var(--primary);
}

.work-list-table {
    width: 100%;
    min-width: 1320px;
    table-layout: fixed;
}

.work-list-so-link {
    display: block !important;
    width: 100%;
    margin-top: 3px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.15;
    white-space: nowrap;
}

.work-list-table .select-col { width: 34px; }
.work-list-table .deadline-col { width: 92px; }
.work-list-table .customer-col { width: 150px; }
.work-list-table .item-col { width: 190px; }
.work-list-table .trf-col { width: 180px; }
.work-list-table .coupon-club-col { width: 186px; }
.work-list-table .coupon-number-col { width: 108px; }
.work-list-table .coupon-submit-col { width: 38px; }
.work-list-table .finish-qty-col { width: 132px; }
.work-list-table .max-col { width: 38px; }

.work-list-table .item-cell {
    min-width: 0;
}

.work-list-table .item-cell span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.trf-cell {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.work-list-table .trf-header {
    text-align: right;
}

.sisa-value,
.sisa-unit {
    display: block;
    white-space: nowrap;
}

.sisa-unit {
    margin-top: 3px;
    color: var(--muted);
    font-weight: 600;
}

.unit-cell {
    padding-left: 8px;
}

.finish-qty-cell {
    min-width: 0;
}

.finish-qty-input {
    min-width: 104px;
}

.coupon-club-name-input,
.coupon-start-input,
.coupon-end-input {
    min-width: 0;
}

.coupon-start-input,
.coupon-end-input {
    min-height: 28px !important;
    padding: 4px 5px !important;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.work-list-table .coupon-number-cell {
    padding-left: 4px;
    padding-right: 4px;
}

.coupon-submit-cell {
    vertical-align: middle;
}

.coupon-action-button {
    width: 100%;
    padding-left: 4px;
    padding-right: 4px;
}

.coupon-club-name-edit {
    max-width: 280px;
}

.finish-list-table {
    min-width: 1300px;
    table-layout: fixed;
}

.sales-orders-table {
    min-width: 860px;
    table-layout: fixed;
}

.sales-orders-table .so-number-col {
    width: 120px;
}

.sales-orders-table .customer-po-col {
    width: 150px;
}

.sales-orders-table .customer-col {
    width: auto;
}

.sales-orders-table .deadline-col {
    width: 120px;
}

.sales-orders-table .status-col {
    width: 95px;
}

.sales-orders-table .created-by-col {
    width: 130px;
}

.sales-orders-table .items-col {
    width: 82px;
}

.sales-orders-table .action-col {
    width: 70px;
}

.finish-list-table .select-col {
    width: 38px;
}

.finish-list-table .customer-col {
    width: 170px;
}

.finish-list-table .so-col {
    width: 120px;
}

.finish-list-table .item-col {
    width: auto;
}

.finish-list-table .club-col {
    width: 180px;
}

.finish-list-table .stock-col {
    width: 130px;
}

.finish-list-table .delivery-progress-col {
    width: 190px;
}

.finish-list-table .unit-col {
    width: 78px;
}

.finish-list-table .delivery-qty-col {
    width: 142px;
}

.finish-list-table .max-col {
    width: 58px;
}

.finish-list-table .item-cell {
    min-width: 190px;
}

.finish-list-table .item-cell span,
.finish-list-table .so-cell span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.stock-cell,
.delivery-progress-cell {
    white-space: nowrap;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.delivery-qty-cell {
    min-width: 142px;
}

.delivery-qty-input {
    min-width: 112px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.content {
    min-width: 0;
    padding: 28px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.topbar h1,
.work-panel h2 {
    margin: 0;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: right;
}

.user-menu span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.profile-menu {
    position: relative;
}

.profile-menu summary {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    list-style: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    padding: 7px 11px;
    color: var(--text);
    cursor: pointer;
}

.profile-menu summary::-webkit-details-marker {
    display: none;
}

.profile-menu summary::after {
    content: "";
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--muted);
}

.profile-menu[open] summary::after {
    transform: rotate(180deg);
}

.profile-menu summary span {
    display: grid;
    gap: 2px;
    margin: 0;
    text-align: left;
}

.profile-menu summary strong {
    color: var(--text);
}

.profile-menu summary em {
    color: var(--muted);
    font-size: 13px;
    font-style: normal;
}

.profile-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    width: 210px;
    display: grid;
    gap: 4px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.profile-menu-panel a {
    min-height: 38px;
    display: flex;
    align-items: center;
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--text);
    font-size: 14px;
    text-align: left;
}

.profile-menu-panel a:hover,
.profile-menu-panel a.active {
    background: var(--surface-muted);
    color: var(--primary);
}

.button,
.logout-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 14px;
    cursor: pointer;
}

.button.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.button.danger {
    border-color: #e4b3b3;
    background: var(--danger-bg);
    color: var(--danger-text);
}

.button.small {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 12px;
}

.toolbar,
.form-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.filter-bar label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.filter-bar select {
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    padding: 8px 10px;
    font: inherit;
}

.form-actions {
    margin-top: 18px;
    margin-bottom: 0;
}

.sales-order-upload-picker {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}

.sales-order-upload-picker input[type="file"] {
    min-width: 0;
}

.clipboard-image-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-muted);
}

.clipboard-image-preview[hidden],
.clipboard-upload-error[hidden] {
    display: none !important;
}

.clipboard-image-preview img {
    width: 160px;
    height: 110px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #ffffff;
    object-fit: contain;
}

.clipboard-image-preview strong,
.clipboard-image-preview small {
    display: block;
}

.clipboard-image-preview small {
    margin-top: 6px;
}

.clipboard-upload-error {
    margin-top: 16px;
    margin-bottom: 0;
}

.row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    white-space: nowrap;
}

.row-actions form {
    display: inline-flex;
    margin: 0;
}

.actions-cell {
    width: 1%;
    text-align: right;
    white-space: nowrap;
}

.field-hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.metric-card,
.work-panel,
.form-panel,
.table-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 6px 22px rgba(24, 32, 42, 0.06);
}

.metric-card {
    padding: 18px;
}

.metric-card span {
    color: var(--muted);
    font-size: 13px;
}

.metric-card strong {
    display: block;
    margin-top: 12px;
    font-size: 32px;
}

.work-panel {
    padding: 22px;
    margin-bottom: 18px;
}

.work-panel p:last-child {
    max-width: 720px;
    color: var(--muted);
    line-height: 1.6;
}

.form-panel {
    display: grid;
    gap: 12px;
    padding: 20px;
    margin-bottom: 18px;
}

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

.form-panel label {
    display: grid;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
}

.form-panel input,
.form-panel select,
.form-panel textarea,
.inline-form input,
.table-card input:not([type="checkbox"]),
.table-card select {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
}

.form-panel textarea {
    resize: vertical;
}

.checkbox-row {
    display: flex !important;
    align-items: center;
    gap: 8px;
}

.checkbox-row input {
    width: auto;
}

.table-card {
    overflow-x: auto;
    margin-bottom: 18px;
}

.table-card input[type="checkbox"] {
    width: 15px;
    height: 15px;
    min-height: 15px;
    margin: 0;
    accent-color: var(--primary);
}

.table-card.compact {
    box-shadow: none;
}

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

.customers-table {
    min-width: 640px;
    table-layout: fixed;
}

.customers-table .customer-name-col {
    width: 36%;
}

.customers-table .customer-address-col {
    width: 38%;
}

.customers-table .customer-po-pdf-col {
    width: 100px;
}

.customers-table .customer-status-col {
    width: 90px;
}

.customers-table .customer-action-col {
    width: 74px;
}

.customer-action-cell {
    text-align: right;
    white-space: nowrap;
}

.customer-po-pdf-cell {
    text-align: center;
    white-space: nowrap;
}

.customer-po-pdf-active {
    display: inline-grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 50%;
    background: #dcfce7;
    color: #15803d;
    font-size: 15px;
    font-weight: 900;
    line-height: 1;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

th {
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.invoice-items-table th:last-child,
.invoice-items-table td:last-child {
    text-align: right;
}

td a {
    color: var(--primary);
    font-weight: 700;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(88px, 1fr) auto;
    gap: 6px;
    align-items: center;
}

.invoice-tt-form {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0 0;
}

.invoice-tt-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.invoice-tt-form input {
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
}

.mark-paid-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.mark-paid-form input {
    width: 132px;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
}

.batch-paid-bar {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 12px;
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.batch-paid-bar label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.batch-paid-total {
    min-width: 150px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-muted);
}

.batch-paid-total span {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.batch-paid-total strong {
    display: block;
    font-size: 18px;
    font-variant-numeric: tabular-nums;
}

.date-picker-field {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 150px;
}

.date-picker-field .date-text-input {
    width: 100%;
    padding-right: 38px;
}

.date-native-input {
    position: absolute;
    top: 0;
    right: 0;
    width: 36px !important;
    height: 100%;
    min-height: 36px;
    opacity: 0;
    cursor: pointer;
}

.date-picker-icon {
    position: absolute;
    right: 11px;
    width: 15px;
    height: 15px;
    border: 1.5px solid var(--muted);
    border-radius: 3px;
    pointer-events: none;
}

.date-picker-icon::before,
.date-picker-icon::after {
    content: "";
    position: absolute;
    left: 2px;
    right: 2px;
}

.date-picker-icon::before {
    top: 3px;
    border-top: 1.5px solid var(--muted);
}

.date-picker-icon::after {
    top: -3px;
    height: 4px;
    border-left: 1.5px solid var(--muted);
    border-right: 1.5px solid var(--muted);
}

.center-cell {
    text-align: center;
    vertical-align: middle;
}

.item-editor table {
    min-width: 900px;
    table-layout: fixed;
}

.item-editor .item-code-col {
    width: 138px;
}

.item-editor .item-name-col {
    width: auto;
}

.item-editor .item-qty-col {
    width: 110px;
}

.item-editor .item-unit-col {
    width: 72px;
}

.item-editor .item-price-col {
    width: 126px;
}

.item-editor .item-deadline-col {
    width: 160px;
}

.item-editor .item-action-col {
    width: 92px;
}

.item-editor .item-notes-row td {
    padding-top: 0;
    background: #ffffff;
}

.item-editor .item-notes-row input {
    width: 100%;
}

.item-editor .unit-input {
    min-width: 0;
    text-transform: none;
}

.extracted-text {
    max-height: 260px;
    overflow: auto;
    white-space: pre-wrap;
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
}

.confirm-dialog {
    width: min(720px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.confirm-dialog::backdrop {
    background: rgba(24, 32, 42, 0.38);
}

.confirm-dialog h2 {
    margin: 0 0 8px;
}

.confirm-dialog p {
    color: var(--muted);
    margin: 0 0 14px;
}

.pdf-viewer-panel {
    height: calc(100vh - 150px);
    min-height: 560px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 6px 22px rgba(24, 32, 42, 0.06);
}

.pdf-viewer-frame {
    width: 100%;
    height: 100%;
    border: 0;
}

.mobile-bottom-nav {
    display: none;
}

@media (min-width: 901px) and (max-width: 1280px) {
    .app-shell {
        grid-template-columns: 150px minmax(0, 1fr);
    }

    .sidebar {
        padding: 14px 8px;
    }

    .sidebar-nav a {
        min-height: 34px;
        padding: 8px 8px;
        font-size: 13px;
    }

    .content {
        padding: 18px;
    }

    .work-list-table th,
    .work-list-table td {
        padding: 7px 5px;
        font-size: 11px;
        line-height: 1.15;
        overflow-wrap: anywhere;
    }

    .work-list-table th {
        font-size: 9px;
    }

    .work-list-table .item-cell span {
        font-size: 10px;
    }

    .work-list-table input:not([type="checkbox"]),
    .work-list-table select {
        min-height: 30px;
        padding: 5px 4px;
        font-size: 11px;
    }

    .work-list-table .coupon-action-button {
        min-height: 30px;
        padding: 5px 3px;
        font-size: 10px;
    }

    .finish-list-table th,
    .finish-list-table td,
    .sales-orders-table th,
    .sales-orders-table td {
        padding: 8px 7px;
        font-size: 12px;
        line-height: 1.2;
        overflow-wrap: anywhere;
    }

    .finish-list-table th,
    .sales-orders-table th {
        font-size: 10px;
    }
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
        align-content: start;
    }

    .sidebar {
        position: static;
        padding: 14px 20px;
    }

    .sidebar-nav {
        display: none;
    }

    .sidebar-brand {
        padding-bottom: 0;
    }

    .content {
        padding-bottom: calc(92px + env(safe-area-inset-bottom));
    }

    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: row;
        margin-bottom: 16px;
    }

    .user-menu {
        margin-left: auto;
        text-align: right;
    }

    .profile-menu summary {
        max-width: 132px;
        padding: 7px 9px;
    }

    .profile-menu summary span {
        min-width: 0;
    }

    .profile-menu summary strong,
    .profile-menu summary em {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .profile-menu-panel {
        right: 0;
        left: auto;
    }

    .mobile-bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        display: flex;
        gap: 6px;
        overflow-x: auto;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--line);
        background: rgba(255, 255, 255, 0.97);
        box-shadow: 0 -10px 28px rgba(24, 32, 42, 0.12);
    }

    .mobile-bottom-nav a {
        flex: 0 0 auto;
        min-width: 86px;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        padding: 8px 10px;
        color: var(--muted);
        font-size: 12px;
        font-weight: 700;
        line-height: 1.2;
        text-align: center;
    }

    .mobile-bottom-nav a:hover,
    .mobile-bottom-nav a.active {
        background: var(--primary);
        color: #ffffff;
    }
}

@media (max-width: 560px) {
    .login-panel {
        padding: 26px;
    }

    .content {
        padding: 18px 16px calc(92px + env(safe-area-inset-bottom));
    }

    .sidebar-nav,
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .topbar h1 {
        font-size: 28px;
        line-height: 1.1;
    }

    .profile-menu summary {
        max-width: 112px;
        min-height: 38px;
        gap: 7px;
    }

    .profile-menu summary em {
        font-size: 12px;
    }

    .toolbar,
    .filter-bar {
        margin-bottom: 12px;
    }

    .button,
    .filter-bar select {
        min-height: 34px;
        padding: 7px 10px;
        font-size: 13px;
    }

    .filter-bar label {
        font-size: 12px;
    }

    .customers-card {
        overflow-x: hidden;
    }

    .customers-table {
        min-width: 0;
    }

    .customers-table th,
    .customers-table td {
        padding: 9px 8px;
        font-size: 12px;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .customers-table th {
        font-size: 10px;
    }

    .customers-table .customer-name-col {
        width: 40%;
    }

    .customers-table .customer-address-col {
        width: auto;
    }

    .customers-table .customer-po-pdf-col {
        width: 68px;
    }

    .customers-table .customer-status-col,
    .customers-table .customer-status-cell {
        display: none;
    }

    .customers-table .customer-action-col {
        width: 54px;
    }

    .sales-orders-table {
        min-width: 690px;
    }

    .sales-orders-table .so-number-col {
        width: 92px;
    }

    .sales-orders-table .customer-po-col {
        width: 112px;
    }

    .sales-orders-table .customer-col {
        width: 148px;
    }

    .sales-orders-table .deadline-col {
        width: 92px;
    }

    .sales-orders-table .status-col {
        width: 74px;
    }

    .sales-orders-table .created-by-col {
        width: 92px;
    }

    .sales-orders-table .items-col {
        width: 48px;
    }

    .sales-orders-table .action-col {
        width: 56px;
    }

    .work-list-table {
        min-width: 1320px;
    }

    .work-list-table .select-col {
        width: 34px;
    }

    .work-list-table .deadline-col {
        width: 92px;
    }

    .work-list-table .customer-col {
        width: 150px;
    }

    .work-list-table .item-col {
        width: 190px;
    }

    .work-list-table .coupon-club-col {
        width: 186px;
    }

    .work-list-table .coupon-number-col {
        width: 108px;
    }

    .work-list-table .coupon-submit-col {
        width: 38px;
    }

    .work-list-table .trf-col {
        width: 180px;
    }

    .work-list-table .finish-qty-col {
        width: 132px;
    }

    .work-list-table .max-col {
        width: 38px;
    }

    .finish-list-table {
        min-width: 900px;
    }

    .finish-list-table .select-col {
        width: 34px;
    }

    .finish-list-table .customer-col {
        width: 142px;
    }

    .finish-list-table .so-col {
        width: 88px;
    }

    .finish-list-table .item-col {
        width: 170px;
    }

    .finish-list-table .stock-col {
        width: 104px;
    }

    .finish-list-table .delivery-progress-col {
        width: 142px;
    }

    .finish-list-table .unit-col {
        width: 50px;
    }

    .finish-list-table .delivery-qty-col {
        width: 82px;
    }

    .finish-list-table .max-col {
        width: 42px;
    }

    .sales-orders-table th,
    .sales-orders-table td,
    .work-list-table th,
    .work-list-table td,
    .finish-list-table th,
    .finish-list-table td {
        padding: 8px 6px;
        font-size: 12px;
        line-height: 1.2;
        overflow-wrap: anywhere;
    }

    .sales-orders-table th,
    .work-list-table th,
    .finish-list-table th {
        font-size: 10px;
        line-height: 1.15;
    }

    .work-list-table .item-cell span,
    .finish-list-table .item-cell span,
    .finish-list-table .so-cell span {
        font-size: 10px;
    }

    .work-list-table input:not([type="checkbox"]),
    .work-list-table select,
    .finish-list-table input:not([type="checkbox"]),
    .finish-list-table select {
        min-height: 30px;
        padding: 5px 4px;
        font-size: 11px;
    }

    .work-list-table .coupon-action-button {
        min-height: 30px;
        padding: 5px 3px;
        font-size: 10px;
    }

    .finish-list-table .item-cell {
        min-width: 0;
    }

    .delivery-qty-cell,
    .delivery-qty-input {
        min-width: 0;
    }
}

table.work-list-table {
    min-width: 1320px;
    table-layout: fixed;
}

table.work-list-table .coupon-number-col {
    width: 98px !important;
}

table.work-list-table .coupon-club-col {
    width: 186px !important;
}

table.work-list-table .coupon-submit-col {
    width: 38px !important;
}

table.work-list-table .trf-col {
    width: 180px !important;
}

table.work-list-table .finish-qty-col {
    width: 132px !important;
}

table.work-list-table .max-col {
    width: 38px !important;
}

table.work-list-table .coupon-number-cell {
    padding-left: 2px;
    padding-right: 2px;
}

table.work-list-table .coupon-start-input,
table.work-list-table .coupon-end-input {
    min-height: 26px !important;
    padding: 3px 4px !important;
    font-size: 12px !important;
}

table.work-list-table .finish-qty-input {
    min-width: 104px !important;
}

table.work-list-table .sisa-value,
table.work-list-table .sisa-unit {
    white-space: nowrap;
}

.sidebar-group {
    color: #dce3ea;
}

.sidebar-group summary {
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 10px;
    border-radius: 6px;
    color: #dce3ea;
    font-size: 14px;
    cursor: pointer;
    list-style: none;
}

.sidebar-group summary::-webkit-details-marker {
    display: none;
}

.sidebar-group summary::after {
    content: "+";
    color: #aeb9c6;
}

.sidebar-group[open] summary::after {
    content: "-";
}

.sidebar-group summary:hover,
.sidebar-group summary.active,
.sidebar-submenu a.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.sidebar-submenu {
    display: grid;
    gap: 3px;
    padding: 3px 0 4px 12px;
}

.sidebar-submenu a {
    min-height: 34px;
    font-size: 13px;
}

.bank-book-toolbar,
.toolbar-actions,
.panel-heading-row,
.inline-form,
.pagination {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.bank-book-toolbar {
    margin-bottom: 18px;
}

.bank-book-action {
    position: relative;
}

.bank-book-action > summary {
    list-style: none;
}

.bank-book-action > summary::-webkit-details-marker {
    display: none;
}

.bank-book-action > summary.button {
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.bank-book-action[open] > summary.button {
    border-color: var(--text);
    background: var(--text);
    color: #ffffff;
}

.bank-book-popover {
    position: absolute;
    z-index: 30;
    top: calc(100% + 8px);
    left: 0;
    width: min(420px, calc(100vw - 32px));
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 16px 42px rgba(24, 32, 42, 0.18);
}

.bank-book-action.wide .bank-book-popover {
    width: min(1100px, calc(100vw - 32px));
    left: auto;
    right: 0;
}

.bank-book-popover label,
.bank-filter-grid label,
.inline-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.bank-book-popover input,
.bank-book-popover select,
.bank-filter-grid input,
.bank-filter-grid select,
.inline-form input,
.inline-form select {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    background: var(--surface);
    font: inherit;
}

.inline-form .general-ledger-category-filter {
    flex: 1 1 520px;
    min-width: min(100%, 320px);
}

.category-list {
    overflow: auto;
}

.category-edit-header,
.category-edit-row {
    display: grid;
    grid-template-columns: 100px minmax(210px, 1.35fr) minmax(180px, 1fr) minmax(180px, 1fr) minmax(180px, 1fr) 100px 74px;
    gap: 10px;
    align-items: center;
    min-width: 1230px;
}

.category-edit-header {
    position: sticky;
    z-index: 1;
    top: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.category-edit-row {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
}

.category-edit-row:last-child {
    border-bottom: 0;
}

.category-management-modal {
    width: min(680px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
    overflow: hidden;
}

.category-management-modal[open] {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.category-management-modal::backdrop {
    background: rgba(15, 23, 42, 0.48);
}

.category-list-modal {
    width: min(1420px, calc(100vw - 32px));
    height: min(760px, calc(100vh - 48px));
}

.category-modal-heading,
.category-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
}

.category-modal-heading {
    border-bottom: 1px solid var(--line);
}

.category-modal-heading h2,
.category-modal-heading p {
    margin-bottom: 0;
}

.category-modal-heading h2 {
    margin-top: 3px;
}

.category-modal-body {
    min-height: 0;
}

.category-add-form {
    display: grid;
    gap: 14px;
    padding: 20px 22px;
    overflow-y: auto;
}

.category-add-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.category-add-form .category-inventory-field span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.category-add-form .category-inventory-checkbox,
.category-edit-row .category-inventory-checkbox {
    width: 18px;
    min-height: 18px;
    padding: 0;
}

.category-add-form input,
.category-add-form select,
.category-edit-row input,
.category-edit-row select {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    background: var(--surface);
    font: inherit;
}

.category-modal-footer {
    justify-content: flex-end;
    border-top: 1px solid var(--line);
    background: var(--surface-muted);
}

.category-save-all-button {
    min-width: 150px;
    min-height: 44px;
    padding: 10px 22px;
    font-size: 15px;
    font-weight: 700;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 5px;
}

.checkbox-label input {
    width: auto;
    min-height: auto;
}

.customer-invoice-option {
    align-items: flex-start;
    width: fit-content;
    margin: 4px 0 10px;
}

.customer-invoice-option span {
    display: grid;
    gap: 3px;
}

.customer-invoice-option small {
    color: var(--muted);
    font-weight: 400;
}

.customer-edit-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.customer-edit-status span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.customer-edit-status strong {
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
}

.customer-edit-status strong.active {
    background: #dcfce7;
    color: #166534;
}

.customer-edit-status strong.inactive {
    background: #fee2e2;
    color: #991b1b;
}

.customer-confirm-modal {
    width: min(440px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 22px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.customer-confirm-modal::backdrop {
    background: rgba(15, 23, 42, 0.48);
}

.customer-confirm-modal h2 {
    margin: 0 0 10px;
}

.customer-confirm-modal p {
    margin: 0 0 20px;
    color: var(--muted);
    line-height: 1.5;
}

.customer-confirm-modal .form-actions {
    justify-content: flex-end;
}

.panel-heading-row {
    justify-content: space-between;
    margin-bottom: 14px;
}

.panel-heading-row h2,
.panel-heading-row p {
    margin-bottom: 0;
}

.bank-checklist th,
.bank-checklist td {
    text-align: center;
}

.bank-checklist td:first-child,
.bank-checklist th:first-child {
    text-align: left;
}

.bank-checklist small,
.bank-transaction-table small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.statement-badge,
.unassigned-badge {
    display: inline-flex;
    min-width: 28px;
    min-height: 24px;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 3px 7px;
    font-size: 11px;
    font-weight: 800;
}

.statement-badge.imported {
    background: #dcfce7;
    color: #166534;
}

.statement-badge.parsed {
    background: #fef3c7;
    color: #92400e;
}

.statement-badge.failed {
    background: #fee2e2;
    color: #991b1b;
}

.statement-badge.missing {
    background: var(--surface-muted);
    color: var(--muted);
}

.unassigned-badge {
    margin-left: 3px;
    background: #fee2e2;
    color: #991b1b;
}

.bank-filter-grid {
    grid-template-columns: repeat(6, minmax(130px, 1fr));
}

.bank-filter-grid .form-actions {
    grid-column: 1 / -1;
}

.bank-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.bank-summary-grid .metric-card strong {
    font-size: 22px;
}

.accounting-statement-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.journal-indent {
    padding-left: 28px !important;
}

.journal-book-table table {
    min-width: 1220px;
}

.journal-book-table .journal-entry-group tr:first-child td {
    border-top: 2px solid #c5ced8;
}

.journal-book-table .journal-entry-group:first-of-type tr:first-child td {
    border-top-width: 1px;
}

.journal-book-table .journal-entry-group td[rowspan] {
    vertical-align: top;
}

.journal-book-table th:nth-child(1),
.journal-book-table .journal-date-cell {
    width: 105px;
}

.journal-book-table th:nth-child(2),
.journal-book-table .journal-description-cell {
    min-width: 310px;
}

.journal-book-table th:nth-child(3),
.journal-book-table .journal-account-cell {
    min-width: 260px;
}

.journal-book-table th:nth-child(4),
.journal-book-table th:nth-child(5),
.journal-book-table td.money-cell {
    width: 150px;
    text-align: right;
    white-space: nowrap;
}

.journal-book-table th:nth-child(6),
.journal-book-table .journal-source-cell {
    width: 120px;
}

.journal-book-table th:nth-child(7),
.journal-book-table .journal-reference-cell {
    min-width: 190px;
}

.journal-book-table td small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.journal-category-form {
    margin: 0;
}

.journal-category-form select {
    width: 100%;
}

.journal-category-form .field-save-status:empty {
    display: none;
}

.preview-panel {
    border-color: #86b7fe;
}

.duplicate-row {
    opacity: 0.62;
    background: var(--surface-muted);
}

.bank-transaction-table table {
    min-width: 1580px;
}

.bank-transaction-table th:nth-child(3),
.bank-transaction-table td:nth-child(3) {
    width: 34%;
    min-width: 480px;
}

.bank-transaction-table th:nth-child(4),
.bank-transaction-table td:nth-child(4) {
    min-width: 300px;
}

.bank-transaction-table th:nth-child(8),
.bank-transaction-table td:nth-child(8) {
    width: 72px;
    min-width: 72px;
    text-align: right;
}

.transaction-edit-form {
    display: grid;
    gap: 5px;
}

.auto-save-control {
    display: grid;
    gap: 4px;
}

.bank-description-editor,
.bank-note-editor {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    background: var(--surface);
    font: inherit;
    resize: vertical;
}

.bank-description-editor {
    white-space: nowrap;
}

.bank-transaction-action .button {
    white-space: nowrap;
}

.transaction-view-modal {
    width: min(620px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0;
    background: var(--surface);
    color: var(--text);
    text-align: left;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
    overflow: hidden;
}

.transaction-view-modal::backdrop {
    background: rgba(15, 23, 42, 0.42);
}

.transaction-view-heading {
    padding: 20px 22px 16px;
    border-bottom: 1px solid var(--line);
}

.transaction-view-heading h3,
.transaction-view-heading p {
    margin-bottom: 0;
}

.transaction-view-heading h3 {
    margin-top: 4px;
}

.transaction-view-form {
    display: grid;
    gap: 14px;
}

.transaction-view-body {
    padding: 20px 22px;
}

.transaction-view-field {
    display: grid;
    gap: 9px;
    width: 100%;
}

.transaction-view-label {
    display: block;
    width: 100%;
    font-size: 16px;
    font-weight: 600;
}

.transaction-view-form textarea {
    display: block;
    width: 100%;
    min-height: 88px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 14px;
    background: var(--surface);
    font: inherit;
    line-height: 1.45;
    resize: vertical;
}

.transaction-view-footer {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    padding: 20px 22px;
    border-top: 1px solid var(--line);
    background: var(--surface-muted);
}

.field-save-status {
    min-height: 14px;
}

.category-select-unassigned {
    border-color: #ef4444 !important;
    color: #b91c1c;
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.08);
}

.category-required-hint {
    display: block;
    margin-top: 4px;
    color: #dc2626 !important;
    font-size: 12px;
}

.category-required-hint[hidden] {
    display: none !important;
}

.cash-transaction-table table {
    min-width: 1100px;
}

.cash-transaction-table th:nth-child(2),
.cash-transaction-table td:nth-child(2) {
    width: 36%;
    min-width: 360px;
}

.cash-transaction-table th:nth-child(3),
.cash-transaction-table td:nth-child(3) {
    width: 30%;
    min-width: 300px;
}

.pagination {
    justify-content: flex-end;
}

@media (max-width: 900px) {
    .bank-filter-grid,
    .bank-summary-grid,
    .accounting-statement-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .category-list-modal {
        width: calc(100vw - 24px);
        height: calc(100vh - 24px);
        max-height: calc(100vh - 24px);
    }
}

@media (max-width: 600px) {
    .sales-order-upload-picker {
        grid-template-columns: 1fr;
    }

    .sales-order-upload-picker .button {
        width: 100%;
    }

    .clipboard-image-preview {
        align-items: flex-start;
        flex-direction: column;
    }

    .clipboard-image-preview img {
        width: 100%;
        height: auto;
        max-height: 220px;
    }

    .bank-filter-grid,
    .bank-summary-grid,
    .accounting-statement-grid {
        grid-template-columns: 1fr;
    }

    .bank-book-action,
    .bank-book-action > summary,
    .bank-book-toolbar > .button {
        width: 100%;
    }

    .bank-book-popover,
    .bank-book-action.wide .bank-book-popover {
        position: fixed;
        top: 72px;
        left: 16px;
        right: 16px;
        width: auto;
        max-height: calc(100vh - 96px);
        overflow-y: auto;
    }
}
