/* MEXINO Stock Management System — brand: black, metallic silver, red */

/* ---------- Theme tokens ---------- */
:root {
    color-scheme: light;
    --bg: #f4f4f5;
    --surface: #ffffff;
    --surface-2: #f8f8f9;
    --hover: #fafafa;
    --border: #e4e4e7;
    --input-bg: #ffffff;
    --input-border: #d4d4d8;
    --text: #18181b;
    --muted: #71717a;

    --brand: #d90000;          /* MEXINO red */
    --brand-dark: #b00000;
    --brand-soft: #fdecec;
    --brand-text: #b00000;     /* links / highlighted text */
    --silver: #a1a1aa;
    --silver-light: #e4e4e7;

    --success: #15803d;
    --success-soft: #e7f6ec;
    --success-border: #b7e2c6;
    --warning: #b45309;
    --warning-soft: #fdf3e1;
    --warning-border: #f0d7a8;
    --danger: #b91c1c;
    --danger-soft: #fdeaea;
    --danger-border: #f2bcbc;
    --info: #3f3f46;
    --info-soft: #f0f0f2;

    --sidebar: #000000;
    --sidebar-text: #b4b4bb;
    --sidebar-line: rgba(255, 255, 255, .08);
    --placeholder: #efeff1;
    --rank-bg: #f0f0f2;
    --champion-bg: linear-gradient(135deg, #fff1f1, #ffffff);
    --champion-border: #f5c9c9;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 1px 3px rgba(0, 0, 0, .06);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0c0c0e;
    --surface: #161619;
    --surface-2: #1c1c20;
    --hover: #1e1e22;
    --border: #2a2a2f;
    --input-bg: #111114;
    --input-border: #3a3a41;
    --text: #ececef;
    --muted: #9d9da6;

    --brand: #e01010;
    --brand-dark: #ff2a2a;
    --brand-soft: rgba(224, 16, 16, .16);
    --brand-text: #ff6b63;
    --silver: #8b8b94;
    --silver-light: #3a3a41;

    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, .12);
    --success-border: rgba(74, 222, 128, .3);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, .12);
    --warning-border: rgba(251, 191, 36, .3);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .12);
    --danger-border: rgba(248, 113, 113, .3);
    --info: #d4d4d8;
    --info-soft: rgba(255, 255, 255, .08);

    --sidebar: #000000;
    --sidebar-text: #a1a1aa;
    --sidebar-line: rgba(255, 255, 255, .06);
    --placeholder: #232327;
    --rank-bg: #26262b;
    --champion-bg: linear-gradient(135deg, rgba(224, 16, 16, .14), rgba(22, 22, 25, 1));
    --champion-border: rgba(224, 16, 16, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
small, .muted { color: var(--muted); }
.icon { width: 18px; height: 18px; flex: none; vertical-align: middle; }
[data-theme="dark"] img[src$="no-image.svg"] { filter: invert(.88) hue-rotate(180deg); }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; flex: none;
    background: var(--sidebar); color: var(--sidebar-text);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    border-right: 1px solid var(--sidebar-line);
}
.brand { padding: 18px 18px 14px; border-bottom: 1px solid var(--sidebar-line); text-align: center; }
.brand-logo { width: 170px; max-width: 100%; height: auto; display: block; margin: 0 auto; }
.brand-sub { font-size: 10.5px; letter-spacing: 2px; text-transform: uppercase; color: #71717a; margin-top: 6px; }
.brand-line { height: 2px; width: 36px; background: var(--brand); margin: 10px auto 0; border-radius: 2px; }
.nav { display: flex; flex-direction: column; padding: 12px 10px; gap: 2px; }
.nav a, .nav button {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; border-radius: 8px;
    color: var(--sidebar-text); font-weight: 500; font: inherit;
    background: none; border: 0; cursor: pointer; text-align: left; width: 100%;
    border-left: 3px solid transparent;
}
.nav a:hover, .nav button:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active { background: linear-gradient(90deg, rgba(217, 0, 0, .22), rgba(217, 0, 0, .04)); color: #fff; border-left-color: var(--brand); }
.nav a.active .icon { color: #ff3b30; }
.nav-badge { margin-left: auto; background: var(--brand); color: #fff; font-size: 11px; border-radius: 10px; padding: 0 7px; line-height: 18px; }
.nav-bottom { margin-top: auto; border-top: 1px solid var(--sidebar-line); }
.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 14px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 12px 24px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; margin: 0; flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.topbar-user small { display: block; font-weight: 400; line-height: 1; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #0a0a0a; color: #fff; display: grid; place-items: center; font-weight: 700; border: 2px solid var(--brand); }
.menu-toggle, .theme-toggle { background: none; border: 0; padding: 6px; cursor: pointer; color: var(--text); border-radius: 8px; display: grid; place-items: center; }
.menu-toggle { display: none; }
.theme-toggle { border: 1px solid var(--border); }
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.content { padding: 24px; flex: 1; }
.footer { padding: 14px 24px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); }

/* ---------- Cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; }
.card.flush .card-head { padding: 16px 18px 0; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > .card { margin-bottom: 0; }
.mb { margin-bottom: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--silver-light); }
.stat.good::before { background: var(--brand); }
.stat.warn::before { background: var(--warning); }
.stat.danger::before { background: var(--danger); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat-value { font-size: 23px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat .icon { position: absolute; right: 16px; top: 16px; width: 22px; height: 22px; color: var(--silver); }
.stat.good .icon { color: var(--brand); }
.stat.warn .stat-value { color: var(--warning); }
.stat.danger .stat-value { color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: var(--surface-2); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--hover); }
tfoot td { font-weight: 700; background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 30px 12px; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); background: var(--placeholder); display: block; flex: none; }
.prod-cell { display: flex; align-items: center; gap: 12px; }
.prod-cell b { display: block; }
.row-archived td { opacity: .55; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--info-soft); color: var(--muted); }
.plus { color: var(--success); font-weight: 600; }
.minus { color: var(--danger); font-weight: 600; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field small { display: block; margin-top: 4px; font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=tel], input[type=file], select, textarea {
    width: 100%; padding: 9px 11px; font: inherit; color: inherit;
    background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 8px;
}
input[disabled] { opacity: .7; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.req { color: var(--danger); }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox input { width: auto; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { margin: 0; min-width: 150px; }
.filters .grow { flex: 1; min-width: 200px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
    font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
    background: var(--brand); color: #fff; text-decoration: none;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-light { background: var(--surface); color: var(--text); border-color: var(--input-border); }
.btn-light:hover { background: var(--surface-2); }
.btn-success { background: #0a0a0a; border-color: #0a0a0a; }
.btn-success:hover { background: #27272a; }
[data-theme="dark"] .btn-success { background: #f4f4f5; border-color: #f4f4f5; color: #0a0a0a; }
[data-theme="dark"] .btn-success:hover { background: #d4d4d8; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 13px 20px; font-size: 16px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.inline { display: inline; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.alert-error { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning); }
.alert-info { background: var(--info-soft); border-color: var(--border); color: var(--text); }
.alert a { color: inherit; text-decoration: underline; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 7px 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 500; font-size: 13px; }
.tabs a.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.tabs a:hover { text-decoration: none; border-color: var(--brand); }

.pagination { display: flex; gap: 4px; justify-content: center; padding: 14px; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 34px; padding: 5px 10px; text-align: center; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .gap { border: 0; background: none; }

/* ---------- Top products ---------- */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.rank-list li:last-child { border-bottom: 0; }
.rank { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; background: var(--rank-bg); color: var(--muted); flex: none; }
.rank-1 { background: var(--brand); color: #fff; }
.rank-2 { background: linear-gradient(135deg, #e4e4e7, #a1a1aa); color: #18181b; }
.rank-3 { background: #3f3f46; color: #fff; }
.rank-info { flex: 1; min-width: 0; }
.rank-info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-info small { display: block; }
.rank-qty { text-align: right; font-variant-numeric: tabular-nums; }
.rank-qty b { display: block; font-size: 15px; }
.bar { height: 6px; border-radius: 3px; background: var(--rank-bg); margin-top: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.champion { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 10px; background: var(--champion-bg); border: 1px solid var(--champion-border); margin-bottom: 8px; }
.champion img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--placeholder); }
.champion .label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--brand-text); letter-spacing: .5px; }

.chart-box { position: relative; height: 290px; }
.chart-box.tall { height: 340px; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(360px, 1fr); gap: 20px; align-items: start; }
.pos-cart { position: sticky; top: 80px; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; max-height: calc(100vh - 250px); overflow-y: auto; padding: 2px; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; text-align: left; padding: 0; font: inherit; color: inherit; transition: box-shadow .15s, border-color .15s; }
.pcard:hover { border-color: var(--brand); box-shadow: 0 4px 12px rgba(217, 0, 0, .15); }
.pcard img { width: 100%; height: 110px; object-fit: cover; display: block; background: var(--placeholder); }
.pcard .pc-body { padding: 9px 10px; }
.pcard .pc-name { font-weight: 600; line-height: 1.3; }
.pcard .pc-meta { font-size: 12px; color: var(--muted); }
.pcard .pc-price { font-weight: 700; color: var(--brand-text); margin-top: 3px; }
.pcard.disabled { opacity: .45; cursor: not-allowed; }
.pcard.disabled:hover { border-color: var(--border); box-shadow: none; }
.cart-table td { padding: 8px 6px; }
.cart-table input { width: 70px; padding: 6px; text-align: center; }
.cart-remove { background: none; border: 0; color: var(--danger); cursor: pointer; padding: 4px; font-size: 18px; }
.totals { margin-top: 12px; }
.totals div { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; }
.totals .grand { font-size: 20px; font-weight: 800; border-top: 2px solid var(--text); margin-top: 6px; padding-top: 10px; }
.totals input { width: 140px; text-align: right; }

/* ---------- Product view ---------- */
.product-hero { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; }
.product-hero img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); background: var(--placeholder); }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 600; }
.img-preview { width: 140px; height: 140px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 8px; display: block; background: var(--placeholder); }

/* ---------- Appearance picker (My Account) ---------- */
.theme-options { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-options button { flex: 1; min-width: 110px; padding: 12px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.theme-options button.active { border-color: var(--brand); }
.theme-options .swatch { width: 100%; height: 34px; border-radius: 6px; border: 1px solid var(--border); }

/* ---------- Receipt ---------- */
.receipt { max-width: 780px; margin: 0 auto; }
.receipt-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--text); padding-bottom: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.receipt-head h2 { font-size: 20px; margin-bottom: 4px; }
.receipt-total { font-size: 22px; font-weight: 800; }
.void-stamp { display: inline-block; border: 3px solid var(--danger); color: var(--danger); font-weight: 800; padding: 4px 14px; border-radius: 6px; transform: rotate(-4deg); letter-spacing: 2px; }

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh; display: grid; place-items: center; padding: 16px;
    background: radial-gradient(ellipse at 50% 0%, rgba(217, 0, 0, .28), transparent 60%), #050505;
    position: relative;
}
.login-box { background: var(--surface); width: 100%; max-width: 400px; border-radius: 14px; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); border: 1px solid rgba(255, 255, 255, .06); }
.login-brand { background: #000; padding: 26px 30px 20px; text-align: center; border-bottom: 3px solid var(--brand); }
.login-brand img { width: 230px; max-width: 100%; height: auto; }
.login-body { padding: 26px 30px 30px; }
.login-body p.sub { text-align: center; color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-page .theme-toggle { position: absolute; top: 16px; right: 16px; color: #e4e4e7; border-color: rgba(255, 255, 255, .15); }
.login-page .theme-toggle:hover { background: rgba(255, 255, 255, .08); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pos { grid-template-columns: 1fr; }
    .pos-cart { position: static; }
    .product-grid { max-height: 420px; }
}
@media (max-width: 860px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 40; }
    .menu-toggle { display: grid; }
    .grid-2, .grid-3, .grid-2-1, .form-grid, .product-hero { grid-template-columns: 1fr; }
    .product-hero img { max-width: 280px; }
    .content { padding: 16px; }
    .topbar { padding: 10px 16px; }
    .hide-sm { display: none; }
    .dl { grid-template-columns: 120px 1fr; }
}

/* ---------- Print (always light, ink-friendly) ---------- */
@media print {
    :root, :root[data-theme="dark"] {
        --bg: #fff; --surface: #fff; --surface-2: #fff; --text: #000; --muted: #444; --border: #ccc;
        --info-soft: #fff; --info: #000; --danger-soft: #fff;
    }
    .sidebar, .topbar, .footer, .no-print, .alert { display: none !important; }
    body, .content { background: #fff; color: #000; padding: 0; }
    .card { border: 0; box-shadow: none; padding: 0; }
    tbody tr:hover { background: none; }
}
