:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --danger-light: #fee2e2;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 12px rgba(15, 23, 42, .06);
    --shadow-lg: 0 4px 6px rgba(15, 23, 42, .1), 0 12px 24px rgba(15, 23, 42, .08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--gray-800);
    background: var(--gray-100);
}

h1, h2, h3 {
    color: var(--gray-900);
    line-height: 1.2;
    margin: 0 0 .75rem;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; margin-top: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 .75rem; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout shell ---- */

.layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.layout-topbar {
    background: var(--gray-900);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    height: 56px;
    box-shadow: var(--shadow);
}

.layout-topbar .brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
}
.layout-topbar .brand:hover { text-decoration: none; }

.layout-topbar nav {
    display: flex;
    align-items: center;
    gap: .25rem;
    overflow-x: auto;
}

.layout-topbar nav a {
    color: var(--gray-300);
    padding: .5rem .75rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    white-space: nowrap;
}
.layout-topbar nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, .08);
    text-decoration: none;
}
.layout-topbar nav a.active {
    color: #fff;
    background: var(--primary);
}

.layout-body {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

/* ---- Cards ---- */

.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.card h2 { margin-top: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; }

/* ---- Buttons ---- */

.btn, button {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: .5rem 1rem;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease;
    text-decoration: none;
}
.btn:hover, button:hover { background: var(--primary-dark); text-decoration: none; }
.btn:disabled, button:disabled { opacity: .55; cursor: not-allowed; }

.btn-secondary {
    background: #fff;
    color: var(--gray-700);
    border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-100); color: var(--gray-900); }

.btn-danger {
    background: #fff;
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: .3rem .6rem; font-size: .85rem; }

/* ---- Forms ---- */

form .form-group { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .9rem; color: var(--gray-700); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
    width: 100%;
    max-width: 420px;
    padding: .55rem .75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: .95rem;
    font-family: var(--font);
    background: #fff;
    color: var(--gray-800);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

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

form.inline-form, .inline { display: inline; }

fieldset {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin: 0 0 1.25rem;
    padding: 1rem 1.25rem 1.25rem;
}
legend { font-weight: 700; color: var(--gray-800); padding: 0 .5rem; }

/* ---- Tables ---- */

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
th, td {
    text-align: left;
    padding: .7rem .9rem;
    border-bottom: 1px solid var(--gray-200);
    vertical-align: middle;
}
th {
    background: var(--gray-50);
    color: var(--gray-600);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

/* ---- Alerts / status ---- */

.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 500; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-light); color: var(--danger-dark); border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #fde68a; }

/* ---- Badges ---- */

.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
}
.badge-green { background: var(--success-light); color: var(--success); }
.badge-red { background: var(--danger-light); color: var(--danger-dark); }
.badge-gray { background: var(--gray-200); color: var(--gray-600); }
.badge-blue { background: var(--primary-light); color: var(--primary-dark); }

/* ---- Auth screens ---- */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--gray-900), #1e3a8a);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 2rem 2rem 2.25rem;
}

.auth-card h1 { text-align: center; font-size: 1.4rem; margin-bottom: .25rem; }
.auth-card .subtitle { text-align: center; color: var(--gray-500); margin-bottom: 1.5rem; }
.auth-card button { width: 100%; padding: .65rem; font-size: 1rem; }
.auth-brand {
    display: block;
    text-align: center;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: .25rem;
}

/* ---- POS screen ---- */

.pos-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    align-items: start;
}
@media (max-width: 900px) { .pos-grid { grid-template-columns: 1fr; } }

.pos-products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: .75rem;
    max-height: 560px;
    overflow-y: auto;
}

.pos-product {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .85rem;
    text-align: left;
    width: 100%;
    font-size: .9rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.pos-product:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-light); }
.pos-product:disabled { opacity: .5; }

