:root {
    --app-header-bg: #0f4c81;
    --app-header-fg: #ffffff;
    --app-navbar-bg: #f5a623;
    --app-navbar-fg: #1f2937;
    --app-navbar-hover-fg: #ffffff;
    --app-navbar-active-bg: #1b2850;
    --shell-header-h: 64px;
    --shell-sidebar-w: 260px;
    --shell-sidebar-mini: 80px;
}

body {
    font-family: Nunito, "Segoe UI", sans-serif;
    font-size: 14px;
    color: #212b36;
    line-height: 1.5;
    background: #fafbfe;
}

.app-header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 50;
    height: var(--shell-header-h);
    background: var(--app-header-bg);
    color: var(--app-header-fg);
    box-shadow: 0 1px 8px rgba(15, 23, 42, 0.18);
}

.app-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 100%;
    padding: 0 16px;
}

.app-header-brand,
.app-header-context,
.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.app-header-context {
    flex: 1;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
}

.icon-btn,
.avatar-btn,
.brand-mark {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    text-decoration: none;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
}

.icon-btn:hover,
.avatar-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 0 12px;
    border-radius: 6px;
    background: #fff;
    color: var(--app-header-bg);
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.context-pill,
.context-muted {
    color: rgba(255, 255, 255, 0.88);
}

.context-pill {
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.12);
}

.context-sep {
    color: rgba(255, 255, 255, 0.6);
}

.avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: #fff;
    color: var(--app-header-bg);
    font-size: 13px;
    font-weight: 700;
}

.user-menu {
    position: relative;
    flex: none;
}

.user-menu-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 224px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    color: #1f2937;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
}

.user-menu-id {
    padding: 12px 16px;
}

.user-menu-id p {
    margin: 0;
}

.user-menu-id p:first-child {
    font-weight: 700;
}

.user-menu-id p:last-child {
    margin-top: 2px;
    color: #6b7280;
    font-size: 12px;
}

.user-menu-panel form {
    border-top: 1px solid #f3f4f6;
}

.user-menu-panel button {
    width: 100%;
    min-height: 40px;
    border: 0;
    background: transparent;
    color: #dc2626;
    text-align: left;
    padding: 0 16px;
    cursor: pointer;
}

.user-menu-panel button:hover {
    background: #fef2f2;
}

.sidebar {
    position: fixed;
    top: var(--shell-header-h);
    bottom: 0;
    left: 0;
    z-index: 40;
    width: var(--shell-sidebar-w);
    overflow: auto;
    background: var(--app-navbar-bg);
    border-right: 1px solid color-mix(in srgb, var(--app-navbar-fg) 12%, var(--app-navbar-bg));
    transition: width 0.2s ease, margin-left 0.4s ease;
}

.sidebar-menu {
    padding: 20px;
}

.sidebar-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-menu > ul > li {
    margin-bottom: 10px;
}

.sidebar-menu > ul > li > a,
.sidebar-menu > ul > li > button {
    display: flex;
    align-items: center;
    width: 100%;
    position: relative;
    padding: 10px 15px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--app-navbar-fg);
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.sidebar-menu > ul > li > a svg,
.sidebar-menu > ul > li > button svg {
    width: 18px;
    height: 18px;
    flex: none;
}

.sidebar-menu > ul > li > a span,
.sidebar-menu > ul > li > button span {
    margin-left: 10px;
}

.sidebar-menu > ul > li > a:hover,
.sidebar-menu > ul > li > button:hover,
.sidebar-menu > ul > li > a.active,
.sidebar-menu > ul > li > button.active,
.sidebar-menu > ul > li.active > a,
.sidebar-menu > ul > li.active > button {
    background: var(--app-navbar-active-bg);
    color: var(--app-navbar-hover-fg);
}

.sidebar-menu > ul > li > button .menu-arrow {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-left: auto;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.2s ease;
}

.sidebar-menu .subdrop .menu-arrow {
    transform: rotate(45deg);
}

.sidebar-menu > ul > li.submenu > ul {
    display: none;
    margin-top: 8px;
    padding: 10px 0;
    border-radius: 5px;
    background: var(--app-navbar-active-bg);
}

.sidebar-menu > ul > li.submenu > ul.is-open {
    display: block;
}

