:root {
    --bg: #f5f7f8;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #64748b;
    --line: #d9e0e7;
    --primary: #0f766e;
    --primary-strong: #0b5f59;
    --danger: #b42318;
    --warning: #b45309;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

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

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 240px 1fr;
}

.sidebar {
    background: #17212b;
    color: #eef4f4;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
}

.brand {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 22px;
}

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

.nav a {
    border-radius: 8px;
    color: #cbd5e1;
    padding: 10px 12px;
}

.nav a.active,
.nav a:hover {
    background: #243241;
    color: #ffffff;
}

.admin-notice {
    align-items: center;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    color: #92400e;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.admin-notice div {
    display: grid;
    gap: 3px;
}

.user-box {
    border-top: 1px solid #334155;
    display: grid;
    gap: 5px;
    margin-top: auto;
    padding-top: 16px;
}

.user-box span,
.user-box a {
    color: #cbd5e1;
    font-size: 13px;
}

.user-box a {
    text-decoration: underline;
}

.main {
    padding: 24px;
}

.topbar {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}

.title {
    font-size: 26px;
    line-height: 1.2;
    margin: 0;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 18px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 14px;
}

.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

label {
    color: var(--muted);
    display: block;
    font-size: 13px;
    margin-bottom: 5px;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    font: inherit;
    min-height: 40px;
    padding: 9px 10px;
    width: 100%;
}

textarea {
    min-height: 82px;
    resize: vertical;
}

.btn {
    background: var(--primary);
    border: 0;
    border-radius: 7px;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-weight: 700;
    min-height: 40px;
    padding: 9px 14px;
}

.btn:hover {
    background: var(--primary-strong);
}

.btn.secondary {
    background: #334155;
}

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

.btn.small {
    min-height: 34px;
    padding: 7px 12px;
}

.btn[disabled],
.product-card[disabled] {
    cursor: not-allowed;
    opacity: 0.55;
}

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

.actions form {
    margin: 0;
}

.form-actions {
    align-items: end;
    display: flex;
    gap: 8px;
}

.compact-form {
    align-items: end;
}

.cancel-form {
    display: grid;
    gap: 6px;
    min-width: 210px;
}

.cancel-form input {
    min-height: 34px;
    padding: 7px 9px;
}

.cancel-form .btn,
.actions .btn {
    min-height: 34px;
    padding: 7px 10px;
}

.report-filter select[multiple] {
    min-height: 142px;
}

.report-filter input[type="search"] {
    margin-bottom: 8px;
}

.report-native-multiple {
    display: none;
}

.report-checklist {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 7px;
    display: grid;
    max-height: 220px;
    overflow-y: auto;
}

.report-check-option {
    align-items: center;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    display: flex;
    gap: 9px;
    min-height: 42px;
    padding: 8px 10px;
}

.report-check-option:last-child {
    border-bottom: 0;
}

.report-check-option:has(input:checked) {
    background: #ecfdf5;
}

.report-check-option input {
    flex: 0 0 auto;
    min-height: 20px;
    width: 20px;
}

.report-check-option span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.report-groups {
    display: grid;
    gap: 20px;
}

.report-groups > section > h2 {
    margin: 22px 0 12px;
}

.table-wrap {
    overflow-x: auto;
}

.table-link {
    color: var(--primary);
    font-weight: 700;
    text-decoration: underline;
}

.table-summary {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 10px;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
}

.pagination a {
    border: 1px solid var(--line);
    border-radius: 6px;
    min-width: 34px;
    padding: 7px 10px;
    text-align: center;
}

.pagination a.active,
.pagination a:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.pagination.compact {
    align-items: center;
}

.pagination.compact span {
    color: var(--muted);
    padding: 7px 4px;
}

table {
    border-collapse: collapse;
    width: 100%;
}

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

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.stat-link {
    display: block;
}

.stat-link:hover {
    border-color: var(--warning);
}

.stat strong {
    display: block;
    font-size: 24px;
    margin-top: 6px;
}

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

.low-stock {
    color: var(--warning);
    font-weight: 700;
}

.pos-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 18px;
}

