:root {
    --zavik: #2563eb;
    --zavik-hover: #1d4ed8;
    --zavik-soft: #eff6ff;
    --sidebar: #0b1220;
    --sidebar-2: #111827;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --info: #0ea5e9;
    --shadow: 0 18px 50px rgba(15, 23, 42, .07);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: #cbd5e1;
    padding: 22px 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 24px;
    border-bottom: 1px solid rgba(226, 232, 240, .09);
    margin-bottom: 18px;
}

.brand strong { display: block; color: white; font-size: 15px; }
.brand span { display: block; color: #94a3b8; font-size: 12px; margin-top: 3px; }

.brand-mark,
.empty-logo {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--zavik);
    color: white;
    font-weight: 800;
}

.brand-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 10px;
    background: white;
    padding: 4px;
}

.nav-group { margin-bottom: 18px; }
.nav-section {
    display: block;
    padding: 8px 10px;
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.nav-btn {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 10px 12px;
    border-radius: 10px;
    color: #cbd5e1;
    font-weight: 600;
    transition: 180ms ease;
}

.nav-btn:hover { background: rgba(255, 255, 255, .06); color: white; }
.nav-btn.active { background: rgba(37, 99, 235, .18); color: white; }
.nav-btn.active::before {
    content: "";
    position: absolute;
    left: -16px;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 999px;
    background: var(--zavik);
}

.main {
    min-width: 0;
    padding: 28px;
}

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

.topbar h1 {
    margin: 4px 0 0;
    font-size: 28px;
    line-height: 1.1;
}

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 800;
}

.muted { color: var(--muted); }
.money { font-weight: 800; color: #0b1220; }

.grid {
    display: grid;
    gap: 16px;
}

.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.panel.narrow { max-width: 760px; }
.section-gap { margin-top: 18px; }

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

.panel-title.compact { margin-bottom: 10px; }
.panel-title h2,
.panel-title h3 { margin: 0; }
.panel-title h2 { font-size: 18px; }
.panel-title h3 { font-size: 15px; }

.metric { min-height: 132px; }
.metric span { color: var(--muted); font-weight: 700; }
.metric strong { display: block; margin: 14px 0 8px; font-size: 28px; line-height: 1; }
.metric small { color: var(--muted); font-weight: 600; }

.tag {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--zavik-soft);
    color: var(--zavik);
    font-size: 12px;
    font-weight: 800;
}
.tag.danger { color: var(--danger); background: #fef2f2; }

.form-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
}

.form-sections { display: grid; gap: 16px; }
.form-section {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    background: #fff;
}
.form-section h3 { margin: 0 0 12px; font-size: 15px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, .6fr);
    gap: 18px;
    align-items: start;
}

label {
    display: grid;
    gap: 7px;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

label.full { grid-column: 1 / -1; }
label.check {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: white;
    color: var(--text);
    outline: none;
    padding: 10px 12px;
    transition: 160ms ease;
}

textarea { min-height: 88px; resize: vertical; }
input:focus,
select:focus,
textarea:focus {
    border-color: var(--zavik);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .10);
}

.input-action {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.primary-btn,
.small-btn,
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid transparent;
    font-weight: 800;
    transition: 160ms ease;
}

.primary-btn {
    background: var(--zavik);
    color: white;
}
.primary-btn:hover { background: var(--zavik-hover); }

.small-btn,
.icon-btn {
    background: white;
    border-color: var(--border);
    color: #1e293b;
}
.small-btn:hover,
.icon-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.danger-soft { color: var(--danger); background: #fef2f2; border-color: #fecaca; }

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

.mini-form {
    display: grid;
    gap: 8px;
    padding: 10px;
    width: 220px;
}
.mini-form.wide { width: min(460px, 88vw); }
.compact-check { min-height: auto; font-size: 12px; }
.summary-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
}
.summary-row strong { color: var(--text); }
.toolbar-input {
    max-width: 340px;
    min-width: 240px;
}