.sidebar-menu > ul > li.submenu > ul a {
    display: block;
    position: relative;
    padding: 8px 8px 8px 40px;
    color: var(--app-navbar-hover-fg);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.sidebar-menu > ul > li.submenu > ul a::after {
    content: "";
    position: absolute;
    top: 13px;
    left: 16px;
    width: 10px;
    height: 10px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 50px;
}

.sidebar-menu > ul > li.submenu > ul a:hover,
.sidebar-menu > ul > li.submenu > ul a.active {
    color: var(--app-navbar-hover-fg);
}

.sidebar-menu > ul > li.submenu > ul a:hover::after,
.sidebar-menu > ul > li.submenu > ul a.active::after {
    background: var(--app-navbar-hover-fg);
    border-color: var(--app-navbar-hover-fg);
}

.page-wrapper {
    min-height: 100vh;
    margin-left: var(--shell-sidebar-w);
    padding-top: var(--shell-header-h);
    background-color: #f1f5f9;
    background-image: linear-gradient(165deg, rgba(15, 76, 129, 0.16) 0%, rgba(15, 76, 129, 0.05) 42%, #f1f5f9 100%);
    transition: margin-left 0.2s ease;
}

.page-wrapper .content {
    padding: 25px;
}

.page-wrapper .shell {
    min-height: 0;
}

.sidebar-overlay {
    display: none;
}

.mobile-only { display: none; }
.desktop-only { display: inline-flex; }

@media (max-width: 991px) {
    .mobile-only { display: inline-flex; }
    .desktop-only { display: none; }
    .app-header-context { display: none; }

    .sidebar {
        width: min(100%, 280px);
        margin-left: -100%;
        z-index: 60;
    }

    .main-wrapper.slide-nav .sidebar {
        margin-left: 0;
    }

    .page-wrapper {
        margin-left: 0;
    }

    .page-wrapper .content {
        padding: 15px;
    }

    .sidebar-overlay.opened {
        display: block;
        position: fixed;
        z-index: 55;
        inset: var(--shell-header-h) 0 0 0;
        background: rgba(0, 0, 0, 0.6);
    }
}

@media (min-width: 992px) {
    body.mini-sidebar .sidebar {
        width: var(--shell-sidebar-mini);
    }

    body.mini-sidebar .page-wrapper {
        margin-left: var(--shell-sidebar-mini);
    }

    body.mini-sidebar .sidebar-menu > ul > li > a span,
    body.mini-sidebar .sidebar-menu > ul > li > button span {
        display: none;
    }

    body.mini-sidebar .sidebar-menu > ul > li > a,
    body.mini-sidebar .sidebar-menu > ul > li > button {
        justify-content: center;
        padding: 10px;
    }

    body.mini-sidebar .sidebar-menu > ul > li.submenu > ul {
        display: none;
    }

    body.mini-sidebar.expand-menu .sidebar {
        width: var(--shell-sidebar-w);
    }

    body.mini-sidebar.expand-menu .sidebar-menu > ul > li > a span,
    body.mini-sidebar.expand-menu .sidebar-menu > ul > li > button span {
        display: inline;
    }

    body.mini-sidebar.expand-menu .sidebar-menu > ul > li > button .menu-arrow {
        display: inline-block;
    }

    body.mini-sidebar.expand-menu .sidebar-menu > ul > li > a,
    body.mini-sidebar.expand-menu .sidebar-menu > ul > li > button {
        justify-content: flex-start;
        padding: 10px 15px;
    }

    body.mini-sidebar.expand-menu .sidebar-menu > ul > li.submenu > ul.is-open {
        display: block;
    }
}

@media (max-width: 720px) {
    .app-header-bar { padding: 0 10px; }
    .brand-mark { height: 34px; font-size: 14px; }
}

.module {
    display: grid;
    gap: 16px;
}

.module-head h1,
.org-card h2 {
    margin: 0;
    font-size: 22px;
}

.module-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.module-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.module-tabs a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    border: 1px solid var(--line);
    font-weight: 600;
}

.module-tabs a.active {
    background: var(--app-header-bg);
    border-color: var(--app-header-bg);
    color: #fff;
}

.table-wrap {
    overflow-x: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
}

.module table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
}

.module thead {
    background: #0047ab;
}

.module th {
    text-align: left;
    background: #0047ab;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    vertical-align: middle;
    white-space: nowrap;
}

.module td {
    padding: 8px;
    color: #637381;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
    white-space: nowrap;
}

.module td strong {
    font-weight: 600;
}

.module tbody tr:hover,
.module tbody tr:hover td {
    background: #f5f9ff;
}

.module td.empty {
    color: var(--muted);
    font-weight: 500;
    white-space: normal;
}

.module .meta {
    display: block;
    color: #6b7280;
    font-size: 12px;
    font-weight: 500;
    white-space: normal;
}

.module .low {
    color: var(--danger);
    font-weight: 700;
}

.module .empty {
    color: var(--muted);
    text-align: center;
}

.org-card h2 {
    font-size: 18px;
}

.org-card dl {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin: 12px 0 0;
}

.org-card dt {
    color: var(--muted);
    font-size: 12px;
}

.org-card dd {
    margin: 2px 0 0;
    font-weight: 600;
}

.module-status {
    margin: 0 0 12px;
    background: #ecfdf3;
    color: #166534;
    border-radius: 12px;
    padding: 10px 12px;
}

.module-head-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.button-link {
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    text-decoration: none;
    white-space: nowrap;
}

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

.filters > div {
    flex: 1;
    min-width: 180px;
}

.module select,
.filters select {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0 12px;
    background: #fafaf9;
}

.secondary {
    min-height: 48px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    padding: 0 16px;
    cursor: pointer;
}

.org-fields {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
    display: grid;
    gap: 16px;
}

.form-card h2 {
    margin: 0 0 12px;
    font-size: 16px;
}

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

