* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f7fb;
    color: #1f2937;
}

body {
    min-height: 100vh;
}

a {
    text-decoration: none;
}

.app {
    min-height: 100vh;
}

/* =========================
   HEADER
========================= */

.topbar {
    background: #0f172a;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

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

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-badge {
    background: rgba(255,255,255,0.12);
    padding: 8px 10px;
    border-radius: 999px;
    font-size: 13px;
}

.hamburger-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    margin: 0;
    padding: 0;
    cursor: pointer;
    flex: 0 0 auto;
}

.brand-logo-small {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 6px;
    background: #fff;
    padding: 2px;
    flex: 0 0 auto;
}

/* =========================
   MENÚ LATERAL
========================= */

.side-menu {
    position: fixed;
    top: 0;
    left: -320px;
    width: 290px;
    max-width: 85vw;
    height: 100vh;
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: #fff;
    z-index: 1001;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
    transition: left 0.28s ease;
    padding: 18px 16px 20px 16px;
    display: flex;
    flex-direction: column;
}

.side-menu.open {
    left: 0;
}

.side-menu-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
}

.side-menu-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.side-menu-logo {
    width: 54px;
    height: 54px;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
    padding: 4px;
}

.side-menu-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.side-menu-brand-text strong {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
}

.side-menu-brand-text span {
    font-size: 13px;
    color: #cbd5e1;
}

.side-menu-close {
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 20px;
    cursor: pointer;
    flex: 0 0 auto;
}

.side-menu-user {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 18px;
}

.side-menu-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.side-menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px;
    border-radius: 14px;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s ease, transform 0.15s ease;
}

.side-menu-link:hover {
    background: rgba(37, 99, 235, 0.22);
    transform: translateX(2px);
}

.side-menu-icon {
    width: 22px;
    text-align: center;
    font-size: 18px;
}

.side-menu-footer {
    margin-top: auto;
    padding-top: 18px;
}

.side-menu-logout {
    display: block;
    text-align: center;
    padding: 13px 14px;
    border-radius: 14px;
    background: rgba(239, 68, 68, 0.15);
    color: #fff;
    font-weight: 700;
    border: 1px solid rgba(239, 68, 68, 0.22);
}

.side-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1000;
    display: none;
}

.side-menu-overlay.open {
    display: block;
}

/* =========================
   CONTENIDO
========================= */

.main-content {
    max-width: 760px;
    margin: 0 auto;
    padding: 16px;
}

.page-card,
.login-card {
    background: #fff;
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    margin-bottom: 16px;
}

.page-card-header h2,
.login-card h1 {
    margin: 0 0 6px 0;
}

.page-card-header p,
.subtitle {
    margin: 0 0 16px 0;
    color: #64748b;
}

.page-card-header-inline {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

/* =========================
   FORMULARIOS
========================= */

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

label {
    font-size: 14px;
    font-weight: 700;
    color: #334155;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"] {
    width: 100%;
    padding: 14px;
    border: 1px solid #dbe2ea;
    border-radius: 14px;
    font-size: 16px;
    background: #fff;
}

input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* =========================
   BOTONES
========================= */

.btn {
    border: none;
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    display: inline-block;
    text-align: center;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-secondary {
    background: #0f766e;
    color: #fff;
}

.btn-success {
    background: #16a34a;
    color: #fff;
}

.btn-light {
    background: #fff;
    color: #0f172a;
    padding: 10px 12px;
    font-size: 14px;
}

.filter-toggle {
    border: none;
    background: #0f172a;
    color: #fff;
    padding: 10px 12px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
}

/* =========================
   ALERTAS
========================= */

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    margin: 16px 0;
    font-size: 15px;
    font-weight: 600;
}

.alert-error {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.success-card {
    border: 2px solid #bbf7d0;
}

/* =========================
   LOGIN
========================= */

.login-body {
    background: linear-gradient(180deg, #eaf2ff 0%, #f4f7fb 100%);
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 18px;
}

.login-card {
    width: 100%;
    max-width: 420px;
}

.login-logo {
    text-align: center;
    margin-bottom: 20px;
}

.login-logo img {
    max-width: 220px;
    width: 100%;
    height: auto;
}

/* =========================
   LOGO DE PÁGINA
========================= */

.page-logo {
    text-align: center;
    margin-bottom: 10px;
}

.page-logo img {
    max-width: 180px;
    width: 100%;
    height: auto;
}

/* =========================
   ESCÁNER
========================= */

.scanner-statusbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #64748b;
    font-weight: 700;
}

.scanner-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #94a3b8;
}

.scanner-dot.on {
    background: #16a34a;
    box-shadow: 0 0 8px rgba(22, 163, 74, 0.5);
}

.scanner-wrap {
    position: relative;
    width: 100%;
    height: 220px;
    background: #0f172a;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 16px;
    border: 1px solid #1e293b;
}

.scanner-wrap-compact {
    height: 150px;
}

#preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#preview.active {
    opacity: 1;
}

