/* style.css - Light-only design system for SPMS */

:root {
    --bg-main: #f4f1ea;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-solid: #ffffff;
    --bg-sidebar: #ffffff;
    --border-color: rgba(51, 65, 85, 0.12);
    --primary: #d4a84f;
    --primary-hover: #e6bd67;
    --primary-glow: rgba(212, 168, 79, 0.16);
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);
    
    --text-main: #182234;
    --text-muted: #617086;
    --sidebar-width: 272px;
    --header-height: 82px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 14px 34px rgba(31, 41, 55, 0.07);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
}

body.light-theme {
    --bg-main: #f4f1ea;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-solid: #ffffff;
    --bg-sidebar: #ffffff;
    --border-color: rgba(51, 65, 85, 0.12);
    --text-main: #182234;
    --text-muted: #617086;
    --shadow: 0 14px 34px rgba(31, 41, 55, 0.07);
}

body.light-theme .sidebar {
    background-color: #ffffff !important;
    border-right: 1px solid rgba(15, 23, 42, 0.08) !important;
}

body.light-theme .sidebar-brand {
    border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
}

body.light-theme .sidebar-brand .brand-logo span {
    color: #0f172a !important;
}

body.light-theme .sidebar-user {
    border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
}

body.light-theme .sidebar-user .user-name {
    color: #0f172a !important;
}

body.light-theme .sidebar-user .user-role {
    color: var(--primary) !important;
}

body.light-theme .sidebar-menu a {
    color: #475569 !important;
}

body.light-theme .sidebar-menu a:hover {
    color: #0f172a !important;
    background-color: #f1f5f9 !important;
}

body.light-theme .sidebar-menu li.active a {
    color: var(--primary) !important;
    background: rgba(99, 102, 241, 0.08) !important;
    box-shadow: none !important;
}

body.light-theme .sidebar-footer {
    border-top: 1px solid rgba(15, 23, 42, 0.08) !important;
}

body.light-theme header.top-header {
    background-color: rgba(255, 255, 255, 0.9) !important;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08) !important;
}

body.light-theme .page-title {
    color: #0f172a !important;
}

body.light-theme .system-time {
    background: #f8fafc !important;
    color: #475569 !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
}

body.light-theme .panel {
    background: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02) !important;
}

body.light-theme .btn-secondary {
    background: #e2e8f0 !important;
    color: #334155 !important;
    border: 1px solid #cbd5e1 !important;
}

body.light-theme .btn-secondary:hover {
    background: #cbd5e1 !important;
}

body.light-theme .kpi-card {
    background: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02) !important;
}

body.light-theme .card-kpi-title {
    color: #64748b !important;
}

body.light-theme input, 
body.light-theme select, 
body.light-theme textarea {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
}

body.light-theme input:focus, 
body.light-theme select:focus, 
body.light-theme textarea:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 2px var(--primary-glow) !important;
}

body.light-theme .offcut-alert {
    background: rgba(99, 102, 241, 0.05) !important;
    border-color: rgba(99, 102, 241, 0.15) !important;
    color: #4f46e5 !important;
}

body.light-theme .offcut-alert h4 {
    color: #312e81 !important;
}

body.light-theme .costing-item span {
    color: #475569 !important;
}

body.light-theme .data-table th {
    background: #f8fafc !important;
    color: #334155 !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

body.light-theme .data-table td {
    color: #334155 !important;
    border-bottom: 1px solid #f1f5f9 !important;
}

body.light-theme .data-table tr:hover {
    background: rgba(0, 0, 0, 0.01) !important;
}

body.light-theme label {
    color: #334155 !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Noto Sans Myanmar', 'Myanmar Text', 'Pyidaungsu', system-ui, sans-serif;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

body.light-theme ::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.02);
}
body.light-theme ::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.2);
}
body.light-theme ::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 23, 42, 0.3);
}

/* Sidebar */
aside.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
}

.brand-logo {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #a5b4fc 0%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-user {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.user-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
}

.user-role {
    font-size: 12px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
    margin-top: 2px;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 12px;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-menu a:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.03);
}

.sidebar-menu li.active a {
    color: var(--text-main);
    background: linear-gradient(135deg, var(--primary) 0%, rgba(99, 102, 241, 0.7) 100%);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--danger);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.logout-btn:hover {
    opacity: 0.8;
}

/* Main Layout */
main.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: calc(100vw - var(--sidebar-width));
    transition: var(--transition);
}

header.top-header {
    height: var(--header-height);
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    position: sticky;
    top: 0;
    z-index: 99;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.system-time {
    font-size: 13px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

/* Content Container */
.content-wrapper {
    padding: 40px;
    flex-grow: 1;
    min-width: 0;
    width: 100%;
}

/* Cards & Grid Layouts */
.grid-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--bg-card);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    border-color: rgba(99, 102, 241, 0.25);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-icon {
    font-size: 20px;
    padding: 8px;
    border-radius: 8px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    margin-top: 12px;
    color: var(--text-main);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.currency-label {
    font-size: 12px;
    font-weight: 500;
    color: inherit;
    opacity: 0.8;
}

/* Custom premium KPI Card styles (Default Night Mode / Dark UI) */
.kpi-card.kpi-running {
    background: rgba(99, 102, 241, 0.04) !important;
    border: 1px solid rgba(99, 102, 241, 0.22) !important;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.08) !important;
}
.kpi-card.kpi-running .kpi-value {
    color: #818cf8 !important;
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}
.kpi-card.kpi-running .kpi-header span {
    color: #a5b4fc !important;
}
.kpi-card.kpi-running .kpi-icon {
    background: rgba(99, 102, 241, 0.15) !important;
    color: #818cf8 !important;
}

.kpi-card.kpi-production {
    background: rgba(16, 185, 129, 0.04) !important;
    border: 1px solid rgba(16, 185, 129, 0.22) !important;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.08) !important;
}
.kpi-card.kpi-production .kpi-value {
    color: #34d399 !important;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}
.kpi-card.kpi-production .kpi-header span {
    color: #6ee7b7 !important;
}
.kpi-card.kpi-production .kpi-icon {
    background: rgba(16, 185, 129, 0.15) !important;
    color: #34d399 !important;
}

.kpi-card.kpi-scheduled {
    background: rgba(245, 158, 11, 0.04) !important;
    border: 1px solid rgba(245, 158, 11, 0.22) !important;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.08) !important;
}
.kpi-card.kpi-scheduled .kpi-value {
    color: #fbbf24 !important;
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
}
.kpi-card.kpi-scheduled .kpi-header span {
    color: #fcd34d !important;
}
.kpi-card.kpi-scheduled .kpi-icon {
    background: rgba(245, 158, 11, 0.15) !important;
    color: #fbbf24 !important;
}

.kpi-card.kpi-balance {
    background: rgba(239, 68, 68, 0.04) !important;
    border: 1px solid rgba(239, 68, 68, 0.22) !important;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.08) !important;
}
.kpi-card.kpi-balance .kpi-value {
    color: #f87171 !important;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}
.kpi-card.kpi-balance .kpi-header span {
    color: #fca5a5 !important;
}
.kpi-card.kpi-balance .kpi-icon {
    background: rgba(239, 68, 68, 0.15) !important;
    color: #f87171 !important;
}

.kpi-card.kpi-cash {
    background: rgba(6, 182, 212, 0.04) !important;
    border: 1px solid rgba(6, 182, 212, 0.22) !important;
    box-shadow: 0 4px 20px rgba(6, 182, 212, 0.08) !important;
}
.kpi-card.kpi-cash .kpi-value {
    color: #22d3ee !important;
    text-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}
.kpi-card.kpi-cash .kpi-header span {
    color: #67e8f9 !important;
}
.kpi-card.kpi-cash .kpi-icon {
    background: rgba(6, 182, 212, 0.15) !important;
    color: #22d3ee !important;
}

/* Light Theme Overrides (Solid Vibrant Gradients for Day Mode) */
body.light-theme .kpi-card.kpi-running {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.15) !important;
}
body.light-theme .kpi-card.kpi-running .kpi-header span, 
body.light-theme .kpi-card.kpi-running .kpi-value {
    color: #ffffff !important;
    text-shadow: none !important;
}
body.light-theme .kpi-card.kpi-running .kpi-icon {
    background: rgba(255, 255, 255, 0.18) !important;
    color: #ffffff !important;
}

body.light-theme .kpi-card.kpi-production {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.15) !important;
}
body.light-theme .kpi-card.kpi-production .kpi-header span, 
body.light-theme .kpi-card.kpi-production .kpi-value {
    color: #ffffff !important;
    text-shadow: none !important;
}
body.light-theme .kpi-card.kpi-production .kpi-icon {
    background: rgba(255, 255, 255, 0.18) !important;
    color: #ffffff !important;
}

body.light-theme .kpi-card.kpi-scheduled {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.15) !important;
}
body.light-theme .kpi-card.kpi-scheduled .kpi-header span, 
body.light-theme .kpi-card.kpi-scheduled .kpi-value {
    color: #ffffff !important;
    text-shadow: none !important;
}
body.light-theme .kpi-card.kpi-scheduled .kpi-icon {
    background: rgba(255, 255, 255, 0.18) !important;
    color: #ffffff !important;
}

body.light-theme .kpi-card.kpi-balance {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.15) !important;
}
body.light-theme .kpi-card.kpi-balance .kpi-header span, 
body.light-theme .kpi-card.kpi-balance .kpi-value {
    color: #ffffff !important;
    text-shadow: none !important;
}
body.light-theme .kpi-card.kpi-balance .kpi-icon {
    background: rgba(255, 255, 255, 0.18) !important;
    color: #ffffff !important;
}

body.light-theme .kpi-card.kpi-cash {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%) !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.15) !important;
}
body.light-theme .kpi-card.kpi-cash .kpi-header span, 
body.light-theme .kpi-card.kpi-cash .kpi-value {
    color: #ffffff !important;
    text-shadow: none !important;
}
body.light-theme .kpi-card.kpi-cash .kpi-icon {
    background: rgba(255, 255, 255, 0.18) !important;
    color: #ffffff !important;
}

body.light-theme .kpi-card.kpi-running:hover {
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4) !important;
}
body.light-theme .kpi-card.kpi-production:hover {
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4) !important;
}
body.light-theme .kpi-card.kpi-scheduled:hover {
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.4) !important;
}
body.light-theme .kpi-card.kpi-balance:hover {
    box-shadow: 0 10px 25px rgba(239, 68, 68, 0.4) !important;
}
body.light-theme .kpi-card.kpi-cash:hover {
    box-shadow: 0 10px 25px rgba(6, 182, 212, 0.4) !important;
}

.kpi-trend {
    font-size: 12px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-trend.positive { color: var(--success); }
.kpi-trend.negative { color: var(--danger); }

/* Standard Containers */
.panel {
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.panel-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Tables styling */
.table-responsive {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

table.data-table {
    width: 100%;
    min-width: max-content;
    border-collapse: collapse;
    text-align: left;
}

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

table.data-table th {
    padding: 14px 16px;
    background-color: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

table.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 14px;
    color: var(--text-main);
    vertical-align: middle;
}

table.data-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.01);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-secondary { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    opacity: 0.9;
}

/* Disabled actions must look disabled as well as behave disabled. */
.btn:disabled,
.btn[disabled],
.btn.is-disabled {
    opacity: 0.48 !important;
    cursor: not-allowed !important;
    filter: grayscale(0.35);
    box-shadow: none !important;
    transform: none !important;
    pointer-events: none;
}

.btn-success:disabled,
.btn-success[disabled],
.btn-success.is-disabled {
    background-color: #94a3b8;
    color: #f8fafc;
}

.btn-warning {
    background-color: var(--warning);
    color: white;
}

.btn-warning:hover {
    opacity: 0.9;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

/* Forms styling */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    background-color: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

select.form-control option {
    background-color: var(--bg-card-solid);
    color: var(--text-main);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* Login Page styling */
.login-container {
    width: 100%;
    max-width: 420px;
    margin: auto;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 6px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-container {
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 600px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transform: scale(0.95);
    transition: var(--transition);
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

.modal-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Alert Boxes / Banners */
.alert {
    padding: 14px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid transparent;
}

.alert-success { background: var(--success-bg); border-color: rgba(16, 185, 129, 0.2); color: var(--success); }
.alert-warning { background: var(--warning-bg); border-color: rgba(245, 158, 11, 0.2); color: var(--warning); }
.alert-danger { background: var(--danger-bg); border-color: rgba(239, 68, 68, 0.2); color: var(--danger); }
.alert-info { background: var(--info-bg); border-color: rgba(59, 130, 246, 0.2); color: var(--info); }

/* Costing & fabrication helper panels */
.offcut-alert {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(59, 130, 246, 0.15) 100%);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.offcut-alert-icon {
    font-size: 18px;
    color: var(--primary);
    margin-top: 2px;
}

.offcut-alert-text h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 4px;
}

.offcut-alert-text p {
    font-size: 13px;
    color: var(--text-muted);
}

.costing-summary-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: rgba(255, 255, 255, 0.02);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

body.light-theme .costing-summary-grid {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
}

.costing-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 14px;
}

.costing-item:last-child {
    border-bottom: none;
}

.costing-item.highlight {
    border-bottom: none;
    padding-top: 15px;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Production Task Checklist */
.task-checklist {
    list-style: none;
}

.task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
    transition: var(--transition);
}

.task-item.completed {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.02);
}

.task-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
}

.task-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* Signature Drawing Canvas */
.signature-pad-wrapper {
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

.signature-canvas {
    display: block;
    width: 100%;
    height: 150px;
    background: #0f172a;
    cursor: crosshair;
}

/* Filter Controls bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: stretch;
    margin-bottom: 24px;
}

/* Keep search fields, status selectors and action buttons uniformly sized. */
.filter-bar > div {
    display: flex;
}

.filter-bar .form-control,
.filter-bar .btn {
    height: 42px;
    min-height: 42px;
}

.filter-bar select.form-control {
    min-width: 196px;
    padding-top: 0;
    padding-bottom: 0;
}

/* Match the archive customer filter to the adjacent keyword field. */
.page-archive .archive-filter-bar .form-control,
.page-archive .archive-filter-bar .btn {
    height: 42px;
    min-height: 42px;
}

.page-archive .archive-filter-bar select.form-control {
    padding-top: 0;
    padding-bottom: 0;
}

/* Two Columns Layout */
.layout-two-cols {
    display: flex;
    gap: 30px;
    flex-direction: row;
}

.col-main {
    flex: 2;
    min-width: 0;
}

.col-side {
    flex: 1;
    min-width: 0;
}

/* Dashboard Chart Row */
.chart-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 24px;
    margin-bottom: 30px;
}

@media (max-width: 1024px) {
    .layout-two-cols {
        flex-direction: column;
    }
    .col-main, .col-side {
        flex: none;
        width: 100%;
    }
    .chart-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Print Styles */
@media print {
    body {
        background: white !important;
        color: black !important;
    }
    aside.sidebar, header.top-header, .btn, .filter-bar, .no-print {
        display: none !important;
    }
    main.main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    .content-wrapper {
        padding: 0 !important;
    }
    .panel {
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        padding: 0 !important;
    }
    .print-only {
        display: block !important;
    }
    table.data-table th {
        background: #f1f5f9 !important;
        color: black !important;
        border-bottom: 2px solid black !important;
    }
    table.data-table td {
        border-bottom: 1px solid #e2e8f0 !important;
        color: black !important;
    }
}

.print-only {
    display: none;
}

/* Responsive sidebar */
@media (max-width: 768px) {
    aside.sidebar {
        transform: translateX(-100%);
    }
    aside.sidebar.active {
        transform: translateX(0);
    }
    main.main-content {
        margin-left: 0;
        max-width: 100vw !important;
    }
    .content-wrapper {
        padding: 20px;
    }
    header.top-header {
        padding: 0 20px;
    }
    .sidebar-toggle {
        display: block !important;
    }
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 24px;
    cursor: pointer;
}

/* Two-Level Accordion Sidebar Menu Styles */
.menu-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    user-select: none;
    margin-bottom: 2px;
}

.menu-group-header:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.03);
}

body.light-theme .menu-group-header:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

.menu-group-header .group-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-group-header .arrow-icon {
    font-size: 11px;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

.menu-group.expanded .menu-group-header {
    color: var(--text-main);
}

body.light-theme .menu-group.expanded .menu-group-header {
    color: #0f172a !important;
}

.menu-group.expanded .arrow-icon {
    transform: rotate(90deg);
}

.submenu {
    list-style: none;
    padding-left: 12px;
    margin-top: 2px;
    margin-bottom: 8px;
}

.submenu li {
    margin-bottom: 2px;
}

.submenu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px 9px 24px;
    color: var(--text-muted) !important;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    transition: var(--transition);
}

.submenu a:hover {
    color: var(--text-main) !important;
    background-color: rgba(255, 255, 255, 0.02);
}

body.light-theme .submenu a {
    color: #475569 !important;
}

body.light-theme .submenu a:hover {
    color: #0f172a !important;
    background-color: #f1f5f9 !important;
}

.submenu li.submenu-active a {
    color: var(--primary) !important;
    background: rgba(99, 102, 241, 0.06) !important;
    font-weight: 600;
}

body.light-theme .submenu li.submenu-active a {
    color: var(--primary) !important;
    background: rgba(99, 102, 241, 0.08) !important;
}

/* Badge statuses for Invoices */
.badge-unpaid {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
body.light-theme .badge-unpaid {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-partially-paid {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}
body.light-theme .badge-partially-paid {
    background: #fef3c7;
    color: #b45309;
}

.badge-paid {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}
body.light-theme .badge-paid {
    background: #d1fae5;
    color: #047857;
}

/* Custom Table Pagination Styles */
.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-top: 15px;
    padding: 10px 2px;
    overflow: hidden;
    box-sizing: border-box;
}
.table-pagination span {
    font-size: 13px;
    color: var(--text-muted);
}
.table-pagination .pagination-buttons {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 100%;
    min-width: 0;
}
.table-pagination button,
.table-pagination .pagination-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-decoration: none;
}
.table-pagination button:hover:not(:disabled),
.table-pagination .pagination-button:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary);
}
.table-pagination button.active,
.table-pagination .pagination-button.active {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #ffffff !important;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}
.table-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 576px) {
    .table-pagination {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
        text-align: center;
    }
    .table-pagination .pagination-buttons {
        justify-content: center;
    }
}