.order-summary {
    position: sticky;
    top: 24px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    text-align: left;
    text-transform: uppercase;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

tr:hover td { background: #fbfdff; }

.status {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    background: #f1f5f9;
    color: #475569;
}
.status.pendiente,
.status.por-cobrar { background: #fffbeb; color: #b45309; }
.status.en-proceso { background: #eff6ff; color: var(--zavik); }
.status.pausado { background: #fef3c7; color: #92400e; }
.status.terminado,
.status.entregado,
.status.activo { background: #f0fdf4; color: #15803d; }
.status.cancelado,
.status.anulada { background: #fef2f2; color: var(--danger); }

.notice {
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    font-weight: 700;
}
.notice.success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.notice.danger { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.pos-lines { display: grid; gap: 10px; }
.pos-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 130px 44px;
    gap: 10px;
    align-items: end;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.detail-grid div {
    display: grid;
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 13px;
}

.logo-preview {
    display: grid;
    place-items: center;
    min-height: 190px;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
    margin-bottom: 16px;
}
.logo-preview img {
    max-width: 220px;
    max-height: 140px;
    object-fit: contain;
}
.stacked { display: grid; gap: 12px; }

.bar-list { display: grid; gap: 14px; }
.bar-row {
    display: grid;
    grid-template-columns: 190px minmax(160px, 1fr) 120px;
    gap: 14px;
    align-items: center;
}
.bar-row span { font-weight: 800; }
.bar-row div {
    height: 12px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}
.bar-row i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--zavik), #60a5fa);
}
.bar-row strong { text-align: right; }

.loyalty-card {
    min-height: 280px;
    display: grid;
    align-content: space-between;
    gap: 18px;
    border-radius: 20px;
    padding: 24px;
    color: white;
    background: linear-gradient(135deg, #0b1220 0%, #111827 56%, #2563eb 100%);
    box-shadow: 0 24px 60px rgba(15, 23, 42, .18);
}
.loyalty-card span {
    color: #bfdbfe;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
}
.loyalty-card h3 { margin: 0; font-size: 24px; }
.loyalty-card strong { font-size: 18px; }
.loyalty-card p,
.loyalty-card small { margin: 0; color: #cbd5e1; }
.visit-track { display: flex; flex-wrap: wrap; gap: 10px; }
.visit-track span {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .28);
    background: rgba(255, 255, 255, .1);
}
.visit-track span.done { background: white; border-color: white; }

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, .22), transparent 30%),
        linear-gradient(135deg, #0b1220 0%, #111827 48%, #172554 100%);
}

.login-card {
    width: min(430px, 100%);
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(255, 255, 255, .45);
    border-radius: 18px;
    box-shadow: 0 28px 70px rgba(0, 0, 0, .26);
    padding: 28px;
}
.login-card h1 { margin: 8px 0 8px; font-size: 30px; }
.login-form { display: grid; gap: 14px; margin: 20px 0 16px; }

@media (max-width: 1100px) {
    .grid.four,
    .grid.three,
    .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-layout,
    .settings-grid { grid-template-columns: 1fr; }
    .order-summary { position: static; }
}

@media (max-width: 760px) {
    .app-shell { display: block; padding-bottom: 72px; }
    .sidebar {
        position: fixed;
        z-index: 30;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        height: 64px;
        padding: 6px;
        overflow: hidden;
        display: flex;
        background: var(--sidebar);
    }
    .brand,
    .nav-section { display: none; }
    .sidebar nav {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 4px;
    }
    .nav-group { display: contents; }
    .nav-group:nth-of-type(n+5) { display: none; }
    .nav-btn {
        min-height: 52px;
        justify-content: center;
        text-align: center;
        padding: 8px;
        font-size: 12px;
    }
    .nav-btn.active::before { display: none; }
    .main { padding: 18px 14px; }
    .topbar { align-items: center; }
    .topbar h1 { font-size: 22px; }
    .grid.four,
    .grid.three,
    .grid.two,
    .form-grid,
    .detail-grid { grid-template-columns: 1fr; }
    .panel { padding: 16px; border-radius: 10px; }
    .pos-row { grid-template-columns: 1fr 94px 40px; }
    table { min-width: 0; }
    thead { display: none; }
    table, tbody, tr, td { display: block; width: 100%; }
    tr {
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 10px;
        margin-bottom: 10px;
        background: white;
    }
    td { border: 0; padding: 8px; }
    td::before {
        content: attr(data-label);
        display: block;
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
        margin-bottom: 4px;
    }
}