.scanner-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scanner-frame {
    width: 78%;
    height: 52%;
    border: 2px solid rgba(37, 99, 235, 0.9);
    border-radius: 14px;
    position: relative;
    box-shadow: 0 0 18px rgba(37, 99, 235, 0.2);
}

.scanner-frame::before,
.scanner-frame::after,
.corner-bl,
.corner-br {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-color: #60a5fa;
    border-style: solid;
}

.scanner-frame::before {
    top: -2px;
    left: -2px;
    border-width: 4px 0 0 4px;
}

.scanner-frame::after {
    top: -2px;
    right: -2px;
    border-width: 4px 4px 0 0;
}

.corner-bl {
    bottom: -2px;
    left: -2px;
    border-width: 0 0 4px 4px;
}

.corner-br {
    bottom: -2px;
    right: -2px;
    border-width: 0 4px 4px 0;
}

.scan-line {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, #22c55e, transparent);
    opacity: 0;
}

.scan-line.active {
    opacity: 1;
    animation: scanMove 2s linear infinite;
}

@keyframes scanMove {
    0% { top: 0; }
    50% { top: calc(100% - 3px); }
    100% { top: 0; }
}

.scanner-idle {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #cbd5e1;
    font-weight: 700;
    text-align: center;
    background: rgba(15, 23, 42, 0.28);
    transition: opacity 0.3s ease;
}

.scanner-idle.hidden {
    opacity: 0;
    pointer-events: none;
}

.scanner-idle-icon {
    font-size: 26px;
    opacity: 0.9;
}

.scanner-input-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scanner-btn {
    width: 100%;
}

/* =========================
   DETALLE DE LÍNEA
========================= */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 16px;
}

.detail-item {
    background: #f8fafc;
    border-radius: 14px;
    padding: 14px;
    border: 1px solid #e2e8f0;
}

.detail-label {
    display: block;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 6px;
    font-weight: 700;
}

.detail-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.detail-item-full {
    grid-column: 1 / -1;
}

.detail-grid-custom {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.row-full {
    display: flex;
    flex-direction: column;
}

.cell {
    display: flex;
    flex-direction: column;
}

.label {
    font-size: 12px;
    color: #666;
}

.value {
    font-size: 16px;
    font-weight: bold;
    color: #111;
}

/* =========================
   ACCIONES
========================= */

.actions-block {
    margin-top: 18px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.partial-box {
    background: #f8fafc;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
}

.inline-form {
    margin: 0;
}

/* =========================
   FILTROS
========================= */

.filter-panel {
    display: none;
    margin-top: 14px;
}

.filter-panel.open {
    display: block;
}

/* =========================
   LISTADOS
========================= */

.list-card {
    padding: 14px;
}

.list-card-row,
.list-card-row-full {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 14px;
}

.list-card-row-full {
    display: block;
}

/* =========================
   PAGINACIÓN
========================= */

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 16px 0 28px 0;
}

.pagination-info {
    font-weight: 700;
    color: #475569;
}

/* =========================
   RESPONSIVE
========================= */

@media (min-width: 640px) {
    .scanner-input-row {
        flex-direction: row;
    }

    .scanner-input-row input {
        flex: 1;
    }

    .scanner-btn {
        width: auto;
        min-width: 140px;
    }
}

@media (min-width: 768px) {
    .detail-grid {
        grid-template-columns: 1fr 1fr;
    }

    .actions-block {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
}

@media (max-width: 480px) {
    .topbar-left {
        gap: 8px;
    }

    .topbar-left h1 {
        font-size: 17px;
    }

    .brand-logo-small {
        width: 38px;
        height: 38px;
    }

    .hamburger-btn {
        font-size: 22px;
    }

    .row-3 {
        grid-template-columns: 1fr;
    }

    .login-logo img {
        max-width: 160px;
    }

    .page-logo img {
        max-width: 140px;
    }
}