:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --ink: #111827;
    --muted: #64748b;
    --line: #d9e0e8;
    --line-strong: #c4ccd7;
    --primary: #1f4e79;
    --primary-hover: #173d61;
    --secondary: #eef2f6;
    --secondary-hover: #e1e7ef;
    --success: #0f766e;
    --success-bg: #e6f4f1;
    --warning: #7c5a10;
    --warning-bg: #f7efd6;
    --danger: #a23a3a;
    --danger-bg: #fae7e7;
    --shadow: 0 10px 24px rgba(15, 23, 42, 0.07);
    --radius: 6px;
    --icon-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3Cpath d='m12 5 7 7-7 7'/%3E%3C/svg%3E");
    --icon-back: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5'/%3E%3Cpath d='m12 19-7-7 7-7'/%3E%3C/svg%3E");
    --icon-plus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v14'/%3E%3Cpath d='M5 12h14'/%3E%3C/svg%3E");
    --icon-list: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 6h13'/%3E%3Cpath d='M8 12h13'/%3E%3Cpath d='M8 18h13'/%3E%3Cpath d='M3 6h.01'/%3E%3Cpath d='M3 12h.01'/%3E%3Cpath d='M3 18h.01'/%3E%3C/svg%3E");
    --icon-file: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3Cpath d='M16 13H8'/%3E%3Cpath d='M16 17H8'/%3E%3C/svg%3E");
    --icon-download: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3Cpath d='M12 15V3'/%3E%3C/svg%3E");
    --icon-pen: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E");
    --icon-save: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2Z'/%3E%3Cpath d='M17 21v-8H7v8'/%3E%3Cpath d='M7 3v5h8'/%3E%3C/svg%3E");
    --icon-eye: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3-7 10-7 10 7 10 7-3 7-10 7S2 12 2 12Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
    --icon-home: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 11 9-8 9 8'/%3E%3Cpath d='M5 10v10h14V10'/%3E%3Cpath d='M9 20v-6h6v6'/%3E%3C/svg%3E");
    --icon-user: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.87'/%3E%3Cpath d='M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E");
    --icon-calculator: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='16' height='20' x='4' y='2' rx='2'/%3E%3Cpath d='M8 6h8'/%3E%3Cpath d='M8 10h.01'/%3E%3Cpath d='M12 10h.01'/%3E%3Cpath d='M16 10h.01'/%3E%3Cpath d='M8 14h.01'/%3E%3Cpath d='M12 14h.01'/%3E%3Cpath d='M16 14h.01'/%3E%3Cpath d='M8 18h.01'/%3E%3Cpath d='M12 18h.01'/%3E%3Cpath d='M16 18h.01'/%3E%3C/svg%3E");
    --icon-report: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3Cpath d='M8 18v-4'/%3E%3Cpath d='M12 18v-7'/%3E%3Cpath d='M16 18v-2'/%3E%3C/svg%3E");
    --icon-excel: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3Cpath d='m8 12 4 6'/%3E%3Cpath d='m12 12-4 6'/%3E%3Cpath d='M15 13h2'/%3E%3Cpath d='M15 16h2'/%3E%3C/svg%3E");
    --icon-power: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2v10'/%3E%3Cpath d='M18.4 6.6a9 9 0 1 1-12.8 0'/%3E%3C/svg%3E");
    --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m20 6-11 11-5-5'/%3E%3C/svg%3E");
    --icon-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.7 18-8-14a2 2 0 0 0-3.4 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.7-3Z'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E");
    --icon-share: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12'/%3E%3Cpath d='m7 8 5-5 5 5'/%3E%3Cpath d='M5 13v6a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6'/%3E%3C/svg%3E");
    --icon-qr: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='7' height='7'/%3E%3Crect x='14' y='3' width='7' height='7'/%3E%3Crect x='3' y='14' width='7' height='7'/%3E%3Cpath d='M14 14h3v3h-3z'/%3E%3Cpath d='M18 14h3'/%3E%3Cpath d='M21 17v4h-4'/%3E%3Cpath d='M14 21h1'/%3E%3C/svg%3E");
    --icon-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79Z'/%3E%3C/svg%3E");
    --icon-sun: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2'/%3E%3Cpath d='M12 20v2'/%3E%3Cpath d='m4.93 4.93 1.41 1.41'/%3E%3Cpath d='m17.66 17.66 1.41 1.41'/%3E%3Cpath d='M2 12h2'/%3E%3Cpath d='M20 12h2'/%3E%3Cpath d='m6.34 17.66-1.41 1.41'/%3E%3Cpath d='m19.07 4.93-1.41 1.41'/%3E%3C/svg%3E");
    --sidebar-width: 224px;
    --app-gutter: 12px;
    --motion-fast: 140ms;
    --motion-mid: 220ms;
    --motion-slow: 360ms;
    --motion-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

html.sidebar-collapsed {
    --sidebar-width: 72px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}

.app-body {
    height: 100vh;
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
}

.auth-body {
    min-height: 100vh;
}

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

a:hover {
    color: var(--primary);
}

.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(420px, 1fr) minmax(380px, 480px);
    background: var(--bg);
}

.auth-hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 52px;
    color: #ffffff;
    background:
        linear-gradient(90deg, rgba(17, 24, 39, 0.96), rgba(31, 78, 121, 0.84)),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0, rgba(255, 255, 255, 0.06) 1px, transparent 1px, transparent 42px),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.045) 0, rgba(255, 255, 255, 0.045) 1px, transparent 1px, transparent 42px);
}

.auth-hero h1 {
    max-width: 720px;
    margin: 0;
    font-size: 48px;
    line-height: 1.08;
    font-weight: 700;
    letter-spacing: 0;
}

.auth-hero p {
    max-width: 600px;
    margin: 18px 0 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 16px;
    line-height: 1.7;
}

.login-auth-page .auth-hero {
    background:
        linear-gradient(90deg, rgba(17, 24, 39, 0.94), rgba(31, 78, 121, 0.62)),
        url("https://images.unsplash.com/photo-1522335789203-aabd1fc54bc9?auto=format&fit=crop&w=1800&q=80") center / cover no-repeat;
}

.auth-panel {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    border-left: 1px solid var(--line);
    background: var(--surface);
}

.login-card {
    width: min(100%, 390px);
}

.logo-lockup,
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 42px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.logo-lockup strong,
.brand strong {
    display: block;
    font-size: 17px;
    line-height: 1.2;
}

.logo-lockup small,
.brand small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.auth-hero .logo-lockup small,
.auth-hero .logo-lockup strong {
    color: #ffffff;
}

.login-card h2,
.page-title h1 {
    margin: 24px 0 8px;
    font-size: 26px;
    line-height: 1.15;
    letter-spacing: 0;
}

.login-card p,
.page-title p {
    margin: 0 0 22px;
    color: var(--muted);
    line-height: 1.55;
}

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

.field {
    display: grid;
    gap: 6px;
}

label {
    color: #334155;
    font-size: 12px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    color: var(--ink);
    background: #ffffff;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    font: inherit;
    transition:
        border-color var(--motion-fast) ease,
        background-color var(--motion-fast) ease,
        box-shadow var(--motion-fast) ease,
        transform var(--motion-fast) ease;
}

input[readonly],
textarea[readonly] {
    color: #64748b;
    background: #f1f5f9;
    border-color: #cbd5e1;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.16);
    cursor: not-allowed;
}

