/**
 * TUNA TRADERS V12 - Core Application Stylesheet
 * Brand Colors: Navy Blue (#132b3a, #1e4053) & Gold (#d5a84c)
 */

:root {
    --navy: #132b3a;
    --navy-dark: #0b1a23;
    --navy-light: #1e4053;
    --navy-hover: #25495c;
    --gold: #d5a84c;
    --gold-hover: #c49638;
    --bg: #f3f6f8;
    --card: #ffffff;
    --ink: #172b38;
    --muted: #6b7c87;
    --line: #e2e8ec;
    --green: #16865b;
    --green-bg: #e6f6ee;
    --red: #c84b4b;
    --red-bg: #fff0f0;
    --yellow-bg: #fff9e6;
    --yellow-border: #f2e2a8;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    font-family: var(--font);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--navy);
    text-decoration: none;
}

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

/* Universal Base for all Buttons and Button-like Links */
button,
a.btn,
.btn,
a.btn-primary,
button.btn-primary,
.btn-primary,
a.btn-gold,
button.btn-gold,
.btn-gold,
a.btn-light,
button.btn-light,
.btn-light,
a.btn-green,
button.btn-green,
.btn-green,
a.btn-red,
button.btn-red,
.btn-red {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    cursor: pointer !important;
    border: 1px solid transparent !important;
    border-radius: 8px !important;
    height: 38px !important;
    padding: 0 16px !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    transition: all 0.18s ease-in-out !important;
    box-shadow: 0 1px 3px rgba(19, 43, 58, 0.08) !important;
    vertical-align: middle !important;
    box-sizing: border-box !important;
    font-family: inherit !important;
}

/* Explicit Button Color Schemes for All Pseudo-States */
a.btn-primary,
a.btn-primary:link,
a.btn-primary:visited,
button.btn-primary,
.btn-primary {
    background: #132b3a !important;
    color: #ffffff !important;
    border-color: #132b3a !important;
}

a.btn-primary:hover,
a.btn-primary:focus,
a.btn-primary:active,
button.btn-primary:hover,
button.btn-primary:focus,
button.btn-primary:active,
.btn-primary:hover {
    background: #0b1a23 !important;
    color: #ffffff !important;
    border-color: #0b1a23 !important;
}

a.btn-gold,
a.btn-gold:link,
a.btn-gold:visited,
button.btn-gold,
.btn-gold {
    background: #d5a84c !important;
    color: #142d3b !important;
    border-color: #c79a40 !important;
}

a.btn-gold:hover,
a.btn-gold:focus,
a.btn-gold:active,
button.btn-gold:hover,
button.btn-gold:focus,
button.btn-gold:active,
.btn-gold:hover {
    background: #c49638 !important;
    color: #0e202a !important;
    border-color: #b38529 !important;
}

a.btn-light,
a.btn-light:link,
a.btn-light:visited,
button.btn-light,
.btn-light {
    background: #edf2f5 !important;
    color: #132b3a !important;
    border-color: #dde5ea !important;
}

a.btn-light:hover,
a.btn-light:focus,
a.btn-light:active,
button.btn-light:hover,
button.btn-light:focus,
button.btn-light:active,
.btn-light:hover {
    background: #e2e9ee !important;
    color: #0b1a23 !important;
    border-color: #cdd8df !important;
}

a.btn-green,
a.btn-green:link,
a.btn-green:visited,
button.btn-green,
.btn-green {
    background: #e6f6ee !important;
    color: #16865b !important;
    border-color: #bce6ce !important;
}

a.btn-green:hover,
a.btn-green:focus,
a.btn-green:active,
button.btn-green:hover,
button.btn-green:focus,
button.btn-green:active,
.btn-green:hover {
    background: #d4f0e2 !important;
    color: #0e633d !important;
    border-color: #a7dbc0 !important;
}

a.btn-red,
a.btn-red:link,
a.btn-red:visited,
button.btn-red,
.btn-red {
    background: #fff0f0 !important;
    color: #c84b4b !important;
    border-color: #fed0d0 !important;
}

a.btn-red:hover,
a.btn-red:focus,
a.btn-red:active,
button.btn-red:hover,
button.btn-red:focus,
button.btn-red:active,
.btn-red:hover {
    background: #fedada !important;
    color: #a42c2c !important;
    border-color: #fca5a5 !important;
}

