:root {
    --bg-1: #f8fafc;
    --bg-2: #e2e8f0;
    --surface: rgba(255, 255, 255, 0.84);
    --surface-solid: #ffffff;
    --ink: #0f172a;
    --muted: #475569;
    --primary: #0f766e;
    --primary-soft: #99f6e4;
    --accent: #f59e0b;
    --danger: #b91c1c;
    --ok: #166534;
    --ring: rgba(15, 118, 110, 0.3);
    --radius: 18px;
    --shadow: 0 18px 44px rgba(15, 23, 42, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: 'Rubik', sans-serif;
    background:
        radial-gradient(circle at 10% 10%, #ccfbf1 0%, transparent 36%),
        radial-gradient(circle at 90% 20%, #fed7aa 0%, transparent 30%),
        linear-gradient(140deg, var(--bg-1), var(--bg-2));
    color: var(--ink);
    min-height: 100%;
}

button,
input,
select,
textarea {
    font-family: 'Rubik', sans-serif;
}

body {
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

.muted {
    color: var(--muted);
    margin: 0;
}

.btn {
    border: 0;
    border-radius: 14px;
    padding: 0.78rem 1.1rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.btn:hover {
    transform: translateY(-1px);
    filter: saturate(1.06);
}

.btn-primary {
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    color: #fff;
    box-shadow: 0 8px 24px rgba(15, 118, 110, 0.35);
}

.alert {
    border-radius: 12px;
    padding: 0.85rem 0.95rem;
    margin-bottom: 0.75rem;
    font-size: 0.92rem;
}

.alert.error {
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.alert.success {
    background: #dcfce7;
    color: var(--ok);
    border: 1px solid #bbf7d0;
}

.auth-body,
.installer-body {
    display: grid;
    place-items: center;
    padding: 1.25rem;
}

.auth-wrap,
.install-wrap {
    width: min(920px, 100%);
}

.auth-card,
.install-card {
    background: var(--surface);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.35rem;
    animation: riseIn 0.45s ease;
}

.auth-card {
    width: min(460px, 100%);
    margin-inline: auto;
}

.auth-card h1,
.install-card h1 {
    margin: 0 0 0.3rem;
    font-size: 1.35rem;
}

.auth-version {
    margin: 0.25rem 0 0;
    color: var(--muted);
    text-align: center;
    font-size: 0.84rem;
}

.auth-version a {
    color: #6366f1;
    text-decoration: none;
    font-weight: 500;
}

.auth-version a:hover {
    text-decoration: underline;
}

.stack-form,
.grid-form {
    display: grid;
    gap: 0.85rem;
    margin-top: 0.95rem;
}

.grid-form h2 {
    margin: 0.5rem 0 0;
    color: #0f766e;
    font-size: 1rem;
}

.grid-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-form.compact {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.grid-form.cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-form .btn,
.grid-form h2 {
    grid-column: 1 / -1;
}

.field-required {
    font-size: 0.75rem;
    font-weight: 500;
    color: #f87171;
}

.field-optional {
    font-size: 0.75rem;
    font-weight: 400;
    color: #94a3b8;
}

label {
    display: grid;
    gap: 0.38rem;
    font-size: 0.9rem;
    color: #334155;
}

input,
select {
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 0.7rem 0.72rem;
    font-family: inherit;
    background: #fff;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
    border-color: #0f766e;
    box-shadow: 0 0 0 4px var(--ring);
}

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
    padding: 1rem 0.85rem;
    display: grid;
    grid-template-rows: auto auto auto auto auto auto;
    gap: 1rem;
    align-content: start;
}

.brand h1 {
    margin: 0;
    font-size: 1rem;
}

.sidebar-clock {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 0.55rem 0.85rem 0.6rem;
    text-align: center;
    align-self: start;
}

.sidebar-clock__time {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #5eead4;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.sidebar-clock__date {
    font-size: 0.82rem;
    color: #e2e8f0;
    margin-top: 0.2rem;
    line-height: 1.2;
}

.brand span {
    font-size: 0.8rem;
    color: #94a3b8;
}

.menu {
    display: grid;
    gap: 0.35rem;
    align-content: start;
}

.menu a {
    border-radius: 12px;
    padding: 0.62rem 0.7rem;
    color: #cbd5e1;
    transition: background 0.2s ease, color 0.2s ease;
}

.menu a:hover,
.menu a.active {
    background: rgba(45, 212, 191, 0.16);
    color: #ccfbf1;
}

.logout-link {
    color: #fecaca;
    font-size: 0.92rem;
    text-align: center;
    padding: 0.65rem;
    border-radius: 12px;
    border: 1px dashed rgba(252, 165, 165, 0.45);
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.logout-link:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border-color: rgba(252, 165, 165, 0.8);
}

.sidebar-support {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 0.55rem 0.85rem 0.6rem;
    text-align: center;
}

.sidebar-support__title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #5eead4;
    line-height: 1.2;
}

.sidebar-support__text {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 0.2rem;
    line-height: 1.2;
}

.sidebar-support__number {
    display: inline-block;
    margin-top: 0.35rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #e2e8f0;
    letter-spacing: 0.03em;
}

/* ── Sidebar subscription card ── */
.sidebar-subscription {
    border-radius: 12px;
    padding: 0.55rem 0.85rem 0.6rem;
    text-align: center;
}

.sidebar-subscription--active {
    background: rgba(34,197,94,0.12);
    border: 1px solid rgba(34,197,94,0.35);
}

.sidebar-subscription--warning {
    background: rgba(234,179,8,0.13);
    border: 1px solid rgba(234,179,8,0.4);
}

.sidebar-subscription--expired {
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.35);
}

.sidebar-subscription__title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #86efac;
    line-height: 1.2;
    margin-bottom: 0.3rem;
}

.sidebar-subscription--warning .sidebar-subscription__title {
    color: #fde047;
}

.sidebar-subscription--expired .sidebar-subscription__title {
    color: #fca5a5;
}

.sidebar-subscription__row {
    font-size: 0.76rem;
    color: #94a3b8;
    line-height: 1.6;
}

.sidebar-subscription__row span {
    color: #e2e8f0;
    font-weight: 600;
}

.sidebar-subscription__row.expired span {
    color: #f87171;
}

/* ── Expired page ── */
.expired-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Rubik', sans-serif;
}

.expired-wrap {
    width: 100%;
    max-width: 420px;
    padding: 1.5rem;
}

.expired-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(15,23,42,0.12);
    padding: 2.5rem 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.expired-icon {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.expired-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: #dc2626;
    margin: 0;
}

.expired-msg {
    font-size: 1rem;
    color: #334155;
    margin: 0.25rem 0 0;
}

.expired-hint {
    font-size: 0.88rem;
    color: #64748b;
    margin: 0;
}

.expired-support {
    margin-top: 1.25rem;
    background: #0f172a;
    border-radius: 12px;
    padding: 0.7rem 1.2rem 0.8rem;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

.expired-support__title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #5eead4;
}

.expired-support__text {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 0.2rem;
}

.expired-support__number {
    display: inline-block;
    margin-top: 0.35rem;
    font-size: 1rem;
    font-weight: 700;
    color: #e2e8f0;
    letter-spacing: 0.04em;
}

.content {
    padding: 1rem;
    display: grid;
    gap: 0.9rem;
    align-content: start;
}

.topbar {
    background: var(--surface);
    backdrop-filter: blur(8px);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.65);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.topbar h2 {
    margin: 0;
    font-size: 1.24rem;
}

.user-chip {
    background: #0f766e;
    color: #fff;
    border-radius: 999px;
    padding: 0.48rem 0.88rem;
    font-size: 0.85rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.8rem;
}

.kpi-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow);
    padding: 1rem;
    animation: riseIn 0.5s ease;
}