.pos-workspace {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.pos-searchbar {
    align-items: center;
    background: #0f6bcb;
    border-radius: 8px;
    display: grid;
    grid-template-columns: 24px 1fr;
    min-height: 48px;
    padding: 5px 6px;
    position: relative;
    width: 100%;
}

.pos-searchbar .search-icon {
    align-items: center;
    color: #ffffff;
    display: flex;
    font-size: 18px;
    justify-content: center;
}

.pos-searchbar input {
    border: 0;
    border-radius: 8px;
    height: 36px;
    min-height: 36px;
    padding: 7px 10px;
    position: relative;
    width: 100%;
    z-index: 2;
}

.pos-suggestions {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
    left: 6px;
    max-height: 360px;
    overflow-y: auto;
    position: absolute;
    right: 6px;
    top: calc(100% + 6px);
    z-index: 20;
}

.pos-suggestions:empty {
    display: none;
}

.pos-suggestion {
    align-items: center;
    background: #ffffff;
    border: 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 12px;
    text-align: left;
    width: 100%;
}

.pos-suggestion:hover {
    background: #eef6ff;
}

.pos-suggestion:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.pos-suggestion small {
    color: var(--muted);
    display: block;
    margin-top: 3px;
}

.pos-order-area {
    align-items: stretch;
    display: grid;
    min-height: 360px;
}

.empty-cart {
    align-self: center;
    color: var(--muted);
    justify-self: center;
    text-align: center;
}

.empty-icon {
    color: #d5dde7;
    font-size: 70px;
    line-height: 1;
    margin-bottom: 12px;
}

.section-title {
    font-weight: 700;
    margin-bottom: 12px;
}

.pos-payment-panel {
    align-self: start;
    position: sticky;
    top: 18px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
}

.product-card {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    min-height: 112px;
    padding: 12px;
    text-align: left;
}

.product-card:hover {
    border-color: var(--primary);
}

.product-card strong {
    display: block;
    margin-bottom: 8px;
}

.cart-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 128px 126px 90px 34px;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.cart-row.editable-price {
    grid-template-columns: minmax(180px, 1fr) 128px 126px 90px 34px;
}

.cart-price-edit {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    display: grid;
    grid-template-columns: 1fr auto;
    min-height: 34px;
    overflow: hidden;
}

.cart-price-edit:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(17, 127, 117, 0.12);
}

.cart-price-edit input {
    border: 0;
    min-height: 32px;
    padding: 5px 6px;
    text-align: right;
}

.cart-price-edit span {
    color: var(--muted);
    font-size: 12px;
    padding-right: 7px;
}

.cart-price-text {
    color: var(--muted);
    text-align: right;
}

.cart-row button {
    min-height: 34px;
    padding: 0;
}

.cart-qty-stepper {
    display: grid;
    gap: 4px;
    grid-template-columns: 34px 50px 34px;
}

.cart-qty-stepper input {
    min-height: 34px;
    padding: 5px;
    text-align: center;
}

.totals {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
}

.totals div {
    display: flex;
    justify-content: space-between;
}

.flash {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    color: #065f46;
    margin-bottom: 18px;
    padding: 12px;
}

.error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.auth-body {
    align-items: center;
    background: #eef2f6;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    max-width: 440px;
    padding: 24px;
    width: 100%;
}

.auth-card h1 {
    margin: 0 0 8px;
}

.check {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--text);
    display: flex;
    gap: 8px;
    min-height: 40px;
    padding: 9px 10px;
}

.check input {
    min-height: auto;
    width: auto;
}

.check-list {
    display: grid;
    gap: 6px;
}

.quick-form {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.quick-form summary {
    cursor: pointer;
    font-weight: 700;
}

.quick-form-body {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.quick-customer-box details {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}

.quick-customer-box summary {
    cursor: pointer;
    font-weight: 700;
}

.quick-customer-grid {
    margin-top: 10px;
}

.stock-lines {
    display: grid;
    gap: 8px;
}

.stock-voucher-toolbar {
    align-items: center;
    display: flex;
    justify-content: flex-start;
}

.stock-voucher-panel {
    border: 2px solid var(--primary);
}

.danger-zone {
    border-color: #fecaca;
}

.stock-add-button {
    background: #0f766e;
    min-width: 230px;
}

.stock-add-button:hover {
    background: #0b5f59;
}

.stock-line {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(260px, 1fr) 140px 180px 210px 44px;
}

.stock-product-picker {
    min-width: 0;
    position: relative;
}

.stock-product-picker input {
    width: 100%;
}

.stock-new-product-fields {
    border: 1px dashed var(--line);
    border-radius: 7px;
    margin-top: 8px;
    padding: 8px;
}

.stock-new-product-fields summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}

.stock-new-product-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 8px;
}

.stock-new-product-grid label {
    color: var(--muted);
    font-size: 12px;
}

.stock-product-suggestions {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 7px;
    box-shadow: 0 10px 24px rgb(15 23 42 / 16%);
    left: 0;
    max-height: 280px;
    overflow-y: auto;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 40;
}

.stock-product-suggestion {
    background: #ffffff;
    border: 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    cursor: pointer;
    display: block;
    min-height: 42px;
    padding: 9px 11px;
    text-align: left;
    width: 100%;
}