.pos-product .name { font-weight: 600; color: var(--gray-900); }
.pos-product .price { font-weight: 700; color: var(--primary-dark); }
.pos-product .stock { font-size: .78rem; color: var(--gray-500); }
.pos-product .stock.low { color: var(--danger); font-weight: 600; }

.pos-cart table { box-shadow: none; }
.pos-cart input { max-width: 90px; padding: .3rem .5rem; }

/* Fila de pago: cada campo con su etiqueta arriba, alineados por abajo para
   que el botón de quitar quede a la altura de los inputs. */
.pos-payment-row { display: flex; gap: .5rem; align-items: flex-end; }
.pos-payment-row label { margin-bottom: .2rem; font-size: .8rem; }
.pos-payment-field { display: flex; flex-direction: column; min-width: 0; }
.pos-payment-field select, .pos-payment-field input { width: 100%; }

.pos-totals {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: .9rem 1rem;
    margin: .75rem 0;
}
.pos-totals .total-row { display: flex; justify-content: space-between; padding: .15rem 0; color: var(--gray-600); }
.pos-totals .total-row.grand { font-weight: 700; color: var(--gray-900); font-size: 1.1rem; border-top: 1px solid var(--gray-200); margin-top: .35rem; padding-top: .45rem; }

/* ---- Shift / caja screens ---- */

.shift-meta { color: var(--gray-600); }
.shift-meta strong { color: var(--gray-900); }

.denominations {
    width: 100%;
    max-width: 360px;
    border-collapse: collapse;
}
.denominations td { border: none; padding: .3rem .4rem; border-bottom: 1px solid var(--gray-100); }
.denominations input { max-width: 100px; }

.list-links a { display: block; padding: .45rem 0; border-bottom: 1px solid var(--gray-100); }

/* ---- Misc ---- */

.muted { color: var(--gray-500); }
.small { font-size: .85rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; gap: .5rem; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }

/* ---- Innova POS visual system ---- */
:root {
    --innova-bg: #f4f5f7;
    --innova-surface: #fff;
    --innova-ink: #20252b;
    --innova-muted: #667085;
    --innova-nav: #202936;
    --innova-nav-soft: #2c3747;
    --innova-accent: #6657d9;
    --innova-accent-soft: #eeecff;
    --innova-success: #2e9b68;
    --innova-warning: #d99024;
    --innova-danger: #c94a58;
    --innova-border: #e4e7ec;
    --innova-radius: 10px;
    --innova-shadow: 0 8px 24px rgba(32, 41, 54, .06);
}

body {
    color: var(--innova-ink);
    background: var(--innova-bg);
    font-family: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--innova-accent); text-underline-offset: 3px; }
a:hover { color: #5041bf; }

button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid rgba(102, 87, 217, .32); outline-offset: 2px; }

.app-shell {
    display: grid;
    grid-template-columns: 244px minmax(0, 1fr);
    min-height: 100vh;
}

.app-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 20px 14px;
    color: #d8dee8;
    background: var(--innova-nav);
}

.app-sidebar .brand {
    display: block;
    padding: 4px 12px 22px;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: -.035em;
    text-decoration: none;
}