.kpi-card h3 {
    margin: 0;
    font-size: 0.94rem;
    color: #334155;
}

.kpi-card strong {
    display: block;
    margin-top: 0.4rem;
    font-size: 1.35rem;
    color: #0f172a;
}

.kpi-card-profit { border-right: 3px solid #16a34a; }

.kpi-section { margin-bottom: 0.6rem; }
.kpi-section-total {
    background: linear-gradient(135deg, #1c263d 0%, #0f172a 100%);
    border: 1px solid #000000;
    border-radius: var(--radius);
    padding: 0.75rem 0.75rem 0.75rem;
    margin-bottom: 0.75rem;
}
.kpi-section-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin: 0 0 0.4rem 0;
    padding-right: 0.2rem;
}
.kpi-positive { color: #16a34a !important; }
.kpi-negative { color: #dc2626 !important; }

.panel {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow);
    padding: 1rem;
    animation: riseIn 0.5s ease;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.65rem;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.panel-head h3 {
    margin: 0;
    font-size: 1rem;
}

.table-search-input {
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 0.45rem 0.85rem;
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
    min-width: 200px;
    transition: border-color .2s, box-shadow .2s;
}

.table-search-input:focus {
    border-color: #0f766e;
    box-shadow: 0 0 0 3px var(--ring);
}

.link-btn {
    color: #0f766e;
    font-weight: 600;
    font-size: 0.88rem;
}

.table-wrap {
    overflow-x: auto;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    justify-content: center;
    margin-top: 1rem;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    background: #fff;
    color: #334155;
    font-size: 0.85rem;
    text-decoration: none;
    transition: background 0.15s;
}

.page-btn:hover { background: #f1f5f9; }
.page-btn-active { background: #0f766e; color: #fff; border-color: #0f766e; font-weight: 700; }
.page-btn-active:hover { background: #0d6460; }
.page-ellipsis { line-height: 2rem; color: #94a3b8; font-size: 0.85rem; }

.pagination-info {
    text-align: center;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 0.4rem;
}

/* ── Sales filter bar ── */
.sales-filter-bar {
    padding: 0.75rem 0;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.filter-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.filter-preset {
    padding: 0.3rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #fff;
    color: #475569;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.filter-preset:hover { background: #f1f5f9; border-color: #94a3b8; }
.filter-preset-active { background: #0f766e; color: #fff; border-color: #0f766e; font-weight: 600; }

.filter-custom-dates {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
}
.filter-custom-dates label { display: flex; align-items: center; gap: 0.35rem; }
.filter-custom-dates input[type="date"] {
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    padding: 0.28rem 0.5rem;
    font-size: 0.85rem;
}
.btn-sm { padding: 0.3rem 0.9rem; font-size: 0.82rem; }
.hidden { display: none !important; }

/* ── Sales summary strip ── */
.sales-summary-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1rem;
}

.summary-item {
    flex: 1;
    min-width: 130px;
    padding: 0.65rem 1rem;
    background: #f8fafc;
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.summary-item:last-child { border-left: none; }
.summary-item span { font-size: 0.78rem; color: #64748b; }
.summary-item strong { font-size: 1rem; color: #0f172a; }
.summary-item strong.balance-positive { color: #16a34a; }
.summary-item strong.balance-negative { color: #dc2626; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead th {
    text-align: right;
    background: #f1f5f9;
    color: #334155;
}

th,
td {
    border-bottom: 1px solid #e2e8f0;
    padding: 0.66rem;
    white-space: nowrap;
}

tr:hover td {
    background: rgba(148, 163, 184, 0.08);
}

.pos-actions {
    margin-top: 0.9rem;
    display: flex;
    justify-content: flex-start;
}

/* ── POS two-column layout ── */
.pos-layout {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 0.9rem;
    align-items: start;
}

/* Left: catalog */
.pos-catalog {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 0.7rem;
}

.pos-search-wrap input {
    width: 100%;
    border-radius: 14px;
    padding: 0.72rem 0.9rem;
    border: 1px solid #cbd5e1;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.pos-search-wrap input:focus {
    border-color: #0f766e;
    box-shadow: 0 0 0 4px var(--ring);
}

.pos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.7rem;
    padding-right: 0.25rem;
    padding-bottom: 0.5rem;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}

/* Scrollbar styling */
.pos-grid::-webkit-scrollbar { width: 6px; }
.pos-grid::-webkit-scrollbar-track { background: transparent; }
.pos-grid::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }

/* Product card */
.pos-card {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.7);
    border-radius: 16px;
    box-shadow: 0 4px 14px rgba(15,23,42,0.08);
    cursor: pointer;
    text-align: right;
    padding: 0;
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    display: flex;
    flex-direction: column;
    font-family: 'Rubik', sans-serif;
}

.pos-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 28px rgba(15,118,110,0.18);
    border-color: #99f6e4;
}

.pos-card:active {
    transform: scale(0.97);
}

.pos-card-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.pos-card-no-img {
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
    display: block;
}

.pos-card-body {
    padding: 0.5rem 0.6rem 0.65rem;
    display: grid;
    gap: 0.15rem;
}

.pos-card-body strong {
    font-size: 0.88rem;
    line-height: 1.3;
    color: #0f172a;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pos-card-price {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f766e;
}

.pos-card-stock {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.15rem 0.45rem;
    margin-top: 0.1rem;
    align-self: start;
}

.pos-card-stock-low {
    color: #92400e;
    background: #fef3c7;
    border-color: #fcd34d;
}

.pos-card-stock-zero {
    color: #991b1b;
    background: #fee2e2;
    border-color: #fca5a5;
    font-weight: 600;
}

.pos-card-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(0.4);
}

.pos-card-disabled:hover {
    transform: none;
    box-shadow: 0 4px 14px rgba(15,23,42,0.08);
    border-color: rgba(255,255,255,0.7);
}

/* Right: cart */
.pos-cart-wrap {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,0.7);
    box-shadow: var(--shadow);
    padding: 0.9rem;
    display: grid;
    gap: 0.7rem;
    align-content: start;
}

.pos-cart-items-wrap {
    display: contents;
}

.pos-cart-items-wrap::-webkit-scrollbar { display: none; }

.pos-cart-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pos-cart-head h3 { margin: 0; font-size: 1rem; }

.clear-cart-btn {
    border: none;
    background: #fee2e2;
    color: #b91c1c;
    border-radius: 8px;
    padding: 0.3rem 0.55rem;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: inherit;
}

.pos-cart-empty {
    color: #94a3b8;
    text-align: center;
    font-size: 0.9rem;
    padding: 1rem 0;
    margin: 0;
}

.pos-cart-items {
    display: grid;
    gap: 0.5rem;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: #f8fafc;
    border-radius: 12px;
    padding: 0.45rem 0.5rem;
    border: 1px solid #e2e8f0;
}

.cart-thumb {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.cart-thumb-ph {
    width: 38px;
    height: 38px;
    background: #e2e8f0;
    border-radius: 8px;
    flex-shrink: 0;
}

.cart-item-info {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 0.08rem;
}

.cart-item-info strong {
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-info span {
    font-size: 0.78rem;
    color: #0f766e;
    font-weight: 600;
}

.cart-item-profit {
    font-size: 0.72rem;
    font-weight: 600;
}
.cart-item-profit.profit-pos { color: #16a34a; }
.cart-item-profit.profit-neg { color: #dc2626; }

.cart-qty-ctrl {
    display: flex;
    align-items: center;
    gap: 0.28rem;
}

.cart-qty-ctrl span {
    min-width: 22px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
}

.qty-btn {
    border: 1px solid #cbd5e1;
    background: #fff;
    border-radius: 6px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s;
}

.qty-btn:hover { background: #e2e8f0; }

.cart-line {
    font-size: 0.82rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
}

.cart-rm {
    border: none;
    background: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0.1rem;
    transition: color 0.15s;
}

.cart-rm:hover { color: #b91c1c; }

.pos-cart-summary {
    border-top: 1px solid #e2e8f0;
    padding-top: 0.5rem;
    display: grid;
    gap: 0.4rem;
}

.cart-total-row,
.cart-net-row,
.cart-discount-row,
.cart-profit-row,
.cart-change-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
}

.cart-total-row    { background: #f1f5f9; border: 1px solid #cbd5e1; border-top: 3px solid #94a3b8; }
.cart-net-row      { background: #f0fdfa; border: 1px solid #99f6e4; border-top: 3px solid #0d9488; }
.cart-discount-row { background: #fff1f2; border: 1px solid #fecdd3; border-top: 3px solid #f43f5e; }
.cart-profit-row   { background: #f0fdf4; border: 1px solid #bbf7d0; border-top: 3px solid #22c55e; }
.cart-change-row   { background: #ecfeff; border: 1px solid #a5f3fc; border-top: 3px solid #06b6d4; }
.cart-paid-row     { background: #faf5ff; border: 1px solid #e9d5ff; border-top: 3px solid #a855f7; display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; padding: 0.4rem 0.6rem; border-radius: 6px; }
.cart-paid-row label { color: #334155; font-size: 0.9rem; }
.cart-paid-row input { width: 90px; text-align: left; border: 1px solid #e9d5ff; border-radius: 6px; padding: 0.25rem 0.4rem; font-size: 1rem; font-weight: 700; color: #6b21a8; background: #faf5ff; direction: ltr; font-family: inherit; }
.cart-paid-row input:focus { outline: none; border-color: #a855f7; }

.cart-delivery-row { background: #eff6ff; border: 1px solid #bfdbfe; border-top: 3px solid #3b82f6; display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; padding: 0.4rem 0.6rem; border-radius: 6px; }
.cart-delivery-row label { color: #334155; font-size: 0.9rem; }
.cart-delivery-row input { width: 90px; text-align: left; border: 1px solid #bfdbfe; border-radius: 6px; padding: 0.25rem 0.4rem; font-size: 1rem; font-weight: 700; color: #1e40af; background: #eff6ff; direction: ltr; font-family: inherit; }
.cart-delivery-row input:focus { outline: none; border-color: #3b82f6; }

.cart-discount-row input {
    width: 80px;
    text-align: left;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.25rem 0.4rem;
    font-size: 1rem;
    font-weight: 700;
    color: #dc2626;
    background: #fff7f7;
}

.discount-input-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.discount-amount-display {
    font-size: 1.1rem;
    color: #dc2626;
}

.discount-type-btns {
    display: flex;
    border: 1px solid #fecdd3;
    border-radius: 6px;
    overflow: hidden;
}

.disc-type-btn {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    font-family: inherit;
    font-weight: 600;
    border: none;
    background: #fff1f2;
    color: #9f1239;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.disc-type-btn + .disc-type-btn {
    border-right: 1px solid #fecdd3;
}

.disc-type-btn.disc-type-active {
    background: #f43f5e;
    color: #fff;
}

.cart-total-row strong,
.cart-net-row strong,
.cart-profit-row strong,
.cart-change-row strong {
    font-size: 1.1rem;
    color: #0f766e;
}

.cart-change-row strong.cart-change-positive,
.cart-profit-row strong.cart-change-positive {
    color: #16a34a;
}

.cart-change-row strong.cart-change-negative,
.cart-profit-row strong.cart-change-negative {
    color: #dc2626;
}

.cart-label {
    display: grid;
    gap: 0.38rem;
    font-size: 0.88rem;
    color: #334155;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    margin-top: 0.4rem;
}

div.cart-label   { background: #fffbeb; border: 1px solid #fde68a; border-top: 3px solid #f59e0b; }
label.cart-label { background: #fffbeb; border: 1px solid #fde68a; border-top: 3px solid #f59e0b; }

.btn-block { width: 100%; }

/* ── Customer mode (POS) ── */
.cmode-tabs {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.4rem;
}
.cmode-btn {
    flex: 1;
    padding: 0.35rem 0.4rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    color: #64748b;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cmode-btn.cmode-active {
    background: #0f172a;
    color: #fff;
    border-color: #0f172a;
}
.customer-panel { margin-top: 0.5rem; }
.cust-field {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
    box-sizing: border-box;
    background: #fff;
}
.cust-results {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    max-height: 200px;
    overflow-y: auto;
    position: relative;
    z-index: 20;
}
.cust-result-item {
    padding: 0.5rem 0.7rem;
    cursor: pointer;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.1rem 0.5rem;
    font-size: 0.82rem;
    border-bottom: 1px solid #f1f5f9;
}
.cust-result-item:last-child { border-bottom: none; }
.cust-result-item:hover { background: #f8fafc; }
.cust-result-item strong { grid-column: 1 / -1; font-size: 0.88rem; color: #0f172a; }
.cust-addr { color: #94a3b8; }
.cust-no-result {
    padding: 0.6rem 0.7rem;
    font-size: 0.83rem;
    color: #94a3b8;
    text-align: center;
}
.cust-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 0.5rem 0.6rem;
    margin-top: 0.4rem;
    gap: 0.5rem;
}
.cust-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    font-size: 0.83rem;
}
.cust-card-info strong { color: #166534; }
.cust-card-info span   { color: #15803d; }
.cust-card-clear {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #94a3b8;
    padding: 0 0.2rem;
    line-height: 1;
    flex-shrink: 0;
}
.cust-card-clear:hover { color: #dc2626; }

@media (max-width: 900px) {
    .pos-layout {
        grid-template-columns: 1fr;
    }

    .pos-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* ── Product thumbnails ── */
.product-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    display: block;
}

.thumb-placeholder {
    display: inline-block;
    width: 48px;
    height: 48px;
    background: #f1f5f9;
    border-radius: 10px;
    line-height: 48px;
    text-align: center;
    color: #94a3b8;
    font-size: 1.1rem;
}

.pos-thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    display: none;
}

.field-hint {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.field-label {
    font-size: 0.84rem;
    font-weight: 600;
    color: #475569;
    display: block;
    margin-bottom: 0.4rem;
}

.current-image-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.edit-product-thumb {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

/* ── Profit badge in product forms ─────────────────────────────────────── */
.profit-badge-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    justify-content: center;
}

.profit-badge {
    display: inline-block;
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    background: #f1f5f9;
    color: #475569;
}

.profit-badge.profit-pos {
    background: #dcfce7;
    color: #15803d;
}

.profit-badge.profit-neg {
    background: #fee2e2;
    color: #b91c1c;
}

.profit-pct {
    font-size: 0.78rem;
    opacity: 0.8;
    margin-right: 0.2rem;
}

.stock-low {
    color: #d97706;
    font-weight: 700;
}

/* ── Site footer ── */
.site-footer {
    margin-top: 1.5rem;
    padding: 0.9rem 1.2rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.82rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.site-footer a {
    color: #6366f1;
    text-decoration: none;
    font-weight: 500;
}

.site-footer a:hover {
    text-decoration: underline;
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        grid-template-rows: auto;
        gap: 0.8rem;
    }

    .menu {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.7rem;
    }
}

/* ── Sales: inline forms & danger / edit action links ──────────────────── */
.inline-form {
    display: inline;
}

.link-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font: inherit;
    font-size: 0.84rem;
    color: var(--primary);
    text-decoration: underline;
}

.link-btn.edit-link {
    color: #0ea5e9;
}

.link-btn.danger-link {
    color: #ef4444;
}

.link-btn:hover {
    opacity: 0.75;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-secondary-sm {
    background: #e2e8f0;
    color: #334155;
    border: none;
    padding: 0.42rem 0.9rem;
    border-radius: 8px;
    font-size: 0.84rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background .15s;
}

.btn-secondary-sm:hover {
    background: #cbd5e1;
}

/* ── Edit-sale form ─────────────────────────────────────────────────────── */
.edit-sale-form .subsection-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #475569;
    margin: 0 0 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #e2e8f0;
}

.remove-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    font-size: 0.84rem;
    color: #ef4444;
}

.new-item-row {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.new-item-row select {
    flex: 2;
    min-width: 200px;
}

.new-item-row input[type="number"] {
    flex: 0 0 6rem;
}

/* ── Alert messages ─────────────────────────────────────────────────────── */
.alert {
    padding: 0.75rem 1.1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.alert.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.muted {
    color: #64748b;
    font-size: 0.86rem;
    margin: 0.3rem 0 1rem;
}

/* ── Danger button ──────────────────────────────────────────────────────── */
.btn-danger {
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 0.42rem 0.9rem;
    border-radius: 8px;
    font-size: 0.84rem;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: #16a34a;
    color: #fff;
    border: none;
    padding: 0.42rem 0.9rem;
    border-radius: 8px;
    font-size: 0.84rem;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s;
}
.btn-success:hover { background: #15803d; }

.edit-link-btn {
    color: #0ea5e9;
}

/* ── Invoice preview page ───────────────────────────────────────────────── */
.invoice-meta-grid {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    margin: 0.8rem 0 1.4rem;
    padding: 0.9rem 1.1rem;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
}

.meta-label {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.meta-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    max-width: 220px;
    word-break: break-word;
    white-space: normal;
}

.preview-totals {
    margin-top: 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
    padding-top: 0.8rem;
    border-top: 1px solid #e2e8f0;
}

.totals-row {
    display: flex;
    gap: 2rem;
    font-size: 0.9rem;
    color: #475569;
    min-width: 320px;
    justify-content: space-between;
}

.totals-row strong {
    color: #1e293b;
}

.totals-row strong.balance-positive {
    color: #16a34a;
}

.totals-row strong.balance-negative {
    color: #dc2626;
}

.totals-change strong {
    font-size: 1rem;
}

.balance-positive {
    color: #16a34a;
    font-size: 1rem;
}

.balance-negative {
    color: #dc2626;
    font-size: 1rem;
}

.balance-label {
    font-size: 0.78rem;
    font-weight: 600;
    margin-right: 0.3rem;
    opacity: 0.85;
}

@media (max-width: 900px) {
    .grid-form.cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .grid-form,
    .grid-form.cols-4 {
        grid-template-columns: 1fr;
    }

    .content,
    .auth-body,
    .installer-body {
        padding: 0.7rem;
    }

    .panel,
    .topbar,
    .auth-card,
    .install-card {
        border-radius: 14px;
        padding: 0.82rem;
    }

    th,
    td {
        padding: 0.54rem;
    }
}