/* Small Button Variant */
a.btn-sm,
button.btn-sm,
.btn-sm {
    height: 30px !important;
    padding: 0 10px !important;
    font-size: 12px !important;
    border-radius: 6px !important;
    gap: 5px !important;
}

/* Icon Action Buttons (Eye for View, Pencil for Edit, Trash for Delete) */
a.btn-icon,
button.btn-icon,
.btn-icon {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px !important;
    border: 1px solid #d3dfe6 !important;
    background: #ffffff !important;
    color: #132b3a !important;
    cursor: pointer !important;
    box-shadow: 0 1px 2px rgba(19, 43, 58, 0.05) !important;
    transition: all 0.15s ease-in-out !important;
    text-decoration: none !important;
    vertical-align: middle !important;
    box-sizing: border-box !important;
    line-height: 1 !important;
}

a.btn-icon:hover,
button.btn-icon:hover,
.btn-icon:hover {
    background: #edf2f5 !important;
    color: #0b1a23 !important;
    border-color: #bbcdd7 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(19, 43, 58, 0.1) !important;
}

/* Specific Action Variants */
a.btn-icon-view:hover,
button.btn-icon-view:hover,
.btn-icon-view:hover {
    background: #e0f2fe !important;
    color: #0284c7 !important;
    border-color: #7dd3fc !important;
}

a.btn-icon-edit:hover,
button.btn-icon-edit:hover,
.btn-icon-edit:hover {
    background: #fef3c7 !important;
    color: #d97706 !important;
    border-color: #fcd34d !important;
}

a.btn-icon-delete,
button.btn-icon-delete,
.btn-icon-delete {
    color: #dc2626 !important;
    border-color: #fecaca !important;
    background: #fffafa !important;
}

a.btn-icon-delete:hover,
button.btn-icon-delete:hover,
.btn-icon-delete:hover {
    background: #fee2e2 !important;
    color: #b91c1c !important;
    border-color: #fca5a5 !important;
}

.btn-icon svg {
    display: block !important;
    pointer-events: none !important;
}

/* App Layout Grid */
.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

/* Sidebar */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    align-self: start;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--navy);
    color: #ffffff;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 2px 0 12px rgba(19, 43, 58, 0.08);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 6px 8px;
}

.brandmark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--gold);
    color: #142d3b;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 19px;
    box-shadow: 0 4px 10px rgba(213, 168, 76, 0.3);
}

.brand strong {
    display: block;
    font-size: 16px;
    letter-spacing: -0.2px;
    color: #ffffff;
}

.brand small {
    color: #a4b9c4;
    font-size: 11px;
}

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