/* Controlled edit approval queue */
.approval-page__intro {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}
.approval-page__intro h2 {
    margin: 3px 0 4px;
}
.approval-page__intro p {
    max-width: 720px;
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
}
.approval-page__stats {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
}
.approval-page__stats span {
    min-width: 92px;
    padding: 10px 13px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
}
.approval-page__stats strong {
    display: block;
    color: var(--text-main);
    font-size: 18px;
    line-height: 1.2;
}
.approval-panel-title {
    margin-bottom: 18px;
}
.approval-page .data-table td {
    vertical-align: top;
}
.approval-page .data-table td > strong,
.approval-page .data-table td > small {
    display: block;
}
.approval-page .data-table td > small {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 10px;
}
.approval-preview {
    display: grid;
    gap: 3px;
    min-width: 180px;
}
.approval-preview span {
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.4;
}
.approval-preview b {
    color: var(--text-main);
}
.approval-status {
    display: inline-flex;
    margin-bottom: 5px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #eef2f6;
    color: #526176;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.approval-status--pending,
.approval-status--approved,
.approval-status--applying {
    background: #fff4da;
    color: #9b6500;
}
.approval-status--applied {
    background: #e4f8f1;
    color: #087a59;
}
.approval-status--rejected,
.approval-status--error {
    background: #feecec;
    color: #b42318;
}
.approval-review-form {
    display: grid;
    min-width: 225px;
    gap: 8px;
}
.approval-review-form .form-control {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 11px;
}
.approval-review-form > div {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}
.approval-locked {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 11px;
}
.approval-empty {
    padding: 34px !important;
    color: var(--text-muted);
    text-align: center;
}
@media (max-width: 760px) {
    .approval-page__intro {
        align-items: stretch;
        flex-direction: column;
    }
    .approval-page__stats {
        width: 100%;
    }
    .approval-page__stats span {
        flex: 1;
    }
}

/* -------------------------------------------------------------------------
   NAN TAW 2026 interface layer
   A restrained gold/slate system shared by every module. These overrides also
   absorb legacy inline layouts into one consistent spacing and typography
   rhythm while old workflow screens are migrated gradually.
   ------------------------------------------------------------------------- */

html {
    color-scheme: light;
}

body.light-theme {
    color-scheme: light;
}

body {
    background:
        radial-gradient(circle at 82% -10%, rgba(212, 168, 79, 0.09), transparent 34rem),
        var(--bg-main);
    font-size: 14px;
    line-height: 1.6;
}

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

aside.sidebar {
    background:
        linear-gradient(180deg, rgba(212, 168, 79, 0.05), transparent 210px),
        var(--bg-sidebar);
    border-right-color: var(--border-color);
}

.sidebar-brand {
    height: auto;
    min-height: 104px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.brand-logo {
    width: 100%;
    min-width: 0;
    gap: 12px;
    background: none;
    -webkit-text-fill-color: initial;
    -webkit-background-clip: initial;
}

.brand-logo__image,
.brand-logo__fallback {
    width: 46px;
    height: 46px;
    flex: 0 0 46px;
    border-radius: 13px;
}

.brand-logo__image {
    object-fit: contain;
    background: #fff;
    padding: 3px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
}

.brand-logo__fallback {
    display: grid;
    place-items: center;
    color: #15100a;
    background: linear-gradient(145deg, #f3d58e, #c59439);
    font-size: 21px;
}

.brand-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.brand-copy strong {
    overflow: hidden;
    color: var(--text-main);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.35;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.brand-copy small {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.sidebar-menu {
    padding: 18px 12px;
}

.sidebar-menu a,
.menu-group-header {
    min-height: 44px;
    border-radius: 11px;
    font-size: 13px;
}

.menu-group-header {
    width: 100%;
    border: 0;
    background: transparent;
    font-family: inherit;
    text-align: left;
}

.sidebar-menu li.active > a,
.submenu li.submenu-active a {
    color: #f7dfaa !important;
    background: linear-gradient(90deg, rgba(212, 168, 79, 0.17), rgba(212, 168, 79, 0.04)) !important;
    box-shadow: inset 3px 0 0 var(--primary) !important;
}

.sidebar-menu li.active > a i,
.submenu li.submenu-active a i {
    color: var(--primary);
}

.sidebar-footer {
    padding: 14px 18px 20px;
}

.logout-btn {
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 10px;
}

.logout-btn:hover {
    background: var(--danger-bg);
    opacity: 1;
}

header.top-header {
    height: var(--header-height);
    padding: 0 clamp(20px, 3vw, 42px);
    background: rgba(8, 16, 29, 0.78);
    border-color: var(--border-color);
}

.header-leading,
.header-right,
.header-user,
.header-title-block,
.header-user-copy {
    display: flex;
}

.header-leading,
.header-user {
    align-items: center;
}

.header-leading {
    min-width: 0;
    gap: 14px;
}

.header-title-block,
.header-user-copy {
    flex-direction: column;
}

.header-eyebrow {
    color: var(--primary);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.11em;
    line-height: 1.3;
    text-transform: uppercase;
}

.page-title {
    margin-top: 2px;
    overflow: hidden;
    font-size: clamp(17px, 1.7vw, 21px);
    font-weight: 700;
    letter-spacing: -0.018em;
    line-height: 1.45;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-right {
    gap: 14px;
}

.system-time {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 11px;
    border-radius: 9px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.header-user {
    gap: 10px;
}

.header-avatar {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid rgba(212, 168, 79, 0.35);
    border-radius: 11px;
    color: #1b1407;
    background: linear-gradient(145deg, #f0d496, #c99a43);
    font-size: 14px;
    font-weight: 800;
}

.header-user-copy {
    align-items: flex-start;
    line-height: 1.35;
}

.header-user-copy strong {
    max-width: 160px;
    overflow: hidden;
    color: var(--text-main);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-user-copy small {
    color: var(--primary);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.content-wrapper {
    padding: clamp(20px, 3vw, 42px);
    max-width: 1720px;
    margin: 0 auto;
}

.panel,
.kpi-card {
    border-color: var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.panel {
    margin-bottom: 24px;
}

.panel-title {
    font-weight: 700;
    letter-spacing: -0.01em;
}

.grid-kpis {
    gap: 18px;
    margin-bottom: 24px;
}

.kpi-card {
    min-height: 132px;
    padding: 20px;
}

.kpi-header {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.kpi-value {
    margin-top: 18px;
    font-size: clamp(23px, 2.4vw, 31px);
    font-variant-numeric: tabular-nums;
}

.btn {
    min-height: 40px;
    padding: 9px 15px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.005em;
}

.btn-sm {
    min-height: 34px;
    padding: 7px 11px;
    border-radius: 9px;
    font-size: 11px;
}

.btn-primary {
    border-color: #c99a43;
    color: #171108;
    background: linear-gradient(145deg, #ebcc87, #c99a43);
    box-shadow: 0 8px 20px rgba(201, 154, 67, 0.16);
}

.btn-primary:hover {
    color: #120d05;
    background: linear-gradient(145deg, #f5d99a, #d5aa5a);
    transform: translateY(-1px);
}

.form-control,
input,
select,
textarea {
    border-radius: 10px;
}

.form-control {
    min-height: 42px;
}

label {
    margin-bottom: 7px;
    font-size: 12px;
    font-weight: 650;
}

.table-responsive {
    border: 1px solid var(--border-color);
    border-radius: 13px;
}

.data-table {
    margin: 0;
}

.data-table th {
    padding: 13px 15px;
    font-size: 9px;
    font-weight: 750;
    letter-spacing: 0.08em;
}

.data-table td {
    padding: 14px 15px;
    font-size: 12px;
}

.badge {
    border-radius: 999px;
    font-size: 9px;
    font-weight: 750;
    letter-spacing: 0.04em;
}

.alert {
    position: relative;
    padding: 14px 48px 14px 16px;
    border-radius: 12px;
    line-height: 1.55;
}

.alert-close {
    position: absolute;
    top: 8px;
    right: 8px;
    display: grid;
    width: 30px;
    height: 30px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 8px;
    color: currentColor;
    background: transparent;
    cursor: pointer;
    opacity: 0.66;
}

.alert-close:hover {
    background: rgba(127, 127, 127, 0.12);
    opacity: 1;
}

/* Persistent contextual action centre */
.action-center {
    margin-bottom: 24px;
    overflow: hidden;
    border: 1px solid rgba(212, 168, 79, 0.28);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, rgba(212, 168, 79, 0.08), transparent 44%),
        var(--bg-card-solid);
    box-shadow: var(--shadow);
}

.action-center__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
}

.action-center__heading {
    display: flex;
    align-items: flex-start;
    gap: 13px;
}

.action-center__heading h2 {
    color: var(--text-main);
    font-size: 14px;
    font-weight: 750;
    line-height: 1.5;
}

.action-center__heading p {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 11px;
}

.action-center__pulse {
    position: relative;
    width: 10px;
    height: 10px;
    margin-top: 6px;
    flex: 0 0 10px;
    border-radius: 50%;
    background: var(--warning);
    box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.12);
}

.action-center__count {
    display: grid;
    min-width: 30px;
    height: 30px;
    padding: 0 9px;
    place-items: center;
    border-radius: 999px;
    color: #1c1406;
    background: var(--primary);
    font-size: 11px;
    font-weight: 800;
}

.action-center__list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
    gap: 1px;
    background: var(--border-color);
}

.action-center__list > .action-item:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.action-item {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 15px 18px;
    background: var(--bg-card-solid);
}

.action-item__icon {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 11px;
    color: var(--info);
    background: var(--info-bg);
}

.action-item--warning .action-item__icon {
    color: var(--warning);
    background: var(--warning-bg);
}

.action-item--danger .action-item__icon {
    color: var(--danger);
    background: var(--danger-bg);
}

.action-item--violet .action-item__icon {
    color: #a78bfa;
    background: rgba(139, 92, 246, 0.12);
}

.action-item__body {
    min-width: 0;
}

.action-item__body h3 {
    overflow: hidden;
    color: var(--text-main);
    font-size: 12px;
    font-weight: 720;
    line-height: 1.5;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.action-item__body p {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.55;
}

.action-item__button {
    white-space: nowrap;
}

body.light-theme .sidebar {
    background:
        linear-gradient(180deg, rgba(212, 168, 79, 0.08), transparent 220px),
        #fff !important;
}

body.light-theme header.top-header {
    background: rgba(255, 255, 255, 0.86) !important;
}

body.light-theme .panel,
body.light-theme .kpi-card,
body.light-theme .action-center,
body.light-theme .action-item {
    background-color: #fff !important;
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow) !important;
}

body.light-theme .kpi-card.kpi-running,
body.light-theme .kpi-card.kpi-production,
body.light-theme .kpi-card.kpi-scheduled,
body.light-theme .kpi-card.kpi-balance,
body.light-theme .kpi-card.kpi-cash {
    border: 1px solid var(--border-color) !important;
    background: #fff !important;
    box-shadow: var(--shadow) !important;
}

body.light-theme .kpi-card.kpi-running .kpi-header span,
body.light-theme .kpi-card.kpi-production .kpi-header span,
body.light-theme .kpi-card.kpi-scheduled .kpi-header span,
body.light-theme .kpi-card.kpi-balance .kpi-header span,
body.light-theme .kpi-card.kpi-cash .kpi-header span {
    color: var(--text-muted) !important;
}

body.light-theme .kpi-card.kpi-running .kpi-value { color: #4f46e5 !important; }
body.light-theme .kpi-card.kpi-production .kpi-value { color: #059669 !important; }
body.light-theme .kpi-card.kpi-scheduled .kpi-value { color: #b45309 !important; }
body.light-theme .kpi-card.kpi-balance .kpi-value { color: #dc2626 !important; }
body.light-theme .kpi-card.kpi-cash .kpi-value { color: #0891b2 !important; }

@media (max-width: 900px) {
    .header-user-copy,
    .system-time {
        display: none;
    }

    .action-item {
        grid-template-columns: 38px minmax(0, 1fr);
    }

    .action-item__button {
        grid-column: 2;
        justify-self: start;
    }
}

@media (max-width: 576px) {
    :root {
        --header-height: 70px;
    }

    .header-eyebrow {
        display: none;
    }

    .content-wrapper {
        padding: 16px;
    }

    .action-center__header {
        padding: 15px 16px;
    }

    .action-center__heading p {
        display: none;
    }

    .action-item {
        padding: 14px;
    }
}

/* Dashboard: compact, information-dense colour cards instead of blank boxes. */
.page-dashboard .grid-kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.page-dashboard .kpi-card {
    position: relative;
    min-height: 148px;
    overflow: hidden;
    isolation: isolate;
    border: 0 !important;
    color: #fff;
    box-shadow: 0 15px 32px rgba(15, 23, 42, 0.15) !important;
}

.page-dashboard .kpi-card::before,
.page-dashboard .kpi-card::after {
    position: absolute;
    z-index: -1;
    border-radius: 999px;
    content: "";
    pointer-events: none;
}

.page-dashboard .kpi-card::before {
    top: -42px;
    right: -28px;
    width: 112px;
    height: 112px;
    border: 20px solid rgba(255, 255, 255, 0.10);
}

.page-dashboard .kpi-card::after {
    right: 28px;
    bottom: -48px;
    width: 88px;
    height: 88px;
    background: rgba(255, 255, 255, 0.08);
}

body.page-dashboard .kpi-card.kpi-running {
    background: linear-gradient(135deg, #6657e8 0%, #4034bd 100%) !important;
}

body.page-dashboard .kpi-card.kpi-production {
    background: linear-gradient(135deg, #13b981 0%, #087e68 100%) !important;
}

body.page-dashboard .kpi-card.kpi-scheduled {
    background: linear-gradient(135deg, #f59e0b 0%, #d45708 100%) !important;
}

body.page-dashboard .kpi-card.kpi-balance {
    background: linear-gradient(135deg, #f04465 0%, #bd1e43 100%) !important;
}

body.page-dashboard .kpi-card.kpi-cash {
    background: linear-gradient(135deg, #14a8c9 0%, #1266ae 100%) !important;
}

body.page-dashboard .grid-kpis .kpi-card .kpi-header,
body.page-dashboard .grid-kpis .kpi-card .kpi-header span,
body.page-dashboard .grid-kpis .kpi-card .kpi-value,
body.page-dashboard .grid-kpis .kpi-card .currency-label {
    color: #fff !important;
    text-shadow: none !important;
}

body.page-dashboard .grid-kpis .kpi-card .kpi-header {
    align-items: flex-start;
    max-width: calc(100% - 36px);
    line-height: 1.45;
    opacity: 0.9;
}

body.page-dashboard .grid-kpis .kpi-card .kpi-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    display: grid;
    width: 34px;
    height: 34px;
    padding: 0;
    place-items: center;
    color: #fff !important;
    background: rgba(255, 255, 255, 0.17) !important;
    border: 1px solid rgba(255, 255, 255, 0.20);
    border-radius: 10px;
    font-size: 14px;
}

body.page-dashboard .grid-kpis .kpi-card .kpi-value {
    margin-top: 28px;
    font-size: clamp(23px, 2.2vw, 31px);
}

.page-dashboard .kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 42px rgba(15, 23, 42, 0.22) !important;
}

body.page-dashboard .dashboard-action-panel {
    padding: 22px !important;
    border: 1px solid rgba(99, 102, 241, 0.14) !important;
    background:
        radial-gradient(circle at 100% 0%, rgba(99, 102, 241, 0.12), transparent 330px),
        linear-gradient(145deg, #f8f7ff 0%, #f5f9ff 100%) !important;
}

body.page-dashboard .dashboard-action-panel > .panel-title {
    margin-bottom: 16px !important;
    color: #27344b !important;
}

.page-dashboard .dashboard-action-card {
    min-height: 162px !important;
    padding: 16px !important;
    border-top-width: 0 !important;
    box-shadow: 0 10px 24px rgba(30, 41, 59, 0.08) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.page-dashboard .dashboard-action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(30, 41, 59, 0.12) !important;
}

.page-dashboard .dashboard-action-card--billing {
    border-color: #d8d3ff !important;
    background: linear-gradient(145deg, #ffffff 0%, #f0eeff 100%) !important;
}

.page-dashboard .dashboard-action-card--payment {
    border-color: #fde3a5 !important;
    background: linear-gradient(145deg, #ffffff 0%, #fff6dc 100%) !important;
}

.page-dashboard .dashboard-action-card--final {
    border-color: #e5d2ff !important;
    background: linear-gradient(145deg, #ffffff 0%, #f6edff 100%) !important;
}

.page-dashboard .dashboard-action-card--due {
    border-color: #ffcfd5 !important;
    background: linear-gradient(145deg, #ffffff 0%, #fff0f2 100%) !important;
}

.page-dashboard.light-theme .chart-row .panel,
.page-dashboard.light-theme .layout-two-cols .panel {
    border: 1px solid rgba(99, 102, 241, 0.10) !important;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(247, 248, 255, 0.96)) !important;
}

@media (max-width: 1180px) {
    .page-dashboard .grid-kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .page-dashboard .grid-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 440px) {
    .page-dashboard .grid-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
/* Premium operational KPI surfaces: HR, finance and expense workspaces */
.operational-kpi-grid {
    gap: 18px;
}

.operational-kpi-grid--four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.operational-kpi-grid--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

body .operational-kpi-card {
    position: relative;
    isolation: isolate;
    min-height: 156px;
    overflow: hidden;
    border: 0 !important;
    color: #ffffff !important;
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.14) !important;
    transition: transform 180ms ease, box-shadow 180ms ease;
}

body .operational-kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 22px 42px rgba(15, 23, 42, 0.19) !important;
}

body .operational-kpi-card::before,
body .operational-kpi-card::after {
    content: "";
    position: absolute;
    z-index: -1;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    pointer-events: none;
}

body .operational-kpi-card::before {
    width: 150px;
    height: 150px;
    top: -76px;
    right: -48px;
}

body .operational-kpi-card::after {
    width: 92px;
    height: 92px;
    right: 54px;
    bottom: -64px;
    background: rgba(255, 255, 255, 0.08);
}

body .operational-kpi-card .kpi-header,
body .operational-kpi-card .kpi-header span,
body .operational-kpi-card .kpi-value,
body .operational-kpi-card .kpi-value span {
    color: #ffffff !important;
}

body .operational-kpi-card .kpi-header span {
    letter-spacing: 0.075em;
    opacity: 0.84;
}

body .operational-kpi-card .kpi-value {
    text-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

body .operational-kpi-card .kpi-icon {
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.16) !important;
    color: #ffffff !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(7px);
}

.operational-kpi-card--hr-staff,
body.light-theme .operational-kpi-card--hr-staff {
    background: linear-gradient(135deg, #b7791f 0%, #e4a83b 100%) !important;
}

.operational-kpi-card--hr-salary,
body.light-theme .operational-kpi-card--hr-salary {
    background: linear-gradient(135deg, #047857 0%, #10b981 100%) !important;
}

.operational-kpi-card--hr-paid,
body.light-theme .operational-kpi-card--hr-paid {
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%) !important;
}

.operational-kpi-card--hr-payroll,
body.light-theme .operational-kpi-card--hr-payroll {
    background: linear-gradient(135deg, #be185d 0%, #f43f5e 100%) !important;
}

.operational-kpi-card--cash-in,
body.light-theme .operational-kpi-card--cash-in {
    background: linear-gradient(135deg, #047857 0%, #0d9488 100%) !important;
}

.operational-kpi-card--cash-out,
body.light-theme .operational-kpi-card--cash-out {
    background: linear-gradient(135deg, #be123c 0%, #ef4444 100%) !important;
}

.operational-kpi-card--cash-balance,
body.light-theme .operational-kpi-card--cash-balance {
    background: linear-gradient(135deg, #b7791f 0%, #d9a93d 52%, #ca8a04 100%) !important;
}

.operational-kpi-card--expense-total,
body.light-theme .operational-kpi-card--expense-total {
    background: linear-gradient(135deg, #b91c1c 0%, #f43f5e 100%) !important;
}

.operational-kpi-card--expense-utilities,
body.light-theme .operational-kpi-card--expense-utilities {
    background: linear-gradient(135deg, #c2410c 0%, #f59e0b 100%) !important;
}

.operational-kpi-card--expense-other,
body.light-theme .operational-kpi-card--expense-other {
    background: linear-gradient(135deg, #334155 0%, #6366f1 100%) !important;
}

body.page-hr.light-theme .content-wrapper .panel {
    background: linear-gradient(145deg, #ffffff 0%, #fff9ec 100%) !important;
}

body.page-finance.light-theme .content-wrapper .panel {
    background: linear-gradient(145deg, #ffffff 0%, #effcf8 100%) !important;
}

body.page-expenses.light-theme .content-wrapper .panel {
    background: linear-gradient(145deg, #ffffff 0%, #fff5f2 100%) !important;
}

@media (max-width: 1100px) {
    .operational-kpi-grid--four,
    .operational-kpi-grid--three {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 640px) {
    .operational-kpi-grid--four,
    .operational-kpi-grid--three {
        grid-template-columns: 1fr !important;
    }

    body .operational-kpi-card {
        min-height: 138px;
    }
}

/* Compact invoice creation workspace */
.page-invoices .invoice-create-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}

.page-invoices .invoice-create-heading h2,
.page-invoices .invoice-create-heading p {
    margin: 0;
}

.page-invoices .invoice-create-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.8fr);
    gap: 20px;
    align-items: start;
}

.page-invoices .invoice-create-workspace.is-final-invoice {
    grid-template-columns: minmax(0, 1fr);
}

.page-invoices .invoice-create-form-panel {
    min-width: 0;
    margin-bottom: 0;
    padding: 22px !important;
}

.page-invoices .invoice-create-form-panel > .panel-title {
    margin-bottom: 16px !important;
}

.page-invoices .invoice-create-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
    align-items: end;
}

.page-invoices .invoice-create-form > .form-group {
    min-width: 0;
    margin-bottom: 0 !important;
}

.page-invoices .invoice-create-form > .alert,
.page-invoices .invoice-create-form > .invoice-accordion,
.page-invoices .invoice-create-form > .invoice-billing-choice {
    grid-column: 1 / -1;
}

.page-invoices .invoice-create-form .form-control {
    min-height: 44px;
}

.page-invoices .invoice-cost-breakdown {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.page-invoices .invoice-cost-card {
    min-width: 0;
    padding: 14px 15px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #fff;
}

.page-invoices .invoice-cost-card--material {
    border-color: rgba(59, 130, 246, 0.22);
    background: linear-gradient(145deg, #f8fbff, #ffffff);
}

.page-invoices .invoice-cost-card--additional {
    border-color: rgba(212, 168, 79, 0.3);
    background: linear-gradient(145deg, #fffaf0, #ffffff);
}

.page-invoices .invoice-cost-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    color: var(--text-main);
    font-size: 11px;
    font-weight: 750;
}

.page-invoices .invoice-cost-card__head span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.page-invoices .invoice-cost-card__head i {
    color: var(--primary);
}

.page-invoices .invoice-cost-card__head small {
    color: var(--text-muted);
    font-size: 9px;
    letter-spacing: 0.04em;
}

.page-invoices .invoice-cost-card > strong {
    display: block;
    color: var(--text-main);
    font-size: 20px;
    line-height: 1.25;
}

.page-invoices .invoice-cost-card > p {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 10px;
}

.page-invoices .invoice-cost-empty {
    padding: 8px 10px;
    border: 1px dashed rgba(148, 163, 184, 0.42);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
}

.page-invoices .invoice-cost-lines {
    display: grid;
    gap: 5px;
}

.page-invoices .invoice-cost-lines[hidden] {
    display: none;
}

.page-invoices .invoice-cost-lines > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-muted);
    font-size: 10px;
}

.page-invoices .invoice-cost-lines > div[hidden] {
    display: none;
}

.page-invoices .invoice-cost-lines b {
    color: var(--text-main);
    white-space: nowrap;
}

.page-invoices .invoice-tax-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.page-invoices .invoice-discount-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
    width: 100%;
    min-width: 0;
    grid-column: 1 / -1;
}

.page-invoices .invoice-discount-meta-grid > div {
    min-width: 0;
}

.page-invoices .invoice-discount-scope-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 5px;
}

.page-invoices .invoice-discount-scope-option {
    display: flex;
    align-items: flex-start;
    width: 100%;
    gap: 8px;
    min-width: 0;
    min-height: 76px;
    margin: 0;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.78);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.page-invoices .invoice-discount-scope-option.is-selected {
    border-color: #3b82f6;
    background: rgba(239, 246, 255, 0.92);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.page-invoices .invoice-discount-scope-option > i {
    flex: 0 0 auto;
    margin-top: 3px;
    color: #64748b;
}

.page-invoices .invoice-discount-scope-option.is-selected > i {
    color: #2563eb;
}

.page-invoices .invoice-discount-scope-option:disabled {
    cursor: not-allowed;
}

.page-invoices .invoice-discount-scope-option span {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.page-invoices .invoice-discount-scope-option strong {
    color: var(--text-main);
    font-size: 11px;
    line-height: 1.35;
}

.page-invoices .invoice-discount-scope-option small {
    color: var(--text-muted);
    font-size: 9px;
    line-height: 1.45;
}

.page-invoices .invoice-final-summary {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
    align-items: start;
    padding-top: 2px;
}

.page-invoices .invoice-final-summary-column {
    display: grid;
    gap: 14px;
    align-content: start;
}

.page-invoices .invoice-final-summary .form-group {
    min-width: 0;
    margin-bottom: 0 !important;
}

.page-invoices .invoice-final-summary > .invoice-submit-bar {
    grid-column: 1 / -1;
    margin-top: 8px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

.page-invoices #itemize-checkbox-container {
    min-height: 44px;
    margin: 0 !important;
    padding: 9px 12px;
    border: 1px solid rgba(212, 168, 79, 0.3);
    border-radius: 10px;
    background: rgba(212, 168, 79, 0.08);
}

.page-invoices #itemize-checkbox-container label {
    font-size: 12px;
    line-height: 1.4;
}

.page-invoices .invoice-accordion {
    overflow: hidden;
    margin: 0;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(212, 168, 79, 0.045);
}

.page-invoices .invoice-accordion > summary {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 11px 14px;
    color: var(--text-main);
    font-size: 12px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.035em;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.page-invoices .invoice-accordion > summary::-webkit-details-marker {
    display: none;
}

.page-invoices .invoice-accordion > summary span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.page-invoices .invoice-accordion > summary i {
    color: var(--primary);
}

.page-invoices .invoice-accordion > summary small {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 650;
    text-transform: none;
    letter-spacing: 0;
}

.page-invoices .invoice-accordion > summary::after {
    content: "+";
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border-radius: 50%;
    background: rgba(212, 168, 79, 0.15);
    color: var(--primary);
    font-size: 17px;
    line-height: 1;
}

.page-invoices .invoice-accordion[open] > summary::after {
    content: "−";
}

.page-invoices .invoice-accordion[open] > summary {
    border-bottom: 1px solid var(--border-color);
}

.page-invoices .invoice-accordion-body {
    padding: 14px;
}

.page-invoices .invoice-tax-settings .invoice-accordion-body {
    background: rgba(255, 255, 255, 0.32);
}

.page-invoices .invoice-billing-choice {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 13px;
    border: 1px solid rgba(59, 130, 246, 0.22);
    border-radius: 12px;
    background: linear-gradient(145deg, rgba(239, 246, 255, 0.82), rgba(255, 255, 255, 0.7));
}

.page-invoices .invoice-billing-choice__heading {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-main);
    font-size: 12px;
    font-weight: 750;
}

.page-invoices .invoice-billing-choice__heading span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.page-invoices .invoice-billing-choice__heading i {
    color: #2563eb;
}

.page-invoices .invoice-billing-choice__heading small {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 550;
}

.page-invoices .invoice-billing-option {
    display: flex;
    align-items: flex-start;
    width: 100%;
    gap: 9px;
    margin: 0;
    padding: 11px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.78);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.page-invoices .invoice-billing-option.is-selected {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.page-invoices .invoice-billing-option > i {
    flex: 0 0 auto;
    margin-top: 3px;
    color: #64748b;
}

.page-invoices .invoice-billing-option.is-selected > i {
    color: #2563eb;
}

.page-invoices .invoice-billing-option span {
    display: grid;
    gap: 3px;
}

.page-invoices .invoice-billing-option strong {
    color: var(--text-main);
    font-size: 12px;
}

.page-invoices .invoice-billing-option small {
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.4;
}

.page-invoices .invoice-item-row.is-deferred-additional {
    background: rgba(245, 158, 11, 0.06);
}

.page-invoices .invoice-item-row.is-deferred-additional .invoice-item-description::after {
    content: "Deferred to final invoice";
    display: block;
    margin-top: 4px;
    color: #b45309;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.35;
}

.page-invoices .invoice-submit-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-height: 44px;
    padding: 4px 0;
}

.page-invoices .invoice-submit-bar .btn-primary {
    min-height: 44px;
    box-shadow: 0 10px 24px rgba(180, 121, 31, 0.2);
}

.page-invoices .invoice-project-summary {
    position: sticky;
    top: 20px;
    min-width: 0;
    margin-bottom: 0;
    padding: 20px !important;
    border: 1px solid rgba(212, 168, 79, 0.24) !important;
    border-top: 4px solid var(--primary) !important;
    background: linear-gradient(155deg, #ffffff 0%, #fff9eb 100%) !important;
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.1) !important;
}

@media (max-width: 1050px) {
    .page-invoices .invoice-create-workspace {
        grid-template-columns: 1fr;
    }

    .page-invoices .invoice-project-summary {
        position: static;
        grid-row: 1;
    }
}

@media (max-width: 720px) {
    .page-invoices .invoice-create-heading {
        display: block;
    }

    .page-invoices .invoice-create-heading p {
        margin-top: 6px;
    }

    .page-invoices .invoice-create-form {
        grid-template-columns: 1fr;
    }

    .page-invoices .invoice-create-form > .invoice-accordion {
        grid-column: auto;
    }

    .page-invoices .invoice-tax-settings-grid {
        grid-template-columns: 1fr !important;
    }

    .page-invoices .invoice-billing-choice {
        grid-template-columns: 1fr;
    }

    .page-invoices .invoice-billing-choice__heading {
        grid-column: auto;
        display: grid;
    }

    .page-invoices .invoice-final-summary {
        grid-template-columns: 1fr;
    }

    .page-invoices .invoice-cost-breakdown,
    .page-invoices .invoice-discount-meta-grid {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .page-invoices .invoice-discount-scope-grid {
        grid-template-columns: 1fr;
    }

    .page-invoices .invoice-submit-bar {
        justify-content: stretch;
    }

    .page-invoices .invoice-submit-bar .btn {
        flex: 1;
        justify-content: center;
    }
}

/* Projects: compact workflow detail layout */
.page-projects .project-back-row {
    margin-bottom: 14px;
}

.page-projects .project-overview-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(210px, 0.9fr) minmax(210px, 0.9fr);
    gap: 0;
    margin-bottom: 24px;
    overflow: hidden;
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.page-projects .project-overview-panel > div {
    min-width: 0;
    padding: 22px 24px;
}

.page-projects .project-overview-panel > div + div {
    border-left: 1px solid var(--border-color);
}

.page-projects .project-overview-kicker,
.page-projects .project-overview-stat > span,
.page-projects .project-progress-label > span {
    display: block;
    margin-bottom: 7px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-projects .project-overview-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.page-projects .project-overview-title-row h2 {
    overflow: hidden;
    color: var(--text-main);
    font-size: clamp(20px, 2vw, 26px);
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-projects .project-overview-identity p {
    margin-top: 7px;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-projects .project-overview-stat {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.page-projects .project-overview-stat.current-stage strong {
    color: var(--primary);
    font-size: 17px;
}

.page-projects .project-overview-stat.current-stage strong i {
    margin-right: 5px;
    font-size: 13px;
}

.page-projects .project-overview-stat small {
    margin-top: 7px;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.4;
}

.page-projects .project-progress-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.page-projects .project-progress-label > span {
    margin-bottom: 0;
}

.page-projects .project-progress-label strong {
    color: var(--text-main);
    font-size: 14px;
}

.page-projects .project-progress-track {
    height: 7px;
    margin-top: 12px;
    overflow: hidden;
    background: rgba(148, 163, 184, 0.16);
    border-radius: 99px;
}

.page-projects .project-progress-track span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    border-radius: inherit;
}

.page-projects .col-main {
    display: flex;
    flex-direction: column;
}

.page-projects .production-workflow-panel {
    order: 2;
}

.page-projects .project-designs-panel {
    order: 1;
}

.page-projects .project-installation-panel {
    order: 3;
}

.page-projects .production-workflow-panel .panel-title {
    margin-bottom: 16px;
}

.page-projects .workflow-count {
    padding: 5px 9px;
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.1);
    border-radius: 99px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.page-projects .production-workflow-panel .task-checklist {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.page-projects .production-workflow-panel .task-item {
    display: block;
    align-self: start;
    min-height: 66px;
    margin-bottom: 0;
    padding: 13px 14px;
    overflow: hidden;
}

.page-projects .production-workflow-panel .task-item:has(.task-record[open]) {
    grid-column: 1 / -1;
}

.page-projects .production-workflow-panel .task-item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 38px;
}

.page-projects .production-workflow-panel .task-label {
    min-width: 0;
}

.page-projects .production-workflow-panel .task-label > span:last-child {
    overflow: hidden;
    color: var(--text-main);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-projects .production-workflow-panel .task-label i {
    font-size: 20px;
}

.page-projects .task-check-state {
    display: inline-grid;
    padding: 0;
    color: inherit;
    background: transparent;
    border: 0;
    font: inherit;
    cursor: pointer;
    place-items: center;
}

.page-projects .task-check-state:hover i {
    transform: scale(1.08);
}

.page-projects .task-status-pill {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.09);
    border-radius: 99px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.page-projects .task-status-pill.is-current {
    color: var(--warning);
    background: var(--warning-bg);
}

.page-projects .task-status-pill.is-completed {
    color: var(--success);
    background: var(--success-bg);
}

.page-projects .task-completed-by {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin: 7px 0 0 32px;
    color: var(--text-muted);
    font-size: 10px;
}

.page-projects .task-completed-by span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-projects .task-completed-by strong {
    color: var(--text-main);
    font-weight: 600;
}

.page-projects .task-completed-by time {
    flex-shrink: 0;
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.page-projects .task-record {
    margin: 12px -14px -13px;
    border-top: 1px solid var(--border-color);
}

.page-projects .task-record summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
    text-transform: uppercase;
}

.page-projects .task-record summary::-webkit-details-marker {
    display: none;
}

.page-projects .task-record summary:hover {
    color: var(--text-main);
    background: rgba(148, 163, 184, 0.06);
}

.page-projects .task-record-chevron {
    font-size: 9px;
    transition: transform 0.2s ease;
}

.page-projects .task-record[open] .task-record-chevron {
    transform: rotate(180deg);
}

.page-projects .task-record-body {
    display: grid;
    gap: 10px;
    padding: 12px 14px 14px;
    background: rgba(148, 163, 184, 0.045);
    border-top: 1px solid var(--border-color);
}

.page-projects .production-workflow-panel .task-item:has(.task-record[open]) .task-record-body {
    grid-template-columns: minmax(0, 1fr) minmax(210px, 0.9fr);
    align-items: start;
}

.page-projects .production-workflow-panel .task-item:has(.task-record[open]) .task-record-row {
    grid-column: 1;
}

.page-projects .production-workflow-panel .task-item:has(.task-record[open]) .task-record-photo {
    grid-column: 2;
    grid-row: 1 / span 3;
}

.page-projects .task-record-row {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 9px;
    align-items: start;
}

.page-projects .task-record-row > i {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    color: var(--success);
    background: var(--success-bg);
    border-radius: 8px;
    font-size: 11px;
}

.page-projects .task-record-row span,
.page-projects .task-record-row strong {
    display: block;
}

.page-projects .task-record-row span {
    margin-bottom: 2px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.page-projects .task-record-row strong {
    overflow-wrap: anywhere;
    color: var(--text-main);
    font-size: 11px;
    line-height: 1.45;
}

.page-projects .task-record-photo {
    margin: 0;
}

.page-projects .task-record-photo a {
    position: relative;
    display: block;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.page-projects .task-record-photo img {
    display: block;
    width: 100%;
    height: 116px;
    object-fit: cover;
}

.page-projects .task-record-photo a > span {
    position: absolute;
    right: 8px;
    bottom: 8px;
    padding: 5px 8px;
    color: #fff;
    background: rgba(15, 23, 42, 0.78);
    border-radius: 7px;
    font-size: 9px;
    font-weight: 700;
}

.page-projects .task-record-photo figcaption {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 9px;
}

.page-projects .task-record-trigger {
    display: flex;
    width: calc(100% + 28px);
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 12px -14px -13px;
    padding: 10px 14px;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-top: 1px solid var(--border-color);
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
}

.page-projects .task-record-trigger:hover {
    color: var(--text-main);
    background: rgba(148, 163, 184, 0.06);
}

.page-projects .task-record-trigger > i {
    font-size: 9px;
}

.page-projects .task-record-modal-container {
    width: min(760px, 92vw);
    max-width: 760px;
}

.page-projects .task-record-modal-kicker {
    display: block;
    margin-bottom: 3px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-projects .task-record-modal .modal-header h3 {
    font-size: 18px;
}

.page-projects .task-record-modal-completion {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
    align-items: center;
    padding: 14px;
    background: var(--success-bg);
    border: 1px solid rgba(16, 185, 129, 0.18);
    border-radius: 12px;
}

.page-projects .task-record-modal-completion > div span,
.page-projects .task-record-modal-completion > div strong {
    display: block;
}

.page-projects .task-record-modal-completion > div span {
    margin-bottom: 3px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.page-projects .task-record-modal-completion > div strong {
    color: var(--text-main);
    font-size: 12px;
}

.page-projects .task-record-modal-content {
    display: grid;
    gap: 18px;
    margin-top: 18px;
}

.page-projects .task-record-modal-content.has-photo,
.page-projects .task-record-modal-content.has-photo-slot {
    grid-template-columns: minmax(0, 0.8fr) minmax(280px, 1.2fr);
}

.page-projects .task-record-modal-notes {
    display: grid;
    align-content: start;
    gap: 12px;
}

.page-projects .task-record-modal-field {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 11px;
    align-items: start;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.page-projects .task-record-modal-field > i {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    color: var(--success);
    background: var(--success-bg);
    border-radius: 10px;
}

.page-projects .task-record-modal-field span,
.page-projects .task-record-modal-field strong {
    display: block;
}

.page-projects .task-record-modal-field span {
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.page-projects .task-record-modal-field strong {
    overflow-wrap: anywhere;
    color: var(--text-main);
    font-size: 12px;
    line-height: 1.5;
}

.page-projects .task-record-modal-empty {
    display: grid;
    min-height: 100%;
    place-items: center;
    align-content: center;
    gap: 8px;
    padding: 24px;
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.04);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    font-size: 11px;
    text-align: center;
}

.page-projects .task-record-modal-empty i {
    font-size: 20px;
}

.page-projects .task-record-modal-photo {
    min-width: 0;
    margin: 0;
}

.page-projects .task-record-modal-photo figcaption {
    margin-bottom: 7px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.page-projects .task-record-modal-photo a {
    position: relative;
    display: block;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.page-projects .task-record-modal-photo img {
    display: block;
    width: 100%;
    height: 240px;
    object-fit: cover;
}

.page-projects .task-record-modal-photo a span {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 7px 10px;
    color: #fff;
    background: rgba(15, 23, 42, 0.82);
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
}

.page-projects .task-record-modal-photo-empty {
    display: grid;
    min-height: 174px;
    align-content: center;
    justify-items: center;
    gap: 6px;
    padding: 22px;
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.035);
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    text-align: center;
}

.page-projects .task-record-modal-photo-empty > i {
    display: grid;
    width: 42px;
    height: 42px;
    margin-bottom: 2px;
    color: var(--primary);
    background: rgba(59, 130, 246, 0.09);
    border-radius: 11px;
    font-size: 17px;
    place-items: center;
}

.page-projects .task-record-modal-photo-empty strong {
    color: var(--text-main);
    font-size: 11px;
}

.page-projects .task-record-modal-photo-empty > span {
    max-width: 260px;
    font-size: 9px;
    line-height: 1.5;
}

.page-projects .task-record-modal-photo-empty .btn {
    margin-top: 5px;
}

.page-projects .task-edit-lock,
.page-projects .task-edit-warning {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 11px;
    align-items: center;
    margin-top: 14px;
    padding: 12px 14px;
    color: var(--text-muted);
    background: rgba(59, 130, 246, 0.06);
    border: 1px solid rgba(59, 130, 246, 0.16);
    border-radius: 12px;
}

.page-projects .task-edit-lock > i,
.page-projects .task-edit-warning > i {
    display: grid;
    width: 38px;
    height: 38px;
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    border-radius: 10px;
    place-items: center;
}

.page-projects .task-edit-lock strong,
.page-projects .task-edit-lock span,
.page-projects .task-edit-warning strong,
.page-projects .task-edit-warning span {
    display: block;
}

.page-projects .task-edit-lock strong,
.page-projects .task-edit-warning strong {
    margin-bottom: 3px;
    color: var(--text-main);
    font-size: 11px;
}

.page-projects .task-edit-lock span,
.page-projects .task-edit-warning span {
    font-size: 10px;
    line-height: 1.45;
}

.page-projects .task-edit-lock.is-pending {
    background: var(--warning-bg);
    border-color: rgba(245, 158, 11, 0.2);
}

.page-projects .task-edit-lock.is-pending > i {
    color: var(--warning);
    background: rgba(245, 158, 11, 0.12);
}

.page-projects .task-edit-lock.is-locked {
    background: rgba(148, 163, 184, 0.07);
    border-color: var(--border-color);
}

.page-projects .task-edit-lock.is-locked > i {
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.12);
}

.page-projects .task-edit-review,
.page-projects .task-edit-history {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

.page-projects .task-edit-review {
    padding: 16px;
    background: var(--warning-bg);
    border: 1px solid rgba(245, 158, 11, 0.22);
    border-radius: 12px;
}

.page-projects .task-edit-section-heading,
.page-projects .task-edit-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.page-projects .task-edit-section-heading > div > span {
    display: block;
    margin-bottom: 3px;
    color: var(--text-muted);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.page-projects .task-edit-section-heading h4 {
    margin: 0;
    color: var(--text-main);
    font-size: 13px;
}

.page-projects .task-edit-section-heading > span:last-child {
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
}

.page-projects .task-edit-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 99px;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.page-projects .task-edit-status.is-pending {
    color: var(--warning);
    background: rgba(245, 158, 11, 0.12);
}

.page-projects .task-edit-status.is-approved {
    color: var(--success);
    background: var(--success-bg);
}

.page-projects .task-edit-status.is-rejected {
    color: var(--danger);
    background: var(--danger-bg);
}

.page-projects .task-edit-diff-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.page-projects .task-edit-diff-list > div {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 9px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 9px;
    font-size: 10px;
}

.page-projects .task-edit-diff-list > div > span {
    color: var(--text-muted);
    font-weight: 700;
}

.page-projects .task-edit-diff-list del {
    color: var(--danger);
    overflow-wrap: anywhere;
}

.page-projects .task-edit-diff-list ins {
    color: var(--success);
    font-weight: 600;
    overflow-wrap: anywhere;
    text-decoration: none;
}

.page-projects .task-edit-diff-list i {
    color: var(--text-muted);
    font-size: 8px;
}

.page-projects .task-edit-review-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.page-projects .task-edit-review-actions form {
    margin: 0;
}

.page-projects .task-edit-history-empty {
    margin: 12px 0 0;
    padding: 13px;
    color: var(--text-muted);
    background: rgba(148, 163, 184, 0.04);
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    font-size: 10px;
    text-align: center;
}

.page-projects .task-edit-history-list {
    display: grid;
    gap: 10px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.page-projects .task-edit-history-list > li {
    padding: 12px;
    background: rgba(148, 163, 184, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.page-projects .task-edit-history-head strong,
.page-projects .task-edit-history-head span {
    display: block;
}

.page-projects .task-edit-history-head strong {
    color: var(--text-main);
    font-size: 10px;
}

.page-projects .task-edit-history-head > div > span {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 9px;
}

.page-projects .task-edit-history-list p {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.45;
}

.page-projects .task-edit-history-list p strong {
    color: var(--text-main);
}

.page-projects .task-edit-history-list small {
    display: block;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 9px;
}

.page-projects .task-edit-modal-container {
    width: min(600px, 92vw);
    max-width: 600px;
}

.page-projects .task-edit-modal .task-edit-warning {
    margin: 0 0 18px;
    background: var(--warning-bg);
    border-color: rgba(245, 158, 11, 0.22);
}

.page-projects .task-edit-modal .task-edit-warning > i {
    color: var(--warning);
    background: rgba(245, 158, 11, 0.12);
}

.page-projects .task-edit-current-photo {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 8px 0 10px;
    padding: 9px;
    background: rgba(148, 163, 184, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.page-projects .task-edit-current-photo img {
    width: 64px;
    height: 48px;
    object-fit: cover;
    border-radius: 7px;
}

.page-projects .task-edit-current-photo strong,
.page-projects .task-edit-current-photo span {
    display: block;
}

.page-projects .task-edit-current-photo strong {
    color: var(--text-main);
    font-size: 10px;
}

.page-projects .task-edit-current-photo span {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 9px;
}

.page-projects .task-edit-photo-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 8px 0 10px;
    padding: 10px 11px;
    color: var(--text-muted);
    background: rgba(59, 130, 246, 0.05);
    border: 1px dashed rgba(59, 130, 246, 0.2);
    border-radius: 9px;
    font-size: 9px;
    line-height: 1.5;
}

.page-projects .task-edit-photo-hint i {
    margin-top: 2px;
    color: var(--primary);
}

.page-projects .task-edit-remove-photo {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 9px;
    color: var(--danger);
    font-size: 10px;
    cursor: pointer;
}

.page-projects .task-edit-remove-photo input {
    accent-color: var(--danger);
}

.page-projects .project-designs-panel .table-responsive.is-empty {
    overflow: hidden !important;
    border: 1px dashed var(--border-color);
    border-radius: 12px;
}

.page-projects .project-designs-panel .table-responsive.is-empty table {
    min-width: 0;
}

.page-projects .project-designs-panel .table-responsive.is-empty thead {
    display: none;
}

.page-projects .project-designs-panel .table-responsive.is-empty td {
    height: 86px;
    padding: 24px;
    border: 0;
    white-space: normal !important;
}

.page-projects .project-summary-panel {
    padding: 24px;
}

.page-projects .project-summary-panel .panel-title {
    margin-bottom: 16px;
}

.page-projects .project-money-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.page-projects .project-money-card {
    min-width: 0;
    padding: 13px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.18);
    border-radius: 12px;
}

.page-projects .project-money-card > span,
.page-projects .project-money-card > small {
    display: block;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.page-projects .project-money-card > strong {
    display: block;
    overflow: hidden;
    margin: 6px 0 2px;
    color: var(--info);
    font-size: 18px;
    font-variant-numeric: tabular-nums;
    text-overflow: ellipsis;
}

.page-projects .project-money-card.is-paid {
    background: var(--success-bg);
    border-color: rgba(16, 185, 129, 0.2);
}

.page-projects .project-money-card.is-paid > strong {
    color: var(--success);
}

.page-projects .project-money-card.has-balance {
    background: var(--danger-bg);
    border-color: rgba(239, 68, 68, 0.2);
}

.page-projects .project-money-card.has-balance > strong {
    color: var(--danger);
}

.page-projects .project-payment-lines {
    display: grid;
    gap: 8px;
    margin-top: 14px;
    font-size: 12px;
}

.page-projects .project-payment-lines > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.page-projects .project-payment-lines span {
    color: var(--text-muted);
}

.page-projects .project-update-cost {
    width: 100%;
    justify-content: center;
    margin-top: 14px;
}

.page-projects .project-job-facts {
    display: grid;
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.page-projects .project-job-facts > div {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
}

.page-projects .project-job-facts > div + div {
    border-top: 1px solid var(--border-color);
}

.page-projects .project-job-facts span {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.page-projects .project-job-facts strong {
    overflow: hidden;
    color: var(--text-main);
    font-size: 13px;
    text-align: right;
    text-overflow: ellipsis;
}

.page-projects .project-summary-section {
    margin-top: 18px;
    padding-top: 17px;
    border-top: 1px solid var(--border-color);
}

.page-projects .project-summary-section h4 {
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-projects .project-summary-section > strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-main);
    font-size: 14px;
}

.page-projects .project-summary-section p {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

.page-projects .advanced-stage-controls {
    margin-top: 18px;
    border-top: 1px solid var(--border-color);
}

.page-projects .advanced-stage-controls summary {
    padding: 15px 0 0;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    list-style-position: inside;
}

.page-projects .advanced-stage-controls summary i {
    margin-right: 6px;
}

.page-projects .advanced-stage-controls > p {
    margin: 10px 0;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.5;
}

.page-projects .advanced-stage-controls form {
    display: grid;
    gap: 8px;
}

.page-projects .advanced-stage-controls label {
    color: var(--text-muted);
    font-size: 11px;
}

.page-projects .advanced-stage-controls .btn {
    justify-content: center;
}

.page-projects .project-activity-panel {
    padding: 24px;
}

@media (max-width: 1180px) {
    .page-projects .project-overview-panel {
        grid-template-columns: minmax(0, 1fr) minmax(200px, 0.75fr);
    }

    .page-projects .project-overview-identity {
        grid-column: 1 / -1;
        border-bottom: 1px solid var(--border-color);
    }

    .page-projects .project-overview-panel > .current-stage {
        border-left: 0;
    }
}

@media (max-width: 720px) {
    .page-projects .project-overview-panel {
        grid-template-columns: 1fr;
    }

    .page-projects .project-overview-panel > div {
        padding: 18px;
    }

    .page-projects .project-overview-panel > div + div {
        border-top: 1px solid var(--border-color);
        border-left: 0;
    }

    .page-projects .project-overview-identity {
        grid-column: auto;
    }

    .page-projects .production-workflow-panel .task-checklist {
        grid-template-columns: 1fr;
    }

    .page-projects .production-workflow-panel .task-item:has(.task-record[open]) .task-record-body {
        grid-template-columns: 1fr;
    }

    .page-projects .production-workflow-panel .task-item:has(.task-record[open]) .task-record-row,
    .page-projects .production-workflow-panel .task-item:has(.task-record[open]) .task-record-photo {
        grid-column: 1;
        grid-row: auto;
    }

    .page-projects .task-record-modal-completion {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .page-projects .task-record-modal-content.has-photo,
    .page-projects .task-record-modal-content.has-photo-slot {
        grid-template-columns: 1fr;
    }

    .page-projects .task-record-modal-photo img {
        height: 200px;
    }

    .page-projects .task-edit-diff-list > div {
        grid-template-columns: 1fr;
    }

    .page-projects .task-edit-diff-list i {
        transform: rotate(90deg);
    }

    .page-projects .task-edit-review-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .page-projects .task-edit-review-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .page-projects .project-overview-title-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-projects .project-overview-identity p {
        white-space: normal;
    }
}

/* Shared material autocomplete ------------------------------------------------ */
.nt-material-search {
    position: relative;
    width: 100%;
}

.nt-material-search > .form-control {
    width: 100%;
    padding-left: 44px !important;
    box-sizing: border-box;
    text-indent: 0 !important;
}

.nt-material-search > .nt-material-search-input {
    padding-left: 44px !important;
}

.nt-material-search-icon {
    position: absolute;
    z-index: 2;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    width: 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    pointer-events: none;
}

.purchase-search-bar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
}

.purchase-search-field,
.purchase-search-field .form-control {
    width: 100%;
    min-width: 0;
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 640px) {
    .purchase-search-bar {
        grid-template-columns: 1fr;
    }

    .purchase-search-bar .btn {
        width: 100%;
        justify-content: center;
    }
}

.nt-native-material-select {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.nt-material-results {
    position: fixed;
    z-index: 6000;
    max-height: 322px;
    overflow: hidden;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18);
}

.nt-material-results[hidden] {
    display: none !important;
}

.nt-material-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 46px;
    padding: 9px 12px;
    border: 0;
    border-bottom: 1px solid #edf1f5;
    background: #fff;
    color: #1e293b;
    text-align: left;
    cursor: pointer;
}

.nt-material-option:last-child {
    border-bottom: 0;
}

.nt-material-option:hover,
.nt-material-option.is-active {
    background: #fff8e8;
}

.nt-material-option strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nt-material-option-content {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 3px;
}

.nt-material-option-meta {
    display: block;
    overflow: hidden;
    color: #64748b;
    font-size: 10px;
    font-weight: 500;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nt-material-option small {
    flex: 0 0 auto;
    padding: 3px 7px;
    border-radius: 999px;
    background: #eef3f8;
    color: #64748b;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
}

.nt-material-search-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 13px;
    color: #64748b;
    font-size: 11px;
}

/* -------------------------------------------------------------------------
   System-wide compact data-table standard
   Navy headers, calm blue-grey grid lines and a low-glare hover treatment.
   Dynamic line-entry tables keep their purpose-built editing dimensions.
   ------------------------------------------------------------------------- */
.table-responsive:has(> table.data-table) {
    max-width: 100%;
    border-color: #b9c9dc;
    border-radius: 11px;
    box-shadow: 0 7px 20px rgba(31, 65, 105, 0.055);
}

table.data-table:not(#materials-table):not(#manual-items-table):not(#specs-table) {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
}

table.data-table thead th,
body.light-theme table.data-table thead th {
    padding: 10px 9px !important;
    background: #1f4f87 !important;
    border-right: 1px solid rgba(255, 255, 255, 0.26) !important;
    border-bottom: 1px solid #173d6a !important;
    color: #ffffff !important;
    font-size: 9px !important;
    font-weight: 750 !important;
    letter-spacing: 0.045em !important;
    line-height: 1.35;
    text-align: left;
    white-space: normal !important;
    overflow-wrap: anywhere;
    text-shadow: 0 1px 1px rgba(4, 22, 44, 0.16);
}

table.data-table thead th:last-child,
body.light-theme table.data-table thead th:last-child {
    border-right: 0 !important;
}

table.data-table:not(#materials-table):not(#manual-items-table):not(#specs-table) tbody td {
    padding: 9px 9px !important;
    border-right: 1px solid rgba(139, 162, 190, 0.34) !important;
    border-bottom: 1px solid rgba(139, 162, 190, 0.34) !important;
    color: var(--text-main);
    font-size: 10.5px !important;
    line-height: 1.4;
    white-space: normal !important;
    overflow-wrap: anywhere;
    transition:
        background-color 150ms ease,
        box-shadow 150ms ease,
        color 150ms ease;
}

table.data-table:not(#materials-table):not(#manual-items-table):not(#specs-table) tbody td:last-child {
    border-right: 0 !important;
}

table.data-table:not(#materials-table):not(#manual-items-table):not(#specs-table) tbody tr:last-child td {
    border-bottom: 0 !important;
}

table.data-table:not(#materials-table):not(#manual-items-table):not(#specs-table) tbody tr:hover td {
    background: rgba(56, 103, 158, 0.14) !important;
    box-shadow:
        inset 0 1px rgba(132, 165, 202, 0.16),
        inset 0 -1px rgba(132, 165, 202, 0.16);
}

body.light-theme table.data-table:not(#materials-table):not(#manual-items-table):not(#specs-table) tbody td {
    color: #26384e !important;
    background: #ffffff;
    border-right-color: #c6d3e2 !important;
    border-bottom-color: #c6d3e2 !important;
}

body.light-theme table.data-table:not(#materials-table):not(#manual-items-table):not(#specs-table) tbody tr:nth-child(even) td {
    background: #fbfcfe;
}

body.light-theme table.data-table:not(#materials-table):not(#manual-items-table):not(#specs-table) tbody tr:hover td {
    background: #e8f0fa !important;
    color: #173653 !important;
    box-shadow:
        inset 0 1px #bfd0e4,
        inset 0 -1px #bfd0e4;
}

table.data-table:not(#materials-table):not(#manual-items-table):not(#specs-table) .btn-sm {
    min-height: 28px;
    padding: 5px 8px !important;
    font-size: 9px !important;
}

table.data-table tbody td .badge {
    white-space: nowrap !important;
    overflow-wrap: normal;
}

table.data-table:is(#materials-table, #manual-items-table, #specs-table) tbody td {
    border-right: 1px solid rgba(139, 162, 190, 0.34) !important;
    border-bottom: 1px solid rgba(139, 162, 190, 0.34) !important;
    transition: background-color 150ms ease, box-shadow 150ms ease;
}

table.data-table:is(#materials-table, #manual-items-table, #specs-table) tbody td:last-child {
    border-right: 0 !important;
}

table.data-table:is(#materials-table, #manual-items-table, #specs-table) tbody tr:hover td {
    background: rgba(56, 103, 158, 0.11) !important;
    box-shadow:
        inset 0 1px rgba(132, 165, 202, 0.14),
        inset 0 -1px rgba(132, 165, 202, 0.14);
}

body.light-theme table.data-table:is(#materials-table, #manual-items-table, #specs-table) tbody tr:hover td {
    background: #e8f0fa !important;
}

@media (min-width: 769px) {
    .table-responsive:has(> table.data-table:not(#materials-table):not(#manual-items-table):not(#specs-table)) {
        overflow-x: hidden !important;
    }
}

@media (max-width: 768px) {
    .table-responsive:has(> table.data-table:not(#materials-table):not(#manual-items-table):not(#specs-table)) {
        overflow-x: auto !important;
    }
    table.data-table:not(#materials-table):not(#manual-items-table):not(#specs-table) {
        min-width: 720px !important;
    }
}

/* Unified tablet and phone layout */
@media (max-width: 1024px) {
    aside.sidebar {
        width: min(var(--sidebar-width), 86vw);
        transform: translateX(-105%);
        box-shadow: none;
    }

    aside.sidebar.active {
        transform: translateX(0);
        box-shadow: 18px 0 45px rgba(15, 23, 42, 0.24);
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 98;
        display: none;
        width: 100%;
        height: 100%;
        padding: 0;
        background: rgba(15, 23, 42, 0.38);
        border: 0;
        border-radius: 0;
        cursor: default;
    }

    .sidebar-backdrop.active {
        display: block;
    }

    main.main-content {
        width: 100%;
        max-width: 100vw !important;
        margin-left: 0;
    }

    .sidebar-toggle {
        display: inline-grid !important;
        width: 40px;
        height: 40px;
        padding: 0;
        place-items: center;
        border-radius: 10px;
    }

    .sidebar-toggle:hover {
        background: rgba(148, 163, 184, 0.12);
    }

    header.top-header {
        padding: 0 24px;
    }

    .content-wrapper {
        padding: 24px;
    }

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

@media (max-width: 640px) {
    :root {
        --header-height: 68px;
    }

    header.top-header {
        padding: 0 14px;
    }

    .header-leading {
        gap: 9px;
    }

    .header-eyebrow,
    .header-user-copy,
    .system-time {
        display: none;
    }

    .page-title {
        font-size: 16px;
        line-height: 1.45;
    }

    .header-avatar {
        width: 34px;
        height: 34px;
    }

    .content-wrapper {
        padding: 12px;
    }

    .panel {
        padding: 16px;
        border-radius: 14px;
    }

    .panel-title {
        align-items: flex-start;
        gap: 10px;
        flex-wrap: wrap;
        line-height: 1.5;
    }

    .filter-bar,
    .archive-filter-bar {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .filter-bar > div,
    .filter-bar .form-control,
    .filter-bar .btn,
    .filter-bar > .btn,
    .archive-filter-bar .form-control,
    .archive-filter-bar .btn {
        width: 100%;
        min-width: 0;
    }

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

    .reports-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .report-card {
        min-height: 104px;
        padding: 18px !important;
    }

    .page-dashboard .grid-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .page-dashboard .kpi-card {
        min-height: 122px;
        padding: 14px;
        border-radius: 14px;
    }

    body.page-dashboard .grid-kpis .kpi-card .kpi-header {
        max-width: calc(100% - 28px);
        font-size: 8px;
        line-height: 1.55;
        letter-spacing: 0.045em;
    }

    body.page-dashboard .grid-kpis .kpi-card .kpi-icon {
        top: 12px;
        right: 12px;
        width: 29px;
        height: 29px;
        border-radius: 8px;
        font-size: 12px;
    }

    body.page-dashboard .grid-kpis .kpi-card .kpi-value {
        gap: 3px;
        align-items: flex-end;
        margin-top: 24px;
        font-size: clamp(17px, 6vw, 23px);
        line-height: 1.2;
    }

    body.page-dashboard .grid-kpis .kpi-card .currency-label {
        flex: 0 0 auto;
        padding-bottom: 2px;
        font-size: 8px;
    }

    .chart-row {
        gap: 14px;
    }

    .modal-container {
        width: calc(100vw - 24px);
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
    }
}

/* Myanmar glyphs need extra vertical breathing room for stacked marks. */
html[lang="my"] body,
html[lang="my"] button,
html[lang="my"] input,
html[lang="my"] select,
html[lang="my"] textarea {
    font-family: "Noto Sans Myanmar", "Myanmar Text", "Pyidaungsu", sans-serif !important;
}

html[lang="my"] body {
    line-height: 1.65;
}

html[lang="my"] h1,
html[lang="my"] h2,
html[lang="my"] h3,
html[lang="my"] h4,
html[lang="my"] h5,
html[lang="my"] h6 {
    overflow: visible;
    padding-top: 3px;
    padding-bottom: 5px;
    line-height: 1.75 !important;
}

html[lang="my"] p {
    line-height: 1.75;
}

html[lang="my"] .page-title,
html[lang="my"] .panel-title,
html[lang="my"] .sidebar-menu a,
html[lang="my"] .menu-group-header,
html[lang="my"] .btn,
html[lang="my"] label,
html[lang="my"] table.data-table th,
html[lang="my"] table.data-table td,
html[lang="my"] .badge,
html[lang="my"] .kpi-header,
html[lang="my"] .kpi-value {
    line-height: 1.65 !important;
}

html[lang="my"] .page-title {
    overflow: visible;
    padding-top: 3px;
    padding-bottom: 5px;
    line-height: 1.75 !important;
    text-overflow: clip;
    white-space: normal;
}

html[lang="my"] .sidebar-menu a,
html[lang="my"] .menu-group-header {
    min-height: 48px;
    padding-top: 9px;
    padding-bottom: 9px;
}

html[lang="my"] .btn {
    padding-top: 7px;
    padding-bottom: 7px;
}

html[lang="my"] .badge {
    padding-top: 5px;
    padding-bottom: 5px;
}

html[lang="my"] .form-control {
    padding-top: 7px;
    padding-bottom: 7px;
}

html[lang="my"] body.page-dashboard .grid-kpis .kpi-card .kpi-header span {
    display: block;
    overflow: visible;
    padding-top: 2px;
    padding-bottom: 3px;
    line-height: 1.85 !important;
}

/* 3D letter measured-material planner */
.letter-spec-panel {
    padding: 20px;
    margin-bottom: 20px;
    border-color: rgba(212, 168, 79, 0.24);
}

.letter-spec-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}

.letter-spec-heading h4 {
    margin: 3px 0 4px;
    font-size: 16px;
    color: var(--text-main);
}

.letter-spec-heading h4 i {
    margin-right: 7px;
    color: var(--primary);
}

.letter-spec-heading p,
.letter-spec-footnote {
    margin: 0;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.6;
}

.letter-spec-rule-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
}

.letter-measure-rule {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
    margin-bottom: 14px;
    border: 1px dashed rgba(212, 168, 79, 0.34);
    border-radius: 12px;
    background: rgba(212, 168, 79, 0.055);
}

.letter-measure-rule > div {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr);
    column-gap: 9px;
    align-items: center;
}

.letter-measure-rule span {
    grid-row: 1 / span 2;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    color: #ffffff;
    background: var(--primary);
    font-size: 11px;
    font-weight: 800;
}

.letter-measure-rule strong {
    color: var(--text-main);
    font-size: 11px;
}

.letter-measure-rule small {
    color: var(--text-muted);
    font-size: 9.5px;
    line-height: 1.4;
}

.letter-spec-list {
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
}

.letter-spec-card {
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 13px;
    background: rgba(148, 163, 184, 0.035);
}

.letter-spec-card-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 12px;
}

.letter-spec-card .form-group {
    margin-bottom: 0;
}

.letter-spec-card label {
    display: block;
    margin-bottom: 5px;
    font-size: 10.5px;
}

.letter-spec-card .form-control {
    width: 100%;
    min-height: 40px;
}

.letter-spec-card .form-group small {
    display: block;
    min-height: 26px;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 9px;
    line-height: 1.45;
}

.letter-spec-remove {
    display: inline-flex;
    align-self: end;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0 !important;
    line-height: 1 !important;
}

.letter-spec-remove i {
    display: block;
    margin: 0;
    line-height: 1;
}

.letter-measure-grid {
    display: grid;
    grid-template-columns: 0.65fr repeat(4, minmax(105px, 1fr));
    gap: 10px;
    align-items: start;
    margin-bottom: 12px;
}

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

.letter-stock-field {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 11px;
    background: var(--bg-card);
}

.letter-stock-label {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 9px;
}

.letter-stock-label > div {
    min-width: 0;
}

.letter-stock-label strong,
.letter-stock-label small {
    display: block;
}

.letter-stock-label strong {
    color: var(--text-main);
    font-size: 11px;
}

.letter-stock-label small {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 9px;
}

.letter-stock-role {
    display: grid;
    place-items: center;
    flex: 0 0 31px;
    width: 31px;
    height: 31px;
    border-radius: 9px;
    color: var(--primary);
    background: var(--primary-glow);
}

.letter-stock-plan {
    min-height: 30px;
    margin-top: 7px;
    font-size: 9.5px;
    font-weight: 650;
    line-height: 1.5;
}

.letter-stock-plan.is-ready {
    color: var(--success);
}

.letter-stock-plan.is-warning {
    color: var(--warning);
}

.letter-stock-plan.is-shortage {
    color: var(--danger);
}

.letter-usage-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    margin-top: 10px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--border-color);
}

.letter-usage-summary > div {
    padding: 8px 10px;
    background: var(--bg-card-solid);
}

.letter-usage-summary span,
.letter-usage-summary strong {
    display: block;
}

.letter-usage-summary span {
    color: var(--text-muted);
    font-size: 8.5px;
    font-weight: 700;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}

.letter-usage-summary strong {
    margin-top: 3px;
    color: var(--text-main);
    font-size: 11px;
}

.letter-spec-footnote {
    margin-top: 9px;
}

.letter-inventory-summary {
    display: grid;
    gap: 0;
    overflow: hidden;
    margin: 0 0 12px;
    border: 1px solid rgba(16, 185, 129, 0.26);
    border-radius: 11px;
    background: var(--bg-card-solid);
}

.letter-inventory-summary[hidden] {
    display: none;
}

.letter-inventory-summary-head,
.letter-inventory-summary-item {
    display: grid;
    grid-template-columns: minmax(190px, 0.8fr) minmax(0, 1.2fr);
    gap: 14px;
    align-items: center;
    padding: 10px 12px;
}

.letter-inventory-summary-head {
    display: block;
    background: var(--success-bg);
}

.letter-inventory-summary-head strong,
.letter-inventory-summary-head small,
.letter-inventory-summary-item strong,
.letter-inventory-summary-item small {
    display: block;
}

.letter-inventory-summary-head strong {
    color: var(--text-main);
    font-size: 11px;
}

.letter-inventory-summary-head small,
.letter-inventory-summary-item small {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 9px;
    line-height: 1.45;
}

.letter-inventory-summary-item + .letter-inventory-summary-item {
    border-top: 1px solid var(--border-color);
}

.letter-inventory-summary-item > div:first-child {
    min-width: 0;
}

.letter-inventory-summary-item > div:first-child strong {
    overflow: hidden;
    color: var(--text-main);
    font-size: 10.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.letter-inventory-summary-item .letter-stock-plan {
    min-height: 0;
    margin-top: 0;
    text-align: right;
}

@media (max-width: 1000px) {
    .letter-measure-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .letter-spec-heading,
    .letter-stock-grid {
        grid-template-columns: 1fr;
    }

    .letter-spec-heading {
        display: grid;
    }

    .letter-spec-rule-badge {
        justify-self: start;
    }

    .letter-measure-rule {
        grid-template-columns: 1fr;
    }

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

    .letter-inventory-summary-item {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .letter-inventory-summary-item .letter-stock-plan {
        text-align: left;
    }
}

@media (max-width: 430px) {
    .letter-spec-panel,
    .letter-spec-card {
        padding: 12px;
    }

    .letter-measure-grid,
    .letter-usage-summary {
        grid-template-columns: 1fr;
    }
}

/* -------------------------------------------------------------------------
   Readability weight pass
   Keep the existing type sizes and colors; add depth to compact UI text.
   ------------------------------------------------------------------------- */
body {
    font-synthesis: weight;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.sidebar-menu a,
.menu-group-header,
.top-header,
.panel-subtitle,
.card-subtitle,
.helper-text,
.text-muted {
    font-weight: 550;
}

.page-title,
.panel-title,
.card-title,
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 800;
}

label,
.form-label,
.filter-label,
.pagination,
.pagination-info {
    font-weight: 600;
}

input,
select,
textarea,
.form-control {
    font-weight: 550;
}

.btn,
button,
.badge,
.status-badge {
    font-weight: 700;
}

table.data-table thead th,
body.light-theme table.data-table thead th {
    font-weight: 800 !important;
}

table.data-table tbody td,
body.light-theme table.data-table tbody td {
    font-weight: 550;
}

table.data-table tbody td strong,
table.data-table tbody td b,
table.data-table tbody td:first-child {
    font-weight: 700;
}

html[lang="my"] body {
    font-weight: 500;
}

html[lang="my"] .sidebar-menu a,
html[lang="my"] .menu-group-header,
html[lang="my"] p,
html[lang="my"] label,
html[lang="my"] input,
html[lang="my"] select,
html[lang="my"] textarea,
html[lang="my"] .form-control,
html[lang="my"] table.data-table tbody td {
    font-weight: 600;
}

html[lang="my"] .page-title,
html[lang="my"] .panel-title,
html[lang="my"] .card-title,
html[lang="my"] h1,
html[lang="my"] h2,
html[lang="my"] h3,
html[lang="my"] h4,
html[lang="my"] h5,
html[lang="my"] h6,
html[lang="my"] table.data-table thead th,
html[lang="my"] .btn,
html[lang="my"] .badge {
    font-weight: 700 !important;
}

@media (max-width: 640px) {
    html[lang="my"] .top-header .page-title {
        max-width: calc(100vw - 112px);
        padding-top: 1px;
        padding-bottom: 5px;
        font-size: 14px;
        line-height: 1.7 !important;
    }
}

@media print {
    .table-responsive:has(> table.data-table) {
        overflow: visible !important;
        box-shadow: none !important;
    }
    table.data-table thead th,
    body.light-theme table.data-table thead th {
        background: #f1f5f9 !important;
        border-color: #94a3b8 !important;
        color: #000000 !important;
        text-shadow: none !important;
    }
    table.data-table tbody td,
    body.light-theme table.data-table tbody td {
        border-color: #cbd5e1 !important;
        color: #000000 !important;
    }
}

/* --------------------------------------------------------------------------
   NAN TAW premium interface normalization
   Shared typography, form rhythm and invoice workflow components. The same
   Myanmar-capable family is used for both scripts so mixed labels do not jump.
   -------------------------------------------------------------------------- */
:root {
    --font-ui: "Noto Sans Myanmar", "Noto Sans", "Myanmar Text", "Pyidaungsu", "Segoe UI", Arial, sans-serif;
    --font-mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    --surface-subtle: #f8fafc;
    --surface-warm: #fffbf3;
    --ring-primary: 0 0 0 4px rgba(212, 168, 79, 0.16);
    --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.07);
    --shadow-lifted: 0 22px 60px rgba(15, 23, 42, 0.11);
}

html,
body,
button,
input,
select,
textarea,
table,
option {
    font-family: var(--font-ui) !important;
}

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

body {
    line-height: 1.55;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

code,
pre,
.monospace,
.reference-code {
    font-family: var(--font-mono) !important;
}

.form-control,
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
    min-height: 44px;
    border-radius: 11px !important;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

textarea.form-control,
textarea {
    min-height: 96px;
}

.form-control:focus,
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
    outline: none;
    box-shadow: var(--ring-primary) !important;
}

label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 7px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.005em;
}

.field-help {
    display: block;
    margin-top: 7px;
    color: var(--text-muted);
    font-size: 10.5px;
    line-height: 1.65;
}

.panel {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

.btn {
    min-height: 40px;
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0.005em;
}

.btn-sm {
    min-height: 34px;
}

/* Persistent actions remain visually distinct from temporary flash messages. */
.action-center {
    position: relative;
    isolation: isolate;
    box-shadow: var(--shadow-lifted);
}

.action-center::before {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: 2;
    width: 4px;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    background: linear-gradient(180deg, var(--primary), var(--warning));
    content: "";
    pointer-events: none;
}

.action-item__body h3,
.action-item__body p {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

.action-item__button {
    min-width: 142px;
    justify-content: center;
}

/* Invoice source selection: project is the source of truth for the customer. */
.page-invoices .invoice-linked-entity {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 10px 12px;
    border: 1px solid rgba(212, 168, 79, 0.32);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(212, 168, 79, 0.10), rgba(255, 255, 255, 0.95));
}

.page-invoices .invoice-linked-entity__icon {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 11px;
    color: #9a6700;
    background: rgba(212, 168, 79, 0.18);
}

.page-invoices .invoice-linked-entity__copy {
    min-width: 0;
}

.page-invoices .invoice-linked-entity__copy strong {
    display: block;
    overflow: hidden;
    color: var(--text-main);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-invoices .invoice-linked-entity__copy small {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 10px;
    line-height: 1.55;
}

.page-invoices .invoice-linked-entity__change {
    min-height: 32px;
    padding: 6px 10px;
    border-radius: 9px;
    color: #8a5a00;
    background: rgba(212, 168, 79, 0.12);
    font-size: 10px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.page-invoices .invoice-linked-entity__change:hover {
    background: rgba(212, 168, 79, 0.22);
}

.page-invoices .invoice-source-alert {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 11px;
    margin-bottom: 18px;
    padding: 13px 14px;
    border: 1px solid rgba(59, 130, 246, 0.22);
    border-radius: 12px;
    color: #1e3a5f;
    background: rgba(59, 130, 246, 0.07);
}

.page-invoices .invoice-source-alert > i {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 10px;
    color: var(--info);
    background: rgba(59, 130, 246, 0.12);
}

.page-invoices .invoice-source-alert strong {
    display: block;
    margin-bottom: 2px;
    color: #153456;
    font-size: 12px;
}

.page-invoices .invoice-source-alert p {
    margin: 0;
    color: #48647f;
    font-size: 10.5px;
    line-height: 1.6;
}

.page-invoices #manual-items-table {
    table-layout: fixed;
}

.page-invoices .invoice-item-cell {
    padding: 9px !important;
    vertical-align: top;
}

.page-invoices .invoice-item-description {
    width: 40%;
}

.page-invoices .invoice-item-size {
    width: 18%;
}

.page-invoices .invoice-item-qty {
    width: 12%;
}

.page-invoices .invoice-item-price {
    width: 22%;
}

.page-invoices .invoice-item-action {
    width: 52px;
    text-align: center;
}

.page-invoices .invoice-item-row.is-locked td {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.06), rgba(255, 255, 255, 0.95));
}

.page-invoices .invoice-item-row.is-locked input[readonly] {
    cursor: not-allowed;
    color: #334155 !important;
    background: #f8fafc !important;
    border-color: #dbe5ef !important;
}

.page-invoices .invoice-line-note {
    display: block;
    margin-top: 6px;
    color: #4c6b88;
    font-size: 9.5px;
    line-height: 1.5;
}

.page-invoices .invoice-line-lock {
    display: inline-grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 9px;
    color: #2563eb;
    background: rgba(59, 130, 246, 0.10);
}

.page-invoices .invoice-line-delete {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    justify-content: center;
}

/* Consistent empty states and source notices across modules. */
.empty-state,
.module-empty-state {
    display: grid;
    min-height: 160px;
    padding: 26px;
    place-items: center;
    border: 1px dashed rgba(100, 116, 139, 0.30);
    border-radius: 14px;
    color: var(--text-muted);
    background: var(--surface-subtle);
    text-align: center;
}

@media (max-width: 900px) {
    .action-item__button {
        min-width: 0;
    }

    .page-invoices .invoice-linked-entity {
        grid-template-columns: 38px minmax(0, 1fr);
    }

    .page-invoices .invoice-linked-entity__change {
        grid-column: 2;
        justify-self: start;
    }
}

@media (max-width: 640px) {
    .page-invoices .invoice-linked-entity {
        padding: 10px;
    }

    .page-invoices #manual-items-table {
        min-width: 720px !important;
    }

    .action-item__body h3 {
        font-size: 11.5px;
    }

    .action-item__body p {
        font-size: 10px;
    }
}

.page-invoices .invoice-field-footer {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.page-invoices .invoice-inline-action {
    flex: 0 0 auto;
    margin-top: 5px;
    padding: 0;
    border: 0;
    color: #9a6700;
    background: transparent;
    font-size: 10px;
    font-weight: 800;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.page-invoices #customer_picker[disabled] {
    cursor: not-allowed;
    color: #475569 !important;
    background: #f8fafc !important;
}

.inline-action-form {
    display: inline-flex;
    margin: 0;
    vertical-align: middle;
}

.inline-action-form .btn {
    margin: 0;
}

/* Invoice customer linked from selected project: retain the familiar form layout. */
.page-invoices .invoice-locked-customer {
    min-width: 0;
}

.page-invoices .invoice-locked-customer .form-control:disabled {
    color: var(--text-main);
    font-weight: 650;
    opacity: 1;
    cursor: not-allowed;
    background: #f8fafc;
    border-color: rgba(212, 168, 79, 0.45);
}

.page-invoices .invoice-locked-customer .field-help i {
    margin-right: 4px;
    color: var(--primary);
}

/* Invoice source row alignment fix (2026-07-28)
   Keep Customer and Project / Job Reference aligned from the top. */
.page-invoices .invoice-create-form {
    align-items: start;
}

.page-invoices .invoice-customer-field,
.page-invoices .invoice-project-field {
    display: flex;
    min-width: 0;
    height: 100%;
    flex-direction: column;
    align-self: stretch;
}

.page-invoices .invoice-customer-field > label,
.page-invoices .invoice-project-field > label {
    display: flex;
    align-items: center;
    min-height: 20px;
    margin-bottom: 8px;
    line-height: 1.35;
}

.page-invoices .invoice-customer-field .form-control,
.page-invoices .invoice-project-field .form-control {
    width: 100%;
    min-height: 50px;
    border-radius: 12px;
}

.page-invoices .invoice-customer-field .invoice-field-footer,
.page-invoices .invoice-project-field > .field-help {
    min-height: 34px;
    margin-top: 7px;
}

.page-invoices .invoice-project-field > .field-help {
    display: block;
    padding-right: 4px;
    line-height: 1.55;
}

.page-invoices .invoice-customer-field .invoice-field-footer {
    align-items: flex-start;
}

.page-invoices .invoice-customer-field .invoice-inline-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    margin-top: 0;
    padding: 4px 9px;
    border: 1px solid rgba(212, 168, 79, 0.28);
    border-radius: 8px;
    background: rgba(212, 168, 79, 0.08);
    text-decoration: none;
}

.page-invoices .invoice-customer-field .invoice-inline-action:hover {
    border-color: rgba(212, 168, 79, 0.48);
    background: rgba(212, 168, 79, 0.16);
}

@media (max-width: 720px) {
    .page-invoices .invoice-customer-field,
    .page-invoices .invoice-project-field {
        height: auto;
    }

    .page-invoices .invoice-customer-field .invoice-field-footer,
    .page-invoices .invoice-project-field > .field-help {
        min-height: 0;
    }
}


/* Header / Sidebar Brand Logo Enhancement */
.sidebar-brand .brand-logo__image {
    width: 58px !important;
    height: 58px !important;
    object-fit: contain;
    filter: drop-shadow(0 8px 14px rgba(212, 168, 79, 0.35));
    transition: transform 0.25s ease, filter 0.25s ease;
}

.sidebar-brand .brand-logo__image:hover {
    transform: scale(1.08);
    filter: drop-shadow(0 10px 20px rgba(212, 168, 79, 0.55));
}

.sidebar-brand .brand-logo {
    display: flex;
    align-items: center;
    gap: 14px;
}


/* Sidebar branding refinement */
.sidebar-brand .brand-copy strong {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.05em;
}

.sidebar-brand .brand-copy small {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

/* === NANN TAW 2026-08-11: Actual costing + finance modal refinements === */
.actual-costing-panel {
    overflow: hidden;
}
.actual-costing-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.actual-costing-help {
    margin: -4px 0 18px;
    color: var(--text-muted);
    line-height: 1.6;
}
.actual-costing-kpis {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.actual-cost-kpi {
    min-width: 0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.actual-cost-kpi small {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .035em;
}
.actual-cost-kpi strong {
    display: block;
    min-width: 0;
    max-width: 100%;
    font-size: clamp(18px, 2vw, 26px);
    line-height: 1.05;
    overflow-wrap: anywhere;
    word-break: break-word;
    font-variant-numeric: tabular-nums;
}
.actual-cost-kpi span {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
}
.actual-cost-kpi--total {
    border-color: rgba(212, 168, 79, .38);
}
.actual-costing-entry-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 18px 0 24px;
}
.actual-costing-form {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: rgba(255,255,255,.42);
}
.actual-costing-form h4,
.actual-costing-section-title {
    margin: 0 0 14px;
}
.actual-costing-inline-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.partial-sheet-box {
    margin: 6px 0 16px;
    padding: 14px;
    border: 1px solid rgba(212,168,79,.36);
    border-radius: 12px;
    background: rgba(212,168,79,.08);
}
.partial-sheet-box[hidden] { display: none !important; }
.partial-sheet-heading {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 10px;
}
.partial-sheet-heading small {
    display: block;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 4px;
}
.switch-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 700;
}
.form-help {
    display: block;
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.45;
}
.cost-payment-details summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 700;
    font-size: 12px;
    margin-bottom: 8px;
}
.cost-payment-form {
    display: grid;
    gap: 6px;
    min-width: 210px;
    margin-bottom: 8px;
}
.actual-costing-finalize {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.page-projects .reopen-costing-details {
    position: relative;
    display: inline-block;
    max-width: 100%;
}
.page-projects .reopen-costing-details > summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 13px;
    border: 1px solid rgba(217, 142, 0, .35);
    border-radius: 9px;
    background: rgba(245, 158, 11, .10);
    color: #a45f00;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    list-style: none;
    white-space: nowrap;
}
.page-projects .reopen-costing-details > summary::-webkit-details-marker {
    display: none;
}
.page-projects .reopen-costing-details > summary:hover {
    background: rgba(245, 158, 11, .16);
    border-color: rgba(217, 142, 0, .5);
}
.page-projects .reopen-costing-details[open] > summary {
    background: rgba(245, 158, 11, .16);
}
.page-projects .reopen-costing-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 8px;
    align-items: center;
    width: min(470px, calc(100vw - 56px));
    margin-top: 8px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-card-solid);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
}
.page-projects .reopen-costing-form .form-control {
    min-width: 0;
    height: 36px;
}
.page-projects .reopen-costing-form .btn {
    min-height: 36px;
    white-space: nowrap;
}
@media (max-width: 620px) {
    .page-projects .reopen-costing-form {
        grid-template-columns: 1fr;
        width: min(100%, calc(100vw - 56px));
    }
}

.finance-payment-open { overflow: hidden !important; }
.finance-payment-modal-overlay {
    position: fixed !important;
    inset: 0;
    z-index: 1050;
    width: 100%;
    height: 100dvh;
    padding: 12px;
    overflow: hidden !important;
    background: rgba(0,0,0,.52);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}
.finance-payment-modal {
    position: relative;
    width: min(620px, 100%);
    max-width: 620px;
    max-height: calc(100dvh - 24px);
    margin: 0 !important;
    padding: 0 24px 0 !important;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg-card-solid);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(0,0,0,.3);
}
.finance-payment-modal-close {
    position: sticky;
    top: 12px;
    z-index: 7;
    float: right;
    width: 34px;
    height: 34px;
    margin: 10px -10px -44px 0;
    border: 0;
    border-radius: 50%;
    background: rgba(148,163,184,.14);
    color: var(--text-muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}
.finance-payment-modal-close:hover { color: var(--text); background: rgba(148,163,184,.24); }

.finance-payment-modal-title {
    position: sticky;
    top: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 -24px 18px;
    padding: 20px 54px 16px 24px;
    color: var(--text);
    font-weight: 700;
    background: var(--bg-card-solid);
    border-bottom: 1px solid var(--border-color);
}
.finance-payment-method-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.finance-payment-modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 4;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin: 8px -24px 0;
    padding: 14px 24px 18px;
    background: var(--bg-card-solid);
    border-top: 1px solid var(--border-color);
}

@media (max-width: 1180px) {
    .actual-costing-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .actual-cost-kpi--total { grid-column: span 2; }
}
@media (max-width: 850px) {
    .actual-costing-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .actual-cost-kpi--total { grid-column: auto; }
    .actual-costing-entry-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
    .actual-costing-kpis { grid-template-columns: 1fr; }
    .actual-costing-inline-grid { grid-template-columns: 1fr; }
    .partial-sheet-heading { flex-direction: column; }
    .finance-payment-modal-overlay { padding: 0; align-items: stretch; }
    .finance-payment-modal {
        width: 100%;
        max-width: none;
        max-height: 100dvh;
        min-height: 100dvh;
        border-radius: 0;
        border: 0;
    }
    .finance-payment-method-grid { grid-template-columns: 1fr; }
    .finance-payment-modal-footer {
        flex-wrap: wrap;
    }
    .finance-payment-modal-footer .btn { flex: 1 1 140px; }
}

/* === NANN TAW R4.1 UI hotfix: project detail ordering + costing readability === */
/* .col-main is a flex container. Unordered children default to order:0, which
   previously pulled Actual Job Costing above Creative Designs. Keep the
   requested operational sequence explicit. */
.page-projects .project-designs-panel { order: 1; }
.page-projects .production-workflow-panel { order: 2; }
.page-projects .actual-costing-panel { order: 3; }
.page-projects .project-installation-panel { order: 4; }

/* The costing panel lives in the narrower main column beside Job Details.
   Use two roomy KPI columns rather than five viewport-driven columns. */
.page-projects .actual-costing-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.page-projects .actual-cost-kpi {
    min-height: 122px;
    justify-content: center;
    padding: 18px 20px;
}
.page-projects .actual-cost-kpi strong {
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
    font-size: clamp(22px, 2.1vw, 30px);
    line-height: 1.05;
    letter-spacing: -0.02em;
}
.page-projects .actual-cost-kpi--total {
    grid-column: 1 / -1;
}

/* Ledger tables contain audit-grade detail. Preserve readable columns and let
   the table scroll horizontally instead of breaking dates/amounts into letters. */
.page-projects .actual-costing-panel .table-responsive {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: auto;
}
.page-projects .actual-costing-panel .table-responsive > .data-table {
    min-width: 980px;
    table-layout: auto;
}
.page-projects .actual-costing-panel .data-table th {
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
}
.page-projects .actual-costing-panel .data-table td {
    word-break: normal;
    overflow-wrap: normal;
    vertical-align: top;
}
.page-projects .actual-costing-panel .data-table td:nth-child(1),
.page-projects .actual-costing-panel .data-table td:nth-child(4),
.page-projects .actual-costing-panel .data-table td:nth-child(5),
.page-projects .actual-costing-panel .data-table td:nth-child(6) {
    white-space: nowrap;
}
.page-projects .actual-costing-panel .cost-payment-form {
    min-width: 240px;
}

@media (max-width: 1024px) {
    .page-projects .actual-costing-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 620px) {
    .page-projects .actual-costing-kpis {
        grid-template-columns: 1fr;
    }
    .page-projects .actual-cost-kpi--total {
        grid-column: auto;
    }
    .page-projects .actual-cost-kpi strong {
        font-size: clamp(22px, 8vw, 30px);
    }
}

/* === NANN TAW R4.5: native-scroll professional actual-costing ledger component ===
   IMPORTANT: these ledgers deliberately do NOT use the global .data-table /
   .table-responsive classes. The global desktop table system hides horizontal
   overflow and forces normal tables to width:100%; audit ledgers need the
   opposite behavior: fixed readable cells inside a dedicated scroll viewport. */
.page-projects .col-main,
.page-projects .actual-costing-panel {
    min-width: 0 !important;
    max-width: 100% !important;
}

.page-projects .actual-costing-entry-grid {
    grid-template-columns: 1fr !important;
}

.page-projects .actual-costing-ledger-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 22px 0 10px;
}
.page-projects .actual-costing-ledger-heading .actual-costing-section-title {
    margin: 0;
}
/* Dedicated horizontal viewport. tabindex in markup makes keyboard scrolling
   available too; Shift+wheel/trackpad/touch work natively. */
.page-projects .actual-ledger-scroll {
    display: block !important;
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 0 !important;
    border: 1px solid #b9c9dc;
    border-radius: 11px;
    background: var(--bg-card-solid);
    box-shadow: 0 7px 20px rgba(31, 65, 105, 0.055);
    scrollbar-gutter: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(55, 82, 116, .62) rgba(148, 163, 184, .15);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
}
.page-projects .actual-ledger-scroll:focus-visible {
    outline: 2px solid rgba(212, 168, 79, .55);
    outline-offset: 2px;
}
.page-projects .actual-ledger-scroll::-webkit-scrollbar {
    height: 8px;
}
.page-projects .actual-ledger-scroll::-webkit-scrollbar-track {
    background: rgba(148, 163, 184, .15);
    border-radius: 999px;
    margin: 0 4px;
}
.page-projects .actual-ledger-scroll::-webkit-scrollbar-thumb {
    min-width: 72px;
    background: rgba(55, 82, 116, .62);
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}
.page-projects .actual-ledger-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(31, 79, 135, .82);
    background-clip: padding-box;
}


/* These tables are self-contained and intentionally wider than the project
   column. Never wrap audit values just to make them fit the card. */
.page-projects .actual-ledger-table {
    display: table;
    width: max-content !important;
    max-width: none !important;
    margin: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    table-layout: auto !important;
    text-align: left;
    color: var(--text-main);
}
.page-projects .actual-ledger-table--materials { min-width: 1370px !important; }
.page-projects .actual-ledger-table--direct-costs { min-width: 1290px !important; }
.page-projects .actual-ledger-table--payments { min-width: 1280px !important; }

.page-projects .actual-ledger-table thead tr {
    height: 44px !important;
}
.page-projects .actual-ledger-table tbody tr:not(.ledger-empty-row) {
    height: 54px !important;
}
.page-projects .actual-ledger-table th,
.page-projects .actual-ledger-table td {
    box-sizing: border-box;
    white-space: nowrap !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
    vertical-align: middle !important;
    text-align: left;
}
.page-projects .actual-ledger-table thead th {
    height: 44px !important;
    padding: 0 13px !important;
    background: #1f4f87 !important;
    border-right: 1px solid rgba(255, 255, 255, .24) !important;
    border-bottom: 1px solid #173d6a !important;
    color: #fff !important;
    font-size: 10px !important;
    font-weight: 750 !important;
    line-height: 1 !important;
    letter-spacing: .045em !important;
    text-transform: uppercase;
    text-shadow: 0 1px 1px rgba(4, 22, 44, .16);
}
.page-projects .actual-ledger-table thead th:last-child {
    border-right: 0 !important;
}
.page-projects .actual-ledger-table tbody td {
    height: 54px !important;
    padding: 0 13px !important;
    border-right: 1px solid rgba(139, 162, 190, .40) !important;
    border-bottom: 1px solid rgba(139, 162, 190, .40) !important;
    background: rgba(255,255,255,.015);
    color: var(--text-main);
    font-size: 11.5px !important;
    font-weight: 550;
    line-height: 1.15 !important;
    font-variant-numeric: tabular-nums;
}
.page-projects .actual-ledger-table tbody td:last-child {
    border-right: 0 !important;
}
.page-projects .actual-ledger-table tbody tr:last-child td {
    border-bottom: 0 !important;
}
.page-projects .actual-ledger-table tbody tr:hover td {
    background: rgba(56, 103, 158, .11) !important;
}
body.light-theme .page-projects .actual-ledger-table tbody td {
    background: #fff;
    color: #26384e;
    border-right-color: #c6d3e2 !important;
    border-bottom-color: #c6d3e2 !important;
}
body.light-theme .page-projects .actual-ledger-table tbody tr:nth-child(even) td {
    background: #f7faff;
}
body.light-theme .page-projects .actual-ledger-table tbody tr:hover td {
    background: #e8f0fa !important;
}

/* Column standards: every normal value fits on one line. The viewport scrolls
   horizontally instead of squeezing or wrapping the table. */
.page-projects .actual-ledger-table--materials th:nth-child(1),
.page-projects .actual-ledger-table--materials td:nth-child(1) { min-width: 158px; }
.page-projects .actual-ledger-table--materials th:nth-child(2),
.page-projects .actual-ledger-table--materials td:nth-child(2) { min-width: 190px; }
.page-projects .actual-ledger-table--materials th:nth-child(3),
.page-projects .actual-ledger-table--materials td:nth-child(3) { min-width: 155px; }
.page-projects .actual-ledger-table--materials th:nth-child(4),
.page-projects .actual-ledger-table--materials td:nth-child(4) { min-width: 140px; }
.page-projects .actual-ledger-table--materials th:nth-child(5),
.page-projects .actual-ledger-table--materials td:nth-child(5) { min-width: 155px; }
.page-projects .actual-ledger-table--materials th:nth-child(6),
.page-projects .actual-ledger-table--materials td:nth-child(6),
.page-projects .actual-ledger-table--materials th:nth-child(7),
.page-projects .actual-ledger-table--materials td:nth-child(7) { min-width: 125px; }
.page-projects .actual-ledger-table--materials th:nth-child(8),
.page-projects .actual-ledger-table--materials td:nth-child(8) { min-width: 260px; }
.page-projects .actual-ledger-table--materials th:nth-child(9),
.page-projects .actual-ledger-table--materials td:nth-child(9) { min-width: 145px; }

.page-projects .actual-ledger-table--direct-costs th:nth-child(1),
.page-projects .actual-ledger-table--direct-costs td:nth-child(1) { min-width: 158px; }
.page-projects .actual-ledger-table--direct-costs th:nth-child(2),
.page-projects .actual-ledger-table--direct-costs td:nth-child(2) { min-width: 190px; }
.page-projects .actual-ledger-table--direct-costs th:nth-child(3),
.page-projects .actual-ledger-table--direct-costs td:nth-child(3) { min-width: 105px; }
.page-projects .actual-ledger-table--direct-costs th:nth-child(4),
.page-projects .actual-ledger-table--direct-costs td:nth-child(4),
.page-projects .actual-ledger-table--direct-costs th:nth-child(5),
.page-projects .actual-ledger-table--direct-costs td:nth-child(5),
.page-projects .actual-ledger-table--direct-costs th:nth-child(6),
.page-projects .actual-ledger-table--direct-costs td:nth-child(6) { min-width: 110px; }
.page-projects .actual-ledger-table--direct-costs th:nth-child(7),
.page-projects .actual-ledger-table--direct-costs td:nth-child(7) { min-width: 170px; }
.page-projects .actual-ledger-table--direct-costs th:nth-child(8),
.page-projects .actual-ledger-table--direct-costs td:nth-child(8) { min-width: 285px; }
.page-projects .actual-ledger-table--direct-costs th:nth-child(9),
.page-projects .actual-ledger-table--direct-costs td:nth-child(9) { min-width: 145px; }

.page-projects .actual-ledger-table--payments th:nth-child(1),
.page-projects .actual-ledger-table--payments td:nth-child(1) { min-width: 158px; }
.page-projects .actual-ledger-table--payments th:nth-child(2),
.page-projects .actual-ledger-table--payments td:nth-child(2) { min-width: 165px; }
.page-projects .actual-ledger-table--payments th:nth-child(3),
.page-projects .actual-ledger-table--payments td:nth-child(3) { min-width: 190px; }
.page-projects .actual-ledger-table--payments th:nth-child(4),
.page-projects .actual-ledger-table--payments td:nth-child(4) { min-width: 160px; }
.page-projects .actual-ledger-table--payments th:nth-child(5),
.page-projects .actual-ledger-table--payments td:nth-child(5) { min-width: 150px; }
.page-projects .actual-ledger-table--payments th:nth-child(6),
.page-projects .actual-ledger-table--payments td:nth-child(6) { min-width: 120px; }
.page-projects .actual-ledger-table--payments th:nth-child(7),
.page-projects .actual-ledger-table--payments td:nth-child(7) { min-width: 280px; }
.page-projects .actual-ledger-table--payments th:nth-child(8),
.page-projects .actual-ledger-table--payments td:nth-child(8) { min-width: 145px; }

.page-projects .actual-ledger-table .ledger-date,
.page-projects .actual-ledger-table .ledger-material,
.page-projects .actual-ledger-table .ledger-notes,
.page-projects .actual-ledger-table .ledger-actions,
.page-projects .actual-ledger-table .actual-costing-subline {
    white-space: nowrap !important;
}
.page-projects .actual-ledger-table .actual-costing-subline {
    display: inline !important;
    margin-left: 5px;
    color: var(--text-muted);
    font-size: 10.5px;
    line-height: inherit;
}
.page-projects .actual-ledger-table .ledger-notes {
    max-width: none !important;
    overflow: visible !important;
    text-overflow: clip !important;
}
.page-projects .actual-ledger-table .ledger-muted {
    color: var(--text-muted);
    font-size: 11px;
}

/* Action UI stays compact while closed, preserving standard row height. */
.page-projects .ledger-action-details {
    min-width: 102px;
}
.page-projects .ledger-action-details > summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 88px;
    height: 32px;
    padding: 0 11px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(148, 163, 184, .10);
    color: var(--text-main);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
    white-space: nowrap;
}
.page-projects .ledger-action-details > summary::-webkit-details-marker { display: none; }
.page-projects .ledger-action-details[open] > summary {
    border-color: rgba(212, 168, 79, .45);
    background: rgba(212, 168, 79, .10);
}
.page-projects .ledger-action-panel {
    display: grid;
    gap: 12px;
    min-width: 330px;
    margin-top: 10px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-card-solid);
}
.page-projects .ledger-action-group {
    display: grid;
    gap: 8px;
}
.page-projects .ledger-action-group + .ledger-action-group {
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}
.page-projects .ledger-action-group > strong { font-size: 12px; }
.page-projects .ledger-action-form {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) auto;
    gap: 8px;
    min-width: 300px;
    align-items: center;
}
.page-projects .ledger-action-form .form-control { min-width: 0; }
.page-projects .ledger-action-form .form-control:not(:first-of-type),
.page-projects .ledger-action-form select,
.page-projects .ledger-action-form input[type="datetime-local"] { grid-column: 1 / -1; }
.page-projects .ledger-action-form .btn { white-space: nowrap; }

/* Empty/pre-entry state stays compact and does not show a meaningless scrollbar. */
.page-projects .actual-ledger-scroll.is-empty {
    overflow-x: hidden !important;
    padding-bottom: 0 !important;
}
.page-projects .actual-ledger-scroll.is-empty .actual-ledger-table {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    table-layout: auto !important;
}
.page-projects .actual-ledger-scroll.is-empty .ledger-empty-row,
.page-projects .actual-ledger-scroll.is-empty .ledger-empty-state {
    height: 68px !important;
}
.page-projects .ledger-empty-state {
    text-align: center !important;
    color: var(--text-muted) !important;
    white-space: normal !important;
    padding: 16px 20px !important;
}

@media (max-width: 620px) {
    .page-projects .actual-costing-ledger-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }
    .page-projects .actual-ledger-table tbody td { font-size: 11px !important; }
}

@media print {
    .page-projects .actual-ledger-scroll {
        overflow: visible !important;
        padding-bottom: 0 !important;
        box-shadow: none !important;
    }
    .page-projects .actual-ledger-table {
        min-width: 100% !important;
        width: 100% !important;
        font-size: 9px !important;
    }
}


/* R4.6 - direct paid job-material purchase lines */
.page-projects .actual-cost-form-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}
.page-projects .actual-cost-form-heading h4 { margin: 0 0 5px; }
.page-projects .actual-cost-form-heading .form-help { margin: 0; max-width: 720px; }
.page-projects .direct-material-lines {
    display: grid;
    gap: 12px;
    margin: 8px 0 14px;
}
.page-projects .direct-material-line {
    display: grid;
    grid-template-columns: minmax(180px, 2fr) minmax(80px, .65fr) minmax(90px, .8fr) minmax(130px, 1fr);
    gap: 10px 12px;
    align-items: end;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255,255,255,.55);
}
.page-projects .direct-material-line .form-group { margin: 0; min-width: 0; }
.page-projects .direct-material-total,
.page-projects .direct-material-line select[name="purchase_payment_method[]"] { min-width: 0; }
.page-projects .direct-material-total-display {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    border-radius: 9px;
    background: rgba(15, 23, 42, .035);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.page-projects .direct-material-notes { grid-column: span 3; }
.page-projects .direct-material-line-action {
    display: flex;
    align-items: end;
    justify-content: flex-end;
    min-height: 42px;
}
@media (max-width: 900px) {
    .page-projects .direct-material-line { grid-template-columns: 1fr 1fr; }
    .page-projects .direct-material-notes { grid-column: 1 / -1; }
    .page-projects .direct-material-line-action { grid-column: 1 / -1; justify-content: flex-end; }
}
@media (max-width: 560px) {
    .page-projects .actual-cost-form-heading { flex-direction: column; }
    .page-projects .direct-material-line { grid-template-columns: 1fr; }
    .page-projects .direct-material-notes,
    .page-projects .direct-material-line-action { grid-column: auto; }
}

/* === NANN TAW R4.7: Project workspace hierarchy & costing usability ===
   Operational sequence: Creative Designs -> Production Workflow -> Installation -> Cost & Close-out.
   This section intentionally overrides earlier project ordering rules. */
.page-projects .project-designs-panel { order: 1 !important; }
.page-projects .production-workflow-panel { order: 2 !important; margin-bottom: 14px; }
.page-projects .project-installation-panel { order: 3 !important; margin-bottom: 30px; }
.page-projects .actual-costing-break { order: 4 !important; }
.page-projects .actual-costing-panel { order: 5 !important; }

/* Keep installation visually attached to the production workflow while still
   reading as its final operational step. */
.page-projects .project-installation-panel {
    position: relative;
    padding: 24px 28px;
    border-color: rgba(37, 99, 235, .18);
    box-shadow: 0 8px 24px rgba(31, 65, 105, .055);
}
.page-projects .project-installation-panel::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    border-radius: 16px 0 0 16px;
    background: linear-gradient(180deg, #2f6fb0 0%, #d4a84f 100%);
}
.page-projects .project-installation-panel .panel-title {
    margin-bottom: 16px;
}
.page-projects .installation-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
    font-size: 13px;
}
.page-projects .installation-summary-grid > div {
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid rgba(148, 163, 184, .20);
    border-radius: 11px;
    background: rgba(248, 250, 252, .72);
}
.page-projects .installation-summary-grid > div > p {
    margin: 0 0 3px !important;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .025em;
    text-transform: uppercase;
}
.page-projects .installation-summary-grid > div > strong,
.page-projects .installation-summary-grid > div > .badge {
    font-size: 13px;
}
.page-projects .installation-evidence,
.page-projects .installation-complete-form {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}
.page-projects .installation-evidence h4,
.page-projects .installation-complete-form h4 {
    margin: 0 0 12px;
    font-size: 13px;
}
.page-projects .installation-evidence-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 4px;
}
.page-projects .installation-evidence-grid img {
    display: block;
    width: 100% !important;
    max-height: 180px !important;
    border-radius: 10px !important;
    object-fit: cover;
}

/* A quiet separator makes Actual Job Costing read as financial close-out,
   not as another production task. */
.page-projects .project-section-break {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 2px 0 12px;
    color: #7a8798;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.page-projects .project-section-break::before,
.page-projects .project-section-break::after {
    content: "";
    height: 1px;
    flex: 1;
    background: rgba(148, 163, 184, .26);
}

/* Costing summary: denser information hierarchy without squeezing figures. */
.page-projects .actual-costing-panel {
    padding: 26px 28px;
}
.page-projects .actual-costing-help {
    max-width: 760px;
    margin-bottom: 16px;
    font-size: 13px;
}
.page-projects .actual-costing-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 10px !important;
    margin-bottom: 18px;
}
.page-projects .actual-cost-kpi {
    min-height: 94px !important;
    padding: 14px 16px !important;
    justify-content: center;
    border-radius: 12px;
}
.page-projects .actual-cost-kpi small {
    font-size: 10px;
}
.page-projects .actual-cost-kpi strong {
    font-size: clamp(20px, 1.8vw, 25px) !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}
.page-projects .actual-cost-kpi--total {
    grid-column: span 2 !important;
    background: linear-gradient(135deg, rgba(212,168,79,.10), rgba(255,255,255,.65));
}

/* Entry tools are collapsed by default. The page stays scannable; the user
   expands only the accounting action they are performing. */
.page-projects .actual-costing-entry-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    margin: 16px 0 22px !important;
}
.page-projects .actual-cost-entry-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid #d7e0ea;
    border-radius: 12px;
    background: rgba(255,255,255,.72);
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.page-projects .actual-cost-entry-card[open] {
    border-color: rgba(47,111,176,.32);
    background: #fff;
    box-shadow: 0 8px 22px rgba(31,65,105,.06);
}
.page-projects .actual-cost-entry-card > summary {
    display: grid;
    grid-template-columns: 38px minmax(0,1fr) 24px;
    gap: 11px;
    align-items: center;
    min-height: 66px;
    padding: 10px 14px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.page-projects .actual-cost-entry-card > summary::-webkit-details-marker { display: none; }
.page-projects .actual-cost-entry-card > summary:hover { background: rgba(47,111,176,.035); }
.page-projects .actual-cost-entry-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(47,111,176,.09);
    color: #275f9a;
    font-size: 14px;
}
.page-projects .actual-cost-entry-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}
.page-projects .actual-cost-entry-copy strong {
    color: var(--text-main);
    font-size: 13px;
    font-weight: 800;
}
.page-projects .actual-cost-entry-copy small {
    overflow: hidden;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.page-projects .actual-cost-entry-chevron {
    color: #8794a4;
    text-align: center;
    transition: transform .18s ease;
}
.page-projects .actual-cost-entry-card[open] .actual-cost-entry-chevron { transform: rotate(180deg); }
.page-projects .actual-cost-entry-body {
    padding: 0 14px 14px;
    border-top: 1px solid #e5ebf2;
}
.page-projects .actual-cost-entry-body .actual-costing-form {
    margin: 0;
    padding: 16px 2px 2px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
}
/* The disclosure header already names the action. Suppress redundant form title. */
.page-projects #cost-entry-inventory .actual-costing-form > h4,
.page-projects #cost-entry-direct-cost .actual-costing-form > h4,
.page-projects #cost-entry-direct-material .actual-cost-form-heading h4 {
    display: none;
}
.page-projects #cost-entry-direct-material .actual-cost-form-heading {
    margin-bottom: 10px;
}
.page-projects #cost-entry-direct-material .actual-cost-form-heading > div {
    min-width: 0;
}

/* Keep ledger region visually subordinate to entry/summary controls. */
.page-projects .actual-costing-ledger-heading {
    margin-top: 18px;
}
.page-projects .actual-costing-section-title {
    font-size: 13px;
    letter-spacing: .01em;
}

@media (max-width: 1180px) {
    .page-projects .actual-costing-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    .page-projects .actual-cost-kpi--total { grid-column: span 1 !important; }
}
@media (max-width: 720px) {
    .page-projects .project-installation-panel,
    .page-projects .actual-costing-panel { padding: 20px; }
    .page-projects .installation-summary-grid,
    .page-projects .installation-evidence-grid { grid-template-columns: 1fr; }
    .page-projects .actual-costing-kpis { grid-template-columns: 1fr !important; }
    .page-projects .actual-cost-entry-card > summary {
        grid-template-columns: 36px minmax(0,1fr) 20px;
        padding-inline: 12px;
    }
    .page-projects .actual-cost-entry-copy small {
        white-space: normal;
        text-overflow: clip;
    }
}
@media print {
    .page-projects .project-section-break { display: none !important; }
    .page-projects .actual-cost-entry-card > summary { display: none !important; }
    .page-projects .actual-cost-entry-card:not([open]) .actual-cost-entry-body { display: none !important; }
}

/* === NANN TAW R4.9: Actual-cost form polish & external-labor cash semantics === */
.page-projects .direct-material-line {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 12px !important;
    align-items: end;
}
.page-projects .direct-material-name { grid-column: 1 / -1; }
.page-projects .direct-material-qty-field { grid-column: span 2; }
.page-projects .direct-material-unit-field { grid-column: span 2; }
.page-projects .direct-material-unit-cost-field { grid-column: span 2; }
.page-projects .direct-material-total { grid-column: span 3; }
.page-projects .direct-material-payment { grid-column: span 3; }
.page-projects .direct-material-notes { grid-column: span 5 !important; }
.page-projects .direct-material-line-action { grid-column: span 1; }
.page-projects .direct-material-total-display,
.page-projects .direct-material-payment select {
    width: 100%;
    min-height: 44px;
}
.page-projects .direct-material-line-action .btn {
    min-width: 44px;
    min-height: 44px;
}

.page-projects .direct-cost-paid-now-lock {
    min-height: 48px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 13px;
    border: 1px solid rgba(16, 185, 129, .32);
    border-radius: 10px;
    background: rgba(16, 185, 129, .08);
    color: #047857;
}
.page-projects .direct-cost-paid-now-lock[hidden] { display: none !important; }
.page-projects .direct-cost-paid-now-lock > i { font-size: 17px; flex: 0 0 auto; }
.page-projects .direct-cost-paid-now-lock span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-projects .direct-cost-paid-now-lock strong { font-size: 13px; line-height: 1.2; }
.page-projects .direct-cost-paid-now-lock small { color: #4b635b; font-size: 10px; line-height: 1.35; }

@media (max-width: 760px) {
    .page-projects .direct-material-line {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    .page-projects .direct-material-name,
    .page-projects .direct-material-unit-cost-field,
    .page-projects .direct-material-notes,
    .page-projects .direct-material-line-action { grid-column: 1 / -1 !important; }
    .page-projects .direct-material-qty-field,
    .page-projects .direct-material-unit-field,
    .page-projects .direct-material-total,
    .page-projects .direct-material-payment { grid-column: span 1; }
    .page-projects .direct-material-line-action { justify-content: flex-end; }
}

@media (max-width: 520px) {
    .page-projects .direct-material-line { grid-template-columns: 1fr !important; }
    .page-projects .direct-material-name,
    .page-projects .direct-material-qty-field,
    .page-projects .direct-material-unit-field,
    .page-projects .direct-material-unit-cost-field,
    .page-projects .direct-material-total,
    .page-projects .direct-material-payment,
    .page-projects .direct-material-notes,
    .page-projects .direct-material-line-action { grid-column: 1 !important; }
}

/* === NANN TAW R4.10: Production fabrication cutting UI === */
.page-projects .fabrication-cut-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.page-projects .fabrication-profile-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 15px;
    border: 1px solid rgba(31, 79, 135, .20);
    border-radius: 12px;
    background: rgba(31, 79, 135, .055);
}
.page-projects .fabrication-profile-banner[hidden] { display: none !important; }
.page-projects .fabrication-profile-banner > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.page-projects .fabrication-profile-kicker {
    color: var(--primary);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.page-projects .fabrication-profile-banner strong {
    color: var(--text-main);
    font-size: 13px;
    line-height: 1.25;
}
.page-projects .fabrication-profile-banner small {
    color: var(--text-muted);
    font-size: 10.5px;
    line-height: 1.4;
}
.page-projects .fabrication-source-size {
    flex: 0 0 auto;
    max-width: 42%;
    padding: 7px 10px;
    border: 1px solid rgba(31, 79, 135, .15);
    border-radius: 999px;
    background: var(--card-bg);
    color: var(--text-main);
    font-size: 10.5px;
    font-weight: 750;
    white-space: nowrap;
}
.page-projects .fabrication-dimension-toolbar,
.page-projects .fabrication-measure-grid,
.page-projects .fabrication-advanced-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.page-projects .fabrication-dimension-toolbar[hidden],
.page-projects .fabrication-measure-grid[hidden],
.page-projects .fabrication-advanced[hidden],
.page-projects .fabrication-cut-note[hidden] { display: none !important; }
.page-projects .fabrication-dimension-toolbar .form-group,
.page-projects .fabrication-measure-grid .form-group,
.page-projects .fabrication-advanced-grid .form-group { margin: 0; min-width: 0; }
.page-projects .fabrication-measure-span { grid-column: 1 / -1; }
.page-projects .fabrication-advanced {
    border: 1px solid #dfe7f0;
    border-radius: 11px;
    overflow: hidden;
    background: rgba(248, 250, 252, .55);
}
.page-projects .fabrication-advanced > summary {
    padding: 11px 13px;
    cursor: pointer;
    color: var(--text-main);
    font-size: 11px;
    font-weight: 750;
    list-style: none;
}
.page-projects .fabrication-advanced > summary::-webkit-details-marker { display: none; }
.page-projects .fabrication-advanced > summary i { margin-right: 6px; color: var(--primary); }
.page-projects .fabrication-advanced-grid {
    padding: 0 13px 13px;
    border-top: 1px solid #e8edf3;
    padding-top: 13px;
}
.page-projects .fabrication-toggle-stack {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    min-width: 0;
}
.page-projects .fabrication-toggle-stack .switch-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0;
    color: var(--text-main);
    font-size: 11px;
    line-height: 1.35;
}
.page-projects .fabrication-toggle-stack input { margin-top: 2px; flex: 0 0 auto; }
.page-projects .fabrication-switch-copy {
    display: block;
    min-width: 0;
}
.page-projects .fabrication-switch-copy > strong {
    display: block;
    font-size: 11px;
    line-height: 1.35;
}
.page-projects .fabrication-switch-copy .form-help {
    margin-top: 3px;
    font-weight: 500;
}
.page-projects .fabrication-cut-note {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 10px 12px;
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    background: rgba(31, 79, 135, .045);
    color: var(--text-muted);
    font-size: 10.5px;
    line-height: 1.45;
}
.page-projects .fabrication-cut-note i { margin-top: 2px; color: var(--primary); }
.page-projects .ledger-cut-details {
    min-width: 210px;
}
.page-projects .ledger-cut-details small {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 9.5px;
    font-weight: 650;
}

/* R4.10 material ledger has a dedicated Cut Details column. Keep every audit
   value on one line and let the existing native horizontal scrollbar do its job. */
.page-projects .actual-ledger-table--materials { min-width: 1665px !important; }
.page-projects .actual-ledger-table--materials th:nth-child(1),
.page-projects .actual-ledger-table--materials td:nth-child(1) { min-width: 158px; }
.page-projects .actual-ledger-table--materials th:nth-child(2),
.page-projects .actual-ledger-table--materials td:nth-child(2) { min-width: 190px; }
.page-projects .actual-ledger-table--materials th:nth-child(3),
.page-projects .actual-ledger-table--materials td:nth-child(3) { min-width: 155px; }
.page-projects .actual-ledger-table--materials th:nth-child(4),
.page-projects .actual-ledger-table--materials td:nth-child(4) { min-width: 140px; }
.page-projects .actual-ledger-table--materials th:nth-child(5),
.page-projects .actual-ledger-table--materials td:nth-child(5) { min-width: 155px; }
.page-projects .actual-ledger-table--materials th:nth-child(6),
.page-projects .actual-ledger-table--materials td:nth-child(6) { min-width: 220px; }
.page-projects .actual-ledger-table--materials th:nth-child(7),
.page-projects .actual-ledger-table--materials td:nth-child(7),
.page-projects .actual-ledger-table--materials th:nth-child(8),
.page-projects .actual-ledger-table--materials td:nth-child(8) { min-width: 125px; }
.page-projects .actual-ledger-table--materials th:nth-child(9),
.page-projects .actual-ledger-table--materials td:nth-child(9) { min-width: 260px; }
.page-projects .actual-ledger-table--materials th:nth-child(10),
.page-projects .actual-ledger-table--materials td:nth-child(10) { min-width: 145px; }

/* Inventory stock dimension entry: the selector is intentionally compact and
   custom dimensions use the chosen engineering unit while storage stays in ft. */
.page-inventory #dimension-unit-group[hidden],
.page-inventory #edit-dimension-unit-group[hidden] { display: none !important; }

@media (max-width: 720px) {
    .page-projects .fabrication-profile-banner {
        align-items: flex-start;
        flex-direction: column;
    }
    .page-projects .fabrication-source-size { max-width: 100%; white-space: normal; }
    .page-projects .fabrication-dimension-toolbar,
    .page-projects .fabrication-measure-grid,
    .page-projects .fabrication-advanced-grid { grid-template-columns: 1fr; }
    .page-projects .fabrication-measure-span { grid-column: auto; }
}

/* R4.10.2 - Professional numeric entry controls.
   Keep semantic input[type=number] validation/mobile keyboards, but remove the
   browser spinner arrows. They are too easy to click accidentally on costing,
   dimensions, quantities and finance fields. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* R4.10.6 - compact, readable Actual Costing finalize gate */
.page-projects .actual-costing-finalize:has(.costing-finalize-gate) {
    justify-content: stretch;
}
.page-projects .costing-finalize-gate {
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid rgba(217, 142, 0, .24);
    border-radius: 12px;
    background: rgba(245, 158, 11, .07);
    color: var(--text-primary);
}
.page-projects .costing-finalize-gate__icon {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: rgba(245, 158, 11, .14);
    color: #b56a00;
    font-size: 13px;
}
.page-projects .costing-finalize-gate__content {
    flex: 1 1 auto;
    min-width: 0;
}
.page-projects .costing-finalize-gate__title {
    margin: 0 0 3px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.35;
}
.page-projects .costing-finalize-gate__text {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
}
.page-projects .costing-finalize-gate__stage {
    display: inline-block;
    margin-left: 3px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(245, 158, 11, .12);
    color: #a45f00;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .02em;
    white-space: nowrap;
    vertical-align: 1px;
}
.page-projects .costing-finalize-gate__sep {
    display: inline-block;
    padding: 0 5px;
    color: var(--text-muted);
}
@media (max-width: 620px) {
    .page-projects .costing-finalize-gate {
        gap: 10px;
        padding: 11px 12px;
    }
    .page-projects .costing-finalize-gate__sep {
        display: none;
    }
    .page-projects .costing-finalize-gate__text {
        font-size: 11.5px;
    }
}

/* === NANN TAW R4.10.7: full-width Cost & Close-out workspace ===
   Keep production/design/installation with contextual sidebar above. Financial
   close-out spans the complete project content width below that operational
   workspace so figures, entry forms and audit ledgers have maximum room. */
.page-projects .project-closeout-fullwidth {
    width: 100%;
    min-width: 0;
    margin-top: 28px;
}
.page-projects .project-closeout-fullwidth .actual-costing-break {
    width: 100%;
    margin: 0 0 12px;
}
.page-projects .project-closeout-fullwidth .actual-costing-panel {
    width: 100%;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0;
    padding: 26px 28px;
}

/* Use the newly available width instead of stacking the summary unnecessarily. */
.page-projects .project-closeout-fullwidth .actual-costing-kpis {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 12px !important;
}
.page-projects .project-closeout-fullwidth .actual-cost-kpi,
.page-projects .project-closeout-fullwidth .actual-cost-kpi--total {
    grid-column: auto !important;
    min-width: 0;
    min-height: 100px !important;
}
.page-projects .project-closeout-fullwidth .actual-cost-kpi strong {
    font-size: clamp(20px, 1.75vw, 27px) !important;
}

/* Entry cards remain true full-width actions. This is intentionally one action
   per row: no split cards and no dead half-column space. */
.page-projects .project-closeout-fullwidth .actual-costing-entry-grid,
.page-projects .project-closeout-fullwidth .actual-cost-entry-card,
.page-projects .project-closeout-fullwidth .actual-cost-entry-body,
.page-projects .project-closeout-fullwidth .actual-costing-form {
    width: 100%;
    max-width: none;
    min-width: 0;
}

/* Full-width close-out means the audit tables no longer need the oversized
   narrow-column dimensions from earlier releases. Preserve one-line rows and
   keep native horizontal scrolling only as a safety fallback for long notes or
   smaller screens. */
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials {
    min-width: 1280px !important;
}
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs {
    min-width: 1120px !important;
}
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments {
    min-width: 1050px !important;
}

.page-projects .project-closeout-fullwidth .actual-ledger-table--materials th:nth-child(1),
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials td:nth-child(1) { min-width: 126px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials th:nth-child(2),
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials td:nth-child(2) { min-width: 145px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials th:nth-child(3),
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials td:nth-child(3) { min-width: 118px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials th:nth-child(4),
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials td:nth-child(4) { min-width: 100px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials th:nth-child(5),
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials td:nth-child(5) { min-width: 110px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials th:nth-child(6),
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials td:nth-child(6) { min-width: 180px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials th:nth-child(7),
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials td:nth-child(7),
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials th:nth-child(8),
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials td:nth-child(8) { min-width: 90px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials th:nth-child(9),
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials td:nth-child(9) { min-width: 220px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials th:nth-child(10),
.page-projects .project-closeout-fullwidth .actual-ledger-table--materials td:nth-child(10) { min-width: 100px; }

/* The right-hand Job Details / Stage Activity column remains part of the upper
   operational workspace only. Completed production activity therefore keeps a
   dedicated readable area without squeezing Cost & Close-out. */
.page-projects .layout-two-cols {
    align-items: flex-start;
}
.page-projects .col-side {
    align-self: flex-start;
}

@media (max-width: 1180px) {
    .page-projects .project-closeout-fullwidth .actual-costing-kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}
@media (max-width: 820px) {
    .page-projects .project-closeout-fullwidth {
        margin-top: 20px;
    }
    .page-projects .project-closeout-fullwidth .actual-costing-panel {
        padding: 20px;
    }
    .page-projects .project-closeout-fullwidth .actual-costing-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}
@media (max-width: 560px) {
    .page-projects .project-closeout-fullwidth .actual-costing-kpis {
        grid-template-columns: 1fr !important;
    }
}

/* Compact direct-cost/payment column standards for the full-width close-out view. */
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs th:nth-child(1),
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs td:nth-child(1) { min-width: 126px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs th:nth-child(2),
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs td:nth-child(2) { min-width: 145px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs th:nth-child(3),
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs td:nth-child(3) { min-width: 85px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs th:nth-child(4),
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs td:nth-child(4),
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs th:nth-child(5),
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs td:nth-child(5),
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs th:nth-child(6),
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs td:nth-child(6) { min-width: 90px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs th:nth-child(7),
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs td:nth-child(7) { min-width: 140px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs th:nth-child(8),
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs td:nth-child(8) { min-width: 200px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs th:nth-child(9),
.page-projects .project-closeout-fullwidth .actual-ledger-table--direct-costs td:nth-child(9) { min-width: 100px; }

.page-projects .project-closeout-fullwidth .actual-ledger-table--payments th:nth-child(1),
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments td:nth-child(1) { min-width: 126px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments th:nth-child(2),
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments td:nth-child(2) { min-width: 145px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments th:nth-child(3),
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments td:nth-child(3) { min-width: 145px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments th:nth-child(4),
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments td:nth-child(4),
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments th:nth-child(5),
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments td:nth-child(5),
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments th:nth-child(6),
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments td:nth-child(6) { min-width: 100px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments th:nth-child(7),
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments td:nth-child(7) { min-width: 200px; }
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments th:nth-child(8),
.page-projects .project-closeout-fullwidth .actual-ledger-table--payments td:nth-child(8) { min-width: 100px; }

/* ==========================================================================
   R4.12 UI POLISH — global alignment, centered copy, professional icon rhythm
   ========================================================================== */

:root {
    --ui-control-height: 42px;
    --ui-control-radius: 12px;
    --ui-icon-badge-size: 34px;
    --ui-icon-soft-bg: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    --ui-icon-soft-text: #8a5a00;
}

html,
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Normalize text/icon vertical rhythm everywhere. */
.sidebar-menu a,
.menu-group-header,
.logout-btn,
.btn,
a.btn,
button.btn,
.table-pagination button,
.table-pagination .pagination-button,
.action-item__button,
.system-time,
.header-user,
.header-leading,
.filter-bar .btn,
.archive-filter-bar .btn,
.modal-footer .btn,
.inline-action-form .btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    line-height: 1.2;
    vertical-align: middle;
}

.sidebar-menu a,
.menu-group-header,
.logout-btn,
.header-user {
    justify-content: flex-start;
}

.btn,
a.btn,
button.btn,
.table-pagination button,
.table-pagination .pagination-button,
.action-item__button,
.filter-bar .btn,
.archive-filter-bar .btn,
.modal-footer .btn,
.inline-action-form .btn {
    min-height: var(--ui-control-height);
    border-radius: var(--ui-control-radius);
    font-weight: 600;
}

input,
select,
textarea,
.filter-bar input,
.filter-bar select,
.archive-filter-bar input,
.archive-filter-bar select {
    min-height: var(--ui-control-height);
    line-height: 1.25;
    border-radius: var(--ui-control-radius);
}

/* Headings with inline icons should sit on the same optical line. */
h1, h2, h3, h4, h5, h6,
.page-title,
.section-title,
.card-title,
.panel-title,
.modal-title {
    line-height: 1.25;
}

h1 i, h2 i, h3 i, h4 i, h5 i, h6 i,
.page-title i,
.section-title i,
.card-title i,
.panel-title i,
.modal-title i,
label i,
th i,
.system-time i,
.header-user i,
.btn i,
a.btn i,
button.btn i,
.sidebar-menu a i,
.menu-group-header i,
.logout-btn i {
    flex: 0 0 auto;
    vertical-align: middle;
    line-height: 1;
}

/* Base icon alignment fix for the local icon layer. */
i.fa-solid,
i.fa-regular,
i.fa-brands {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 1.2rem;
    height: 1.2rem;
    min-width: 1.2rem;
    min-height: 1.2rem;
    line-height: 1 !important;
    position: relative;
    top: 0;
    transform: none;
}

/* Sidebar icon badges. */
.sidebar-menu > li > a > i,
.menu-group-header .group-title > i,
.logout-btn > i {
    width: var(--ui-icon-badge-size) !important;
    height: var(--ui-icon-badge-size) !important;
    min-width: var(--ui-icon-badge-size) !important;
    min-height: var(--ui-icon-badge-size) !important;
    border-radius: 12px;
    background: var(--ui-icon-soft-bg);
    color: var(--ui-icon-soft-text) !important;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    font-size: 16px !important;
}

/* Submenu dots remain compact and aligned. */
.submenu a {
    padding-block: 10px;
}

.submenu a > i {
    width: 18px !important;
    min-width: 18px !important;
    height: 18px !important;
    min-height: 18px !important;
    font-size: 10px !important;
    color: var(--primary) !important;
}

/* Distinct group colors for a more professional colourful navigation. */
.sidebar-menu > li:nth-child(1) > a > i {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1d4ed8 !important;
}

#group-sales_customers .menu-group-header .group-title > i {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #15803d !important;
}
#group-operations_production .menu-group-header .group-title > i {
    background: linear-gradient(135deg, #ffedd5 0%, #fed7aa 100%);
    color: #c2410c !important;
}
#group-inventory_logistics .menu-group-header .group-title > i {
    background: linear-gradient(135deg, #cffafe 0%, #a5f3fc 100%);
    color: #0f766e !important;
}
#group-hr_payroll .menu-group-header .group-title > i {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #b45309 !important;
}
#group-finance_accounting .menu-group-header .group-title > i {
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
    color: #6d28d9 !important;
}
#group-system_admin .menu-group-header .group-title > i,
.logout-btn > i {
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
    color: #be185d !important;
}

/* Active nav items should remain crisp and centered. */
.sidebar-menu li.active > a,
.menu-group.expanded > .menu-group-header,
.submenu-active > a {
    align-items: center;
}

/* R4.14: active navigation must preserve the professional category icon palette.
   The old white-icon override was removed because it made the Dashboard SVG
   disappear on the light active background and could override group icons. */

body.light-theme .submenu-active > a {
    background: rgba(212, 168, 79, 0.12) !important;
    border-radius: 10px;
}

/* Header polish. */
.header-leading {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.header-title-block {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    gap: 4px;
}

.header-eyebrow {
    font-size: 12px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--primary);
}

.page-title {
    margin: 0;
    display: block;
}

.system-time,
.header-user {
    min-height: 44px;
    padding: 8px 14px;
    border-radius: 14px;
}

.header-user {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}

.header-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 12px;
    background: linear-gradient(135deg, #fde68a 0%, #f59e0b 100%);
    color: #4a2a00;
    font-weight: 800;
}

.header-user-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.15;
}

.header-user-copy strong {
    font-size: 14px;
}

.header-user-copy small {
    font-size: 11px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 2px;
}

/* Section headings and page-level action bars. */
.panel,
.card,
.module-card,
.content-card {
    overflow: hidden;
}

.panel h3,
.panel h4,
.section-header h3,
.section-header h4,
.card-header h3,
.card-header h4 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel h3 i,
.panel h4 i,
.section-header h3 i,
.section-header h4 i,
.card-header h3 i,
.card-header h4 i {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    border-radius: 10px;
    background: linear-gradient(135deg, #eef2ff 0%, #dbeafe 100%);
    color: #3b5ccc !important;
    box-shadow: inset 0 0 0 1px rgba(59, 92, 204, 0.08);
}

/* Button icons should align with button labels cleanly. */
.btn > i,
a.btn > i,
button.btn > i,
.action-item__button > i,
.table-pagination button > i,
.table-pagination .pagination-button > i {
    margin: 0;
}

/* Filter/search toolbars feel centered and consistent. */
.filter-bar,
.archive-filter-bar,
.page-archive .archive-filter-bar {
    align-items: center;
}

.filter-bar > *,
.archive-filter-bar > * {
    align-self: center;
}

/* Table cells and form copy get a tighter baseline so they no longer appear high/low. */
.data-table th,
.data-table td,
label,
.badge,
.status-badge,
.kpi-header,
.kpi-value,
.user-name,
.user-role,
.brand-copy strong,
.brand-copy small {
    line-height: 1.25;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-width: 0;
}

.brand-copy strong {
    font-size: 15px;
    letter-spacing: 0.04em;
}

.brand-copy small {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.brand-logo__image,
.brand-logo__fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    min-width: 54px;
    min-height: 54px;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
}

.brand-logo__image {
    object-fit: cover;
}

.brand-logo__fallback {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    color: #fbbf24;
}

/* KPI icons align nicely inside cards. */
.kpi-header {
    align-items: center;
}

.kpi-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    border-radius: 14px;
}

/* Modal and form titles. */
.modal-header,
.card-header,
.section-header {
    align-items: center;
}

/* Small screens: keep alignment intact without cramping text. */
@media (max-width: 991px) {
    .header-right {
        gap: 12px;
    }

    .header-user {
        padding-inline: 12px;
    }

    .sidebar-menu > li > a > i,
    .menu-group-header .group-title > i,
    .logout-btn > i {
        width: 30px !important;
        height: 30px !important;
        min-width: 30px !important;
        min-height: 30px !important;
        border-radius: 10px;
        font-size: 14px !important;
    }
}

@media (max-width: 640px) {
    .btn,
    a.btn,
    button.btn,
    .table-pagination button,
    .table-pagination .pagination-button {
        min-height: 40px;
    }

    .system-time {
        padding-inline: 10px;
    }

    .header-user-copy strong {
        font-size: 13px;
    }
}

/* ==========================================================================
   R4.13 PROFESSIONAL SIDEBAR STANDARDIZATION
   ========================================================================== */

:root {
    --sidebar-row-height: 48px;
    --sidebar-row-radius: 12px;
    --sidebar-row-gap: 6px;
    --sidebar-icon-size: 34px;
    --sidebar-indent: 14px;
}

/* Make every hover/active hit-area deterministic. No shrink-to-content rows. */
.sidebar-menu,
.sidebar-menu > li,
.menu-group,
.submenu,
.submenu > li {
    width: 100%;
    min-width: 0;
}

.sidebar-menu {
    padding: 18px 14px 20px !important;
}

.sidebar-menu > li {
    display: block;
    margin: 0 0 var(--sidebar-row-gap) 0 !important;
}

.sidebar-menu a,
.menu-group-header {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    min-height: var(--sidebar-row-height) !important;
    box-sizing: border-box !important;
    border-radius: var(--sidebar-row-radius) !important;
    padding: 7px 10px !important;
    margin: 0 !important;
    gap: 10px !important;
    line-height: 1.25 !important;
    overflow: hidden;
    transition: background-color .18s ease, color .18s ease, box-shadow .18s ease, border-color .18s ease !important;
    transform: none !important;
}

.menu-group-header {
    justify-content: space-between !important;
    border: 1px solid transparent !important;
    background: transparent !important;
}

.menu-group-header .group-title {
    display: flex !important;
    align-items: center !important;
    flex: 1 1 auto;
    min-width: 0;
    gap: 10px !important;
}

.sidebar-menu a > span,
.menu-group-header .group-title > span {
    display: flex;
    align-items: center;
    min-height: 24px;
    min-width: 0;
    line-height: 1.25 !important;
}

/* Professional local vector icon badges: understated, consistent and business-like. */
.sidebar-menu > li > a > i,
.menu-group-header .group-title > i,
.logout-btn > i {
    width: var(--sidebar-icon-size) !important;
    height: var(--sidebar-icon-size) !important;
    min-width: var(--sidebar-icon-size) !important;
    min-height: var(--sidebar-icon-size) !important;
    border-radius: 10px !important;
    font-size: 15px !important;
    box-shadow: none !important;
    border: 1px solid transparent;
}

/* Neutral dashboard / section palette with restrained category accents. */
.sidebar-menu > li:first-child > a > i {
    background: #eef4ff !important;
    color: #3568c8 !important;
    border-color: #dbe8ff !important;
}
#group-sales_customers .group-title > i {
    background: #edf9f2 !important;
    color: #26845a !important;
    border-color: #d7f0e1 !important;
}
#group-operations_production .group-title > i {
    background: #f4f0fb !important;
    color: #6d56a8 !important;
    border-color: #e6ddf5 !important;
}
#group-inventory_logistics .group-title > i {
    background: #ebf8fa !important;
    color: #237a88 !important;
    border-color: #d2eef2 !important;
}
#group-hr_payroll .group-title > i {
    background: #fff7e6 !important;
    color: #a86e18 !important;
    border-color: #f7e7bd !important;
}
#group-finance_accounting .group-title > i {
    background: #eef7ed !important;
    color: #4d7c4b !important;
    border-color: #dbead9 !important;
}
#group-system_admin .group-title > i {
    background: #f6f1f3 !important;
    color: #87586a !important;
    border-color: #eadde2 !important;
}
.logout-btn > i {
    background: #fff1f1 !important;
    color: #c54a4a !important;
    border-color: #f5d9d9 !important;
}

/* Full-width hover surfaces. Never animate width or horizontal position. */
body.light-theme .sidebar-menu > li > a:hover,
body.light-theme .menu-group-header:hover {
    background: #f6f8fb !important;
    color: #1e293b !important;
    box-shadow: inset 0 0 0 1px #e7ebf0 !important;
}

body.light-theme .menu-group.expanded > .menu-group-header {
    background: #f8f6f0 !important;
    color: #172033 !important;
    box-shadow: inset 0 0 0 1px #ece5d4 !important;
}

/* Submenu rail is indented once; every child then uses the exact same width. */
.submenu {
    list-style: none;
    padding: 5px 0 4px var(--sidebar-indent) !important;
    margin: 2px 0 4px !important;
    box-sizing: border-box;
}

.submenu > li {
    display: block;
    margin: 0 0 4px 0 !important;
}

.submenu a {
    display: flex !important;
    width: 100% !important;
    min-height: 42px !important;
    padding: 6px 10px !important;
    border-radius: 10px !important;
    gap: 9px !important;
    box-sizing: border-box !important;
    border: 1px solid transparent;
}

.submenu a > i {
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    min-height: 16px !important;
    font-size: 8px !important;
    background: transparent !important;
    border: 0 !important;
    color: #a6afbc !important;
}

body.light-theme .submenu a:hover {
    background: #f7f8fa !important;
    color: #1f2937 !important;
    border-color: #edf0f3 !important;
}

body.light-theme .submenu li.submenu-active > a {
    background: #fbf7ee !important;
    color: #9a6a16 !important;
    border-color: #efe2c5 !important;
    box-shadow: inset 3px 0 0 var(--primary) !important;
}

body.light-theme .submenu li.submenu-active > a > i {
    color: var(--primary) !important;
}

/* Keep top-level active rows identical in length to all other top-level rows. */
body.light-theme .sidebar-menu > li.active > a {
    background: #fbf7ee !important;
    color: #8b6119 !important;
    box-shadow: inset 3px 0 0 var(--primary), inset 0 0 0 1px #efe2c5 !important;
}

/* Arrow is a fixed-size control so long labels do not push it outside the row. */
.menu-group-header .arrow-icon {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    margin-left: 8px;
    color: #8b96a6 !important;
    background: transparent !important;
    border: 0 !important;
    transition: transform .18s ease, color .18s ease !important;
}

.menu-group.expanded .arrow-icon {
    color: #9a6a16 !important;
}

/* Logout follows the same layout grid as navigation rows. */
.sidebar-footer {
    padding: 14px !important;
}

.logout-btn {
    display: flex !important;
    width: 100% !important;
    min-height: var(--sidebar-row-height) !important;
    padding: 7px 10px !important;
    border-radius: var(--sidebar-row-radius) !important;
    box-sizing: border-box !important;
}

.logout-btn:hover {
    background: #fff5f5 !important;
    box-shadow: inset 0 0 0 1px #f5dddd !important;
}

/* Myanmar labels may wrap, but row geometry stays stable and centered. */
html[lang="my"] .sidebar-menu a,
html[lang="my"] .menu-group-header {
    min-height: var(--sidebar-row-height) !important;
    padding-top: 7px !important;
    padding-bottom: 7px !important;
    line-height: 1.45 !important;
}

html[lang="my"] .submenu a {
    min-height: 44px !important;
    line-height: 1.45 !important;
}

@media (max-width: 991px) {
    :root {
        --sidebar-row-height: 46px;
        --sidebar-icon-size: 32px;
    }
}

/* ==========================================================================
   R4.14 ACTIVE ICON VISIBILITY / STATE CASCADE FIX
   ========================================================================== */

/* Dashboard: preserve the existing R4.13 blue vector badge in active state. */
body.light-theme .sidebar-menu > li.active:first-child > a > i {
    background: #eef4ff !important;
    color: #3568c8 !important;
    border-color: #dbe8ff !important;
}

/* Expanded groups: never recolor the category badge to white. The existing
   group-specific R4.13 palette remains authoritative. */
body.light-theme #group-sales_customers.expanded > .menu-group-header .group-title > i {
    background: #edf9f2 !important;
    color: #26845a !important;
    border-color: #d7f0e1 !important;
}
body.light-theme #group-operations_production.expanded > .menu-group-header .group-title > i {
    background: #f4f0fb !important;
    color: #6d56a8 !important;
    border-color: #e6ddf5 !important;
}
body.light-theme #group-inventory_logistics.expanded > .menu-group-header .group-title > i {
    background: #ebf8fa !important;
    color: #237a88 !important;
    border-color: #d2eef2 !important;
}
body.light-theme #group-hr_payroll.expanded > .menu-group-header .group-title > i {
    background: #fff7e6 !important;
    color: #a86e18 !important;
    border-color: #f7e7bd !important;
}
body.light-theme #group-finance_accounting.expanded > .menu-group-header .group-title > i {
    background: #eef7ed !important;
    color: #4d7c4b !important;
    border-color: #dbead9 !important;
}
body.light-theme #group-system_admin.expanded > .menu-group-header .group-title > i {
    background: #f6f1f3 !important;
    color: #87586a !important;
    border-color: #eadde2 !important;
}

/* Submenu active indicators keep the established gold treatment. */
body.light-theme .submenu li.submenu-active > a > i {
    background: transparent !important;
    color: var(--primary) !important;
    border-color: transparent !important;
}

/* ==========================================================================\n   R4.15 DASHBOARD ACTIVE PROJECT PIPELINE\n   Replaces the decorative status doughnut with a compact operational list.\n   Four rows fit the existing dashboard card without increasing its height.\n   ========================================================================== */
.page-dashboard .dashboard-pipeline-panel {
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 24px 22px 20px;
}

.page-dashboard .dashboard-pipeline-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.page-dashboard .dashboard-pipeline-heading .panel-title {
    margin: 0 0 3px;
}

.page-dashboard .dashboard-pipeline-subtitle {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.3;
}

.page-dashboard .dashboard-pipeline-count {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef2ff;
    border: 1px solid #dbe4ff;
    color: #3557b7;
    font-size: 10px;
    line-height: 1;
    font-weight: 800;
    white-space: nowrap;
}

.page-dashboard .dashboard-pipeline-table-wrap {
    min-height: 242px;
    overflow: hidden;
    border: 1px solid #e1e8f2;
    border-radius: 13px;
    background: #ffffff;
}

.page-dashboard .dashboard-pipeline-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.page-dashboard .dashboard-pipeline-table th {
    height: 34px;
    padding: 7px 9px;
    background: #f7f9fc;
    border-bottom: 1px solid #e1e8f2;
    color: #65738a;
    font-size: 9px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
}

.page-dashboard .dashboard-pipeline-table th:nth-child(1) { width: 47%; }
.page-dashboard .dashboard-pipeline-table th:nth-child(2) { width: 31%; }
.page-dashboard .dashboard-pipeline-table th:nth-child(3) { width: 22%; }

.page-dashboard .dashboard-pipeline-table td {
    height: 52px;
    padding: 7px 9px;
    border-bottom: 1px solid #edf1f6;
    vertical-align: middle;
}

.page-dashboard .dashboard-pipeline-table tbody tr:last-child td {
    border-bottom: 0;
}

.page-dashboard .dashboard-pipeline-table tbody tr:hover td {
    background: #fbfcff;
}

.page-dashboard .dashboard-pipeline-project {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
}

.page-dashboard .dashboard-pipeline-project strong {
    display: block;
    max-width: 100%;
    overflow: hidden;
    color: var(--text-main);
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-dashboard .dashboard-pipeline-project span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 600;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-dashboard .dashboard-pipeline-stage {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    min-height: 24px;
    padding: 4px 7px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 800;
    line-height: 1.15;
    text-align: center;
}

.page-dashboard .dashboard-pipeline-stage.is-design {
    background: #eef2ff;
    border-color: #dbe4ff;
    color: #4f46e5;
}

.page-dashboard .dashboard-pipeline-stage.is-waiting {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #c2410c;
}

.page-dashboard .dashboard-pipeline-stage.is-production {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.page-dashboard .dashboard-pipeline-stage.is-ready {
    background: #ecfeff;
    border-color: #a5f3fc;
    color: #0f766e;
}

.page-dashboard .dashboard-pipeline-stage.is-installed {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #15803d;
}

.page-dashboard .dashboard-pipeline-action-head,
.page-dashboard .dashboard-pipeline-action {
    text-align: right !important;
}

.page-dashboard .dashboard-pipeline-view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 30px;
    padding: 5px 8px;
    border: 1px solid #d7dfeb;
    border-radius: 9px;
    background: #f3f6fa;
    color: #32445e;
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.page-dashboard .dashboard-pipeline-view:hover {
    background: #e9eef6;
    border-color: #c4cfdd;
    color: #17253b;
    box-shadow: 0 5px 12px rgba(15, 23, 42, 0.08);
}

.page-dashboard .dashboard-pipeline-view i {
    width: 12px !important;
    height: 12px !important;
    min-width: 12px !important;
    min-height: 12px !important;
}

.page-dashboard .dashboard-pipeline-empty {
    height: 242px !important;
    text-align: center;
    color: var(--text-muted);
}

.page-dashboard .dashboard-pipeline-empty i,
.page-dashboard .dashboard-pipeline-empty strong,
.page-dashboard .dashboard-pipeline-empty span {
    display: block;
    margin-inline: auto;
}

.page-dashboard .dashboard-pipeline-empty i {
    width: 32px !important;
    height: 32px !important;
    margin-bottom: 8px;
    color: var(--success);
}

.page-dashboard .dashboard-pipeline-empty strong {
    color: var(--text-main);
    font-size: 12px;
}

.page-dashboard .dashboard-pipeline-empty span {
    margin-top: 3px;
    font-size: 10px;
}

.page-dashboard .dashboard-pipeline-pagination {
    min-height: 38px;
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.page-dashboard .dashboard-pipeline-page-summary {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.page-dashboard .dashboard-pipeline-page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
}

.page-dashboard .dashboard-pipeline-page-btn,
.page-dashboard .dashboard-pipeline-page-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    border-radius: 9px;
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.page-dashboard .dashboard-pipeline-page-btn {
    gap: 4px;
    padding: 5px 7px;
    border: 1px solid #dce3ec;
    background: #ffffff;
    color: #46566e;
    text-decoration: none;
}

.page-dashboard .dashboard-pipeline-page-btn:hover {
    background: #f4f7fb;
    border-color: #c7d2e0;
    color: #17253b;
}

.page-dashboard .dashboard-pipeline-page-btn.is-disabled {
    opacity: .42;
    cursor: default;
    pointer-events: none;
}

.page-dashboard .dashboard-pipeline-page-btn i {
    width: 10px !important;
    height: 10px !important;
    min-width: 10px !important;
    min-height: 10px !important;
}

.page-dashboard .dashboard-pipeline-page-number {
    min-width: 38px;
    padding: 5px 7px;
    background: #dcae4d;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(220, 174, 77, .18);
}

@media (max-width: 1180px) and (min-width: 1025px) {
    .page-dashboard .dashboard-pipeline-panel {
        padding-inline: 18px;
    }

    .page-dashboard .dashboard-pipeline-view span {
        display: none;
    }

    .page-dashboard .dashboard-pipeline-view {
        width: 30px;
        padding-inline: 0;
    }
}

@media (max-width: 1024px) {
    .page-dashboard .dashboard-pipeline-table th:nth-child(1) { width: 50%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(2) { width: 30%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(3) { width: 20%; }

    .page-dashboard .dashboard-pipeline-project strong {
        font-size: 12px;
    }

    .page-dashboard .dashboard-pipeline-project span,
    .page-dashboard .dashboard-pipeline-stage,
    .page-dashboard .dashboard-pipeline-view,
    .page-dashboard .dashboard-pipeline-page-btn,
    .page-dashboard .dashboard-pipeline-page-number {
        font-size: 10px;
    }
}

@media (max-width: 560px) {
    .page-dashboard .dashboard-pipeline-panel {
        padding: 18px 14px 16px;
    }

    .page-dashboard .dashboard-pipeline-table th:nth-child(1) { width: 52%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(2) { width: 30%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(3) { width: 18%; }

    .page-dashboard .dashboard-pipeline-view span {
        display: none;
    }

    .page-dashboard .dashboard-pipeline-view {
        width: 30px;
        padding-inline: 0;
    }

    .page-dashboard .dashboard-pipeline-pagination {
        align-items: flex-end;
    }
}

/* ==========================================================================
   R4.16 ESTIMATION AUTOCOMPLETE ICON POSITION FIX
   Keep the existing professional SVG icon design; only restore the absolute
   positioning required by the shared searchable-select / datalist controls.
   ========================================================================== */

.nt-material-search > i.nt-material-search-icon.fa-solid,
.nt-material-search > i.nt-material-search-icon.fa-regular {
    position: absolute !important;
    z-index: 3 !important;
    top: 50% !important;
    left: 14px !important;
    right: auto !important;
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: translateY(-50%) !important;
    color: #94a3b8 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

.nt-material-search > .nt-material-search-input,
.nt-material-search > .form-control {
    padding-left: 44px !important;
}

/* The same SVG-base rule can affect the Purchase material picker because its
   magnifier is also absolutely positioned. Preserve its existing layout too. */
.material-search-picker > i.material-search-icon.fa-solid,
.material-search-picker > i.material-search-icon.fa-regular,
.material-search-field > i.material-search-icon.fa-solid,
.material-search-field > i.material-search-icon.fa-regular {
    position: absolute !important;
    z-index: 3 !important;
    top: 50% !important;
    left: 14px !important;
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    margin: 0 !important;
    transform: translateY(-50%) !important;
    pointer-events: none !important;
}

/* ==========================================================================
   R4.21 DASHBOARD PIPELINE FULL PROJECT TEXT
   Keep the existing pipeline design, but never truncate project identity.
   Project name, project number and start date wrap cleanly inside the card.
   ========================================================================== */
.page-dashboard .dashboard-pipeline-table th:nth-child(1) { width: 54%; }
.page-dashboard .dashboard-pipeline-table th:nth-child(2) { width: 27%; }
.page-dashboard .dashboard-pipeline-table th:nth-child(3) { width: 19%; }

.page-dashboard .dashboard-pipeline-table td {
    height: 62px;
    padding-top: 8px;
    padding-bottom: 8px;
}

.page-dashboard .dashboard-pipeline-project {
    width: 100%;
    min-width: 0;
    gap: 4px;
}

.page-dashboard .dashboard-pipeline-project strong {
    display: block;
    width: 100%;
    max-width: none;
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
    overflow-wrap: anywhere;
    word-break: normal;
    font-size: 11px;
    line-height: 1.28;
}

.page-dashboard .dashboard-pipeline-project span {
    display: block;
    width: 100%;
    max-width: none;
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
    overflow-wrap: anywhere;
    word-break: normal;
    font-size: 9px;
    line-height: 1.28;
}

.page-dashboard .dashboard-pipeline-stage {
    white-space: normal;
    overflow-wrap: anywhere;
}

.page-dashboard .dashboard-pipeline-action {
    padding-left: 5px;
    padding-right: 7px;
}

.page-dashboard .dashboard-pipeline-view {
    max-width: 100%;
    padding-inline: 7px;
}

.page-dashboard .dashboard-pipeline-table-wrap {
    min-height: 282px;
}

.page-dashboard .dashboard-pipeline-empty {
    height: 282px !important;
}

@media (max-width: 1180px) and (min-width: 1025px) {
    .page-dashboard .dashboard-pipeline-table th:nth-child(1) { width: 56%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(2) { width: 26%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(3) { width: 18%; }

    /* Keep the View label visible: the project card remains easier to scan. */
    .page-dashboard .dashboard-pipeline-view span {
        display: inline !important;
    }

    .page-dashboard .dashboard-pipeline-view {
        width: auto;
        min-width: 48px;
        padding-inline: 7px;
    }
}

@media (max-width: 1024px) {
    .page-dashboard .dashboard-pipeline-table th:nth-child(1) { width: 55%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(2) { width: 27%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(3) { width: 18%; }
}

@media (max-width: 560px) {
    .page-dashboard .dashboard-pipeline-table th:nth-child(1) { width: 57%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(2) { width: 27%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(3) { width: 16%; }

    .page-dashboard .dashboard-pipeline-view span {
        display: none !important;
    }

    .page-dashboard .dashboard-pipeline-view {
        width: 30px;
        min-width: 30px;
        padding-inline: 0;
    }
}

/* ==========================================================================
   R4.22 DASHBOARD PIPELINE MICRO-POLISH
   Compact single-line stage badge and clean orange View action.
   Existing project text wrapping and icon family remain unchanged.
   ========================================================================== */
.page-dashboard .dashboard-pipeline-stage {
    white-space: nowrap !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    min-height: 22px;
    padding: 3px 6px;
    font-size: 8px !important;
    line-height: 1 !important;
    letter-spacing: 0;
}

.page-dashboard .dashboard-pipeline-view {
    min-width: 46px;
    min-height: 30px;
    padding: 6px 10px !important;
    gap: 0 !important;
    border-color: #d89a23 !important;
    background: linear-gradient(135deg, #f4b942 0%, #dc9f2f 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 5px 12px rgba(216, 154, 35, 0.18);
}

.page-dashboard .dashboard-pipeline-view:hover {
    border-color: #c88717 !important;
    background: linear-gradient(135deg, #e9a92e 0%, #ca8b1f 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 7px 15px rgba(200, 135, 23, 0.24);
}

.page-dashboard .dashboard-pipeline-view i {
    display: none !important;
}

.page-dashboard .dashboard-pipeline-view span {
    display: inline !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}

@media (max-width: 560px) {
    .page-dashboard .dashboard-pipeline-view {
        width: auto !important;
        min-width: 42px !important;
        padding-inline: 8px !important;
    }

    .page-dashboard .dashboard-pipeline-view span {
        display: inline !important;
    }
}

/* ==========================================================================
   R4.27 DASHBOARD PIPELINE READY-STAGE FIT
   Keep compact one-line production stages such as Designing, but allow the
   longer Ready for Installation label to stay fully inside its stage column.
   ========================================================================== */
.page-dashboard .dashboard-pipeline-table th:nth-child(1) { width: 54%; }
.page-dashboard .dashboard-pipeline-table th:nth-child(2) { width: 29%; }
.page-dashboard .dashboard-pipeline-table th:nth-child(3) { width: 17%; }

.page-dashboard .dashboard-pipeline-table td:nth-child(2) {
    min-width: 0;
    overflow: hidden;
    text-align: center;
}

.page-dashboard .dashboard-pipeline-stage {
    max-width: 100%;
    box-sizing: border-box;
    margin-inline: auto;
}

.page-dashboard .dashboard-pipeline-stage.is-ready {
    width: 100%;
    min-width: 0;
    min-height: 28px;
    padding: 4px 3px;
    white-space: normal !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    font-size: 7px !important;
    line-height: 1.12 !important;
    text-align: center;
}

.page-dashboard .dashboard-pipeline-action {
    min-width: 0;
    padding-left: 3px;
    padding-right: 3px;
}

.page-dashboard .dashboard-pipeline-view {
    min-width: 42px;
    padding-inline: 7px !important;
}

@media (max-width: 1180px) and (min-width: 1025px) {
    .page-dashboard .dashboard-pipeline-table th:nth-child(1) { width: 54%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(2) { width: 29%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(3) { width: 17%; }

    .page-dashboard .dashboard-pipeline-stage.is-ready {
        font-size: 6.8px !important;
    }
}

@media (max-width: 1024px) {
    .page-dashboard .dashboard-pipeline-table th:nth-child(1) { width: 53%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(2) { width: 30%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(3) { width: 17%; }
}

@media (max-width: 560px) {
    .page-dashboard .dashboard-pipeline-table th:nth-child(1) { width: 52%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(2) { width: 30%; }
    .page-dashboard .dashboard-pipeline-table th:nth-child(3) { width: 18%; }

    .page-dashboard .dashboard-pipeline-stage.is-ready {
        font-size: 6.5px !important;
        line-height: 1.08 !important;
    }
}

/* ============================================================
   R4.46 HEADER BRAND / ACCOUNT POLISH
   - Keep the sidebar brand header aligned to the main top header.
   - Force the logo frame to a true 1:1 square with even white inset.
   - Give the signed-in user's name a safe line box so glyphs do not clip.
   ============================================================ */
.sidebar-brand {
    height: var(--header-height);
    min-height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.sidebar-brand .brand-logo {
    min-height: 0;
    align-items: center;
}

.sidebar-brand .brand-logo__image {
    width: 58px !important;
    height: 58px !important;
    min-width: 58px !important;
    min-height: 58px !important;
    flex: 0 0 58px;
    aspect-ratio: 1 / 1;
    box-sizing: border-box;
    padding: 4px;
    border-radius: 16px;
    background: #fff;
    object-fit: cover;
}

.header-user-copy {
    line-height: 1.25;
    overflow: visible;
}

.header-user-copy strong {
    display: block;
    line-height: 1.35;
    padding-block: 1px;
}

.header-user-copy small {
    line-height: 1.25;
}

@media (max-width: 760px) {
    .sidebar-brand {
        padding-inline: 16px;
    }

    .sidebar-brand .brand-logo__image {
        width: 52px !important;
        height: 52px !important;
        min-width: 52px !important;
        min-height: 52px !important;
        flex-basis: 52px;
    }
}


/* ============================================================
   R4.47 DASHBOARD PIPELINE ACTION COLUMN FIT
   UI-only correction after inspecting the real table cascade:
   the action column was percentage-sized (17-18%) while the View button
   has a fixed minimum width. Adding more right padding reduced the usable
   cell width and could make the button overflow into that padding at some
   browser zoom / viewport widths. Reserve a stable action column instead,
   leave Stage at its existing proportion, and let Project use the remainder.
   ============================================================ */
.page-dashboard .dashboard-pipeline-table th:nth-child(1) {
    width: auto !important;
}

.page-dashboard .dashboard-pipeline-table th:nth-child(2) {
    width: 29% !important;
}

.page-dashboard .dashboard-pipeline-table th:nth-child(3) {
    width: 60px !important;
}

.page-dashboard .dashboard-pipeline-action-head,
.page-dashboard .dashboard-pipeline-action {
    padding-left: 6px !important;
    padding-right: 10px !important;
}

@media (max-width: 1024px) {
    .page-dashboard .dashboard-pipeline-table th:nth-child(2) {
        width: 30% !important;
    }
}


/* ==========================================================================
   R4.48 RESPONSIVE PRODUCTION HARDENING
   Mobile/tablet-only overrides after full UI audit. Desktop geometry and
   business logic remain unchanged. The goals are: no page-level horizontal
   overflow, readable forms/modals/tables, compact mobile header, and a truly
   responsive invoice/PO document preview without changing print output.
   ========================================================================== */

@media screen and (max-width: 900px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    main.main-content,
    .content-wrapper,
    .page-content,
    .panel,
    .card,
    .module-card,
    .content-card,
    form {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Phone/tablet header: preserve the page title and menu button; secondary
       account/time detail is available in the sidebar/profile and should not
       squeeze the working area. */
    header.top-header {
        gap: 10px;
        padding-inline: 14px !important;
    }

    .header-leading {
        flex: 1 1 auto;
        min-width: 0;
    }

    .header-title-block {
        flex: 1 1 auto;
        min-width: 0;
    }

    .page-title {
        max-width: 58vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-right {
        flex: 0 0 auto;
        gap: 6px !important;
    }

    .system-time,
    .header-user-copy {
        display: none !important;
    }

    .header-user {
        min-width: 42px;
        min-height: 42px;
        padding: 4px !important;
        justify-content: center !important;
        border-radius: 12px;
    }

    .header-avatar {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
    }

    /* Shared content safety. */
    .alert,
    .panel,
    .card,
    .module-card,
    .content-card,
    .form-group,
    .form-control,
    .btn {
        max-width: 100%;
    }

    .alert {
        align-items: flex-start;
        overflow-wrap: anywhere;
        word-break: normal;
    }

    .table-responsive {
        width: 100%;
        max-width: 100%;
        overflow-x: auto !important;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }

    .modal-overlay {
        padding: 12px;
    }

    .modal-container,
    .modal-content,
    .modal-content.card {
        width: min(100%, calc(100vw - 24px)) !important;
        max-width: calc(100vw - 24px) !important;
        max-height: calc(100dvh - 24px) !important;
        overflow-y: auto;
        box-sizing: border-box;
    }

    /* KPI groups remain dense on tablets but never overflow. */
    .operational-kpi-grid--four,
    .operational-kpi-grid--three,
    .actual-costing-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .actual-costing-entry-grid {
        grid-template-columns: 1fr !important;
    }

    /* Reports: two-column tablet layout, horizontal tables only where detail
       genuinely requires it. */
    .page-reports .reports-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .page-reports [style*="grid-template-columns: 1fr 1.6fr"],
    .page-reports [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Settings and HR tab/action strips may wrap instead of forcing viewport
       expansion. */
    .page-settings .content-wrapper [style*="display: flex"][style*="flex-wrap: wrap"],
    .page-hr .content-wrapper > [style*="display: flex"][style*="border-bottom"] {
        flex-wrap: wrap !important;
    }

    .page-settings [style*="grid-template-columns: 2fr 1fr"],
    .page-hr .modal-content [style*="grid-template-columns"],
    .page-expenses .modal-content [style*="grid-template-columns"],
    .page-purchase .modal-content [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    .page-archive .archive-split-layout {
        grid-template-columns: 1fr !important;
    }

    /* -------------------- Invoice detail / customer document -------------------- */
    .page-invoices .invoice-internal-record {
        display: block !important;
        width: 100%;
        padding: 15px 18px !important;
        line-height: 1.6;
        overflow-wrap: anywhere;
    }

    .page-invoices .invoice-internal-record > strong:first-child {
        display: block;
        margin-bottom: 5px;
    }

    .page-invoices .invoice-internal-record small {
        display: block;
        margin-top: 8px;
        line-height: 1.6;
    }

    .page-invoices .invoice-internal-record > div {
        display: block;
        margin-top: 10px !important;
        padding-top: 9px;
        border-top: 1px solid rgba(180, 121, 31, 0.18);
        line-height: 1.6;
    }

    .page-invoices .invoice-view-actions {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 10px;
        width: 100%;
    }

    .page-invoices .invoice-view-actions > .btn {
        justify-self: start;
    }

    .page-invoices .invoice-view-action-buttons {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
        gap: 8px !important;
        width: 100%;
    }

    .page-invoices .invoice-view-action-buttons .btn,
    .page-invoices .invoice-view-action-buttons form,
    .page-invoices .invoice-view-action-buttons form .btn {
        width: 100%;
        min-width: 0;
        justify-content: center;
        white-space: normal;
        text-align: center;
    }

    .page-invoices .printable-invoice-panel {
        width: 100% !important;
        max-width: 100% !important;
        margin-inline: 0 !important;
        padding: clamp(14px, 3.4vw, 24px) !important;
        overflow: hidden;
        box-sizing: border-box;
    }

    .page-invoices .print-wrapper-table,
    .page-invoices .invoice-brand-table,
    .page-invoices .invoice-deliverables-table {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    .page-invoices .invoice-brand-logo-cell {
        width: 84px !important;
        padding-right: 12px !important;
    }

    .page-invoices .invoice-header-logo {
        width: 70px !important;
        height: 70px !important;
    }

    .page-invoices .invoice-brand-text-cell {
        padding-top: 4px !important;
    }

    .page-invoices .invoice-brand-title,
    .page-invoices .invoice-brand-subtitle,
    .page-invoices .invoice-brand-contact {
        max-width: 100%;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        word-break: normal !important;
    }

    .page-invoices .invoice-brand-title {
        font-size: clamp(19px, 4.8vw, 24px) !important;
        line-height: 1.04 !important;
    }

    .page-invoices .invoice-brand-subtitle {
        margin-top: 2px !important;
        font-size: clamp(10px, 2.9vw, 13px) !important;
        line-height: 1.2 !important;
    }

    .page-invoices .invoice-brand-contact {
        font-size: 10px !important;
        line-height: 1.35 !important;
    }

    .page-invoices .invoice-meta-grid {
        grid-template-columns: 1fr !important;
        margin-bottom: 14px !important;
        font-size: 11px !important;
        line-height: 1.55 !important;
    }

    .page-invoices .invoice-meta-grid > div:first-child {
        border-right: 0 !important;
        border-bottom: 1px solid #000;
    }

    .page-invoices .invoice-meta-grid > div {
        min-width: 0;
        padding: 8px !important;
        overflow-wrap: anywhere;
    }

    .page-invoices .invoice-deliverables-table {
        table-layout: fixed !important;
        margin-bottom: 14px !important;
        font-size: clamp(8.5px, 1.85vw, 11px) !important;
    }

    .page-invoices .invoice-deliverables-table th,
    .page-invoices .invoice-deliverables-table td {
        min-width: 0;
        padding: 6px 4px !important;
        line-height: 1.35 !important;
        overflow-wrap: anywhere;
        word-break: normal;
        white-space: normal !important;
    }

    .page-invoices .invoice-deliverables-table th:nth-child(5),
    .page-invoices .invoice-deliverables-table th:nth-child(6),
    .page-invoices .invoice-deliverables-table td:nth-child(5),
    .page-invoices .invoice-deliverables-table td:nth-child(6) {
        white-space: normal !important;
    }

    .page-invoices .invoice-terms-financials {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        margin-bottom: 14px !important;
    }

    .page-invoices .invoice-agreement-block,
    .page-invoices .invoice-financials-block {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }

    .page-invoices .invoice-financials-block table {
        width: 100% !important;
        table-layout: fixed;
    }

    .page-invoices .invoice-payment-transactions > td > div {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        box-sizing: border-box;
    }

    .page-invoices .invoice-payment-transactions table {
        width: 100% !important;
        table-layout: fixed;
        font-size: 9px !important;
    }

    .page-invoices .invoice-payment-transactions th,
    .page-invoices .invoice-payment-transactions td {
        padding: 5px 3px !important;
        overflow-wrap: anywhere;
        word-break: normal;
    }

    /* -------------------- Purchase order document -------------------- */
    .page-purchase .content-wrapper > .panel[style*="max-width: 800px"],
    .page-purchase .content-wrapper > .panel[style*="max-width:800px"] {
        width: 100% !important;
        max-width: 100% !important;
        padding: 22px !important;
        box-sizing: border-box;
    }

    .page-purchase .content-wrapper > .panel[style*="max-width: 800px"] > [style*="display: flex"][style*="justify-content: space-between"] {
        flex-wrap: wrap !important;
        gap: 14px !important;
    }

    .page-purchase .content-wrapper > .panel[style*="max-width: 800px"] > [style*="grid-template-columns: 1fr 1fr"],
    .page-purchase .content-wrapper > .panel[style*="max-width:800px"] [style*="grid-template-columns:repeat(3,1fr)"],
    .page-purchase .content-wrapper > .panel[style*="max-width:800px"] [style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .page-purchase .content-wrapper > .panel[style*="max-width: 800px"] table {
        width: 100%;
        max-width: 100%;
        font-size: 11px !important;
        table-layout: fixed;
    }

    .page-purchase .content-wrapper > .panel[style*="max-width: 800px"] th,
    .page-purchase .content-wrapper > .panel[style*="max-width: 800px"] td {
        padding-inline: 5px !important;
        overflow-wrap: anywhere;
    }
}

@media screen and (max-width: 640px) {
    .content-wrapper {
        padding: 10px !important;
    }

    .panel,
    .card,
    .module-card,
    .content-card {
        border-radius: 12px;
    }

    .panel {
        padding: 14px;
    }

    .btn,
    a.btn,
    button.btn {
        white-space: normal;
        text-align: center;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-inline: 14px;
    }

    .modal-footer {
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1 1 130px;
        justify-content: center;
    }

    .operational-kpi-grid--four,
    .operational-kpi-grid--three,
    .actual-costing-kpis {
        grid-template-columns: 1fr !important;
    }

    .page-reports .reports-grid {
        grid-template-columns: 1fr !important;
    }

    .page-hr .modal-content [style*="grid-template-columns"],
    .page-expenses .modal-content [style*="grid-template-columns"],
    .page-settings [style*="grid-template-columns"],
    .page-purchase .modal-content [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    .page-hr [style*="justify-content: flex-end"],
    .page-expenses [style*="justify-content: flex-end"] {
        flex-wrap: wrap !important;
    }

    .page-invoices .invoice-view-action-buttons {
        grid-template-columns: 1fr;
    }

    .page-invoices .invoice-view-actions > .btn {
        width: 100%;
        justify-content: center;
    }

    .page-invoices .printable-invoice-panel {
        padding: 12px !important;
        border-radius: 10px !important;
    }

    .page-invoices .invoice-brand-logo-cell {
        width: 66px !important;
        padding-right: 8px !important;
    }

    .page-invoices .invoice-header-logo {
        width: 58px !important;
        height: 58px !important;
        padding: 2px !important;
    }

    .page-invoices .invoice-brand-title {
        font-size: 18px !important;
    }

    .page-invoices .invoice-brand-subtitle {
        font-size: 9.5px !important;
    }

    .page-invoices .invoice-brand-contact {
        margin-top: 3px !important;
        font-size: 8.5px !important;
    }

    .page-invoices .invoice-deliverables-row > td {
        width: 100%;
        max-width: 100%;
    }

    .page-invoices .invoice-deliverables-table {
        min-width: 0 !important;
        font-size: 8.5px !important;
    }

    .page-invoices .invoice-deliverables-table th,
    .page-invoices .invoice-deliverables-table td {
        padding: 4px 2px !important;
    }

    .page-invoices .invoice-payment-summary {
        font-size: 10px !important;
    }

    .page-invoices .invoice-payment-transactions table {
        min-width: 0 !important;
        font-size: 8px !important;
    }

    /* Inline form grids inherited from legacy screens collapse to one column
       on a phone without changing any desktop layout. */
    .page-hr .content-wrapper [style*="grid-template-columns"],
    .page-expenses .content-wrapper [style*="grid-template-columns"],
    .page-settings .content-wrapper [style*="grid-template-columns"],
    .page-purchase .content-wrapper [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
}

/* R4.48b: responsive hardening for the remaining document-style screens. */
@media screen and (max-width: 900px) {
    .page-estimates .content-wrapper > [class~="no-print"][style*="justify-content: space-between"],
    .page-purchase .content-wrapper > [class~="no-print"][style*="justify-content: space-between"],
    .page-archive .content-wrapper > [class~="no-print"][style*="justify-content: space-between"] {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }

    .page-estimates .content-wrapper > [class~="no-print"][style*="justify-content: space-between"] > div,
    .page-purchase .content-wrapper > [class~="no-print"][style*="justify-content: space-between"] > div {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .page-estimates .content-wrapper > .panel[style*="max-width: 800px"] {
        width: 100% !important;
        max-width: 100% !important;
        padding: 22px !important;
        box-sizing: border-box;
    }

    .page-estimates .content-wrapper > .panel[style*="max-width: 800px"] > [style*="display: flex"][style*="justify-content: space-between"] {
        flex-wrap: wrap !important;
        gap: 14px !important;
    }

    .page-estimates .content-wrapper > .panel[style*="max-width: 800px"] > [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .page-estimates .content-wrapper > .panel[style*="max-width: 800px"] table {
        width: 100%;
        max-width: 100%;
        table-layout: fixed;
        font-size: 10px !important;
    }

    .page-estimates .content-wrapper > .panel[style*="max-width: 800px"] th,
    .page-estimates .content-wrapper > .panel[style*="max-width: 800px"] td {
        padding: 6px 4px !important;
        overflow-wrap: anywhere;
        word-break: normal;
    }

    .page-estimates .content-wrapper > .panel[style*="max-width: 800px"] [style*="width: 320px"] {
        width: min(100%, 360px) !important;
        max-width: 100% !important;
    }

    .page-purchase .content-wrapper > [class~="no-print"] .btn,
    .page-estimates .content-wrapper > [class~="no-print"] .btn {
        white-space: normal;
        text-align: center;
    }
}

@media screen and (max-width: 640px) {
    .page-estimates .content-wrapper > [class~="no-print"][style*="justify-content: space-between"],
    .page-purchase .content-wrapper > [class~="no-print"][style*="justify-content: space-between"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
    }

    .page-estimates .content-wrapper > [class~="no-print"] .btn,
    .page-estimates .content-wrapper > [class~="no-print"] form,
    .page-estimates .content-wrapper > [class~="no-print"] form .btn,
    .page-purchase .content-wrapper > [class~="no-print"] .btn,
    .page-purchase .content-wrapper > [class~="no-print"] form,
    .page-purchase .content-wrapper > [class~="no-print"] form .btn {
        width: 100%;
        min-width: 0;
        justify-content: center;
    }

    .page-estimates .content-wrapper > .panel[style*="max-width: 800px"],
    .page-purchase .content-wrapper > .panel[style*="max-width: 800px"],
    .page-purchase .content-wrapper > .panel[style*="max-width:800px"] {
        padding: 14px !important;
    }

    .page-estimates .content-wrapper > .panel[style*="max-width: 800px"] table,
    .page-purchase .content-wrapper > .panel[style*="max-width: 800px"] table {
        font-size: 8.5px !important;
    }

    .page-estimates .content-wrapper > .panel[style*="max-width: 800px"] th,
    .page-estimates .content-wrapper > .panel[style*="max-width: 800px"] td,
    .page-purchase .content-wrapper > .panel[style*="max-width: 800px"] th,
    .page-purchase .content-wrapper > .panel[style*="max-width: 800px"] td {
        padding: 5px 3px !important;
    }
}

/* ========================================================================
   NANN TAW Mobile Responsive Hardening — 2026-09-05
   Scope: Web + Windows WebView2 + Android WebView presentation only.
   No business formulas, API contracts, database writes or finance logic here.
   ======================================================================== */
body.modal-open {
    overflow: hidden !important;
    overscroll-behavior: none;
}

@media (max-width: 768px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .content-wrapper {
        width: 100%;
        min-width: 0;
        padding: 14px !important;
    }

    .panel {
        min-width: 0;
        padding: 18px !important;
        margin-bottom: 18px;
        border-radius: 14px;
    }

    header.top-header {
        padding: 0 14px !important;
    }

    .header-leading,
    .header-title-block,
    .header-title-block .page-title {
        min-width: 0;
    }

    .header-title-block .page-title {
        max-width: min(62vw, 360px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .form-grid {
        min-width: 0;
    }

    .form-group,
    .form-control,
    .nt-material-search {
        min-width: 0;
        max-width: 100%;
    }

    /* 16px prevents mobile browsers from zooming the viewport on input focus. */
    input.form-control,
    select.form-control,
    textarea.form-control,
    .nt-material-search-input {
        font-size: 16px !important;
    }

    .btn {
        min-height: 42px;
        justify-content: center;
        touch-action: manipulation;
    }

    .table-responsive {
        max-width: 100%;
        overscroll-behavior-inline: contain;
        scrollbar-width: thin;
    }

    /* Generic application modals become safe app-like bottom sheets on phones. */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal-container {
        width: 100%;
        max-width: none !important;
        max-height: calc(100dvh - 8px);
        margin: 0;
        border-radius: 18px 18px 0 0;
        display: flex;
        flex-direction: column;
    }

    .modal-header {
        flex: 0 0 auto;
        padding: 16px 18px;
    }

    .modal-header h3 {
        min-width: 0;
        padding-right: 8px;
        overflow-wrap: anywhere;
    }

    .modal-body {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        padding: 18px;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .modal-footer {
        flex: 0 0 auto;
        flex-wrap: wrap;
        padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
        gap: 10px;
    }

    .modal-footer .btn {
        flex: 1 1 140px;
        min-width: 0;
    }

    .modal-body input[type="file"].form-control {
        height: auto !important;
        min-height: 46px;
        padding: 7px !important;
        overflow: hidden;
    }

    .modal-body input[type="file"]::file-selector-button {
        min-height: 34px;
        margin-right: 8px;
        padding: 6px 10px;
        border: 1px solid var(--border-color);
        border-radius: 7px;
        background: var(--bg-card);
        color: var(--text-main);
        font-weight: 700;
    }

    /* Autocomplete portal stays inside the visible WebView viewport. */
    .nt-material-results {
        max-width: calc(100vw - 16px);
        border-radius: 12px;
    }

    .nt-material-option {
        min-height: 50px;
        padding: 10px;
    }

    .nt-material-option strong,
    .nt-material-option-meta {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    /* ------------------------- Expenses ------------------------- */
    .page-expenses .expenses-page-header {
        align-items: stretch !important;
    }

    .page-expenses .expenses-page-header .page-title {
        flex: 1 1 100%;
        font-size: 20px;
    }

    .page-expenses .expenses-page-header > .btn {
        width: 100%;
    }

    .page-expenses .expense-filter-form {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        width: 100%;
        gap: 8px !important;
    }

    .page-expenses .expense-filter-form select,
    .page-expenses .expense-filter-form input[type="text"] {
        width: 100% !important;
        height: 42px !important;
    }

    .page-expenses .expense-filter-form select,
    .page-expenses .expense-filter-form input[type="text"] {
        grid-column: 1 / -1;
    }

    .page-expenses .expense-filter-form .btn {
        min-width: 42px;
        height: 42px !important;
    }

    .page-expenses .expense-entry-modal {
        padding: 0 !important;
        align-items: flex-end !important;
        overflow: hidden !important;
    }

    .page-expenses .expense-entry-modal__content {
        width: 100% !important;
        max-width: none !important;
        max-height: calc(100dvh - 8px);
        margin: 0 !important;
        padding: 18px !important;
        border-radius: 18px 18px 0 0 !important;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .page-expenses .expense-entry-modal__tabs {
        gap: 14px !important;
        overflow-x: auto;
        white-space: nowrap;
        scrollbar-width: none;
    }

    .page-expenses .expense-entry-modal__tabs::-webkit-scrollbar {
        display: none;
    }

    .page-expenses .expense-entry-modal__actions {
        position: sticky;
        bottom: 0;
        z-index: 2;
        flex-wrap: wrap;
        padding-top: 12px;
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--bg-card-solid);
    }

    .page-expenses .expense-entry-modal__actions .btn {
        flex: 1 1 140px;
    }

    .page-expenses .expense-kpi-card__breakdown span {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .page-expenses .table-responsive .badge {
        white-space: normal;
        line-height: 1.35;
    }

    /* ---------------------- Inventory damage -------------------- */
    .page-inventory #adjust-stock-modal .form-help {
        display: block;
        margin-top: 7px;
        line-height: 1.55;
    }

    .page-inventory #adjust-stock-modal textarea.form-control {
        min-height: 100px;
    }

    /* ---------------------- Job estimation ---------------------- */
    .page-estimates .estimate-customer-grid,
    .page-estimates .estimate-cost-grid,
    .page-estimates .estimate-terms-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .page-estimates .estimate-size-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 12px !important;
    }

    .page-estimates .estimate-size-grid > .form-group:first-child,
    .page-estimates .estimate-size-grid > .form-group:last-child {
        grid-column: 1 / -1;
    }

    .page-estimates .estimate-materials-panel {
        padding: 14px !important;
    }

    .page-estimates .estimate-materials-table-wrap {
        overflow: visible !important;
        border: 0;
        box-shadow: none;
    }

    .page-estimates #materials-table,
    .page-estimates #materials-table tbody {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
    }

    .page-estimates #materials-table thead {
        display: none;
    }

    .page-estimates #materials-table .inv-calc-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        width: 100%;
        margin-bottom: 12px;
        padding: 12px;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        background: rgba(148, 163, 184, 0.04) !important;
    }

    .page-estimates #materials-table .inv-calc-row td {
        display: block;
        min-width: 0;
        padding: 0 !important;
        border: 0 !important;
        white-space: normal !important;
        text-align: left !important;
    }

    .page-estimates #materials-table .inv-calc-row td:first-child {
        grid-column: 1 / -1;
    }

    .page-estimates #materials-table .inv-calc-row td:nth-child(5),
    .page-estimates #materials-table .inv-calc-row td:nth-child(6) {
        align-self: end;
    }

    .page-estimates #materials-table .inv-calc-row td:nth-child(2)::before,
    .page-estimates #materials-table .inv-calc-row td:nth-child(3)::before,
    .page-estimates #materials-table .inv-calc-row td:nth-child(4)::before,
    .page-estimates #materials-table .inv-calc-row td:nth-child(5)::before {
        display: block;
        margin-bottom: 5px;
        color: var(--text-muted);
        font-size: 9px;
        font-weight: 800;
        letter-spacing: .04em;
        text-transform: uppercase;
    }

    .page-estimates #materials-table .inv-calc-row td:nth-child(2)::before { content: "Qty"; }
    .page-estimates #materials-table .inv-calc-row td:nth-child(3)::before { content: "Unit"; }
    .page-estimates #materials-table .inv-calc-row td:nth-child(4)::before { content: "Unit Cost"; }
    .page-estimates #materials-table .inv-calc-row td:nth-child(5)::before { content: "Est. Cost"; }

    .page-estimates #materials-table .row-total-label {
        display: flex;
        align-items: center;
        min-height: 40px;
        font-size: 16px !important;
    }

    .page-estimates #materials-table .inv-calc-row td:last-child .btn {
        width: 100%;
        min-height: 40px;
    }

    /* ---------------------- Project design JPG ------------------ */
    .page-projects #upload-design-modal .modal-body .form-group:last-child {
        margin-bottom: 0;
    }

    .page-projects #upload-design-modal select#file_type,
    .page-projects #upload-design-modal input#design_file {
        width: 100%;
    }

    /* ------------------------- Reports -------------------------- */
    .page-reports .report-filter-form {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: end !important;
        gap: 12px !important;
    }

    .page-reports .report-filter-form > .form-group {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
    }

    .page-reports .report-filter-form > .form-group select,
    .page-reports .report-filter-form > .form-group input {
        width: 100%;
    }

    .page-reports .report-filter-actions {
        grid-column: 1 / -1;
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
        width: 100%;
        gap: 8px !important;
    }

    .page-reports .report-filter-actions .btn {
        width: 100%;
        min-width: 0;
        height: auto !important;
        min-height: 42px;
        padding: 8px 10px !important;
        white-space: normal;
        line-height: 1.25;
        text-align: center;
    }

    .page-reports .report-metric-card {
        overflow: hidden;
    }

    .page-reports .report-metric-value {
        overflow-wrap: anywhere;
    }

    .page-reports .table-responsive {
        position: relative;
        padding-bottom: 4px;
    }

    /* ---------------------- Dashboard restock ------------------- */
    .page-dashboard .dashboard-restock-table-wrap {
        overflow-x: hidden !important;
        border: 0;
        box-shadow: none;
    }

    .page-dashboard .dashboard-restock-table,
    .page-dashboard .dashboard-restock-table tbody {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
    }

    .page-dashboard .dashboard-restock-table thead {
        display: none;
    }

    .page-dashboard .dashboard-restock-table tbody tr:not(.dashboard-restock-empty-row) {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 14px;
        margin-bottom: 10px;
        padding: 12px;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        background: var(--bg-card-solid);
    }

    .page-dashboard .dashboard-restock-table tbody tr:not(.dashboard-restock-empty-row) td {
        display: flex;
        min-width: 0;
        padding: 0 !important;
        border: 0 !important;
        flex-direction: column;
        gap: 4px;
        white-space: normal !important;
        overflow-wrap: anywhere;
    }

    .page-dashboard .dashboard-restock-table tbody tr:not(.dashboard-restock-empty-row) td:first-child,
    .page-dashboard .dashboard-restock-table tbody tr:not(.dashboard-restock-empty-row) td:last-child {
        grid-column: 1 / -1;
    }

    .page-dashboard .dashboard-restock-table tbody tr:not(.dashboard-restock-empty-row) td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 9px;
        font-weight: 800;
        letter-spacing: .05em;
        text-transform: uppercase;
    }

    .page-dashboard .dashboard-restock-table tbody tr:not(.dashboard-restock-empty-row) td:last-child .btn {
        width: 100%;
    }

    .page-dashboard .dashboard-restock-empty-row,
    .page-dashboard .dashboard-restock-empty {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    .page-dashboard .dashboard-restock-empty {
        padding: 18px 10px !important;
        white-space: normal !important;
        line-height: 1.5;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 480px) {
    .content-wrapper {
        padding: 12px !important;
    }

    .panel {
        padding: 15px !important;
    }

    .header-title-block .page-title {
        max-width: 58vw;
        font-size: 18px;
    }

    .page-estimates .estimate-size-grid {
        grid-template-columns: 1fr !important;
    }

    .page-estimates .estimate-size-grid > .form-group {
        grid-column: auto !important;
    }

    .page-reports .report-filter-form {
        grid-template-columns: 1fr !important;
    }

    .page-reports .report-filter-actions {
        grid-column: auto;
    }

    .page-expenses .expense-entry-modal__content {
        padding: 16px 14px !important;
    }
}

/* ========================================================================== 
   R4.50 MOBILE DRAWER + HORIZONTAL TABLE POLISH
   Stabilizes the touch drawer and lets audit/data tables use horizontal scroll
   instead of breaking words or monetary values across multiple lines.
   ========================================================================== */

@media screen and (max-width: 1024px) {
    aside.sidebar {
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden !important;
        contain: layout paint;
        -webkit-tap-highlight-color: transparent;
    }

    .sidebar-brand,
    .sidebar-footer {
        flex: 0 0 auto;
    }

    .sidebar-menu {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-menu > li,
    .sidebar-menu .menu-group,
    .sidebar-menu .submenu,
    .sidebar-menu .submenu > li {
        position: relative;
        max-width: 100%;
        box-sizing: border-box;
    }

    .sidebar-menu a,
    .menu-group-header,
    .menu-group-header .group-title,
    .submenu a {
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        -webkit-tap-highlight-color: transparent;
    }

    .menu-group-header .group-title > span,
    .sidebar-menu a > span,
    .submenu a > span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* A submenu is always contained by the drawer. This prevents a repainted
       active/hover row from visually bleeding into the backdrop on Android. */
    .submenu {
        overflow: hidden;
        isolation: isolate;
    }

    .sidebar-backdrop {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
}

/* Android/WebView can keep :hover after a tap. Disable those synthetic hover
   surfaces on coarse touch screens while preserving the real active/expanded
   state. */
@media (hover: none) and (pointer: coarse) and (max-width: 1024px) {
    body.light-theme .sidebar-menu > li:not(.active) > a:hover {
        background: transparent !important;
        color: var(--text-muted) !important;
        box-shadow: none !important;
    }

    body.light-theme .menu-group:not(.expanded) > .menu-group-header:hover {
        background: transparent !important;
        color: var(--text-muted) !important;
        box-shadow: none !important;
        border-color: transparent !important;
    }

    body.light-theme .submenu li:not(.submenu-active) > a:hover {
        background: transparent !important;
        color: #475569 !important;
        box-shadow: none !important;
        border-color: transparent !important;
    }
}

@media screen and (max-width: 900px) {
    /* Horizontal scrolling is intentional on phone/tablet. Keep the table's
       intrinsic column widths instead of squeezing every column into 100vw. */
    .table-responsive:has(> table.data-table.nt-mobile-scroll-table) {
        width: 100%;
        max-width: 100%;
        overflow-x: auto !important;
        overflow-y: hidden;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    table.data-table.nt-mobile-scroll-table {
        width: max-content !important;
        min-width: 100% !important;
        max-width: none !important;
        table-layout: auto !important;
    }

    /* Never split a header in the middle of a word. A wider table is preferred
       because the user can intentionally swipe horizontally. */
    table.data-table.nt-mobile-scroll-table thead th,
    body.light-theme table.data-table.nt-mobile-scroll-table thead th {
        min-width: max-content;
        white-space: nowrap !important;
        word-break: normal !important;
        overflow-wrap: normal !important;
        hyphens: none;
    }

    table.data-table.nt-mobile-scroll-table tbody td,
    body.light-theme table.data-table.nt-mobile-scroll-table tbody td {
        word-break: normal !important;
        overflow-wrap: normal !important;
        hyphens: none;
    }

    /* Monetary columns are audit values: amount/cost/price/paid/balance/etc.
       They must remain one line and receive enough width for comma formatting. */
    table.data-table.nt-mobile-scroll-table .nt-money-column {
        min-width: 92px !important;
        white-space: nowrap !important;
        word-break: keep-all !important;
        overflow-wrap: normal !important;
        font-variant-numeric: tabular-nums;
    }

    table.data-table.nt-mobile-scroll-table tbody td.nt-money-column {
        text-align: right;
    }

    /* IDs/status/buttons should also stay compact while descriptive text may
       still wrap naturally at spaces. */
    table.data-table.nt-mobile-scroll-table .nt-compact-column {
        white-space: nowrap !important;
        overflow-wrap: normal !important;
        word-break: keep-all !important;
    }

    .page-expenses .table-responsive .badge,
    .page-purchase .table-responsive .badge,
    .page-inventory .table-responsive .badge {
        white-space: nowrap !important;
        overflow-wrap: normal !important;
    }
}


/* ========================================================================== 
   R4.51 PURCHASE / MONEY COLUMN RESPONSIVE POLISH
   Financial figures stay on one line at every viewport size. Purchase tables
   deliberately prefer horizontal scrolling over squeezing/breaking columns.
   ========================================================================== */

/* JS tags financial columns with .nt-money-column. Keep the amount intact on
   desktop, tablet and phone; the surrounding .table-responsive owns overflow. */
table.data-table.nt-mobile-scroll-table th.nt-money-column,
table.data-table.nt-mobile-scroll-table td.nt-money-column,
table.data-table.nt-mobile-scroll-table td.nt-money-column > strong,
table.data-table.nt-mobile-scroll-table td.nt-money-column > span {
    min-width: 92px !important;
    white-space: nowrap !important;
    word-break: keep-all !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
    font-variant-numeric: tabular-nums;
}

/* Purchase registers contain many audit columns. Do not compress them until
   words/numbers break. The user intentionally swipes horizontally instead. */
.page-purchase .table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table {
    width: max-content !important;
    min-width: 100% !important;
    max-width: none !important;
    table-layout: auto !important;
}

.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table th,
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table td {
    white-space: nowrap !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    hyphens: none !important;
}

/* Give common purchase register fields comfortable intrinsic room. These are
   minimums only; content can grow and remain horizontally scrollable. */
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table th:nth-child(1),
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table td:nth-child(1) { min-width: 150px; }
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table th:nth-child(2),
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table td:nth-child(2) { min-width: 130px; }
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table th:nth-child(3),
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table td:nth-child(3),
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table th:nth-child(4),
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table td:nth-child(4),
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table th:nth-child(5),
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table td:nth-child(5) { min-width: 92px; }
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table th:nth-child(6),
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table td:nth-child(6),
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table th:nth-child(7),
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table td:nth-child(7) { min-width: 120px; }
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table th:nth-child(8),
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table td:nth-child(8) { min-width: 100px; }
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table th:nth-child(9),
.page-purchase .table-responsive > table.data-table.nt-mobile-scroll-table td:nth-child(9) { min-width: 200px; }

@media screen and (max-width: 900px) {
    table.data-table.nt-mobile-scroll-table td.nt-money-column {
        text-align: right;
    }
}

/* ========================================================================== 
   R4.52 PURCHASE REGISTER PAGE-FIT POLISH
   Desktop/tablet: keep every column visible inside the purchase card.
   Phone: retain intentional horizontal scrolling, but with tighter widths.
   PO numbers/descriptive fields may wrap; financial figures never do.
   ========================================================================== */

/* Override the earlier max-content purchase rule for the actual PO register on
   desktop. This keeps ACTION and DATE visible instead of clipping off-right. */
@media screen and (min-width: 901px) {
    .page-purchase .table-responsive > table.data-table.nt-purchase-register {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        table-layout: fixed !important;
    }

    .page-purchase .table-responsive > table.data-table.nt-purchase-register th,
    .page-purchase .table-responsive > table.data-table.nt-purchase-register td {
        min-width: 0 !important;
        max-width: none !important;
        box-sizing: border-box;
        vertical-align: middle;
    }

    /* The register is intentionally balanced to exactly fit one card width. */
    .page-purchase table.nt-purchase-register th:nth-child(1),
    .page-purchase table.nt-purchase-register td:nth-child(1) { width: 15%; }
    .page-purchase table.nt-purchase-register th:nth-child(2),
    .page-purchase table.nt-purchase-register td:nth-child(2) { width: 13%; }
    .page-purchase table.nt-purchase-register th:nth-child(3),
    .page-purchase table.nt-purchase-register td:nth-child(3),
    .page-purchase table.nt-purchase-register th:nth-child(4),
    .page-purchase table.nt-purchase-register td:nth-child(4),
    .page-purchase table.nt-purchase-register th:nth-child(5),
    .page-purchase table.nt-purchase-register td:nth-child(5) { width: 8%; }
    .page-purchase table.nt-purchase-register th:nth-child(6),
    .page-purchase table.nt-purchase-register td:nth-child(6) { width: 12%; }
    .page-purchase table.nt-purchase-register th:nth-child(7),
    .page-purchase table.nt-purchase-register td:nth-child(7) { width: 13%; }
    .page-purchase table.nt-purchase-register th:nth-child(8),
    .page-purchase table.nt-purchase-register td:nth-child(8) { width: 10%; }
    .page-purchase table.nt-purchase-register th:nth-child(9),
    .page-purchase table.nt-purchase-register td:nth-child(9) { width: 13%; }

    /* PO numbers are safe to use two lines. Break around hyphens instead of
       sacrificing the finance/action columns. */
    .page-purchase table.nt-purchase-register th:nth-child(1),
    .page-purchase table.nt-purchase-register td:nth-child(1),
    .page-purchase table.nt-purchase-register th:nth-child(2),
    .page-purchase table.nt-purchase-register td:nth-child(2),
    .page-purchase table.nt-purchase-register th:nth-child(9),
    .page-purchase table.nt-purchase-register td:nth-child(9) {
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        word-break: normal !important;
        line-height: 1.25;
    }

    /* Financial values are the only columns that must never wrap. */
    .page-purchase table.nt-purchase-register th.nt-money-column,
    .page-purchase table.nt-purchase-register td.nt-money-column {
        min-width: 0 !important;
        white-space: nowrap !important;
        overflow-wrap: normal !important;
        word-break: keep-all !important;
        text-align: left;
        font-variant-numeric: tabular-nums;
    }

    .page-purchase table.nt-purchase-register .badge {
        max-width: 100%;
        padding-left: 10px;
        padding-right: 10px;
        white-space: nowrap !important;
        font-size: clamp(9px, .72vw, 12px);
    }

    /* Keep action controls inside their own cell; text can use two lines. */
    .page-purchase table.nt-purchase-register td:nth-child(9) .btn,
    .page-purchase table.nt-purchase-register td:nth-child(9) button,
    .page-purchase table.nt-purchase-register td:nth-child(9) a {
        max-width: 100%;
        padding-left: 9px;
        padding-right: 9px;
        white-space: normal !important;
        line-height: 1.2;
    }

    .page-purchase table.nt-purchase-register td:nth-child(9) {
        overflow: visible !important;
    }
}

/* Mobile still uses horizontal scroll, but no column needs the previous very
   large minimums. This reduces swipe distance without breaking money values. */
@media screen and (max-width: 900px) {
    .page-purchase .table-responsive > table.data-table.nt-purchase-register {
        width: max-content !important;
        min-width: 860px !important;
        table-layout: auto !important;
    }

    .page-purchase table.nt-purchase-register th:nth-child(1),
    .page-purchase table.nt-purchase-register td:nth-child(1) {
        min-width: 118px !important;
        max-width: 138px;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        line-height: 1.25;
    }

    .page-purchase table.nt-purchase-register th:nth-child(2),
    .page-purchase table.nt-purchase-register td:nth-child(2) {
        min-width: 108px !important;
        max-width: 135px;
        white-space: normal !important;
    }

    .page-purchase table.nt-purchase-register th:nth-child(3),
    .page-purchase table.nt-purchase-register td:nth-child(3),
    .page-purchase table.nt-purchase-register th:nth-child(4),
    .page-purchase table.nt-purchase-register td:nth-child(4),
    .page-purchase table.nt-purchase-register th:nth-child(5),
    .page-purchase table.nt-purchase-register td:nth-child(5) {
        min-width: 82px !important;
        white-space: nowrap !important;
    }

    .page-purchase table.nt-purchase-register th:nth-child(6),
    .page-purchase table.nt-purchase-register td:nth-child(6),
    .page-purchase table.nt-purchase-register th:nth-child(7),
    .page-purchase table.nt-purchase-register td:nth-child(7) {
        min-width: 105px !important;
    }

    .page-purchase table.nt-purchase-register th:nth-child(8),
    .page-purchase table.nt-purchase-register td:nth-child(8) {
        min-width: 92px !important;
    }

    .page-purchase table.nt-purchase-register th:nth-child(9),
    .page-purchase table.nt-purchase-register td:nth-child(9) {
        min-width: 126px !important;
        white-space: normal !important;
    }
}

/* ========================================================================== 
   R4.53 PURCHASE REGISTER STATUS + ACTION FIT POLISH
   Keep the PO register inside the card on desktop while allowing descriptive
   identifiers/statuses to use two lines. Monetary values remain single-line.
   Action controls are stacked vertically so receipt state never spills outside.
   ========================================================================== */
@media screen and (min-width: 901px) {
    .page-purchase .table-responsive > table.data-table.nt-purchase-register {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        table-layout: fixed !important;
    }

    /* Rebalance all nine columns to a true 100% page-fit layout. */
    .page-purchase table.nt-purchase-register th:nth-child(1),
    .page-purchase table.nt-purchase-register td:nth-child(1) { width: 13% !important; }
    .page-purchase table.nt-purchase-register th:nth-child(2),
    .page-purchase table.nt-purchase-register td:nth-child(2) { width: 11% !important; }
    .page-purchase table.nt-purchase-register th:nth-child(3),
    .page-purchase table.nt-purchase-register td:nth-child(3),
    .page-purchase table.nt-purchase-register th:nth-child(4),
    .page-purchase table.nt-purchase-register td:nth-child(4),
    .page-purchase table.nt-purchase-register th:nth-child(5),
    .page-purchase table.nt-purchase-register td:nth-child(5) { width: 7% !important; }
    .page-purchase table.nt-purchase-register th:nth-child(6),
    .page-purchase table.nt-purchase-register td:nth-child(6) { width: 13% !important; }
    .page-purchase table.nt-purchase-register th:nth-child(7),
    .page-purchase table.nt-purchase-register td:nth-child(7) { width: 14% !important; }
    .page-purchase table.nt-purchase-register th:nth-child(8),
    .page-purchase table.nt-purchase-register td:nth-child(8) { width: 10% !important; }
    .page-purchase table.nt-purchase-register th:nth-child(9),
    .page-purchase table.nt-purchase-register td:nth-child(9) { width: 18% !important; }

    .page-purchase table.nt-purchase-register th,
    .page-purchase table.nt-purchase-register td {
        min-width: 0 !important;
        box-sizing: border-box;
        vertical-align: middle !important;
    }

    /* PO number and supplier may use two natural lines instead of stealing
       width from financial/status/action columns. */
    .page-purchase table.nt-purchase-register th:nth-child(1),
    .page-purchase table.nt-purchase-register td:nth-child(1),
    .page-purchase table.nt-purchase-register th:nth-child(2),
    .page-purchase table.nt-purchase-register td:nth-child(2) {
        white-space: normal !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;
        hyphens: manual !important;
        line-height: 1.28;
    }

    /* Audit numbers never wrap or drop to another line. */
    .page-purchase table.nt-purchase-register th:nth-child(3),
    .page-purchase table.nt-purchase-register td:nth-child(3),
    .page-purchase table.nt-purchase-register th:nth-child(4),
    .page-purchase table.nt-purchase-register td:nth-child(4),
    .page-purchase table.nt-purchase-register th:nth-child(5),
    .page-purchase table.nt-purchase-register td:nth-child(5) {
        white-space: nowrap !important;
        word-break: keep-all !important;
        overflow-wrap: normal !important;
        font-variant-numeric: tabular-nums;
    }

    /* Stock/payment labels belong inside their own cells. Long statuses can
       break only at spaces (Pending Receipt / Partially Paid) and stay centered. */
    .page-purchase table.nt-purchase-register th:nth-child(6),
    .page-purchase table.nt-purchase-register td:nth-child(6),
    .page-purchase table.nt-purchase-register th:nth-child(7),
    .page-purchase table.nt-purchase-register td:nth-child(7) {
        white-space: normal !important;
        overflow: hidden !important;
        word-break: normal !important;
        overflow-wrap: normal !important;
        text-align: center !important;
    }

    .page-purchase table.nt-purchase-register td:nth-child(6) .badge,
    .page-purchase table.nt-purchase-register td:nth-child(7) .badge {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
        padding: 6px 8px !important;
        margin: 0 auto !important;
        white-space: normal !important;
        word-break: normal !important;
        overflow-wrap: normal !important;
        text-align: center;
        line-height: 1.12;
        font-size: clamp(9px, .68vw, 11px) !important;
    }

    /* Date stays compact and readable. */
    .page-purchase table.nt-purchase-register th:nth-child(8),
    .page-purchase table.nt-purchase-register td:nth-child(8) {
        white-space: nowrap !important;
        font-variant-numeric: tabular-nums;
    }

    /* Action cell: View Details on top, Receive Stock / Stock Received below. */
    .page-purchase table.nt-purchase-register td:nth-child(9) {
        padding-left: 10px !important;
        padding-right: 10px !important;
        text-align: center !important;
        white-space: normal !important;
        overflow: hidden !important;
    }

    .page-purchase table.nt-purchase-register td:nth-child(9) > a,
    .page-purchase table.nt-purchase-register td:nth-child(9) > form,
    .page-purchase table.nt-purchase-register td:nth-child(9) > span {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        margin: 0 !important;
    }

    .page-purchase table.nt-purchase-register td:nth-child(9) > form {
        display: block !important;
        margin-top: 6px !important;
    }

    .page-purchase table.nt-purchase-register td:nth-child(9) > span {
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 5px;
        margin-top: 7px !important;
        white-space: normal !important;
        line-height: 1.2;
    }

    .page-purchase table.nt-purchase-register td:nth-child(9) > a.btn,
    .page-purchase table.nt-purchase-register td:nth-child(9) > form > button.btn {
        display: inline-flex !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        align-items: center;
        justify-content: center;
        gap: 6px;
        margin: 0 !important;
        padding: 7px 8px !important;
        white-space: nowrap !important;
        line-height: 1.15;
        box-sizing: border-box;
        font-size: clamp(10px, .72vw, 12px) !important;
    }
}

/* Tablet/phone keeps horizontal scrolling, but status badges and action controls
   still remain inside their cells and use predictable vertical stacking. */
@media screen and (max-width: 900px) {
    .page-purchase table.nt-purchase-register th:nth-child(6),
    .page-purchase table.nt-purchase-register td:nth-child(6),
    .page-purchase table.nt-purchase-register th:nth-child(7),
    .page-purchase table.nt-purchase-register td:nth-child(7) {
        min-width: 116px !important;
        white-space: normal !important;
        text-align: center !important;
    }

    .page-purchase table.nt-purchase-register td:nth-child(6) .badge,
    .page-purchase table.nt-purchase-register td:nth-child(7) .badge {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        max-width: 100% !important;
        box-sizing: border-box;
        white-space: normal !important;
        line-height: 1.12;
        text-align: center;
    }

    .page-purchase table.nt-purchase-register th:nth-child(9),
    .page-purchase table.nt-purchase-register td:nth-child(9) {
        min-width: 142px !important;
        white-space: normal !important;
        text-align: center !important;
    }

    .page-purchase table.nt-purchase-register td:nth-child(9) > form {
        display: block !important;
        margin-top: 6px !important;
    }

    .page-purchase table.nt-purchase-register td:nth-child(9) > span {
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 5px;
        margin-top: 7px !important;
    }

    .page-purchase table.nt-purchase-register td:nth-child(9) > a.btn,
    .page-purchase table.nt-purchase-register td:nth-child(9) > form > button.btn {
        display: inline-flex !important;
        width: 100% !important;
        max-width: 100% !important;
        align-items: center;
        justify-content: center;
        margin: 0 !important;
        box-sizing: border-box;
        white-space: nowrap !important;
    }
}