input[type="number"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.app-date-control {
    position: relative;
    display: block;
    width: 100%;
}

.app-date-display {
    cursor: pointer;
}

.app-date-picker {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
}

textarea {
    resize: vertical;
    line-height: 1.45;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 22px;
    justify-self: start;
}

.checkbox-field input[type="checkbox"] {
    appearance: auto;
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    max-width: 16px;
    flex: 0 0 16px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 3px;
    accent-color: var(--primary);
}

.checkbox-field label {
    color: #334155;
    font-size: 13px;
    line-height: 1.2;
    cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(31, 78, 121, 0.15);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px rgba(31, 78, 121, 0.08);
}

.button {
    --button-icon: var(--icon-arrow);
    min-width: 112px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    color: #ffffff;
    background: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    transition:
        color var(--motion-fast) ease,
        background-color var(--motion-fast) ease,
        border-color var(--motion-fast) ease,
        box-shadow var(--motion-fast) ease,
        transform var(--motion-fast) var(--motion-ease);
}

.button::before,
.nav a::before,
.badge::before,
.toast::before,
.module-card h2 a::before {
    width: 16px;
    height: 16px;
    display: inline-block;
    flex: 0 0 16px;
    content: "";
    background: currentColor;
    mask: var(--button-icon) center / contain no-repeat;
    -webkit-mask: var(--button-icon) center / contain no-repeat;
}

.button[type="submit"] {
    --button-icon: var(--icon-save);
}

.button[href*="dashboard"] {
    --button-icon: var(--icon-home);
}

.button[href*="po_create"] {
    --button-icon: var(--icon-plus);
}

.button[href*="po_orders"],
.button[href*="master_list"],
.button[href*="users"] {
    --button-icon: var(--icon-list);
}

.button[href*="po_accounting"] {
    --button-icon: var(--icon-calculator);
}

.button[href*="cash_advance.php"] {
    --button-icon: var(--icon-file);
}

.button[href*="cash_balance_report.php"] {
    --button-icon: var(--icon-report);
}

.button[href*="download=excel"] {
    --button-icon: var(--icon-excel);
}

.button[href*="po_print"] {
    --button-icon: var(--icon-download);
}

.button[href*="po_view"] {
    --button-icon: var(--icon-file);
}

.button[href*="po_sign"] {
    --button-icon: var(--icon-pen);
}

.button:hover {
    color: #ffffff;
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: 0 3px 8px rgba(31, 78, 121, 0.12);
}

.button:active {
    box-shadow: none;
    transform: scale(0.99);
}

.button.is-loading,
form.is-submitting .button[type="submit"] {
    color: rgba(255, 255, 255, 0.72);
    pointer-events: none;
}

.button.is-loading::after,
form.is-submitting .button[type="submit"]::after {
    width: 14px;
    height: 14px;
    margin-left: 2px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    content: "";
    animation: spin var(--motion-slow) linear infinite;
}

.button-secondary {
    color: #1f2937;
    background: var(--secondary);
    border-color: var(--line-strong);
}

.button-secondary:hover {
    color: #111827;
    background: var(--secondary-hover);
    border-color: #aeb8c5;
}

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

.button-danger:hover {
    color: #ffffff;
    background: #842f2f;
    border-color: #842f2f;
}

.button-back {
    --button-icon: var(--icon-back);
    justify-self: start;
    align-self: start;
    min-width: 88px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.master-data-tabs-wrap {
    flex: 0 0 auto;
    margin-bottom: 16px;
    padding: 0;
}

.master-data-tabs-label {
    display: block;
    margin: 0 0 7px 1px;
    color: #475569;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.master-data-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding-left: 10px;
    border-bottom: 1px solid var(--line-strong);
}

.master-data-tabs a {
    position: relative;
    margin: 0 0 -1px -1px;
    padding: 10px 15px;
    border: 1px solid var(--line-strong);
    border-radius: 6px 6px 0 0;
    color: #334155;
    background: #eef2f6;
    font-size: 13px;
    font-weight: 700;
    transition:
        color var(--motion-fast) ease,
        background-color var(--motion-fast) ease,
        border-color var(--motion-fast) ease,
        transform var(--motion-fast) var(--motion-ease);
}

.master-data-tabs a:hover {
    color: var(--primary);
    background: #f7fafc;
}

.master-data-tabs a.active {
    z-index: 1;
    color: var(--primary);
    border-bottom-color: #ffffff;
    background: #ffffff;
    font-weight: 800;
}

.master-data-tabs a.active::before {
    position: absolute;
    top: -1px;
    right: -1px;
    left: -1px;
    height: 3px;
    border-radius: 6px 6px 0 0;
    background: var(--primary);
    content: "";
}

.topbar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 18px;
    padding: 16px 12px;
    background: #ffffff;
    border-right: 1px solid var(--line);
    overflow-y: auto;
    transition: width var(--motion-mid) var(--motion-ease);
}

.topbar .brand small {
    color: var(--muted);
}

.topbar .brand {
    width: 100%;
    align-items: center;
    padding: 2px 4px 14px;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}

.nav {
    width: 100%;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 4px;
}

.nav .sidebar-toggle {
    width: 100%;
    justify-content: flex-start;
    margin-top: auto;
}

.nav .theme-toggle {
    width: 100%;
    justify-content: flex-start;
}

.nav a[href="logout.php"] {
    margin-top: 2px;
}

.nav a {
    --button-icon: var(--icon-arrow);
    width: 100%;
    padding: 10px 11px;
    color: #334155;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition:
        color var(--motion-fast) ease,
        background-color var(--motion-fast) ease,
        box-shadow var(--motion-fast) ease,
        transform var(--motion-fast) var(--motion-ease);
}

.nav a.active {
    color: var(--primary);
    background: #e7f0f8;
    box-shadow: inset 3px 0 0 var(--primary);
}

.nav a[href*="dashboard"] {
    --button-icon: var(--icon-home);
}

.nav a[href*="po_create"] {
    --button-icon: var(--icon-plus);
}

.nav a[href*="po_orders"],
.nav a[href*="master_list"] {
    --button-icon: var(--icon-list);
}

.nav a[href*="po_accounting"] {
    --button-icon: var(--icon-calculator);
}

.nav a[href*="cash_advance"] {
    --button-icon: var(--icon-file);
}

.nav a[href*="cash_balance_report"] {
    --button-icon: var(--icon-report);
}

.nav a[href*="management_report"] {
    --button-icon: var(--icon-report);
}

.nav a[href*="users"] {
    --button-icon: var(--icon-user);
}

.nav a[href*="master_data"] {
    --button-icon: var(--icon-list);
}

.nav a:hover {
    color: var(--primary);
    background: #eef4fa;
}

.nav a[href="logout.php"] {
    --button-icon: var(--icon-power);
    color: #a23a3a;
}

.nav a[href="logout.php"]:hover {
    color: #ffffff;
    background: #a23a3a;
}

.theme-toggle,
.sidebar-toggle {
    --button-icon: var(--icon-moon);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 11px;
    color: #334155;
    background: transparent;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    transition:
        color var(--motion-fast) ease,
        background-color var(--motion-fast) ease,
        transform var(--motion-fast) var(--motion-ease);
}

.sidebar-toggle {
    --button-icon: var(--icon-back);
}

.theme-toggle::before,
.sidebar-toggle::before {
    width: 16px;
    height: 16px;
    display: inline-block;
    flex: 0 0 16px;
    content: "";
    background: currentColor;
    mask: var(--button-icon) center / contain no-repeat;
    -webkit-mask: var(--button-icon) center / contain no-repeat;
}

.theme-toggle:hover,
.sidebar-toggle:hover {
    color: var(--primary);
    background: #eef4fa;
}

.dark-mode .theme-toggle {
    --button-icon: var(--icon-sun);
}

.sidebar-collapsed .sidebar-toggle {
    --button-icon: var(--icon-arrow);
}

.sidebar-collapsed .topbar {
    align-items: center;
    padding-inline: 10px;
}

.sidebar-collapsed .topbar .brand {
    justify-content: center;
    padding-inline: 0;
}

.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .theme-toggle-label,
.sidebar-collapsed .sidebar-toggle-label {
    display: none;
}

.sidebar-collapsed .nav a,
.sidebar-collapsed .theme-toggle,
.sidebar-collapsed .sidebar-toggle {
    min-width: 0;
    justify-content: center;
    padding-inline: 0;
}

.sidebar-collapsed .nav a.active {
    box-shadow: inset 0 -3px 0 var(--primary);
}

.shell {
    width: calc(100vw - var(--sidebar-width) - (var(--app-gutter) * 2));
    height: 100vh;
    flex: 1 1 auto;
    margin: 0 var(--app-gutter) 0 calc(var(--sidebar-width) + var(--app-gutter));
    padding: 14px 0 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    transition:
        width var(--motion-mid) var(--motion-ease),
        margin var(--motion-mid) var(--motion-ease);
}

.home-shell {
    height: auto;
    min-height: 100vh;
    padding-top: 16px;
    padding-bottom: 24px;
    overflow: visible;
}

.home-overview-layout {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(340px, 0.85fr);
    gap: 16px;
    align-items: start;
    min-height: 0;
    overflow: visible;
}

.home-overview-left {
    display: grid;
    grid-template-rows: none;
    gap: 16px;
    min-width: 0;
    min-height: 0;
    align-content: start;
    overflow: visible;
}

.home-overview-left .home-hero {
    margin-bottom: 0;
}

.page-title {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}

.page-title-with-back {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
}

.page-title h1 {
    margin-top: 0;
}

.stats-grid {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition:
        border-color var(--motion-fast) ease,
        box-shadow var(--motion-fast) ease,
        transform var(--motion-fast) var(--motion-ease);
}

.stat-card {
    padding: 16px;
}

.stat-card:hover,
.panel:hover {
    border-color: var(--line-strong);
}

.stat-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
    line-height: 1;
}

.stat-card small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.home-hero {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
    padding: 16px 18px;
    color: #ffffff;
    background: linear-gradient(135deg, #12324d, #1f4e79 54%, #0f766e);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.home-hero h1 {
    margin: 8px 0 5px;
    font-size: 26px;
    line-height: 1.12;
}

.home-hero p {
    max-width: 720px;
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1.55;
}

.home-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 4px 9px;
    color: #ecfeff;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.home-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.home-actions .button-secondary {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.32);
}

.home-stats .stat-card-accent {
    border-color: rgba(31, 78, 121, 0.28);
    background: #f7fbff;
}

.home-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 0;
}

.home-stats .stat-card {
    position: relative;
    min-height: 100px;
    padding: 14px 16px;
    overflow: hidden;
}

.home-stats .stat-card::after {
    position: absolute;
    right: -22px;
    bottom: -28px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(30, 64, 175, 0.05);
    content: "";
}

.dashboard-grid {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    min-height: 0;
    margin-bottom: 0;
}

.dashboard-insights-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
    gap: 16px;
    min-height: 0;
}

.home-shell .module-grid {
    margin-bottom: 16px;
}

.home-overview-left .dashboard-grid,
.home-overview-left .module-grid {
    margin-bottom: 0;
}

.home-overview-left .module-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.home-overview-left .chart-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.home-overview-left .chart-panel .panel-body {
    min-height: 0;
    padding: 12px;
    overflow: hidden;
}

.home-overview-left .bar-chart {
    height: min(170px, 19vh);
    min-height: 0;
}

.home-overview-left .status-chart-wrap {
    min-height: 0;
}

.insight-panel .panel-header {
    min-height: 50px;
    padding: 11px 14px;
}

.insight-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.insight-panel .panel-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px 14px;
}

.supplier-rank-list {
    display: grid;
    align-content: start;
    gap: 13px;
}

.supplier-rank-item {
    min-width: 0;
}

.supplier-rank-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
    font-size: 12px;
}