.nav-item {
    background: transparent;
    color: #d1dde3;
    text-align: left;
    padding: 11px 14px;
    display: flex;
    gap: 12px;
    align-items: center;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover,
.nav-item.active {
    background: var(--navy-hover);
    color: #ffffff;
}

.nav-item.active {
    font-weight: 700;
    border-left: 3px solid var(--gold);
}

.nav .ico {
    width: 20px;
    text-align: center;
    font-size: 15px;
}

/* Sidebar Submenu */
.nav-group {
    display: flex;
    flex-direction: column;
}

.nav-sub {
    display: none;
    flex-direction: column;
    padding-left: 28px;
    margin: 4px 0 6px;
    gap: 2px;
}

.nav-group.open .nav-sub,
.nav-sub.show {
    display: flex !important;
}

.nav-sub-item {
    color: #9cb0bc !important;
    padding: 6px 10px !important;
    font-size: 13px;
    font-weight: 500;
    background: transparent !important;
    border: none !important;
    border-left: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    text-decoration: none !important;
    display: flex;
    align-items: center;
    transition: color 0.15s ease-in-out;
}

.nav-sub-item:hover {
    color: #ffffff !important;
    background: transparent !important;
}

.nav-sub-item.active {
    color: var(--gold) !important;
    font-weight: 700 !important;
    background: transparent !important;
    border: none !important;
    border-left: none !important;
    box-shadow: none !important;
}

/* Master Setup 2-Column Split Layout (Left Form, Right Table) */
.grid-master {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 22px;
    align-items: start;
}

@media (max-width: 960px) {
    .grid-master {
        grid-template-columns: 1fr;
    }
}

.sidefoot {
    margin-top: auto;
    border-top: 1px solid #234356;
    padding: 16px 8px 4px;
    color: #a2b7c2;
    font-size: 12px;
}

/* Topbar */
.main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 70px;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar h1 {
    font-size: 19px;
    margin: 0;
    font-weight: 700;
    color: var(--navy);
}

.topright {
    display: flex;
    gap: 10px;
    align-items: center;
}

.topright select.role,
.topright .role {
    height: 36px;
    border: 1px solid #ced8de;
    padding: 0 12px;
    border-radius: 8px;
    background: #ffffff;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    outline: none;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(19, 43, 58, 0.04);
}

.topright select.role:focus {
    border-color: var(--navy-light);
}

.topright .badge-role {
    height: 36px;
    padding: 0 12px;
    border-radius: 8px;
    background: #f1f5f8;
    border: 1px solid #dde5ea;
    color: var(--navy);
    font-size: 12.5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.topright .pill {
    height: 36px;
    border-radius: 8px;
    padding: 0 12px;
    background: #edf2f5;
    border: 1px solid #dde5ea;
    color: #485c67;
    font-size: 12.5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.topright .btn-logout,
a.btn-logout {
    height: 36px;
    padding: 0 14px;
    border-radius: 8px;
    background: #fff2f2 !important;
    border: 1px solid #fcd2d2 !important;
    color: #c43838 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.topright .btn-logout:hover,
a.btn-logout:hover {
    background: #fee2e2 !important;
    color: #9c1c1c !important;
    border-color: #fca5a5 !important;
    text-decoration: none !important;
}

.content {
    padding: 26px 32px;
    max-width: 1540px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

.mainfoot {
    padding: 18px 32px;
    border-top: 1px solid var(--line);
    background: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
}

/* Headings and Actions */
.pagehead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.pagehead>div:first-child {
    flex: 1 1 300px;
    min-width: 240px;
}

.pagehead h2 {
    margin: 0 0 4px;
    font-size: 24px;
    letter-spacing: -0.4px;
    color: var(--navy);
}

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

.quick {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.pagehead .quick {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap;
}

.linkbtn,
a.linkbtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #466275 !important;
    text-decoration: none !important;
    padding: 4px 8px;
    border-radius: 6px;
    background: transparent;
    transition: all 0.15s ease-in-out;
}

.linkbtn:hover,
a.linkbtn:hover {
    color: var(--navy) !important;
    background: #edf2f5;
    text-decoration: none !important;
}

.quick-nav {
    display: grid;
    gap: 8px;
}

.quick-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    background: #f5f8fa;
    border: 1px solid #e2e8ec;
    color: var(--navy) !important;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none !important;
    transition: all 0.15s ease-in-out;
}

.quick-nav-link:hover {
    background: #eaf0f4;
    border-color: #ccd8df;
    color: var(--navy-dark) !important;
}

/* Panels and Cards */
.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(19, 43, 58, 0.04);
}

.panel h3 {
    margin: 0 0 14px;
    font-size: 16px;
    color: var(--navy);
}

.grid2 {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 18px;
}

.grid-equal {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
    gap: 18px;
}

@media (max-width: 980px) {
    .grid-equal {
        grid-template-columns: 1fr;
    }
}

/* Toolbars */
.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

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

.field label {
    font-size: 12px;
    color: #4b5a64;
    font-weight: 600;
}

.field input,
.field select,
.field textarea,
.toolbar input,
.toolbar select {
    border: 1px solid #ced8de;
    border-radius: 8px;
    padding: 9px 12px;
    background: #ffffff;
    min-width: 0;
    color: var(--ink);
    font-size: 13.5px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.toolbar input:focus,
.toolbar select:focus {
    outline: none;
    border-color: var(--navy-light);
    box-shadow: 0 0 0 3px rgba(30, 64, 83, 0.15);
}

/* Tables */
.tablewrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    -webkit-overflow-scrolling: touch;
}

table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
    white-space: nowrap;
}

th {
    background: #f7f9fa;
    color: #556671;
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

th,
td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
}

/* Compact Table Variant */
.table-compact th {
    padding: 10px 12px !important;
    font-size: 11px !important;
}

.table-compact td {
    padding: 9px 12px !important;
    font-size: 13px !important;
    vertical-align: middle !important;
}

/* Statement Table: Clean, readable columns with graceful scrolling and no header truncation */
.statement-wrap,
.tablewrap.statement-wrap {
    overflow-x: auto !important;
    overflow-y: visible !important;
    border: 1px solid #ccd5da;
    border-radius: 8px;
    background: #ffffff;
    width: 100%;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

.statement-table,
table.statement-table {
    width: 100% !important;
    min-width: 1020px;
    font-size: 12px !important;
    border-collapse: collapse !important;
}

.statement-table th {
    background: #f4f7f9 !important;
    color: #435560 !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    padding: 10px 8px !important;
    border-bottom: 2px solid #ccd5da !important;
    white-space: nowrap !important;
    line-height: 1.25 !important;
    letter-spacing: 0.03em !important;
    text-transform: uppercase !important;
    overflow: visible !important;
    text-overflow: clip !important;
}

.statement-table td {
    padding: 8px 8px !important;
    font-size: 12px !important;
    border-bottom: 1px solid #edf1f4 !important;
    color: var(--ink) !important;
    vertical-align: middle !important;
    line-height: 1.35 !important;
}

.statement-table th.amount,
.statement-table td.amount {
    text-align: right !important;
    white-space: nowrap !important;
    font-variant-numeric: tabular-nums !important;
}

/* Balanced Column Widths without truncation */
.statement-table .col-date {
    width: 95px !important;
    white-space: nowrap !important;
}

.statement-table .col-desc {
    min-width: 200px !important;
    white-space: normal !important;
    word-break: normal !important;
}

.statement-table .col-qty {
    width: 85px !important;
    white-space: nowrap !important;
    text-align: center !important;
}

.statement-table .col-rate {
    width: 90px !important;
    white-space: nowrap !important;
    text-align: right !important;
}

.statement-table .col-disc {
    width: 70px !important;
    white-space: nowrap !important;
    text-align: center !important;
}

.statement-table .col-veh {
    width: 150px !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow: visible !important;
}

.statement-table .col-due {
    width: 105px !important;
    white-space: nowrap !important;
    text-align: right !important;
}

.statement-table .col-paid {
    width: 100px !important;
    white-space: nowrap !important;
    text-align: right !important;
}

.statement-table .col-bal {
    width: 115px !important;
    white-space: nowrap !important;
    text-align: right !important;
    font-weight: 700 !important;
}

.statement-table .col-rem {
    width: 130px !important;
    white-space: normal !important;
    word-break: normal !important;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: #fafcfd;
}

.amount {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.positive {
    color: var(--green) !important;
}

.negative {
    color: var(--red) !important;
}

.empty {
    padding: 32px;
    text-align: center;
    color: var(--muted);
    font-style: italic;
}

/* Notice and Alerts */
.notice {
    background: var(--yellow-bg);
    border: 1px solid var(--yellow-border);
    color: #72551a;
    border-radius: 10px;
    padding: 13px 15px;
    font-size: 12.5px;
    line-height: 1.5;
}

.alerts-container {
    margin-bottom: 18px;
    display: grid;
    gap: 8px;
}

.alert {
    padding: 12px 16px;
    border-radius: 9px;
    font-size: 13.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: opacity 0.35s ease, transform 0.35s ease, max-height 0.35s ease, padding 0.35s ease, margin 0.35s ease;
    overflow: hidden;
}

.alert-success {
    background: var(--green-bg);
    border: 1px solid #bde6d3;
    color: #0b633d;
}

.alert-error {
    background: var(--red-bg);
    border: 1px solid #f9cccc;
    color: #9c2c2c;
}

.alert-warning {
    background: var(--yellow-bg);
    border: 1px solid var(--yellow-border);
    color: #765a20;
}

.alert-info {
    background: #eef6fa;
    border: 1px solid #cee4f0;
    color: #175270;
}

.alert-close {
    background: none;
    border: none;
    font-size: 18px;
    color: inherit;
    opacity: 0.6;
    padding: 0 4px;
}

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

/* Modals */
.modalback {
    position: fixed;
    inset: 0;
    background: rgba(11, 29, 40, 0.65);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.modalback.show {
    display: flex;
}

/* Professional Confirmation Modal */
.confirm-modalback {
    z-index: 1000 !important;
    background: rgba(11, 29, 40, 0.72) !important;
    backdrop-filter: blur(5px) !important;
}

.confirm-modal {
    max-width: 440px !important;
    width: 90% !important;
    border-radius: 16px !important;
    padding: 28px 26px 22px !important;
    text-align: center !important;
    background: #ffffff !important;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.12) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    animation: confirmScaleUp 0.18s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

@keyframes confirmScaleUp {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

.confirm-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    background: #fef2f2;
    color: #dc2626;
    border: 4px solid #fee2e2;
    box-sizing: border-box;
}

.confirm-icon.warning {
    background: #fffbeb;
    color: #d97706;
    border-color: #fef3c7;
}

.confirm-title {
    margin: 0 0 10px;
    font-size: 19px;
    font-weight: 700;
    color: #132b3a;
    line-height: 1.3;
}

.confirm-message {
    margin: 0 0 24px;
    font-size: 14px;
    color: #4b6372;
    line-height: 1.55;
    word-break: break-word;
    max-width: 380px;
}

.confirm-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.confirm-actions button {
    flex: 1;
    height: 42px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    justify-content: center !important;
}

.modal {
    background: #ffffff;
    border-radius: 16px;
    width: min(720px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.modalhead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}

.modalhead h3 {
    margin: 0;
    font-size: 18px;
    color: var(--navy);
}

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

.formgrid .wide {
    grid-column: 1 / -1;
}

.modalactions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.modalactions button,
.modalactions a.btn,
.modalactions a.btn-light,
.modalactions a.btn-primary {
    min-width: 100px;
    height: 40px !important;
}

.mobilemenu {
    display: none;
}

.navscrim {
    display: none;
}

/* Mobile & Tablet Responsiveness */
@media (max-width: 960px) {
    .app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: flex;
        position: fixed;
        z-index: 40;
        inset: 0 auto 0 0;
        width: min(84vw, 290px);
        transform: translateX(-105%);
        transition: transform 0.22s ease-in-out;
        box-shadow: 12px 0 35px rgba(16, 39, 53, 0.25);
    }

    body.nav-open .sidebar {
        transform: translateX(0);
    }

    body.nav-open .navscrim {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(7, 25, 35, 0.6);
        z-index: 39;
    }

    .mobilemenu {
        display: inline-block;
    }

    .content {
        padding: 18px;
    }

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

@media (max-width: 580px) {
    .topbar {
        padding: 0 14px;
        height: 62px;
    }

    .topright .role {
        max-width: 120px;
        font-size: 12px;
        padding: 6px 8px;
    }

    .content {
        padding: 14px;
    }

    .pagehead {
        display: block;
    }

    .pagehead .quick {
        margin-top: 12px;
    }

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

    .formgrid .wide {
        grid-column: auto;
    }

    .toolbar input,
    .toolbar select {
        width: 100%;
    }

    .modalback {
        padding: 0;
        align-items: flex-end;
    }

    .modal {
        border-radius: 18px 18px 0 0;
        max-height: 94vh;
        width: 100%;
    }
}

/* Universal Vehicle Number formatting */
.vehicle-input,
input[name*="vehicle"],
input[name^="vehicle"] {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Destination re-uses the vehicle2 column but is free text - no uppercase */
input.destination-input[name^="vehicle"] {
    text-transform: none;
    letter-spacing: normal;
}
/* ==========================================================================
   Date fields (DD/MM/YY display) - see public/assets/js/dates.js
   The real <input type="date"> stays in the form (YYYY-MM-DD value) but is
   visually hidden; it only provides the native calendar popup.
   ========================================================================== */
.date-field {
    position: relative;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.field .date-field {
    display: flex;
    width: 100%;
}

.date-field input.date-text {
    width: 9.5em;
    padding-right: 34px;
    font-variant-numeric: tabular-nums;
}

.field .date-field input.date-text {
    flex: 1 1 auto;
    width: 100%;
}

.date-field.is-invalid input.date-text {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(200, 75, 75, 0.15);
}

/* !important needed to beat the global `button { ... !important }` base rule */
.date-field button.date-pick {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px !important;
    height: 28px !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    background: transparent;
    color: var(--muted);
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.date-field button.date-pick svg {
    flex: none;
}

.date-field button.date-pick:hover {
    color: var(--navy);
    background: #f1f5f8;
}

.date-field input.date-native {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 1px;
    height: 1px;
    min-width: 0;
    padding: 0;
    margin: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

@media print {
    .date-field button.date-pick {
        display: none !important;
    }
}

/* ==========================================================================
   Customer live search - see public/assets/js/customer-search.js
   ========================================================================== */
#customerList [hidden] {
    display: none !important;
}

#customerList tbody {
    transition: opacity 0.15s ease 0.1s;
}

#customerList.is-loading tbody {
    opacity: 0.55;
}

.live-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--muted);
}

.live-status.is-error {
    color: var(--red);
}

.live-spinner {
    width: 13px;
    height: 13px;
    border: 2px solid #ced8de;
    border-top-color: var(--navy-light);
    border-radius: 50%;
    animation: live-spin 0.7s linear infinite;
}

.live-status button.live-retry {
    border: 1px solid currentColor !important;
    background: transparent;
    color: inherit;
    border-radius: 6px !important;
    height: 24px !important;
    padding: 0 8px !important;
    font-size: 12px !important;
    box-shadow: none !important;
    cursor: pointer;
}

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

@media (prefers-reduced-motion: reduce) {
    .live-spinner { animation-duration: 2s; }
}

/* Vehicle number + destination cell (View::vehicleDestination) */
.veh-no {
    display: block;
    white-space: nowrap;
}

.veh-dest {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

/* Print-only customer statement - never visible on screen */
.print-statement {
    display: none;
}

/* ==========================================================================
   Reporting period filter (resources/views/components/period_filter.php)
   ========================================================================== */
.period-filter {
    margin-bottom: 8px;
    padding: 14px 18px;
}

.pf-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.pf-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.pf-field > span {
    font-size: 12px;
    font-weight: 600;
    color: #4b5a64;
}

.pf-field select,
.pf-field input {
    border: 1px solid #ced8de;
    border-radius: 8px;
    padding: 9px 12px;
    background: #ffffff;
    color: var(--ink);
    font-size: 13.5px;
    min-width: 150px;
    height: 40px;
    box-sizing: border-box;
}

.pf-field select:focus,
.pf-field input:focus {
    outline: none;
    border-color: var(--navy-light);
    box-shadow: 0 0 0 3px rgba(30, 64, 83, 0.15);
}

.pf-field .date-field input.date-text {
    width: 9.5em;
    min-width: 0;
}

.pf-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.period-filter [hidden] {
    display: none !important;
}

.pf-summary {
    margin: 0 0 16px 2px;
    font-size: 13px;
    color: var(--muted);
}

.pf-summary strong {
    color: var(--navy);
}

.pf-note {
    margin: 12px 2px 0;
    font-size: 12.5px;
}

@media (max-width: 640px) {
    .pf-field,
    .pf-field select {
        width: 100%;
    }

    .pf-actions {
        margin-left: 0;
        width: 100%;
    }
}

/* Print letterhead (layouts/main.php) - only visible when printing */
.print-letterhead {
    display: none;
}

/* Shown only when printing (e.g. full, un-paginated report tables) */
.print-only {
    display: none;
}

/* TUNA POULTRY egg sale lines (transactions/_poultry_form.php) */
.egg-table input[type="text"],
.egg-table input[type="number"] {
    width: 100%;
    border: 1px solid #ced8de;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13.5px;
    box-sizing: border-box;
}

.egg-table input[type="number"] {
    text-align: right;
}

.egg-table td {
    vertical-align: middle;
}

/* Number inputs: no spinner arrows (values change only by typing) */
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;
}

/* TUNA POULTRY ledger: fit the panel without horizontal scrolling */
table.poultry-ledger th,
table.poultry-ledger td {
    padding: 9px 8px;
}

table.poultry-ledger th {
    white-space: normal;
    line-height: 1.25;
}

table.poultry-ledger td:nth-child(2),
table.poultry-ledger td:nth-child(8) {
    white-space: normal;
    min-width: 110px;
}

table.poultry-ledger td.pl-bf {
    white-space: nowrap; /* "Balance Brought Forward" on one line */
}


/* ==========================================================================
   Mobile responsive layer (phones & small tablets). Desktop is unchanged.
   ========================================================================== */
@media (max-width: 760px) {
    /* --- Header: row 1 = menu + title, row 2 = workspace / date / sign out --- */
    .topbar {
        height: auto;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 14px;
    }

    .topbar > div:first-child {
        min-width: 0;
        flex: 1 1 100%;
    }

    .topbar h1 {
        font-size: 16px;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topright {
        width: 100%;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .topright form {
        flex: 1 1 auto;
        min-width: 0;
    }

    .topright select.role {
        width: 100%;
        max-width: none;
    }

    .topright .badge-role {
        display: none !important; /* role is not needed on the phone header */
    }

    .topright #today,
    .topright .btn-logout {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    /* --- Page heading + action buttons --- */
    .pagehead {
        display: block;
    }

    .pagehead h2 {
        font-size: 20px;
    }

    .pagehead .quick {
        display: flex !important;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 12px;
    }

    .pagehead .quick > *,
    .pagehead .quick > form > button {
        flex: 1 1 calc(50% - 8px);
        min-width: 0;
    }

    .pagehead .quick > form {
        display: flex !important;
    }

    .pagehead .quick > form > button {
        width: 100%;
    }

    /* --- Grids / panels never wider than the screen --- */
    .grid2,
    .grid-equal,
    .grid-master,
    .formgrid {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .panel,
    section.panel {
        min-width: 0;
        max-width: 100%;
        padding: 16px;
    }

    .toolbar {
        min-width: 0;
    }

    .toolbar > h3,
    .panel h3 {
        min-width: 0;
        overflow-wrap: anywhere;
    }

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

    .stat strong {
        font-size: 19px;
        overflow-wrap: anywhere;
    }

    /* Tables scroll inside their own box, never the page */
    .tablewrap {
        max-width: 100%;
    }

    /* --- Forms: 16px text stops iOS zoom-on-focus; comfortable tap targets --- */
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    select,
    textarea {
        font-size: 16px !important;
    }

    .field input,
    .field select,
    .field textarea,
    .toolbar input,
    .toolbar select,
    .pf-field select,
    .pf-field input {
        min-height: 42px;
    }

    button.btn-sm,
    a.btn-sm,
    .btn-sm {
        min-height: 36px !important;
    }

    .btn-icon {
        width: 36px !important;
        height: 36px !important;
    }

    .nav-item,
    .nav-sub-item {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* --- Modals: full width bottom sheet, scroll inside --- */
    .modal {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh;
        overflow-y: auto;
    }

    .modalactions {
        flex-wrap: wrap;
    }

    .modalactions > * {
        flex: 1 1 auto;
    }

    /* --- Poultry egg lines: horizontal scroll inside the table box --- */
    .egg-table input[type="text"] {
        min-width: 140px;
    }

    .egg-table input[type="number"] {
        min-width: 90px;
    }
}

@media (max-width: 380px) {
    .stats {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .topright #today {
        display: none; /* very small phones: keep switcher + sign out only */
    }
}

/* Grid columns may shrink below their content (wide tables scroll inside .tablewrap instead) */
.grid2 {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
}

.grid2 > *,
.grid-equal > *,
.grid-master > *,
.dashboard-grid > * {
    min-width: 0;
}

@media (max-width: 960px) {
    .grid2 {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 760px) {
    /* long button labels wrap instead of overflowing (icon buttons keep their size) */
    .content a[class*="btn-"]:not(.btn-icon),
    .content button[class*="btn-"]:not(.btn-icon) {
        white-space: normal !important;
        height: auto !important;
        min-height: 40px;
        padding-top: 8px !important;
        padding-bottom: 8px !important;
        text-align: center;
        line-height: 1.25 !important;
    }
}

/* Full-width button whose label may wrap (any screen size) */
.content a.btn-block,
.content button.btn-block {
    width: 100%;
    white-space: normal !important;
    height: auto !important;
    min-height: 38px;
    padding-top: 8px !important;
    padding-bottom: 8px !important;
    line-height: 1.3 !important;
}

@media (max-width: 760px) {
    /* Customer ledger / statement table: keep readable columns and scroll inside its box on phones */
    .content .statement-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .content table.statement-table {
        min-width: 880px !important;
        font-size: 12.5px !important;
    }
}

/* Phones: each egg line becomes a card (label + field), no sideways scrolling */
@media (max-width: 760px) {
    .egg-wrap {
        border: 0;
        overflow: visible;
    }

    .egg-table thead {
        display: none;
    }

    .egg-table,
    .egg-table tbody,
    .egg-table tfoot {
        display: block;
        width: 100%;
    }

    .egg-table tr.egg-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 10px 12px;
        border: 1px solid var(--line);
        border-radius: 12px;
        padding: 12px;
        margin-bottom: 12px;
        background: #ffffff;
        position: relative;
    }

    .egg-table tr.egg-row td {
        display: block;
        padding: 0;
        border: 0;
    }

    .egg-table tr.egg-row td[data-label="Description"] {
        grid-column: 1 / -1;
        padding-right: 44px;
    }

    .egg-table tr.egg-row td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 12px;
        font-weight: 600;
        color: #4b5a64;
        margin-bottom: 4px;
    }

    .egg-table tr.egg-row td.egg-remove {
        position: absolute;
        top: 10px;
        right: 10px;
    }

    .egg-table input[type="text"],
    .egg-table input[type="number"] {
        min-width: 0 !important;
    }

    .egg-table tfoot tr {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: #f6f9fb;
        border: 1px solid var(--line);
        border-radius: 10px;
        padding: 10px 12px;
    }

    .egg-table tfoot th {
        background: transparent !important;
        border: 0 !important;
        padding: 0 !important;
    }

    .egg-table tfoot th:empty {
        display: none;
    }

}

/* ==========================================================================
   TUNA POULTRY egg sale form - invoice layout (transactions/_poultry_form.php)
   ========================================================================== */
.egg-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    align-items: start;
}

.egg-main {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.egg-card {
    margin: 0;
}

.egg-card-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.egg-card-head h3 {
    margin: 0;
    font-size: 16px;
    color: var(--navy);
}

.egg-card-head p {
    margin: 2px 0 0;
    font-size: 12.5px;
    color: var(--muted);
}

.egg-step {
    flex: 0 0 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--navy);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.egg-table th,
.egg-table td {
    padding: 10px 10px;
    vertical-align: middle;
}

.egg-table input[type="text"],
.egg-table input[type="number"] {
    width: 100%;
    border: 1px solid #ced8de;
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 13.5px;
    box-sizing: border-box;
    background: #ffffff;
}

.egg-table input[type="number"] {
    text-align: right;
}

.egg-table input:focus,
.money-input input:focus {
    outline: none;
    border-color: var(--navy-light);
    box-shadow: 0 0 0 3px rgba(30, 64, 83, 0.15);
}

.egg-calc {
    font-variant-numeric: tabular-nums;
    color: #4b5a64;
}

.egg-calc-strong {
    color: var(--navy);
    font-weight: 700;
}

.egg-table tfoot th {
    background: #f6f9fb;
    font-variant-numeric: tabular-nums;
}

.content button.egg-add {
    margin-top: 12px;
    height: auto !important;
    padding: 8px 4px !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    color: var(--navy-light) !important;
    font-weight: 700 !important;
    justify-content: flex-start !important;
}

.content button.egg-add:hover {
    color: var(--navy) !important;
    text-decoration: underline !important;
}

.content button.egg-add:disabled {
    color: var(--muted) !important;
    cursor: not-allowed !important;
    text-decoration: none !important;
}

/* Rs prefix inside money fields */
.money-input {
    position: relative;
}

.money-input > span {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 13.5px;
    pointer-events: none;
}

.money-input > input,
.field .money-input > input {
    width: 100%;
    padding-left: 26px !important;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

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

/* Bill summary */
.egg-summary {
    position: sticky;
    top: 90px;
    margin: 0;
}

.egg-summary h3 {
    margin: 0 0 12px;
    font-size: 16px;
    color: var(--navy);
}

.egg-summary dl {
    margin: 0 0 16px;
}

.egg-summary dl > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    font-size: 13.5px;
}

.egg-summary dt {
    color: var(--muted);
}

.egg-summary dd {
    margin: 0;
    font-weight: 600;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.egg-summary .sum-sep {
    border-top: 1px solid var(--line);
    margin-top: 6px;
    padding-top: 12px;
}

.egg-summary .sum-total {
    margin: 10px 0;
    padding: 12px;
    border-radius: 10px;
    background: var(--navy);
}

.egg-summary .sum-total dt,
.egg-summary .sum-total dd {
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
}

.egg-summary .sum-total dd {
    font-size: 19px;
}

.egg-summary .sum-balance {
    border-top: 1px dashed #ced8de;
    margin-top: 4px;
    padding-top: 12px;
}

.egg-summary .sum-balance dd {
    color: var(--red);
    font-size: 16px;
    font-weight: 700;
}

.content .egg-summary .egg-save,
.content .egg-summary .egg-cancel {
    width: 100%;
    margin-top: 8px;
}

@media (max-width: 1100px) {
    .egg-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .egg-summary {
        position: static;
    }
}

@media (max-width: 760px) {
    .egg-charge-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .egg-card-head {
        margin-bottom: 12px;
    }

    .egg-table tr.egg-row td[data-label="Rate / Box"],
    .egg-table tr.egg-row td[data-label="Amount"] {
        text-align: left;
        background: #f6f9fb;
        border-radius: 8px;
        padding: 8px 10px;
    }
}

.edit-calc {
    background: #f6f9fb;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13.5px;
}

.edit-calc strong {
    color: var(--navy);
}

/* Poultry ledger: charges included in the bill, shown under the description */
.bill-charges {
    margin-top: 3px;
    font-size: 12px;
    color: var(--muted);
    white-space: normal;
}