.app-sidebar .nav-section {
    margin: 18px 12px 6px;
    color: #8f9aaa;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.app-sidebar nav { display: grid; gap: 3px; }
.app-sidebar nav a {
    display: flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 7px;
    color: #d8dee8;
    font-size: .9rem;
    text-decoration: none;
}
.app-sidebar nav a:hover,
.app-sidebar nav a.active { color: #fff; background: var(--innova-nav-soft); }
.app-sidebar nav a.active { box-shadow: inset 3px 0 0 var(--innova-accent); }
.app-sidebar .sidebar-spacer { flex: 1; }
.app-sidebar .sidebar-footer { padding: 14px 12px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: .78rem; color: #9fa9b8; }

.app-main { min-width: 0; }
.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 12px 30px;
    border-bottom: 1px solid var(--innova-border);
    background: var(--innova-surface);
}
.app-topbar .topbar-title { color: var(--innova-ink); font-size: .95rem; font-weight: 600; }
.app-topbar .topbar-actions { display: flex; align-items: center; gap: 12px; }
.app-body { width: min(1240px, calc(100% - 60px)); margin: 0 auto; padding: 34px 0 56px; }
.app-menu-toggle { display: none; }

.app-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.app-page-head h1 { margin: 0; color: var(--innova-ink); font-size: clamp(1.6rem, 2vw, 2rem); letter-spacing: -.025em; }
.app-page-head p { margin: 5px 0 0; color: var(--innova-muted); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card { padding: 18px; border: 1px solid var(--innova-border); border-radius: var(--innova-radius); background: #fff; box-shadow: var(--innova-shadow); }
.metric-card .metric-label { color: var(--innova-muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.metric-card .metric-value { margin-top: 7px; color: var(--innova-ink); font-size: 1.65rem; font-weight: 700; letter-spacing: -.04em; }

.app-panel { border: 1px solid var(--innova-border); border-radius: var(--innova-radius); background: #fff; box-shadow: var(--innova-shadow); }
.app-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--innova-border); }
.app-panel-body { padding: 20px; }

.app-shell .card {
    border-color: var(--innova-border);
    border-radius: var(--innova-radius);
    box-shadow: var(--innova-shadow);
}
.app-shell .page-head,
.app-shell .page-header {
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 24px;
}
.app-shell .page-head h1,
.app-shell .page-header h1 { color: var(--innova-ink); font-size: clamp(1.6rem, 2vw, 2rem); letter-spacing: -.025em; }
.app-shell table { border-color: var(--innova-border); box-shadow: var(--innova-shadow); }
.app-shell th { color: var(--innova-muted); background: #fafbfc; }
.app-shell td { border-color: var(--innova-border); }
.app-shell tbody tr:hover { background: #fbfbfe; }
.app-shell .badge-blue { color: #4840a5; background: var(--innova-accent-soft); }
.app-shell .badge-green { color: #176b49; background: #e5f5ec; }
.app-shell .badge-red { color: #9f3040; background: #fde9ec; }
.app-shell .badge-gray { color: #566070; background: #eef1f4; }

.app-shell .btn { background: var(--innova-accent); border-color: var(--innova-accent); }
.app-shell .btn:hover { background: #5748c8; border-color: #5748c8; }
.app-shell .btn-secondary { color: var(--innova-ink); background: #fff; border-color: var(--innova-border); }
.app-shell .btn-secondary:hover { background: #f8f9fb; border-color: #c8ccd5; }
.app-shell .btn-danger { background: var(--innova-danger); border-color: var(--innova-danger); }
.app-shell .btn-primary { display: inline-block; padding: .5rem 1rem; border: 1px solid var(--innova-accent); border-radius: 7px; color: #fff; background: var(--innova-accent); font-weight: 600; cursor: pointer; text-decoration: none; }
.app-shell .btn-primary:hover { color: #fff; background: #5748c8; text-decoration: none; }
.app-shell .filters { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; padding: 14px; border: 1px solid var(--innova-border); border-radius: var(--innova-radius); background: #fff; }
.app-shell .filters label { min-width: 180px; margin: 0; }
.app-shell .filters input, .app-shell .filters select { margin-top: 5px; }

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .app-sidebar { position: fixed; z-index: 20; width: 244px; transform: translateX(-100%); transition: transform .18s ease; }
    .app-shell.sidebar-open .app-sidebar { transform: translateX(0); }
    .app-menu-toggle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid var(--innova-border); border-radius: 7px; background: #fff; color: var(--innova-ink); cursor: pointer; }
    .app-body { width: min(100% - 32px, 680px); padding-top: 24px; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
    .app-topbar { padding: 11px 16px; }
    .app-body { width: calc(100% - 24px); }
    .app-page-head { flex-direction: column; }
    .app-page-head .btn { width: 100%; }
    .metric-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}