.span-2 { grid-column: 1 / -1; }

.field-error {
    color: var(--danger);
    font-size: 12px;
    margin: 4px 0 0;
}

.form-actions {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-top: 16px;
}

.form-actions .primary {
    width: auto;
    min-height: 38px;
    padding: 0 16px;
}

.catalogue-record .primary {
    width: auto;
    min-height: 38px;
    padding: 0 16px;
}

.form-actions a {
    color: var(--muted);
}

.actions-heading,
.actions-cell {
    position: sticky;
    right: 0;
    text-align: right;
}

.actions-heading {
    z-index: 2;
    background: #0047ab;
}

.actions-cell {
    z-index: 1;
    background: #fff;
    box-shadow: -8px 0 8px -8px rgba(15, 23, 42, 0.28);
}

.module tbody tr:hover .actions-cell {
    background: #f5f9ff;
}

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

.row-actions form { margin: 0; }

.action-btn {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    width: auto;
}

.action-edit {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #dbeafe;
}

.action-edit:hover { background: #dbeafe; }

.action-switch {
    background: #f9fafb;
    color: #374151;
    border-color: #e5e7eb;
}

.action-switch:hover { background: #f3f4f6; }

.pill {
    display: inline-flex;
    align-items: center;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.pill-current { background: #dbeafe; color: #1e3a8a; }
.pill-active { background: #dcfce7; color: #166534; }
.pill-inactive { background: #f3f4f6; color: #374151; }
.pill-suspended { background: #fee2e2; color: #991b1b; }

.pager {
    display: flex;
    gap: 12px;
    align-items: center;
}

.pager a { color: var(--app-header-bg); font-weight: 700; }

.index-page .module-head h1 {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.index-page .module-head p {
    margin-top: 2px;
    font-size: 12px;
    color: #6b7280;
}

.index-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.index-card-pad { padding: 12px 16px; }

.index-card-body { padding: 16px; }

.index-filters {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}

.index-page .index-filters label {
    display: block;
    margin-bottom: 4px;
    color: #0f4c81;
    font-size: 14px;
    font-weight: 600;
}

.index-page .index-control {
    width: 100%;
    min-height: 38px;
    border: 1px solid #22c55e;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    padding: 6px 10px;
}

.index-page .index-control:focus {
    outline: 2px solid #bbf7d0;
    border-color: #16a34a;
}

.index-found {
    min-height: 38px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 8px;
    background: #f0fdf4;
    color: #15803d;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.index-clear {
    width: 100%;
    min-height: 38px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.index-page .table-wrap {
    border: 0;
    border-radius: 0;
    background: transparent;
}

.index-page tbody tr:hover { background: #f5f9ff; }

.index-cards { display: none; }

.index-card-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
}

.index-card-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.index-card-side { font-weight: 700; white-space: nowrap; }

[data-live] { position: relative; }

[data-live].is-loading::after {
    content: "Loading...";
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
    color: #374151;
    font-size: 14px;
}

.index-pages { margin-top: 16px; overflow-x: auto; }

.index-pages ul {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.index-pages a,
.index-pages span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    color: #0f4c81;
    text-decoration: none;
}

.index-pages .active span {
    background: #0f4c81;
    border-color: #0f4c81;
    color: #fff;
}

.index-pages .disabled span {
    background: #f8f9fa;
    color: #9ca3af;
}

@media (max-width: 1100px) {
    .index-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
    .index-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .index-page .table-wrap { display: none; }
    .index-cards { display: flex; flex-direction: column; gap: 8px; }
}

.index-page .form-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    padding: 16px;
}

.index-page .module-form {
    display: grid;
    gap: 16px;
}

.index-page .form-grid label,
.index-page .module-form label,
.index-page .till-layout label,
.login.index-page label {
    color: #0f4c81;
    font-size: 14px;
    font-weight: 600;
}

.index-page .form-grid input,
.index-page .form-grid select,
.index-page .index-control {
    width: 100%;
    min-height: 38px;
    border: 1px solid #22c55e;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    padding: 6px 10px;
}

.index-page .form-grid input:focus,
.index-page .form-grid select:focus,
.index-page .index-control:focus {
    outline: 2px solid #bbf7d0;
    border-color: #16a34a;
}

.till-layout {
    display: grid;
    gap: 12px;
    max-width: 720px;
}

.till-sale {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.till-layout:has(#receipt-card:not([hidden])) {
    max-width: 1120px;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
    align-items: start;
}

.till-layout:has(#receipt-card:not([hidden])) .till-search {
    grid-column: 1 / -1;
}

.till-receipt {
    position: sticky;
    top: 76px;
    min-width: 0;
}

@media (max-width: 1080px) {
    .till-layout:has(#receipt-card:not([hidden])) {
        grid-template-columns: 1fr;
        max-width: 720px;
    }

    .till-layout:has(#receipt-card:not([hidden])) .till-search {
        grid-column: auto;
    }

    .till-receipt {
        position: static;
    }
}

.login.index-page form {
    display: grid;
    gap: 12px;
}