.supplier-rank-head strong {
    min-width: 0;
    overflow: hidden;
    color: #1f2937;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.supplier-rank-head span {
    flex: 0 0 auto;
    color: var(--primary);
    font-weight: 800;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.supplier-rank-track {
    height: 6px;
    overflow: hidden;
    background: #e8eef5;
    border-radius: 999px;
}

.supplier-rank-track span {
    height: 100%;
    display: block;
    background: linear-gradient(90deg, #2f7db7, #0f766e);
    border-radius: inherit;
}

.supplier-rank-item small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.purchasing-snapshot {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.purchasing-snapshot > div {
    min-width: 0;
    padding: 11px;
    background: #f7fafc;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.purchasing-snapshot span,
.purchasing-snapshot small {
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.purchasing-snapshot span {
    text-transform: uppercase;
}

.purchasing-snapshot strong {
    display: block;
    margin: 6px 0 4px;
    overflow: hidden;
    color: #111827;
    font-size: 17px;
    line-height: 1;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.chart-panel .panel-body {
    min-height: 220px;
}

.bar-chart {
    height: 190px;
    display: flex;
    align-items: end;
    gap: 12px;
}

.bar-item {
    min-width: 62px;
    flex: 1 1 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 8px;
    align-items: end;
    text-align: center;
}

.bar-value {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}

.bar-track {
    width: 100%;
    height: 118px;
    display: flex;
    align-items: end;
    padding: 0 10px;
    background: #edf3f8;
    border: 1px solid #d9e5ef;
    border-radius: var(--radius);
}

.bar-track span {
    width: 100%;
    min-height: 8px;
    display: block;
    background: linear-gradient(180deg, #2f7db7, #0f766e);
    border-radius: 4px 4px 0 0;
    transform-origin: bottom;
}

.bar-item strong {
    color: #334155;
    font-size: 12px;
}

.status-chart-wrap {
    display: grid;
    place-items: center;
    gap: 16px;
}

.donut-chart {
    width: 148px;
    height: 148px;
    display: grid;
    place-items: center;
    align-content: center;
    border-radius: 50%;
    background: conic-gradient(var(--success) 0 var(--checked), #f0d78f var(--checked) 100%);
    position: relative;
}

.donut-chart::before {
    position: absolute;
    inset: 18px;
    content: "";
    background: #ffffff;
    border-radius: 50%;
}

.donut-chart strong,
.donut-chart span {
    position: relative;
    z-index: 1;
}

.donut-chart strong {
    font-size: 28px;
    line-height: 1;
}

.donut-chart span {
    margin-top: 4px;
    color: var(--muted);
    font-weight: 800;
}

.status-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    color: var(--muted);
    font-weight: 700;
}

.legend-dot {
    width: 10px;
    height: 10px;
    display: inline-block;
    margin-right: 6px;
    border-radius: 50%;
}

.legend-dot.checked {
    background: var(--success);
}

.legend-dot.pending {
    background: #f0d78f;
}

.recent-panel {
    margin-top: 16px;
    flex: 0 0 auto !important;
    overflow: visible;
}

.recent-panel .table-wrap {
    max-height: none;
    min-height: 0;
    overflow: auto;
}

.recent-panel .data-table {
    min-width: 760px;
}

.recent-panel-featured {
    position: sticky;
    top: 16px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 32px);
    min-height: 0;
    margin-top: 0;
    overflow: hidden;
    border-top: 4px solid var(--primary);
}

.recent-panel-featured .panel-header {
    padding: 14px 16px;
}

.panel-eyebrow {
    display: block;
    margin-bottom: 3px;
    color: var(--primary);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.recent-order-list {
    flex: 1 1 auto;
    display: grid;
    align-content: start;
    gap: 8px;
    min-height: 0;
    padding: 12px 14px;
    overflow-y: auto;
}

.recent-order-card {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.recent-order-card:hover {
    border-color: var(--line-strong);
    box-shadow: 0 5px 14px rgba(15, 23, 42, 0.08);
}

.recent-order-card-head,
.recent-order-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.recent-order-card-head > strong {
    color: var(--primary);
    font-size: 13px;
}

.recent-order-card h3 {
    margin: 8px 0 7px;
    font-size: 14px;
    line-height: 1.28;
}

.recent-order-meta {
    color: var(--muted);
    font-size: 11px;
}

.recent-order-meta strong {
    color: #111827;
    font-size: 14px;
}

.recent-order-empty {
    margin: 0;
    padding: 16px;
    text-align: center;
}

.recent-panel-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--line);
    background: var(--surface-alt);
}

.recent-panel-footer .button {
    width: 100%;
}

.module-grid {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}

.module-card {
    position: relative;
    height: 100%;
    padding: 18px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    box-shadow: none;
    transition:
        background-color var(--motion-fast) ease,
        border-color var(--motion-fast) ease,
        box-shadow var(--motion-fast) ease,
        transform var(--motion-fast) var(--motion-ease);
}

.module-card:hover {
    background: #ffffff;
    border-color: var(--line-strong);
    border-left-color: var(--primary-hover);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.07);
}

.module-card small {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 3px 8px;
    color: #475569;
    background: #e8eef5;
    border: 1px solid #d5dee9;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.module-card h2 {
    margin: 12px 0 6px;
    font-size: 17px;
}

.module-card h2 a {
    --button-icon: var(--icon-arrow);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary);
}

.module-card h2 a[href*="po_create"] {
    --button-icon: var(--icon-plus);
}

.module-card h2 a[href*="po_orders"],
.module-card h2 a[href*="master_list"] {
    --button-icon: var(--icon-list);
}

.module-card h2 a[href*="po_accounting"] {
    --button-icon: var(--icon-calculator);
}

.module-card h2 a[href*="cash_advance"] {
    --button-icon: var(--icon-file);
}

.module-card h2 a:hover {
    color: var(--primary-hover);
}

.module-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.panel {
    overflow: hidden;
    min-height: 0;
}

.panel-header {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-alt);
}

.panel-header h2 {
    margin: 0;
    font-size: 16px;
}

.panel-body {
    padding: 16px;
    min-height: 0;
    overflow: auto;
}

.motion-collapse {
    display: block !important;
    max-height: 0;
    opacity: 0;
    overflow: hidden !important;
    transform: translateY(-6px);
    transition:
        max-height var(--motion-slow) var(--motion-ease),
        opacity var(--motion-mid) ease,
        transform var(--motion-mid) var(--motion-ease);
}

.motion-collapse.is-open {
    max-height: var(--collapse-height, 900px);
    opacity: 1;
    transform: translateY(0);
}

.split {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 14px;
    align-items: stretch;
    min-height: 0;
    overflow: hidden;
}

.shell > .panel,
.split > .panel,
.split > section.panel,
.po-form,
.sign-layout > .panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.shell > .panel {
    flex: 1 1 auto;
}

.table-wrap {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: auto;
    position: relative;
}

.panel > .table-wrap {
    flex: 1 1 auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
}

.data-table,
.po-lines-table {
    min-width: 980px;
}

.acc-table {
    min-width: 1280px;
}

.account-register-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

th,
td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    color: #475569;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

td {
    line-height: 1.35;
}

tbody tr:hover td {
    background: #f8fbfd;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f1f5f9;
    box-shadow: inset 0 -1px 0 var(--line-strong);
}

tfoot th,
tfoot td {
    background: #f8fafc;
    font-weight: 700;
}

.data-table td,
.data-table th {
    white-space: nowrap;
}

.po-list-table td:nth-child(5),
.po-lines-table td:nth-child(4),
.po-lines-table td:nth-child(6),
.po-lines-table td:nth-child(7),
.po-lines-table tfoot td,
.mini-po td:nth-child(3),
.mini-po td:nth-child(4),
.cash-advance-table td:nth-child(5),
.account-register-table td:nth-child(4),
.account-register-table td:nth-child(5),
.account-register-table td:nth-child(6),
.po-item-table td:nth-child(4),
.cash-balance-table td:nth-child(2),
.money-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.po-list-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.po-list-table th,
.po-list-table td {
    padding-inline: 8px;
}

.po-list-table th:nth-child(1),
.po-list-table td:nth-child(1) {
    width: 180px;
    min-width: 0;
}

.po-list-table th:nth-child(2),
.po-list-table td:nth-child(2) {
    width: 92px;
}

.po-list-table th:nth-child(3),
.po-list-table td:nth-child(3) {
    width: 25%;
    min-width: 0;
    white-space: normal;
}

.po-list-table th:nth-child(4),
.po-list-table td:nth-child(4) {
    width: 116px;
}

.po-list-table th:nth-child(5),
.po-list-table td:nth-child(5) {
    width: 104px;
}

.po-list-table th:nth-child(6),
.po-list-table td:nth-child(6),
.po-list-table th:nth-child(7),
.po-list-table td:nth-child(7) {
    width: 96px;
}

.po-list-table th:nth-child(8),
.po-list-table td:nth-child(8) {
    width: 214px;
}

.po-list-table .row-actions {
    width: 100%;
    gap: 6px;
}

.po-list-table .row-actions .button {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 12px;
}

.data-table td:nth-child(3),
.data-table td:first-child,
.po-lines-table td:nth-child(2) {
    min-width: 220px;
}

.data-table td:nth-child(3),
.data-table td:first-child {
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table.po-list-table td:first-child,
.data-table.po-list-table td:nth-child(3) {
    min-width: 0;
    max-width: none;
}

.po-lines-table th:nth-child(1),
.po-lines-table td:nth-child(1) {
    min-width: 76px;
}

.po-lines-table th:nth-child(2),
.po-lines-table td:nth-child(2) {
    min-width: 240px;
}

.po-lines-table th:nth-child(3),
.po-lines-table td:nth-child(3) {
    min-width: 420px;
}

.po-lines-table th:nth-child(4),
.po-lines-table td:nth-child(4),
.po-lines-table th:nth-child(5),
.po-lines-table td:nth-child(5),
.po-lines-table th:nth-child(6),
.po-lines-table td:nth-child(6) {
    min-width: 130px;
}

.po-line-thumbnail {
    display: block;
    width: 52px;
    height: 52px;
    border: 1px solid var(--line);
    border-radius: 6px;
    object-fit: cover;
}

.po-line-thumbnail-button {
    display: block;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
}

.po-view-thumbnail {
    display: block;
    width: 56px;
    height: 56px;
    border: 1px solid var(--line);
    border-radius: 6px;
    object-fit: cover;
}

.po-view-thumbnail-button {
    display: block;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
}

.line-description {
    display: block;
    overflow: hidden;
    resize: vertical;
}

.acc-table th:nth-child(8),
.acc-table td:nth-child(8) {
    min-width: 260px;
}

.acc-table th:nth-child(9),
.acc-table td:nth-child(9) {
    min-width: 168px;
}

.account-entry-panel {
    min-width: 0;
}

.account-entry-grid {
    grid-template-columns: 1fr;
}

.account-layout {
    flex: 0 1 auto;
    display: grid;
    grid-template-columns: minmax(260px, 30%) minmax(0, 70%);
    gap: 16px;
    align-items: stretch;
    min-height: 0;
    overflow: hidden;
}

.account-layout-manual-hidden {
    grid-template-columns: minmax(0, 1fr);
}

.account-list-panel {
    min-width: 0;
}

.account-list-panel .table-wrap {
    padding-bottom: 20px;
}

.account-entry-panel,
.account-list-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.account-entry-panel .panel-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.account-entry-help {
    margin: 0 0 14px;
}

.account-summary-row {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(520px, 0.72fr);
    gap: 14px;
    align-items: stretch;
    margin: 0 0 16px;
}

.account-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
}

.account-stats .stat-card {
    min-height: 66px;
    padding: 10px 12px;
}

.account-stats .stat-card span {
    font-size: 10px;
}

.account-stats .stat-card strong {
    margin-top: 6px;
    font-size: 22px;
}

.month-pager {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    margin: 0;
}

.month-pager strong,
.month-picker-button {
    min-width: 140px;
    text-align: center;
}

.month-picker-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.month-picker-button {
    min-height: 32px;
    padding: 4px 10px;
    border: 0;
    color: var(--text);
    background: transparent;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.month-picker-button:hover {
    color: var(--primary);
}

.month-picker-input {
    position: absolute;
    inset: auto 50% 0 auto;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.account-split-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.account-split-controls form {
    margin: 0;
}

.icon-button {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    background: var(--surface-alt);
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.icon-button:hover {
    border-color: var(--line-strong);
}

.icon-button-placeholder {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
}

.account-split-toggle {
    color: var(--primary);
    background: transparent;
}

.account-split-toggle::before {
    content: "";
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 7px solid currentColor;
}

.account-split-toggle[aria-expanded="true"]::before {
    border-top: 0;
    border-bottom: 7px solid currentColor;
}

.account-split-add {
    color: #ffffff;
    background: var(--primary);
    border-color: var(--primary);
}

.account-split-add:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.account-split-parent td {
    background: color-mix(in srgb, var(--muted) 10%, var(--surface));
    border-top: 1px solid color-mix(in srgb, var(--muted) 18%, var(--line));
    border-bottom-color: color-mix(in srgb, var(--muted) 18%, var(--line));
}

.account-split-parent .account-source-link {
    color: var(--text);
}

.account-split-child td {
    background: color-mix(in srgb, var(--primary) 5%, var(--surface-alt));
}

.account-split-child.is-expanding td {
    animation: account-split-row-in var(--motion-mid) var(--motion-ease);
}

.account-split-child.is-collapsing td {
    animation: account-split-row-out var(--motion-fast) ease forwards;
}

.account-split-child td:first-child {
    position: relative;
}

.account-split-child td:first-child::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 28px;
    width: 34px;
    height: 50%;
    border-left: 4px solid var(--primary);
    border-bottom: 4px solid var(--primary);
    border-radius: 0 0 0 18px;
    background: transparent;
    opacity: 0.55;
}

.account-split-child td:first-child::after {
    content: "";
    position: absolute;
    left: 28px;
    top: 50%;
    bottom: 0;
    width: 4px;
    height: auto;
    border-radius: 999px;
    background: var(--primary);
    opacity: 0.55;
}

.account-split-child-last td:first-child::before {
    height: 50%;
}

.account-split-child-last td:first-child::after {
    display: none;
}

.account-split-child input {
    background: color-mix(in srgb, var(--primary) 5%, var(--surface));
}

.account-row-kind {
    display: inline-flex;
    align-items: center;
    min-height: 18px;
    margin-top: 5px;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
}

.account-row-kind-parent {
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 14%, transparent);
}

.account-row-kind-child {
    color: #0f766e;
    background: rgba(20, 184, 166, 0.14);
}

.account-row-highlight td {
    animation: account-row-highlight 6s ease-out;
}

.account-confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.56);
    opacity: 0;
    transition: opacity var(--motion-mid) ease;
}

.account-confirm-backdrop.is-open {
    opacity: 1;
}

.account-confirm-card {
    width: min(420px, 100%);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.34);
    transform: translateY(10px) scale(0.96);
    transition: transform var(--motion-mid) var(--motion-ease);
}

.account-confirm-backdrop.is-open .account-confirm-card {
    transform: translateY(0) scale(1);
}

.account-confirm-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #ffffff;
    background: var(--primary);
    font-size: 22px;
    font-weight: 800;
}