.stock-product-suggestion:hover,
.stock-product-suggestion:focus {
    background: #ecfdf5;
}

.stock-product-suggestion:last-child {
    border-bottom: 0;
}

.stock-product-suggestion.empty {
    color: var(--muted);
    cursor: default;
}

.stock-voucher-footer {
    align-items: center;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 16px;
    justify-content: flex-end;
    padding-top: 14px;
}

.stock-voucher-total {
    align-items: flex-end;
    display: grid;
    gap: 2px;
    text-align: right;
}

.stock-voucher-total span {
    color: var(--muted);
    font-size: 13px;
}

.stock-voucher-total strong {
    color: var(--primary);
    font-size: 22px;
}

.stock-voucher-actions {
    margin: 12px 0;
}

.stock-line-head {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.stock-line .btn {
    min-height: 40px;
    padding: 0;
}

.stepper {
    display: grid;
    grid-template-columns: 38px 1fr 38px;
    gap: 6px;
}

.stepper input {
    text-align: right;
}

.app-toolbar {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-bottom: 12px;
    min-height: 38px;
}

.notification-menu {
    position: relative;
}

.notification-button {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    font-weight: 700;
    gap: 7px;
    min-height: 36px;
    padding: 7px 11px;
}

.notification-button::marker {
    content: "";
}

.notification-badge {
    align-items: center;
    background: #dc2626;
    border-radius: 999px;
    color: #ffffff;
    display: inline-flex;
    font-size: 11px;
    justify-content: center;
    min-height: 20px;
    min-width: 20px;
    padding: 2px 6px;
}

.notification-popover {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgb(15 23 42 / 16%);
    display: grid;
    min-width: 340px;
    overflow: hidden;
    position: absolute;
    right: 0;
    top: calc(100% + 7px);
    width: min(420px, calc(100vw - 32px));
    z-index: 30;
}

.notification-preview {
    border-bottom: 1px solid var(--line);
    color: var(--text);
    display: grid;
    gap: 3px;
    padding: 11px 13px;
    text-decoration: none;
}

.notification-preview.unread,
.notification-item.unread {
    background: #ecfdf5;
}

.notification-preview span,
.notification-preview small,
.notification-item p,
.notification-item small {
    color: var(--muted);
}

.notification-preview span {
    font-size: 13px;
}

.notification-all-link,
.notification-empty {
    padding: 11px 13px;
    text-align: center;
}

.notification-all-link {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.panel-heading,
.notification-item,
.notification-actions {
    align-items: center;
    display: flex;
}

.panel-heading,
.notification-item {
    justify-content: space-between;
}

.panel-heading {
    gap: 16px;
    margin-bottom: 12px;
}

.panel-heading h2 {
    margin: 0;
}

.notification-list {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.notification-item {
    border-bottom: 1px solid var(--line);
    gap: 16px;
    padding: 13px;
}

.notification-item:last-child {
    border-bottom: 0;
}

.notification-item p {
    margin: 4px 0;
}

.notification-actions {
    flex-shrink: 0;
    gap: 7px;
}

.pwa-dialog {
    border: 0;
    border-radius: 8px;
    box-shadow: 0 18px 50px rgb(15 23 42 / 28%);
    color: var(--text);
    max-width: 520px;
    padding: 0;
    width: calc(100% - 32px);
}

.pwa-dialog::backdrop {
    background: rgb(15 23 42 / 54%);
}

.pwa-dialog-heading {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    font-size: 18px;
    justify-content: space-between;
    padding: 14px 16px;
}

.pwa-dialog-close {
    background: transparent;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
    padding: 0 4px;
}

.pwa-dialog-body {
    line-height: 1.55;
    padding: 8px 16px;
}

.pwa-dialog-body ol {
    padding-left: 22px;
}

.pwa-dialog > .btn {
    margin: 0 16px 16px;
    width: calc(100% - 32px);
}

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

    .sidebar {
        position: static;
    }

    .nav {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    }

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

    .stock-line {
        grid-template-columns: 1fr;
    }

    .stock-line-head {
        display: none;
    }

    .stock-voucher-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .stock-voucher-footer .btn {
        width: 100%;
    }

    .stock-voucher-total {
        align-items: start;
        text-align: left;
    }

    .app-toolbar {
        flex-wrap: wrap;
    }

    .notification-popover {
        position: fixed;
        right: 16px;
        top: 64px;
    }

    .notification-item,
    .panel-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .admin-notice,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .col-3,
    .col-4,
    .col-6,
    .col-8 {
        grid-column: span 12;
    }
}
