:root {
    --app-ink: #172033;
    --app-muted: #667085;
    --app-line: #e4e7ec;
    --app-surface: #ffffff;
    --app-canvas: #f4f7fb;
    --app-brand: #0f766e;
    --app-brand-dark: #115e59;
    --app-accent: #e08b32;
    --app-danger: #c24148;
    --app-sidebar: #172033;
    --app-sidebar-hover: #24324b;
    --app-radius: 12px;
    --app-shadow: 0 10px 28px rgba(23, 32, 51, 0.07);
}

html {
    background: var(--app-canvas);
    overflow-x: hidden;
}

body {
    color: var(--app-ink);
    background: var(--app-canvas) !important;
    font-family: "Noto Sans Gujarati", "Nirmala UI", "Segoe UI", sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
    max-width: 100vw;
}

button,
a,
input,
select,
textarea {
    font: inherit;
}

button,
a.btn,
.btn {
    border-radius: 8px !important;
    transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

button:hover,
a.btn:hover,
.btn:hover {
    transform: translateY(-1px);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(224, 139, 50, 0.35);
    outline-offset: 2px;
}

.admin-sidebar {
    position: sticky;
    top: 0;
    z-index: 1030;
    width: 248px !important;
    min-width: 248px !important;
    max-width: 248px !important;
    flex: 0 0 248px !important;
    height: 100vh;
    overflow-y: auto;
    background: var(--app-sidebar) !important;
    border-right: 1px solid #2c3850 !important;
    box-shadow: 8px 0 24px rgba(23, 32, 51, 0.08);
}

.row:has(> .admin-sidebar) {
    flex-wrap: nowrap;
}

.admin-sidebar ~ div[class*="col-"],
.admin-sidebar ~ main[class*="col-"] {
    width: auto !important;
    max-width: none !important;
    flex: 1 1 0 !important;
    min-width: 0;
}

.admin-sidebar .brand-row {
    min-height: 74px;
    padding: 18px 16px;
    background: linear-gradient(135deg, #172033, #1d2c48) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-sidebar .brand {
    font-size: 20px;
    letter-spacing: 0.01em;
}

.admin-sidebar .nav-link {
    margin: 3px 10px;
    padding: 11px 14px;
    border: 0 !important;
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 14px;
}

.admin-sidebar .nav-link:hover,
.admin-sidebar .nav-link.active {
    color: #ffffff;
    background: var(--app-sidebar-hover);
}

.admin-sidebar .nav-link.active {
    box-shadow: inset 3px 0 0 var(--app-accent);
}

.admin-sidebar + .col-md-9,
.admin-sidebar + .col-lg-10 {
    width: auto;
    max-width: none;
    flex: 1 1 auto;
}

.admin-sidebar ~ .col-md-9,
.admin-sidebar ~ .col-lg-10 {
    min-width: 0;
}

.admin-sidebar.collapsed {
    width: 76px !important;
    min-width: 76px !important;
    max-width: 76px !important;
    flex-basis: 76px !important;
}

.admin-sidebar.collapsed .nav-link {
    margin-inline: 10px;
    font-size: 0;
}

.admin-sidebar.collapsed .nav-link::first-letter {
    font-size: 16px;
}

.admin-sidebar.collapsed .sidebar-footer span {
    display: none;
}

.admin-sidebar.collapsed .sidebar-footer a {
    padding-inline: 0;
    text-align: center;
}

.search-with-clear {
    position: relative;
}

.search-with-clear input {
    padding-right: 38px !important;
}

.search-clear {
    position: absolute;
    top: 50%;
    right: 8px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--app-muted);
    font-size: 20px;
    line-height: 1;
    transform: translateY(-50%);
    cursor: pointer;
}

.search-clear:hover {
    background: #eef2f5;
    color: var(--app-ink);
}

.dashboard-card {
    display: block;
    min-height: 140px;
    cursor: pointer;
}

.dashboard-card:hover {
    box-shadow: 0 14px 30px rgba(23, 32, 51, 0.12);
}

.support-modal {
    position: fixed;
    inset: 0;
    z-index: 1080;
    display: none;
    place-items: center;
    padding: 18px;
    background: rgba(23, 32, 51, .45);
}

.support-modal.is-open {
    display: grid;
}

.support-dialog {
    position: relative;
    width: min(420px, 100%);
    padding: 26px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 20px 55px rgba(23, 32, 51, .2);
}

.support-dialog h5 { margin: 0 0 10px; }
.support-copy { color: var(--app-muted); }
.support-detail { margin: 0; line-height: 1.8; }

.support-close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: 0;
    background: transparent;
    color: var(--app-muted);
    font-size: 25px;
    cursor: pointer;
}