.account-confirm-card h2 {
    margin: 0 0 6px;
    font-size: 20px;
}

.account-confirm-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.account-confirm-card p strong {
    color: var(--text);
}

.account-confirm-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 4px;
}

@keyframes account-row-highlight {
    0%,
    55% {
        background: rgba(96, 165, 250, 0.28);
        box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.5);
    }

    100% {
        background: color-mix(in srgb, var(--primary) 4%, var(--surface-alt));
        box-shadow: inset 0 0 0 1px transparent;
    }
}

@keyframes account-split-row-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes account-split-row-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

.account-check-field {
    align-self: start;
    margin-top: 0;
}

.account-register-table input {
    min-width: 0;
    min-height: 30px;
    padding: 6px 7px;
    font-size: 12px;
}

.account-register-table input[type="number"] {
    overflow: visible;
    text-overflow: clip;
}

.account-register-table td:nth-child(5) input {
    min-width: 0;
}

.account-register-table input[readonly],
.account-register-table .po-sourced-amount-input,
.account-register-table .po-sourced-date-display {
    color: #475569;
    background: #f8fafc;
    border-color: #cbd5e1;
    cursor: not-allowed;
}

.account-register-table th,
.account-register-table td {
    padding: 7px 5px;
    font-size: 12px;
}

.account-register-table .account-control-column {
    width: 80px;
    min-width: 0;
    max-width: 80px;
}

.account-register-table th:nth-child(2),
.account-register-table td:nth-child(2),
.account-register-table .account-date-column {
    width: 112px;
    min-width: 0;
    max-width: 112px;
}

.account-register-table th:nth-child(3),
.account-register-table td:nth-child(3),
.account-register-table .account-delivery-column {
    width: 116px;
    min-width: 0;
    max-width: 116px;
}

.account-register-table th:nth-child(4),
.account-register-table td:nth-child(4),
.account-register-table .account-po-column {
    width: 112px;
    min-width: 0;
    max-width: 112px;
    text-align: center;
}

.account-register-table .account-po-column .account-source-link {
    margin: 0 auto;
    font-size: 13px;
    font-weight: 800;
}

.account-register-table th:nth-child(5),
.account-register-table td:nth-child(5),
.account-register-table .account-company-column {
    width: 220px;
    min-width: 0;
    max-width: 220px;
}

.account-register-table th:nth-child(6),
.account-register-table td:nth-child(6),
.account-register-table th:nth-child(8),
.account-register-table td:nth-child(8) {
    width: 108px;
}

.account-register-table th:nth-child(7),
.account-register-table td:nth-child(7) {
    width: 86px;
}

.account-register-table th:nth-child(9),
.account-register-table td:nth-child(9) {
    width: 82px;
}

.account-register-table th:nth-child(10),
.account-register-table td:nth-child(10) {
    width: 118px;
    min-width: 0;
}

.account-register-table th:nth-child(11),
.account-register-table td:nth-child(11) {
    width: 96px;
    min-width: 0;
}

.account-register-table th:nth-child(12),
.account-register-table td:nth-child(12) {
    width: 136px;
}

.account-register-table th:nth-child(13),
.account-register-table td:nth-child(13) {
    width: 92px;
}

.account-register-table .row-actions {
    width: 82px;
    display: grid;
    gap: 6px;
}

.account-register-table .row-actions .button {
    width: 82px;
    min-width: 0;
    min-height: 32px;
    padding: 6px 8px;
    font-size: 12px;
}

.account-register-table .badge {
    max-width: 100%;
    white-space: normal;
}

.account-source-link {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 700;
}

.delivery-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: 16px;
}

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

.delivery-summary-body div {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-alt);
}

.delivery-summary-body span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.delivery-summary-body strong {
    display: block;
    margin-top: 6px;
    font-size: 20px;
}

.delivery-page-panel {
    flex: 0 0 auto !important;
}

.delivery-shell {
    gap: 0;
}

.delivery-page-layout {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(560px, 0.9fr) minmax(420px, 1.1fr);
    gap: 14px;
    min-height: 0;
    overflow: hidden;
}

.delivery-create-panel {
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.delivery-batches-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.delivery-create-panel .panel-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.delivery-batches-panel .delivery-batch-grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding-bottom: 24px;
}

.delivery-create h3,
.delivery-existing h3 {
    margin: 0 0 12px;
    font-size: 16px;
}

.delivery-header-grid {
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
    margin-bottom: 12px;
}

.delivery-header-grid-wide {
    grid-template-columns: 1fr;
}

.delivery-lines-wrap {
    max-height: 320px;
    margin-bottom: 12px;
}

.delivery-lines-wrap-wide {
    max-height: none;
}

.delivery-lines-table {
    min-width: 760px;
}

.delivery-lines-table-wide {
    min-width: 760px;
}

.delivery-lines-table td:nth-child(2),
.delivery-lines-table td:nth-child(3),
.delivery-lines-table td:nth-child(4),
.delivery-lines-table td:nth-child(5) {
    text-align: right;
}

.delivery-lines-table input {
    max-width: 120px;
    margin-left: auto;
}

.delivery-existing {
    display: grid;
    gap: 10px;
    align-content: start;
}

.delivery-batch-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.delivery-batch-card {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-alt);
}

.delivery-batch-highlight {
    animation: account-row-highlight 6s ease-out;
}

.delivery-batch-head,
.delivery-batch-total,
.delivery-batch-card li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.delivery-batch-head strong {
    color: var(--primary);
}

