:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #e4e7ec;
    --primary: #1455d9;
    --primary-dark: #0d3f9f;
    --danger: #d92d20;
    --success: #087443;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 26px; margin-bottom: 6px; }
h2 { font-size: 18px; margin-bottom: 14px; }
p { color: var(--muted); }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    width: 250px;
    background: #101828;
    color: #fff;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand strong, .brand span { display: block; }
.brand strong { font-size: 18px; margin-bottom: 4px; }
.brand span { color: #cbd5e1; font-size: 13px; }
.menu { display: grid; gap: 8px; }
.menu a {
    color: #d0d5dd;
    padding: 11px 12px;
    border-radius: 8px;
}
.menu a.active, .menu a:hover {
    background: #1d2939;
    color: #fff;
}
.content {
    width: calc(100% - 250px);
    padding: 28px;
}
.auth-content {
    width: 100%;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-card {
    width: min(420px, 100%);
    background: var(--panel);
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.login-header { margin-bottom: 22px; }
.login-note {
    margin-top: 16px;
    padding: 12px;
    background: #f2f4f7;
    border-radius: 8px;
    color: var(--muted);
    font-size: 13px;
}
.page-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 20px;
}
.panel, .stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}
.panel { margin-bottom: 20px; }
.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin-bottom: 14px;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}
.stat-card strong { font-size: 24px; }
.split-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
}
.pos-grid {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) 520px;
    gap: 20px;
}
.form-grid {
    display: grid;
    gap: 14px;
}
.form-grid.two, .product-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.product-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
}
label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}
input, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 11px;
    color: var(--text);
    background: #fff;
}
.wide { grid-column: span 2; }
.btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline {
    background: transparent;
    color: #fff;
    border-color: #475467;
}
.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-small { padding: 7px 10px; font-size: 12px; }
.full { width: 100%; }
.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 700;
}
.alert-success { background: #ecfdf3; color: var(--success); }
.alert-error { background: #fef3f2; color: var(--danger); }
.table-wrap {
    overflow: auto;
    width: 100%;
}
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}
th, td {
    border-bottom: 1px solid var(--line);
    padding: 11px;
    text-align: left;
    vertical-align: middle;
}
th {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--muted);
    background: #f9fafb;
}
td span { color: var(--muted); font-size: 12px; }
.empty {
    text-align: center;
    color: var(--muted);
    padding: 22px;
}
.badge {
    display: inline-block;
    padding: 5px 8px;
    background: #eef4ff;
    color: #194185;
    border-radius: 999px;
    font-weight: 700;
}
.badge.danger {
    background: #fef3f2;
    color: var(--danger);
}
.actions {
    display: flex;
    gap: 8px;
}
.product-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    max-height: 680px;
    overflow: auto;
}
.product-tile {
    display: grid;
    gap: 7px;
    text-align: left;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
}
.product-tile:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 22px rgba(20, 85, 217, .08);
}
.product-tile span {
    color: var(--muted);
    font-size: 12px;
}
.product-tile b { color: var(--primary); }
.cart-table-wrap { max-height: 330px; }
.qty-input { max-width: 76px; }
.icon-btn {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: #fef3f2;
    color: var(--danger);
    cursor: pointer;
    font-weight: 800;
}
.totals {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 14px 0;
}
.totals div {
    display: flex;
    justify-content: space-between;
    background: #f9fafb;
    padding: 12px;
    border-radius: 8px;
    grid-column: span 2;
}
.receipt {
    max-width: 520px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    margin: 0 auto;
}
.receipt-head {
    text-align: center;
    border-bottom: 1px dashed var(--line);
    padding-bottom: 14px;
}
.receipt-head h2 { margin-bottom: 6px; }
.receipt-head p { margin: 3px 0; font-size: 13px; }
.receipt-meta {
    display: grid;
    gap: 5px;
    padding: 14px 0;
    font-size: 13px;
}
.receipt-table {
    min-width: 0;
    font-size: 13px;
}
.receipt-total {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    border-top: 1px dashed var(--line);
    padding-top: 14px;
}
.receipt-footer {
    text-align: center;
    margin: 18px 0 0;
}

@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split-grid, .pos-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    .content { width: 100%; padding: 18px; }
    .page-header { align-items: flex-start; flex-direction: column; }
    .stats-grid, .form-grid.two, .product-form { grid-template-columns: 1fr; }
    .wide { grid-column: span 1; }
    .totals { grid-template-columns: 1fr; }
    .totals div { grid-column: span 1; }
}

@media print {
    body { background: #fff; }
    .sidebar, .no-print, .alert { display: none !important; }
    .content { width: 100%; padding: 0; }
    .receipt { border: 0; max-width: 100%; }
}