.date-with-custom {
    position: relative;
}

.date-with-custom input[type="date"] {
    padding-right: 82px !important;
}

.custom-date-trigger {
    position: absolute;
    top: 50%;
    right: 7px;
    min-height: 28px;
    padding: 3px 8px;
    border: 1px solid var(--app-line);
    border-radius: 6px;
    background: #f8fafc;
    color: var(--app-brand-dark);
    font-size: 11px;
    transform: translateY(-50%);
    cursor: pointer;
}

.custom-date-trigger:hover { background: #e7f4f1; }

.custom-calendar-modal {
    position: fixed;
    inset: 0;
    z-index: 1090;
    display: none;
    place-items: center;
    padding: 18px;
    background: rgba(23, 32, 51, .45);
}

.custom-calendar-modal.is-open { display: grid; }

.custom-calendar-dialog {
    width: min(360px, 100%);
    padding: 16px;
    border: 1px solid var(--app-line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 20px 55px rgba(23, 32, 51, .22);
}

.custom-calendar-header,
.custom-calendar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.custom-calendar-header { margin-bottom: 12px; }
.calendar-nav { width: 32px; height: 32px; border: 0; border-radius: 7px; background: #eef5f4; color: var(--app-brand-dark); font-size: 22px; cursor: pointer; }
.custom-calendar-weekdays,
.custom-calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; text-align: center; }
.custom-calendar-weekdays { margin-bottom: 5px; color: var(--app-muted); font-size: 11px; }
.custom-calendar-day { display: grid; min-height: 34px; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--app-ink); font-size: 13px; cursor: pointer; }
.custom-calendar-day:not(.empty):hover { background: var(--app-brand); color: #fff; }
.custom-calendar-day.empty { cursor: default; }
.custom-calendar-footer { justify-content: flex-end; margin-top: 14px; }

.ledger-workspace {
    display: grid;
    grid-template-columns: minmax(190px, 0.32fr) minmax(300px, 1fr);
    gap: 16px;
}

.customer-rail-list {
    max-height: 300px;
    overflow-y: auto;
}

.customer-rail-item {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 48px;
    padding: 8px 12px;
    color: var(--app-ink);
    text-decoration: none;
    border-bottom: 1px solid #f0f2f5;
    font-size: 13px;
}

.customer-rail-item:hover,
.customer-rail-item.active { background: #eef7f6; color: var(--app-brand-dark); }

.customer-avatar {
    display: inline-grid;
    width: 28px;
    height: 28px;
    place-items: center;
    flex: 0 0 28px;
    border-radius: 50%;
    background: #dcefeb;
    color: var(--app-brand-dark);
    font-size: 12px;
    font-weight: 700;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(28px, 1fr));
    gap: 5px;
    padding: 12px;
}

.calendar-weekdays {
    padding-bottom: 0;
    color: var(--app-muted);
    font-size: 11px;
    text-align: center;
}

.calendar-day {
    display: grid;
    min-height: 34px;
    place-items: center;
    border-radius: 7px;
    color: var(--app-ink);
    text-decoration: none;
    font-size: 12px;
}

.calendar-day.has-orders { background: #d8f0ec; color: var(--app-brand-dark); font-weight: 700; }
.calendar-day.has-orders:hover { background: var(--app-brand); color: #fff; }
.calendar-day.disabled { color: #c5ccd5; text-decoration: line-through; }

@media (max-width: 767.98px) {
    body.sidebar-open,
    body.notification-open {
        overflow: hidden;
        touch-action: none;
    }

    .ledger-workspace { grid-template-columns: 1fr; }
}

.sidebar-backdrop {
    display: none;
}

.mobile-menu-trigger {
    display: none;
}

.bg-white.border-bottom,
.topbar {
    background: rgba(255, 255, 255, 0.94) !important;
    border-color: var(--app-line) !important;
    box-shadow: 0 1px 0 rgba(23, 32, 51, 0.03);
    backdrop-filter: blur(12px);
}

.card,
.dashboard-card,
.account-card,
.quick-btn,
.quick-actions {
    border: 1px solid var(--app-line) !important;
    border-radius: var(--app-radius) !important;
    box-shadow: var(--app-shadow) !important;
}

.card-header {
    border-bottom: 1px solid var(--app-line) !important;
}

.table {
    --bs-table-border-color: var(--app-line);
    color: var(--app-ink);
}

.table thead th,
.table-dark th {
    background: #22304a !important;
    color: #ffffff !important;
    border-color: #34435f !important;
    font-size: 12px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.table tbody tr:hover {
    background: #f8fafc;
}

.form-control,
.form-select,
input,
select,
textarea {
    min-height: 42px;
    border-color: #cfd6e2 !important;
    border-radius: 8px !important;
    color: var(--app-ink);
}

.form-control:focus,
.form-select:focus,
input:focus,
select:focus,
textarea:focus {
    border-color: var(--app-brand) !important;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14) !important;
}

.btn-primary,
.btn-success {
    background: var(--app-brand) !important;
    border-color: var(--app-brand) !important;
}

.btn-primary:hover,
.btn-success:hover {
    background: var(--app-brand-dark) !important;
    border-color: var(--app-brand-dark) !important;
}

.btn-warning {
    background: var(--app-accent) !important;
    border-color: var(--app-accent) !important;
    color: #ffffff !important;
}

.alert {
    border: 0;
    border-left: 4px solid currentColor;
    border-radius: 8px;
}

@media (max-width: 767.98px) {
    .row:has(> .admin-sidebar) {
        flex-wrap: wrap;
    }

    .admin-sidebar ~ div[class*="col-"],
    .admin-sidebar ~ main[class*="col-"] {
        width: 100% !important;
        flex: 1 1 100% !important;
    }

    .admin-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 286px !important;
        min-width: 286px !important;
        max-width: 286px !important;
        transform: translateX(-105%);
        transition: transform 220ms ease;
        overscroll-behavior: contain;
    }

    .admin-sidebar.is-open {
        transform: translateX(0);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .admin-sidebar.collapsed {
        width: 286px !important;
        min-width: 286px !important;
        max-width: 286px !important;
        flex-basis: 286px !important;
    }

    .admin-sidebar.collapsed .brand {
        display: block;
    }

    .admin-sidebar.collapsed .nav-link {
        font-size: 14px;
        text-align: left;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1020;
        background: rgba(23, 32, 51, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 220ms ease;
    }

    .sidebar-backdrop.is-visible {
        opacity: 1;
        pointer-events: auto;
    }

    .bg-white.border-bottom,
    .topbar {
        min-height: 68px;
        padding-left: 60px !important;
        padding-right: 56px !important;
        flex-wrap: wrap !important;
        row-gap: 6px;
    }

    .bg-white.border-bottom .d-flex.justify-content-between {
        flex-wrap: wrap;
        row-gap: 6px;
    }

    .card-header.d-flex {
        flex-wrap: wrap;
        row-gap: 8px;
    }

    /* Inline flex headers ("title + action button") used on several pages */
    [style*="justify-content:space-between"],
    [style*="justify-content: space-between"] {
        flex-wrap: wrap !important;
        row-gap: 8px;
    }

    /* Bootstrap utility headers ("title + button/badge") should wrap instead
       of squeezing both pieces onto one cramped line */
    .d-flex.justify-content-between {
        flex-wrap: wrap !important;
        row-gap: 8px;
    }

    .mobile-menu-trigger {
        position: fixed;
        top: 14px;
        left: 14px;
        z-index: 1040;
        display: inline-flex;
        width: 38px;
        height: 38px;
        padding: 8px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        border: 1px solid #cfd6e2;
        border-radius: 8px;
        background: #ffffff;
        box-shadow: 0 6px 16px rgba(23, 32, 51, 0.12);
    }

    .activity-dock {
        top: 12px;
        right: 14px;
    }

    .activity-panel {
        top: 48px;
        right: -2px;
        max-height: min(70vh, 520px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .mobile-menu-trigger span {
        width: 18px;
        height: 2px;
        background: var(--app-ink);
        border-radius: 2px;
    }

    .p-4 {
        padding: 1rem !important;
    }

    /* Selects/inputs/buttons: full-width, comfortable touch targets on phones */
    .form-select,
    .form-control,
    select,
    input,
    textarea {
        width: 100% !important;
        max-width: 100% !important;
        font-size: 16px !important;
    }

    .btn {
        min-height: 42px;
    }

    /*
     * Tables: instead of forcing horizontal scroll on tiny screens, stack each
     * row into a labelled card. Works together with the small script in
     * sidebar.php that copies each column's header text into a data-th
     * attribute on every cell (including rows added dynamically by JS).
     */
    .table-responsive {
        border: none;
        border-radius: 0;
        overflow-x: visible !important;
    }

    .table-responsive table,
    .table-responsive table.table,
    table {
        min-width: 0 !important;
        width: 100% !important;
    }

    .table-responsive table thead {
        display: none;
    }

    .table-responsive table,
    .table-responsive table tbody,
    .table-responsive table tfoot,
    .table-responsive table tr,
    .table-responsive table td,
    .table-responsive table th {
        display: block;
        width: 100%;
    }

    .table-responsive table tr {
        margin-bottom: 12px;
        border: 1px solid var(--app-line);
        border-radius: 10px;
        padding: 6px 10px;
        background: #ffffff;
    }

    .table-responsive table tbody tr:last-child,
    .table-responsive table tfoot tr:last-child {
        margin-bottom: 0;
    }

    .table-responsive table td,
    .table-responsive table th {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding: 7px 2px !important;
        border: none !important;
        border-bottom: 1px solid var(--app-line) !important;
        text-align: left !important;
        white-space: normal !important;
        word-break: break-word;
        min-height: auto;
    }

    .table-responsive table td:last-child,
    .table-responsive table th:last-child {
        border-bottom: none !important;
    }

    .table-responsive table td[data-th]::before,
    .table-responsive table th[data-th]::before {
        content: attr(data-th);
        font-weight: 600;
        font-size: 12px;
        color: var(--app-muted);
    }

    .table-responsive table td[data-th=""]::before,
    .table-responsive table th[data-th=""]::before {
        content: none;
    }

    .table-responsive table td > *,
    .table-responsive table th > * {
        width: 100%;
        min-width: 0;
    }

    /* Cells that only hold a short action control (checkbox, delete button,
       row number) look better centered inline instead of stacked full-width */
    .table-responsive table td:has(> input[type="checkbox"]:only-child),
    .table-responsive table td:has(> button:only-child),
    .table-responsive table td[data-th=""] {
        flex-direction: row;
        align-items: center;
    }

    .table-responsive table td:has(> input[type="checkbox"]:only-child) > *,
    .table-responsive table td:has(> button:only-child) > * {
        width: auto;
    }

    .table-responsive table td:empty,
    .table-responsive table th:empty {
        display: none;
    }

    /* A row that spans the full table (e.g. "no records found") should not look like a labelled field */
    .table-responsive table td[colspan] {
        display: block;
        text-align: center !important;
    }

    .table-responsive table td[colspan]::before {
        content: none;
    }
}

.staff-app .sidebar {
    background: var(--app-sidebar) !important;
    padding-top: 14px !important;
    box-shadow: 8px 0 24px rgba(23, 32, 51, 0.08);
}

.staff-app .sidebar a {
    margin: 3px 10px;
    padding: 11px 14px !important;
    border-radius: 8px;
    color: #cbd5e1 !important;
    font-size: 14px !important;
}

.staff-app .sidebar a:hover,
.staff-app .sidebar a.active {
    background: var(--app-sidebar-hover) !important;
    color: #ffffff !important;
}

.staff-app .card,
.staff-app .quick-actions {
    border: 1px solid var(--app-line) !important;
    border-radius: var(--app-radius) !important;
    box-shadow: var(--app-shadow) !important;
}

.staff-app .btn {
    background: var(--app-brand);
}

@media (max-width: 900px) {
    .staff-app .layout {
        display: block !important;
    }

    .staff-app .sidebar {
        width: 100% !important;
        display: flex;
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .staff-app .sidebar a {
        flex: 1 1 150px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ---- Compact tappable rows on phones (see mobile_rows.js) ---- */
@media (max-width: 767.98px) {
    .table-responsive.mobile-rows table { display: table !important; width: 100% !important; table-layout: auto; }
    .table-responsive.mobile-rows table thead { display: table-header-group !important; }
    .table-responsive.mobile-rows table tbody { display: table-row-group !important; }
    .table-responsive.mobile-rows table tr { display: table-row !important; margin: 0; padding: 0; border: none; border-radius: 0; background: transparent; width: auto; }
    .table-responsive.mobile-rows table td,
    .table-responsive.mobile-rows table th {
        display: table-cell !important; width: auto; padding: 10px 6px !important;
        border-bottom: 1px solid var(--app-line) !important; font-size: 14px; vertical-align: middle;
    }
    .table-responsive.mobile-rows table td::before,
    .table-responsive.mobile-rows table th::before { content: none !important; }
    .table-responsive.mobile-rows table thead th { font-size: 12px; white-space: nowrap !important; }
    .table-responsive.mobile-rows .mr-hide { display: none !important; }
    .table-responsive.mobile-rows table td.text-end,
    .table-responsive.mobile-rows table th.text-end { text-align: right !important; }
    .table-responsive.mobile-rows table tbody tr { cursor: pointer; }
    .table-responsive.mobile-rows table tbody tr:active { background: rgba(0, 0, 0, 0.05) !important; }
    .table-responsive.mobile-rows table tbody td:first-child { font-weight: 600; }
    .table-responsive.mobile-rows table tfoot tr { display: flex !important; justify-content: space-between; padding: 8px 6px; }
    .table-responsive.mobile-rows table tfoot th { display: block !important; border: none !important; padding: 0 !important; width: auto !important; }
}

.mr-overlay {
    position: fixed; inset: 0; z-index: 2000; background: rgba(15, 23, 42, 0.55);
    display: flex; align-items: flex-end; justify-content: center;
}
.mr-sheet {
    width: 100%; max-width: 520px; max-height: 85vh; overflow-y: auto; background: #fff;
    border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
    animation: mr-up 0.18s ease-out;
}
@keyframes mr-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.mr-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; background: #fff; }
.mr-title { font-size: 18px; font-weight: 700; word-break: break-word; }
.mr-close { border: none; background: #f1f5f9; width: 34px; height: 34px; border-radius: 50%; font-size: 22px; line-height: 1; }
.mr-body { padding: 6px 18px; }
.mr-line { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid #f1f5f9; }
.mr-line span { color: #64748b; font-size: 14px; }
.mr-line b { font-weight: 600; text-align: right; word-break: break-word; }
.mr-actions { padding: 12px 18px 20px; display: flex; gap: 10px; }
.mr-btn { flex: 1; text-align: center; padding: 12px; border-radius: 10px; background: #2563eb; color: #fff; font-weight: 600; text-decoration: none; }
body.mr-open { overflow: hidden; }
/* Keep amounts (e.g. ₹1,640) on a single line in phone tables */
@media (max-width: 767.98px) {
    .table-responsive table td.mr-amt,
    .table-responsive table td.text-end,
    .table-responsive table th.text-end,
    .table-responsive table td.text-nowrap {
        white-space: nowrap !important;
        word-break: keep-all !important;
        overflow-wrap: normal !important;
    }
}