.delivery-batch-total {
    flex-wrap: wrap;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.delivery-batch-total strong {
    color: var(--text);
}

.delivery-batch-card p {
    margin: 8px 0 0;
    color: var(--muted);
}

.delivery-batch-card ul {
    display: grid;
    gap: 6px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.delivery-batch-card li {
    padding-top: 6px;
    border-top: 1px solid var(--line);
    font-size: 12px;
}

.cash-advance-layout {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(250px, 24%) minmax(0, 76%);
    gap: 16px;
    min-height: 0;
    overflow: hidden;
}

.cash-advance-entry,
.cash-advance-list {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.cash-advance-entry .panel-body {
    flex: 1 1 auto;
    overflow-y: auto;
}

.cash-advance-table {
    min-width: 0;
    table-layout: fixed;
}

.cash-advance-table th,
.cash-advance-table td {
    min-width: 0;
    padding: 9px 8px;
}

.cash-advance-table th:nth-child(1),
.cash-advance-table td:nth-child(1) {
    width: 4%;
}

.cash-advance-table th:nth-child(2),
.cash-advance-table td:nth-child(2) {
    width: 9%;
}

.cash-advance-table th:nth-child(3),
.cash-advance-table td:nth-child(3) {
    width: 18%;
    white-space: normal;
}

.cash-advance-table th:nth-child(4),
.cash-advance-table td:nth-child(4) {
    width: 11%;
}

.cash-advance-table th:nth-child(5),
.cash-advance-table td:nth-child(5) {
    width: 9%;
}

.cash-advance-table th:nth-child(6),
.cash-advance-table td:nth-child(6),
.cash-advance-table th:nth-child(7),
.cash-advance-table td:nth-child(7) {
    width: 9%;
}

.cash-advance-table th:nth-child(8),
.cash-advance-table td:nth-child(8) {
    width: 12%;
}

.cash-advance-table th:nth-child(9),
.cash-advance-table td:nth-child(9) {
    width: 18%;
}

.cash-advance-table td:nth-child(8) {
    vertical-align: top;
}

.cash-advance-table td:nth-child(8) .badge {
    min-width: 126px;
    justify-content: center;
}

.cash-advance-signature {
    display: block;
    width: 126px;
    max-width: 126px;
    height: 54px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    object-fit: contain;
}

.cash-advance-signature-button {
    display: block;
    width: 126px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
}

.cash-advance-signed-at {
    display: block;
    margin-top: 4px;
    font-size: 10px;
}

.cash-sign-button {
    --button-icon: var(--icon-pen);
    display: flex;
    width: 126px;
    min-width: 126px;
    min-height: 30px;
    margin-top: 7px;
    padding: 5px 10px;
    font-size: 12px;
}

.cash-signature-resign {
    --button-icon: var(--icon-pen);
    display: flex;
    width: max-content;
    margin: 12px auto 0;
}

#cash-signature-full {
    max-height: calc(90vh - 100px);
}

.cash-advance-action-buttons {
    display: flex;
    gap: 6px;
}

.cash-advance-table .qr-sign-button,
.cash-advance-table .share-sign-button {
    flex: 1 1 auto;
    min-width: 82px;
    min-height: 32px;
    gap: 5px;
    padding: 5px 8px;
    font-size: 12px;
}

.cash-advance-table .share-sign-button {
    --button-icon: var(--icon-share);
}

.cash-advance-table .qr-sign-button {
    --button-icon: var(--icon-qr);
}

.cash-advance-table .qr-sign-button::before,
.cash-advance-table .share-sign-button::before {
    width: 13px;
    height: 13px;
    flex-basis: 13px;
}

.qr-sign-dialog {
    width: min(92vw, 420px);
    padding: 38px 20px 20px;
    border: 0;
    border-radius: var(--radius);
    background: #ffffff;
    box-shadow: var(--shadow);
    text-align: center;
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    transition:
        opacity var(--motion-mid) ease,
        transform var(--motion-mid) var(--motion-ease);
}

.qr-sign-dialog[open] {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.qr-sign-dialog::backdrop {
    background: rgba(15, 23, 42, 0.72);
}

.qr-sign-dialog h2 {
    margin: 0 0 14px;
}

.qr-sign-dialog #qr-sign-code {
    display: grid;
    place-items: center;
    width: 280px;
    height: 280px;
    max-width: 100%;
    margin: 0 auto 14px;
}

.qr-sign-dialog a {
    display: block;
    overflow-wrap: anywhere;
    font-size: 12px;
}

.cash-advance-sign-shell {
    overflow-y: auto;
}

.cash-advance-report-shell {
    height: 100vh;
}

.cash-report-panel {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

.cash-report-header {
    align-items: center;
    flex-wrap: wrap;
}

.month-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.month-selector input[type="month"] {
    width: 160px;
    min-height: 36px;
}

.month-arrow {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    color: var(--primary);
    background: var(--secondary);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    font-size: 18px;
    font-weight: 800;
}

.month-arrow:hover {
    color: #ffffff;
    background: var(--primary);
}

.cash-report-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.cash-advance-report-table {
    width: max(100%, var(--cash-report-min-width, 1180px));
    min-width: 100%;
    table-layout: fixed;
}

.cash-advance-report-table th,
.cash-advance-report-table td {
    padding: 7px 6px;
    min-width: 0;
    white-space: normal;
    font-size: 12px;
}

.cash-advance-report-table th:nth-child(1),
.cash-advance-report-table td:nth-child(1) {
    width: 92px;
}

.cash-advance-report-table th:nth-child(2),
.cash-advance-report-table td:nth-child(2) {
    width: 180px;
}

.cash-advance-report-table th:nth-child(3),
.cash-advance-report-table td:nth-child(3) {
    width: 108px;
}

.cash-advance-report-table th:nth-last-child(3),
.cash-advance-report-table td:nth-last-child(3) {
    width: 112px;
}

.cash-advance-report-table th:nth-last-child(2),
.cash-advance-report-table td:nth-last-child(2),
.cash-advance-report-table th:nth-last-child(1),
.cash-advance-report-table td:nth-last-child(1) {
    width: 118px;
}

.cash-advance-report-table th:not(:nth-child(1)):not(:nth-child(2)):not(:nth-child(3)):not(:nth-last-child(1)):not(:nth-last-child(2)):not(:nth-last-child(3)),
.cash-advance-report-table td:not(:nth-child(1)):not(:nth-child(2)):not(:nth-child(3)):not(:nth-last-child(1)):not(:nth-last-child(2)):not(:nth-last-child(3)) {
    width: 82px;
}

.cash-advance-report-table .money-cell {
    text-align: right;
    white-space: nowrap;
}

.cash-report-summary {
    flex: 0 0 auto;
    overflow-x: auto;
    overflow-y: hidden;
    border-top: 1px solid var(--line-strong);
    background: var(--surface-alt);
}

.cash-report-summary-inner {
    min-width: var(--cash-report-min-width, 1180px);
    display: grid;
    grid-template-columns: 150px repeat(auto-fit, minmax(82px, 1fr));
    gap: 0;
    align-items: stretch;
}

.cash-report-summary-label,
.cash-report-summary-card {
    min-height: 58px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 9px 8px;
    border-right: 1px solid var(--line);
}

.cash-report-summary-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.cash-report-summary-card span {
    overflow: hidden;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.cash-report-summary-card strong {
    display: block;
    margin-top: 5px;
    color: var(--ink);
    font-size: 13px;
    line-height: 1.1;
    text-align: right;
}

.cash-report-summary-final {
    background: rgba(31, 78, 121, 0.08);
}

.cash-balance-table {
    min-width: 860px;
    table-layout: fixed;
}

.cash-balance-table th:nth-child(1),
.cash-balance-table td:nth-child(1) {
    width: 150px;
}

.cash-balance-table th:nth-child(2),
.cash-balance-table td:nth-child(2) {
    width: 160px;
}

.cash-balance-table th:nth-child(3),
.cash-balance-table td:nth-child(3) {
    width: 140px;
}

.cash-balance-table th:nth-child(4),
.cash-balance-table td:nth-child(4) {
    width: 170px;
}

.cash-balance-table th:nth-child(5),
.cash-balance-table td:nth-child(5) {
    width: 260px;
}

.party-table td:first-child,
.party-table td:nth-child(3),
.cash-option-table td:first-child,
.cash-option-table td:nth-child(3),
.cash-balance-table td:first-child,
.cash-balance-table td:nth-child(3),
.po-item-table td:first-child,
.po-item-table td:nth-child(3) {
    min-width: 0;
    max-width: none;
}

.user-cell {
    min-width: 280px;
}

.permissions-cell {
    min-width: 360px;
}

.users-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.users-table th,
.users-table td {
    padding: 8px 10px;
}

.users-table th:nth-child(1),
.users-table td:nth-child(1) {
    width: 200px;
}

.users-table th:nth-child(2),
.users-table td:nth-child(2) {
    width: 118px;
}

.users-table th:nth-child(3),
.users-table td:nth-child(3) {
    width: 360px;
}

.users-table th:nth-child(4),
.users-table td:nth-child(4) {
    width: 160px;
}

.users-table th:nth-child(5),
.users-table td:nth-child(5) {
    width: 286px;
}

.users-table .user-cell,
.users-table .permissions-cell,
.users-table .role-cell,
.users-table .status-cell,
.users-table .login-cell {
    min-width: 0;
}

.users-table .user-cell strong,
.users-table .user-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.users-table .permission-grid-table {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
    margin-bottom: 8px;
}

.users-table .permission-grid .checkbox-field {
    overflow: hidden;
}

.users-table .permission-grid .checkbox-field span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.permission-fieldset {
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.permission-fieldset legend {
    padding: 0 6px;
    color: #475569;
    font-size: 12px;
    font-weight: 800;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
}

.permission-grid .checkbox-field {
    margin: 0;
    white-space: nowrap;
}

.permission-grid-table {
    margin-bottom: 10px;
}

.permission-save {
    width: 100%;
}

.role-cell {
    min-width: 120px;
}

.users-table .role-cell .table-select {
    min-width: 0;
    width: 96px;
    padding-inline: 8px;
}

.users-table .permission-save {
    width: 100%;
    min-height: 32px;
    padding-block: 6px;
    font-size: 12px;
}

.users-table .row-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 6px;
    align-items: start;
}

.users-table .row-actions .button {
    min-width: 0;
    min-height: 32px;
    padding: 6px 8px;
    font-size: 12px;
}

.users-table .password-reset {
    grid-template-columns: 1fr;
    gap: 6px;
    width: 100%;
}

.users-table .password-reset input {
    min-height: 32px;
    padding: 6px 8px;
}

.users-table .password-reset .button {
    width: 100%;
}

.users-table .login-cell .badge {
    margin-bottom: 8px;
}

.users-table .user-cell,
.users-table .role-cell,
.users-table .login-cell,
.users-table .actions-cell {
    vertical-align: top;
}

.users-table .login-cell {
    text-align: center;
}

.user-login-date,
.user-login-time {
    display: block;
    font-weight: 700;
    line-height: 1.3;
}

.user-login-time {
    margin-top: 2px;
}

.status-cell {
    min-width: 110px;
}

.login-cell {
    min-width: 170px;
}

.actions-heading,
.actions-cell {
    width: 1%;
    min-width: 360px;
    white-space: nowrap;
}

.users-table .actions-heading,
.users-table .actions-cell {
    width: 286px;
    min-width: 0;
}

.user-meta {
    display: block;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-select {
    min-width: 92px;
    min-height: 36px;
    padding: 7px 9px;
}

.table-money-input {
    width: 150px;
    min-width: 0;
    min-height: 34px;
    padding: 7px 9px;
    text-align: right;
}

.master-sortable-table {
    transition: opacity var(--motion-fast) ease;
}

.master-sortable-table.is-saving-order {
    opacity: 0.72;
}

.master-sortable-table tbody tr[data-sort-id] {
    cursor: default;
}

.master-sortable-table tbody tr.is-dragging {
    opacity: 0.55;
}

.master-sortable-table tbody tr[data-sort-id] > td:first-child {
    position: relative;
    padding-left: 42px;
}

.drag-handle {
    position: absolute;
    top: 50%;
    left: 6px;
    z-index: 1;
    width: 32px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    color: var(--muted);
    border-radius: var(--radius);
    cursor: grab;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    transform: translateY(-50%);
    touch-action: none;
    user-select: none;
}

.drag-handle:hover {
    color: var(--primary);
    background: var(--secondary);
}

.drag-handle:active {
    cursor: grabbing;
}

.badge {
    --button-icon: var(--icon-check);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 26px;
    padding: 4px 9px;
    color: var(--success);
    background: var(--success-bg);
    border: 1px solid rgba(15, 118, 110, 0.22);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.badge-muted {
    --button-icon: var(--icon-alert);
    color: var(--warning);
    background: var(--warning-bg);
    border-color: rgba(124, 90, 16, 0.22);
}

.badge-warning {
    --button-icon: var(--icon-alert);
    color: var(--warning);
    background: var(--warning-bg);
    border-color: rgba(124, 90, 16, 0.22);
}

.badge-danger {
    --button-icon: var(--icon-alert);
    color: var(--danger);
    background: var(--danger-bg);
    border-color: rgba(162, 58, 58, 0.24);
}

.button-danger {
    color: var(--danger);
    background: var(--danger-bg);
    border-color: rgba(162, 58, 58, 0.3);
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) repeat(4, minmax(140px, auto)) auto auto;
    gap: 10px;
    align-items: center;
    padding: 14px 18px;
    border-top: 1px solid var(--line);
}

.filter-bar .app-date-control {
    min-width: 140px;
}

.workflow-grid,
.attention-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.shell > .workflow-panel {
    flex: 0 0 auto;
    overflow: visible;
}

.workflow-panel .panel-body {
    overflow: visible;
}

.workflow-grid > div,
.attention-list {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-alt);
}

.workflow-grid span,
.attention-list span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.workflow-grid strong {
    display: block;
    margin-top: 6px;
}

.workflow-grid small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.workflow-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 0 18px 18px;
    min-height: 58px;
}

.workflow-actions form,
.workflow-reject-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.workflow-reject-form input {
    min-width: 220px;
}

.attention-list h3 {
    margin: 0 0 10px;
    font-size: 14px;
}

.attention-list a {
    display: block;
    padding: 9px 0;
    border-top: 1px solid var(--line);
}

.attention-list a:first-of-type {
    border-top: 0;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    width: max-content;
    max-width: 100%;
    min-width: 0;
}

.row-actions form:not(.password-reset) {
    flex: 0 0 auto;
}

.row-actions > .button {
    flex: 0 0 auto;
}

.row-actions .button {
    min-width: 104px;
    width: auto;
    min-height: 34px;
    padding: 7px 10px;
    font-size: 12px;
}

.party-table .row-actions,
.po-item-table .row-actions {
    width: 128px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    justify-items: stretch;
}

.party-table .row-actions form,
.po-item-table .row-actions form {
    width: 100%;
    min-width: 0;
}

.party-table .row-actions .button,
.po-item-table .row-actions .button {
    width: 100%;
    min-width: 0;
    min-height: 32px;
    padding: 6px 7px;
    font-size: 11px;
}

.cash-option-table .row-actions,
.cash-balance-table .row-actions {
    display: inline-flex;
    flex-wrap: nowrap;
    width: max-content;
    max-width: none;
    gap: 6px;
}

.cash-option-table .row-actions form,
.cash-balance-table .row-actions form {
    width: auto;
    min-width: 0;
}

.cash-option-table .row-actions .button,
.cash-balance-table .row-actions .button {
    width: auto;
    min-width: 0;
    min-height: 32px;
    padding: 6px 7px;
    font-size: 11px;
}

.password-reset .button {
    min-width: 0;
    width: 100%;
}

.password-reset {
    display: grid;
    grid-template-columns: 220px 96px;
    gap: 8px;
    width: auto;
    min-width: 0;
}

.password-reset input {
    min-width: 0;
    min-height: 36px;
    padding: 7px 9px;
}

.inline-edit {
    display: grid;
    gap: 8px;
    min-width: 320px;
}

.party-table {
    min-width: 0;
    table-layout: fixed;
}

.party-table th:nth-child(1),
.party-table td:nth-child(1) {
    width: 25%;
    min-width: 0;
    max-width: none;
    overflow: visible;
}

.party-table th:nth-child(2),
.party-table td:nth-child(2) {
    width: 32%;
    min-width: 0;
}

.party-table th:nth-child(3),
.party-table td:nth-child(3) {
    width: 13%;
    min-width: 0;
    max-width: none;
    overflow: visible;
}

.party-table th:nth-child(4),
.party-table td:nth-child(4) {
    width: 10%;
}

.party-table th:nth-child(5),
.party-table td:nth-child(5) {
    width: 148px;
}

.party-table td:nth-child(5) .row-actions {
    padding-right: 0;
}

.party-table-company th:nth-child(4),
.party-table-company td:nth-child(4) {
    width: 180px;
}

.party-table-company th:nth-child(5),
.party-table-company td:nth-child(5) {
    width: 10%;
}

.party-table-company th:nth-child(6),
.party-table-company td:nth-child(6) {
    width: 148px;
}

.party-table-company td:nth-child(6) .row-actions {
    padding-right: 0;
}

.party-table input,
.party-table textarea {
    width: 100%;
    min-width: 0;
}

.party-table .row-actions {
    gap: 6px;
}

.party-table .row-actions .button {
    min-width: 0;
    padding-inline: 8px;
}

.party-logo-placeholder {
    width: 88px;
    height: 54px;
    margin-bottom: 8px;
}

.party-logo-wrap {
    width: 88px;
    height: 54px;
    margin-bottom: 8px;
}

.party-logo-button {
    width: 88px;
    height: 54px;
    display: block;
    cursor: pointer;
}

.party-logo-thumbnail {
    object-fit: contain;
}

.cash-option-table {
    table-layout: fixed;
}

.cash-option-table th:nth-child(1),
.cash-option-table td:nth-child(1) {
    width: 58%;
}

.cash-option-table th:nth-child(2),
.cash-option-table td:nth-child(2) {
    width: 12%;
}

.cash-option-table th:nth-child(3),
.cash-option-table td:nth-child(3) {
    width: 240px;
}

.cash-option-table input {
    min-width: 0;
}

#photo,
.pretty-file-input {
    padding: 6px;
    color: var(--muted);
    background: #f8fafc;
    border: 1px dashed var(--line-strong);
    border-radius: 12px;
    cursor: pointer;
}

#photo::file-selector-button,
.pretty-file-input::file-selector-button {
    min-height: 32px;
    margin-right: 10px;
    padding: 7px 13px;
    color: #ffffff;
    background: var(--primary);
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition:
        background-color var(--motion-fast) ease,
        box-shadow var(--motion-fast) ease,
        transform var(--motion-fast) ease;
}

#photo:hover,
.pretty-file-input:hover {
    background: #eef6fb;
    border-color: var(--primary);
}

#photo:hover::file-selector-button,
#photo:focus-visible::file-selector-button,
.pretty-file-input:hover::file-selector-button,
.pretty-file-input:focus-visible::file-selector-button {
    background: var(--primary-dark);
    box-shadow: 0 7px 16px rgba(31, 78, 121, 0.18);
}

#photo:focus-visible,
.pretty-file-input:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.item-photo-button {
    display: block;
    width: 72px;
    height: 72px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    overflow: hidden;
    transition:
        border-color var(--motion-fast) ease,
        box-shadow var(--motion-fast) ease,
        transform var(--motion-fast) var(--motion-ease);
}

.item-photo-button:hover {
    border-color: var(--primary);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
}

.item-photo-wrap {
    position: relative;
    width: 72px;
    height: 72px;
}

.item-photo-wrap form {
    margin: 0;
}

.item-photo-delete {
    position: absolute;
    top: -7px;
    right: -7px;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid #ffffff;
    border-radius: 50%;
    color: #ffffff;
    background: #000000;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.po-item-table td:first-child,
.po-item-table th:first-child {
    width: 110px;
    min-width: 110px;
    max-width: 110px;
    overflow: visible;
}

.po-item-table {
    table-layout: fixed;
}

.po-item-table th:nth-child(2),
.po-item-table td:nth-child(2) {
    width: 32%;
}

.po-item-table th:nth-child(3),
.po-item-table td:nth-child(3) {
    width: 12%;
}

.po-item-table th:nth-child(4),
.po-item-table td:nth-child(4) {
    width: 13%;
}

.po-item-table th:nth-child(5),
.po-item-table td:nth-child(5) {
    width: 10%;
}

.po-item-table th:nth-child(6),
.po-item-table td:nth-child(6) {
    width: 148px;
}

.po-item-table input {
    min-width: 0;
}

.item-photo-thumbnail {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-photo-placeholder {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    color: var(--muted);
    border: 1px solid #000000;
    border-radius: 8px;
    font-size: 11px;
    text-align: center;
    cursor: pointer;
}

.item-photo-input {
    display: none;
}

.item-photo-dialog {
    max-width: min(90vw, 1000px);
    max-height: 90vh;
    padding: 36px 12px 12px;
    border: 0;
    border-radius: var(--radius);
    background: #ffffff;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    transition:
        opacity var(--motion-mid) ease,
        transform var(--motion-mid) var(--motion-ease);
}

.item-photo-dialog[open] {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.item-photo-dialog::backdrop {
    background: rgba(15, 23, 42, 0.72);
}

.item-photo-dialog img {
    display: block;
    max-width: 100%;
    max-height: calc(90vh - 48px);
    object-fit: contain;
}

.item-photo-dialog-close {
    position: absolute;
    top: 6px;
    right: 10px;
    padding: 0;
    border: 0;
    color: #475569;
    background: transparent;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

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

.summary-grid div {
    padding: 12px;
    background: var(--surface-alt);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.summary-grid span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.summary-grid strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sign-layout {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(300px, 0.8fr)) minmax(420px, 1.2fr);
    gap: 14px;
    align-items: stretch;
    min-height: 0;
    overflow: hidden;
}

.signature-pad-wrap {
    padding: 10px;
    background: #f8fafc;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
}

.signature-pad {
    display: block;
    width: 100%;
    height: 220px;
    background: #ffffff;
    border-radius: 4px;
    touch-action: none;
}

.saved-signature {
    display: grid;
    gap: 8px;
    padding-top: 8px;
}

.saved-signature img {
    max-width: 260px;
    max-height: 120px;
    padding: 8px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.mini-po {
    padding: 14px;
    color: #0f172a;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.mini-po-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.mini-po table {
    margin-top: 12px;
}

.mini-po th,
.mini-po td {
    padding: 8px;
    color: #0f172a;
}

.mini-total {
    margin: 12px 0 0;
    text-align: right;
    font-weight: 800;
}

.po-header-grid {
    flex: 0 0 auto;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    margin-bottom: 24px;
}

.po-create-layout {
    display: grid;
    grid-template-columns: minmax(260px, 30%) minmax(0, 70%);
    gap: 18px;
    align-items: start;
    min-height: 0;
}

.po-party-column {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-alt);
}

.po-party-column h2 {
    margin: 0 0 14px;
    font-size: 16px;
}

.po-order-column {
    min-width: 0;
}

.po-party-grid {
    flex: 0 0 auto;
    grid-template-columns: 1fr;
    margin-bottom: 0;
}

.po-party-grid .field:last-child {
    margin-top: 0;
}

.po-order-column .po-header-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.po-order-column .po-lines-table {
    min-width: 0;
    table-layout: fixed;
}

.po-order-column .po-lines-table th:nth-child(1),
.po-order-column .po-lines-table td:nth-child(1) {
    width: 8%;
    min-width: 0;
}

.po-order-column .po-lines-table th:nth-child(2),
.po-order-column .po-lines-table td:nth-child(2) {
    width: 25%;
    min-width: 0;
}

.po-order-column .po-lines-table th:nth-child(3),
.po-order-column .po-lines-table td:nth-child(3) {
    width: 31%;
    min-width: 0;
}

.po-order-column .po-lines-table th:nth-child(4),
.po-order-column .po-lines-table td:nth-child(4) {
    width: 10%;
}

.po-order-column .po-lines-table th:nth-child(5),
.po-order-column .po-lines-table td:nth-child(5) {
    width: 10%;
}

.po-order-column .po-lines-table th:nth-child(6),
.po-order-column .po-lines-table td:nth-child(6) {
    width: 16%;
}

.po-form .panel-body {
    display: flex;
    flex-direction: column;
}

.po-form .field:last-child {
    flex: 0 0 auto;
    margin-top: 14px;
}

.po-header-grid .field:nth-child(2) {
    grid-column: span 2;
}

.po-lines-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 6px 0 12px;
}

.po-lines-head h2 {
    margin: 0;
    font-size: 16px;
}

.po-live-totals {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.po-live-totals div {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-alt);
}

.po-live-totals span,
.po-live-totals strong {
    display: block;
}

.po-live-totals span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.po-live-totals strong {
    margin-top: 4px;
    font-size: 18px;
}

.print-body {
    background: #e9edf3;
    font-family: "Angsana New", "TH Sarabun New", "Times New Roman", serif;
}

.print-toolbar {
    width: min(210mm, calc(100% - 32px));
    margin: 18px auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.po-document {
    position: relative;
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto 32px;
    padding: 6mm 9mm 5mm;
    background: #fff;
    color: #000;
    box-shadow: 0 16px 50px rgba(29, 36, 51, 0.16);
    font-size: 20px;
    line-height: 1.1;
    break-after: page;
    page-break-after: always;
}

.po-doc-page-count {
    position: absolute;
    top: 3mm;
    right: 6mm;
    color: #555;
    font-family: Arial, Tahoma, sans-serif;
    font-size: 10px;
}

.po-document:last-of-type {
    break-after: auto;
    page-break-after: auto;
}

.po-document-continued .po-doc-lines tbody tr:last-child td {
    border-bottom: 1px solid #000;
}

.po-doc-continued-note {
    margin: 4mm 0 0;
    text-align: right;
    font-size: 14px;
    font-style: italic;
}

.po-doc-top {
    position: relative;
    min-height: 43mm;
    margin-bottom: 2.5mm;
}

.po-doc-company-logo {
    position: absolute;
    top: 3mm;
    left: 7mm;
    width: 31mm;
    max-height: 31mm;
    object-fit: contain;
}

.po-doc-header {
    text-align: center;
    padding: 1.5mm 4mm 0;
}

.po-doc-top-with-logo .po-doc-header {
    padding-left: 30mm;
}

.po-doc-header h1,
.po-doc-header h2,
.po-doc-header p {
    margin: 0;
}

.po-doc-header h1 {
    color: #000;
    font-size: 20px;
    line-height: 1.1;
    font-weight: 800;
}

.po-doc-header h2 {
    margin-top: 1mm;
    color: #000;
    font-family: "Times New Roman", "Angsana New", serif;
    font-size: 23px;
    line-height: 1.1;
    font-weight: 800;
}

.po-doc-header p {
    margin-top: 1.2mm;
    font-size: 15px;
    line-height: 1.2;
}

.po-doc-title-box {
    width: 118mm;
    min-height: 9.5mm;
    display: grid;
    place-items: center;
    margin: 1.5mm auto 0;
    color: #000;
    border: 2px solid #de6d0b;
    border-radius: 7px;
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
}


.po-doc-info {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 50mm;
    align-items: stretch;
    border-left: 1px solid #000;
    border-right: 1px solid #000;
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    margin-bottom: 2mm;
}

.po-doc-recipient {
    min-height: 28mm;
    display: flex;
    flex-direction: column;
    padding: 1.2mm 1mm 1mm;
    border-right: 0;
    font-size: 17px;
    line-height: 1.08;
}

.po-doc-recipient p {
    margin: 0 0 1mm;
}

.po-doc-recipient strong {
    color: #000;
    font-weight: 700;
}

.po-doc-address {
    padding-left: 6mm;
}

.po-doc-tax {
    margin-top: auto !important;
    margin-bottom: 0;
}

.po-doc-meta,
.po-doc-lines {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.po-doc-meta th,
.po-doc-meta td,
.po-doc-lines th,
.po-doc-lines td {
    border: 1px solid #000;
    font-size: 18px;
    white-space: normal;
}

.po-doc-meta th,
.po-doc-meta td {
    height: 5.6mm;
    padding: 0.45mm 1mm;
    font-size: 15px;
    text-align: left;
    vertical-align: middle;
}

.po-doc-meta th {
    width: 21mm;
    color: #000;
    font-style: italic;
    font-weight: 700;
}

.po-doc-lines th {
    height: 7.8mm;
    padding: 0.5mm 1mm;
    text-align: center;
    position: static;
    color: #000;
    background: #fff;
    box-shadow: none;
    font-weight: 400;
}

.po-doc-lines tbody td {
    height: 9.7mm;
    padding: 0.6mm 1mm;
    vertical-align: top;
    border-top: 0;
    border-bottom: 0;
}

.po-doc-lines tbody tr:first-child td {
    border-top: 1px solid #000;
}

.po-doc-lines tbody tr:last-child td {
    border-bottom: 1px solid #000;
}

.po-col-no {
    width: 13mm;
}

.po-col-desc {
    width: 84mm;
}

.po-col-qty,
.po-col-unit,
.po-col-price {
    width: 18mm;
}

.po-col-amount {
    width: 31mm;
}

.po-doc-lines td:nth-child(1),
.po-doc-lines td:nth-child(3),
.po-doc-lines td:nth-child(4) {
    text-align: center;
}

.po-doc-lines td:nth-child(5),
.po-doc-lines td:nth-child(6),
.po-doc-lines tfoot td {
    text-align: right;
}

.po-line-description {
    color: #000;
    text-align: left !important;
}

.po-doc-lines tfoot th,
.po-doc-lines tfoot td {
    height: 7.2mm;
    padding: 0.6mm 1mm;
    background: #fff;
    color: #000;
    border: 1px solid #000;
    font-size: 15px;
    font-weight: 400;
}

.po-doc-lines tfoot th[colspan="2"] {
    text-align: left;
}

.po-doc-amount-words th,
.po-doc-amount-words td {
    border-top: 1px solid #000 !important;
    border-bottom: 1px solid #000 !important;
}

.po-doc-amount-words th:first-child {
    width: 24mm;
    text-align: left;
}

.po-doc-signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 38mm;
    border: 1px solid #000;
    border-top: 0;
    font-size: 20px;
}

.po-doc-signature-box {
    display: flex;
    min-height: 38mm;
    padding: 7mm 8mm 2mm;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    text-align: center;
}

.po-doc-signature-box:first-child {
    border-right: 1px solid #000;
}

.po-doc-signature-box p {
    margin: 0;
}

.po-doc-sign-line {
    width: 58mm;
    height: 12mm;
    margin: 1mm 0;
    border-bottom: 1px solid #555;
    display: flex;
    align-items: end;
    justify-content: center;
}

.po-doc-sign-line img {
    max-width: 42mm;
    max-height: 10mm;
    object-fit: contain;
}

.signature-meta {
    color: #4b5563;
    font-size: 14px !important;
}

.toast-container {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 10000;
    display: grid;
    gap: 10px;
    width: min(380px, calc(100vw - 36px));
    pointer-events: none;
}

.toast {
    --button-icon: var(--icon-alert);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 12px 12px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-weight: 700;
    pointer-events: auto;
    animation: toast-enter 220ms ease-out;
}

.toast-error {
    color: var(--danger);
    background: var(--danger-bg);
    border-color: rgba(162, 58, 58, 0.22);
}

.toast-success {
    --button-icon: var(--icon-check);
    color: var(--success);
    background: var(--success-bg);
    border-color: rgba(15, 118, 110, 0.22);
}

.toast-message {
    flex: 1 1 auto;
    line-height: 1.4;
}

.toast-close {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    color: currentColor;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
}

.toast-close:hover {
    opacity: 1;
}

.toast-leaving {
    opacity: 0;
    transform: translateX(18px);
    transition: opacity 220ms ease, transform 220ms ease;
}

@keyframes toast-enter {
    from {
        opacity: 0;
        transform: translateX(18px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }

    .motion-collapse {
        transform: none !important;
    }
}

.muted {
    color: var(--muted);
}

.dark-mode {
    color-scheme: dark;
    --bg: #0f172a;
    --surface: #172033;
    --surface-alt: #1e293b;
    --ink: #e5edf7;
    --muted: #9aa9bd;
    --line: #334155;
    --line-strong: #475569;
    --primary: #60a5fa;
    --primary-hover: #93c5fd;
    --secondary: #263449;
    --secondary-hover: #33445c;
    --success: #5eead4;
    --success-bg: #153d3b;
    --warning: #f5d27a;
    --warning-bg: #473a1d;
    --danger: #fca5a5;
    --danger-bg: #4b252b;
    --shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

.dark-mode .topbar,
.dark-mode .nav,
.dark-mode .recent-order-card,
.dark-mode .donut-chart::before,
.dark-mode .item-photo-button,
.dark-mode .item-photo-dialog img,
.dark-mode .qr-sign-dialog,
.dark-mode .toast {
    background: var(--surface);
}

.dark-mode .cash-advance-signature,
.dark-mode #cash-signature-full,
.dark-mode .saved-signature img,
.dark-mode .signature-pad,
.dark-mode .mini-po {
    background: #ffffff;
}

.dark-mode .mini-po,
.dark-mode .mini-po strong,
.dark-mode .mini-po span,
.dark-mode .mini-po p,
.dark-mode .mini-po th,
.dark-mode .mini-po td,
.dark-mode .mini-total {
    color: #0f172a;
}

.dark-mode .mini-po thead th {
    color: #ffffff;
    background: #1e293b;
}

.dark-mode .mini-po tbody tr:hover td {
    background: #ffffff;
}

.dark-mode .brand strong,
.dark-mode .nav a,
.dark-mode .theme-toggle,
.dark-mode .sidebar-toggle,
.dark-mode .panel-header h2,
.dark-mode .recent-order-card h3,
.dark-mode .recent-order-meta strong,
.dark-mode .supplier-rank-head strong,
.dark-mode .purchasing-snapshot strong,
.dark-mode .module-card h2,
.dark-mode .module-card h2 a,
.dark-mode .button-secondary,
.dark-mode input,
.dark-mode select,
.dark-mode textarea {
    color: var(--ink);
}

.dark-mode input,
.dark-mode select,
.dark-mode textarea {
    background: #111b2d;
    border-color: var(--line);
}

.dark-mode input[readonly],
.dark-mode textarea[readonly] {
    background: #1b2739;
}

.dark-mode .account-register-table input[readonly],
.dark-mode .account-register-table .po-sourced-amount-input,
.dark-mode .account-register-table .po-sourced-date-display {
    color: #dbeafe;
    background: #1f2a3d;
    border-color: #64748b;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.22);
}

.dark-mode #photo,
.dark-mode .pretty-file-input {
    color: #cbd5e1;
    background: #111b2d;
    border-color: #334155;
}

.dark-mode #photo:hover,
.dark-mode .pretty-file-input:hover {
    background: #172033;
    border-color: var(--primary);
}

.dark-mode .button-secondary,
.dark-mode .master-data-tabs a,
.dark-mode .module-card,
.dark-mode .purchasing-snapshot > div,
.dark-mode .bar-track {
    background: var(--secondary);
    border-color: var(--line);
}

.dark-mode .master-data-tabs a {
    color: #cbd5e1;
}

.dark-mode .button-secondary:hover,
.dark-mode .master-data-tabs a:hover,
.dark-mode .module-card:hover {
    color: var(--ink);
    background: var(--secondary-hover);
}

.dark-mode .master-data-tabs a.active {
    color: var(--primary);
    border-bottom-color: var(--surface);
    background: var(--surface);
}

.dark-mode .panel-header,
.dark-mode thead th,
.dark-mode tfoot th,
.dark-mode tfoot td,
.dark-mode .recent-panel-footer {
    background: var(--surface-alt);
}

.dark-mode thead th {
    color: #ffffff;
}

.dark-mode label,
.dark-mode .master-data-tabs-label {
    color: #dbeafe;
}

.dark-mode .muted,
.dark-mode .brand small,
.dark-mode .login-card p,
.dark-mode .page-title p {
    color: #cbd5e1;
}

.dark-mode tbody tr:hover td {
    background: #1d2a3d;
}

.dark-mode .home-stats .stat-card-accent {
    background: #172942;
    border-color: #365b82;
}

.dark-mode .module-card small,
.dark-mode .home-badge {
    color: #dbeafe;
    background: #263b57;
    border-color: #3b5778;
}

.dark-mode .bar-track {
    border-color: var(--line);
}

.dark-mode .item-photo-placeholder {
    color: var(--muted);
    background: #111b2d;
    border-color: #94a3b8;
}

.dark-mode .theme-toggle:hover,
.dark-mode .sidebar-toggle:hover,
.dark-mode .nav a:hover {
    color: var(--primary-hover);
    background: #22344d;
}

.dark-mode .nav a.active {
    color: var(--primary);
    background: #1f3652;
    box-shadow: inset 3px 0 0 var(--primary);
}

.dark-mode.sidebar-collapsed .nav a.active {
    box-shadow: inset 0 -3px 0 var(--primary);
}

.dark-mode .nav a[href="logout.php"] {
    color: #fca5a5;
}

.dark-mode .nav a[href="logout.php"]:hover {
    color: #ffffff;
    background: #a23a3a;
}

@media (min-width: 1500px) and (min-height: 900px) {
    .home-stats {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .home-stats .stat-card {
        min-height: 92px;
        padding: 13px 15px;
    }

    .home-stats .stat-card strong {
        margin-top: 6px;
        font-size: 25px;
    }

    .home-stats .stat-card small {
        margin-top: 6px;
    }

    .home-overview-left .module-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .home-overview-left .module-card {
        padding: 13px 14px;
    }

    .home-overview-left .module-card h2 {
        margin: 10px 0 5px;
        font-size: 17px;
    }

    .home-overview-left .module-card p {
        font-size: 12px;
        line-height: 1.4;
    }

    .home-overview-left .bar-chart {
        min-height: 0;
    }

    .home-overview-left .bar-track {
        height: min(118px, 14vh);
    }

    .home-overview-left .donut-chart {
        width: min(148px, 16vh);
        height: min(148px, 16vh);
    }
}

@media (min-width: 1101px) and (max-height: 1079px) {
    .home-overview-left .bar-chart {
        height: 126px;
    }

    .home-overview-left .bar-track {
        height: 68px;
    }

    .home-overview-left .donut-chart {
        width: 96px;
        height: 96px;
    }

    .home-overview-left .donut-chart::before {
        inset: 12px;
    }

    .home-overview-left .donut-chart strong {
        font-size: 20px;
    }

    .home-overview-left .status-chart-wrap {
        gap: 5px;
    }

    .home-overview-left .status-legend {
        gap: 7px;
        font-size: 11px;
    }
}

@media (max-width: 1100px) {
    :root {
        --sidebar-width: 196px;
        --app-gutter: 10px;
    }

    .app-body {
        height: auto;
        min-height: 100vh;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .topbar {
        gap: 14px;
        padding-inline: 10px;
    }

    .nav a {
        padding: 10px;
    }

    .nav .theme-toggle {
        padding: 10px;
    }

    .nav .sidebar-toggle {
        padding: 10px;
    }

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

    .home-overview-layout {
        grid-template-columns: 1fr;
        overflow: visible;
    }

    .home-shell {
        height: auto;
        overflow-y: auto;
        padding-bottom: 48px;
    }

    .account-summary-row {
        grid-template-columns: 1fr;
    }

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

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

    .delivery-page-layout {
        grid-template-columns: 1fr;
        overflow: visible;
    }

    .delivery-summary-body,
    .delivery-batch-grid {
        grid-template-columns: 1fr;
    }

    .shell {
        height: auto;
        flex: 0 0 auto;
        overflow: visible;
        padding-bottom: 48px;
    }

    .panel,
    .panel-body,
    .split,
    .account-layout,
    .cash-advance-layout,
    .po-form {
        overflow: visible;
    }

    .panel {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }

    .split,
    .account-layout,
    .cash-advance-layout,
    .po-create-layout,
    .po-party-column,
    .po-order-column {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .shell > .panel,
    .split > .panel,
    .split > section.panel,
    .po-form,
    .sign-layout > .panel,
    .account-entry-panel,
    .account-list-panel,
    .cash-advance-entry,
    .cash-advance-list {
        flex: 0 0 auto;
        min-height: auto;
    }

    .panel-body,
    .account-entry-panel .panel-body,
    .cash-advance-entry .panel-body {
        flex: 0 0 auto;
        overflow: visible;
    }

    .table-wrap,
    .panel > .table-wrap {
        width: 100%;
        max-width: 100%;
        flex: 0 0 auto;
        max-height: min(70vh, 720px);
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: auto;
    }

    .home-overview-left {
        grid-template-rows: none;
        overflow: visible;
    }

    .recent-panel-featured {
        position: static;
        height: auto;
    }

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

    .account-layout {
        grid-template-columns: 1fr;
    }

    .cash-advance-layout {
        grid-template-columns: 1fr;
        overflow: visible;
    }

    .cash-advance-table {
        width: 1120px;
        min-width: 1120px;
        table-layout: fixed;
    }

    .cash-advance-table th:nth-child(1),
    .cash-advance-table td:nth-child(1) {
        width: 46px;
    }

    .cash-advance-table th:nth-child(2),
    .cash-advance-table td:nth-child(2) {
        width: 130px;
    }

    .cash-advance-table th:nth-child(3),
    .cash-advance-table td:nth-child(3) {
        width: 210px;
        padding-left: 14px;
    }

    .cash-advance-table th:nth-child(4),
    .cash-advance-table td:nth-child(4) {
        width: 140px;
    }

    .cash-advance-table th:nth-child(5),
    .cash-advance-table td:nth-child(5) {
        width: 110px;
    }

    .cash-advance-table th:nth-child(6),
    .cash-advance-table td:nth-child(6),
    .cash-advance-table th:nth-child(7),
    .cash-advance-table td:nth-child(7) {
        width: 120px;
    }

    .cash-advance-table th:nth-child(8),
    .cash-advance-table td:nth-child(8) {
        width: 160px;
    }

    .cash-advance-table th:nth-child(9),
    .cash-advance-table td:nth-child(9) {
        width: 260px;
    }

    .cash-advance-table .cash-advance-action-buttons {
        width: 100%;
    }

    .cash-advance-table .qr-sign-button,
    .cash-advance-table .share-sign-button {
        min-width: 118px;
    }

    .account-register-table {
        width: 1360px;
        min-width: 1360px;
        table-layout: fixed;
    }

    .account-register-table input,
    .account-register-table td:nth-child(5) input {
        display: block;
        box-sizing: border-box;
        inline-size: 100%;
        width: 100%;
        max-inline-size: 100%;
        min-width: 0;
        max-width: 100%;
    }

    .account-register-table .account-date-column input[type="date"] {
        min-inline-size: 0;
        -webkit-appearance: none;
        appearance: none;
    }

    .account-register-table .account-date-column input[type="date"]::-webkit-date-and-time-value {
        min-width: 0;
        text-align: left;
    }

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

    .po-party-grid {
        grid-template-columns: 1fr;
    }

    .po-create-layout {
        grid-template-columns: 1fr;
    }

    .po-order-column .po-lines-table {
        min-width: 820px;
        table-layout: auto;
    }

    .po-form .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .po-form .panel-header .toolbar {
        width: 100%;
    }

    .po-header-grid .field:nth-child(2) {
        grid-column: auto;
    }
}

@media (max-width: 900px) {
    :root {
        --sidebar-width: 180px;
        --app-gutter: 8px;
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }

    .auth-page,
    .split,
    .sign-layout {
        grid-template-columns: 1fr;
    }

    .auth-hero {
        min-height: 360px;
        padding: 34px 24px;
    }

    .auth-panel {
        min-height: auto;
        border-left: 0;
    }

    .page-title,
    .home-hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .panel-header {
        flex-wrap: wrap;
    }

    .page-title .toolbar,
    .po-form .panel-header .toolbar {
        width: 100%;
    }

    .page-title .toolbar .button,
    .po-form .panel-header .toolbar .button {
        flex: 1 1 140px;
    }

    .master-data-tabs {
        flex-wrap: nowrap;
        padding-left: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .master-data-tabs a {
        flex: 0 0 auto;
    }

    .page-title-with-back {
        display: flex;
    }

    .shell {
        width: calc(100vw - var(--sidebar-width) - (var(--app-gutter) * 2));
        margin-left: calc(var(--sidebar-width) + var(--app-gutter));
        margin-right: var(--app-gutter);
    }

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

    .summary-grid strong {
        overflow: visible;
        overflow-wrap: anywhere;
        text-overflow: clip;
        white-space: normal;
    }

    .cash-advance-entry .field:has(input[type="date"]) {
        min-width: 0;
        overflow: hidden;
    }

    .cash-advance-entry input[type="date"] {
        display: block;
        box-sizing: border-box;
        inline-size: 100%;
        width: 100%;
        max-inline-size: 100%;
        max-width: 100%;
        min-inline-size: 0;
        min-width: 0;
        -webkit-appearance: none;
        appearance: none;
    }

    .cash-advance-entry input[type="date"]::-webkit-date-and-time-value {
        min-width: 0;
        text-align: left;
    }
}

@media (max-width: 620px) {
    :root {
        --sidebar-width: 156px;
        --app-gutter: 6px;
    }

    .topbar {
        padding-inline: 7px;
    }

    .brand-mark {
        width: 34px;
        height: 34px;
        flex-basis: 34px;
    }

    .brand strong {
        font-size: 13px;
    }

    .brand small,
    .nav a,
    .theme-toggle,
    .sidebar-toggle {
        font-size: 12px;
    }

    .auth-hero h1 {
        font-size: 34px;
    }

    .auth-panel,
    .login-card {
        padding: 22px;
    }

    .module-grid,
    .stats-grid,
    .dashboard-grid,
    .dashboard-insights-grid,
    .account-entry-grid,
    .po-header-grid,
    .po-party-grid {
        grid-template-columns: 1fr;
    }

    .home-overview-left .module-grid {
        grid-template-columns: 1fr;
    }

    .page-title h1 {
        font-size: 24px;
    }
}

@media print {
    @page {
        size: A4;
        margin: 0;
    }

    body.print-body {
        background: #fff;
    }

    .print-toolbar {
        display: none;
    }

    body.app-body {
        height: auto;
        overflow: visible;
        background: #fff;
    }

    .app-body .topbar,
    .app-body .page-title .toolbar,
    .app-body .filter-bar {
        display: none !important;
    }

    .app-body .shell {
        width: 100%;
        height: auto;
        margin: 0;
        padding: 12mm;
        overflow: visible;
    }

    .app-body .panel,
    .app-body .panel-body,
    .app-body .table-wrap {
        overflow: visible;
        box-shadow: none;
    }

    .po-document {
        width: 210mm;
        min-height: 297mm;
        margin: 0;
        box-shadow: none;
    }
}
