:root {
    --primary: #253746;
    --primary-dark: #16232e;
    --muted: #5b6b78;
    --border: #d8dee3;
    --bg: #f4f6f8;
    --success: #1c7c3f;
    --success-bg: #e5f5ea;
    --error: #b3261e;
    --error-bg: #fbe9e7;
    --info-bg: #eef2f5;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: #1a2530;
}

a {
    color: var(--primary);
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        linear-gradient(rgba(5, 8, 17, 0.45), rgba(5, 8, 17, 0.65)),
        url("../images/login_bg.png") no-repeat center center;
    background-size: cover;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: rgba(10, 15, 29, 0.6);
    backdrop-filter: blur(10px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    padding: 32px;
}

.login-brand {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo {
    max-width: 120px;
    max-height: 72px;
    font-size: 40px;
    display: inline-block;
    margin-bottom: 8px;
}

.login-brand h1 {
    font-size: 20px;
    margin: 4px 0;
    color: #ffffff;
}

.login-subtitle {
    color: #94a3b8;
    font-size: 14px;
    margin: 0;
}

.login-footer {
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
    margin-top: 20px;
    margin-bottom: 0;
}

.login-page .form-group {
    margin-bottom: 16px;
}

.login-page .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #ffffff;
}

.login-page .form-group input,
.login-page .form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.03);
    color: #ffffff;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.login-page .form-group input::placeholder {
    color: #94a3b8;
    opacity: 0.5;
}

.login-page .form-group input:focus,
.login-page .form-group select:focus {
    outline: none;
    border-color: #06b6d4;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.25);
}

.login-page .hint {
    color: #94a3b8;
    font-size: 12px;
    margin: 8px 0 16px;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
}

.password-toggle:hover {
    color: #e2e8f0;
}

.password-toggle svg[hidden] {
    display: none;
}

.password-toggle:focus-visible {
    outline: 2px solid #06b6d4;
    outline-offset: -2px;
    border-radius: 8px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--primary-dark);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.hint {
    color: var(--muted);
    font-size: 12px;
    margin: 8px 0 16px;
}

.btn {
    display: inline-block;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-ghost {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}

.btn-block {
    display: block;
    width: 100%;
}

.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
}

/* --- Portal (post-login): app shell con sidebar --- */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--primary-dark);
    color: #e2e8f0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    padding: 18px 16px;
    white-space: nowrap;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
}

.sidebar-user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-role {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.65);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
}

.menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.menu-item {
    margin-bottom: 2px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.82);
    text-decoration: none;
    font-size: 14px;
}

.menu-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.menu-link.is-active {
    background: rgba(6, 182, 212, 0.15);
    color: #fff;
    font-weight: 600;
}

.menu-icon {
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
}

.topbar-context {
    flex: 1;
}

.icon-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.icon-burger {
    position: relative;
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--primary-dark);
}

.icon-burger::before,
.icon-burger::after {
    content: "";
    position: absolute;
    left: 0;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--primary-dark);
}

.icon-burger::before {
    top: -6px;
}

.icon-burger::after {
    top: 6px;
}

.sidebar-scrim {
    display: none;
}

.topbar-context {
    color: var(--primary-dark);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logout-form {
    display: inline;
}

.content {
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
}

.content h1 {
    margin: 0 0 4px;
    font-size: 22px;
    color: var(--primary-dark);
}

.panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

.panel-title {
    margin: 0 0 12px;
    font-size: 16px;
    color: var(--primary-dark);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-item .label {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.info-item .value {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-dark);
}

.chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.chip-success {
    background: var(--success-bg);
    color: var(--success);
}

.chip-danger {
    background: var(--error-bg);
    color: var(--error);
}

.empty {
    color: var(--muted);
    font-size: 14px;
    padding: 12px 0;
}

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th,
.table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.chip-info {
    background: var(--info-bg);
    color: var(--primary);
}

/* ---------- Historial de retiros de bodega ---------- */

.withdrawal-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
}

.withdrawal-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    list-style: none;
    background: #fbfbfc;
}

.withdrawal-summary::-webkit-details-marker {
    display: none;
}

.withdrawal-body {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.withdrawal-diagram-wrap {
    display: flex;
    justify-content: center;
    background: var(--bg);
    border-radius: 10px;
    padding: 16px;
    margin: 16px 0;
}

/* ---------- Diagrama de camión (solo lectura) ---------- */

.tire-install-diagram {
    width: 100%;
    max-width: 220px;
    height: auto;
}

.tire-install-diagram .ti-chassis {
    stroke-width: 1.5;
}

.tire-install-diagram .ti-chassis-tracto {
    fill: #1e293b;
    stroke: #0f172a;
}

.tire-install-diagram .ti-chassis-semi {
    fill: #334155;
    stroke: #1e293b;
}

.tire-install-diagram .ti-cab {
    fill: #e11d48;
    stroke: #9f1239;
    stroke-width: 1.5;
}

.tire-install-diagram .ti-hood {
    fill: #e11d48;
    stroke: #9f1239;
    stroke-width: 1.5;
}

.tire-install-diagram .ti-bumper {
    fill: #1e293b;
    stroke: #0f172a;
    stroke-width: 1;
}

.tire-install-diagram .ti-windshield {
    fill: #1e293b;
    stroke: #0f172a;
    stroke-width: 1.5;
}

.tire-install-diagram .ti-windshield-reflection {
    stroke: #ffffff;
    stroke-width: 1.5;
    stroke-linecap: round;
    opacity: 0.35;
}

.tire-install-diagram .ti-mirror-bracket {
    stroke: #e11d48;
    stroke-width: 1.5;
    stroke-linecap: round;
}

.tire-install-diagram .ti-mirror {
    fill: #e11d48;
    stroke: #9f1239;
    stroke-width: 1;
}

.tire-install-diagram .ti-headlight {
    fill: #fbbf24;
    stroke: #d97706;
    stroke-width: 0.5;
}

.tire-install-diagram .ti-fuel-tank {
    fill: #cbd5e1;
    stroke: #94a3b8;
    stroke-width: 1;
}

.tire-install-diagram .ti-tank-strap {
    stroke: #475569;
    stroke-width: 1.5;
}

.tire-install-diagram .ti-catwalk {
    fill: #475569;
    stroke: #334155;
    stroke-width: 1;
}

.tire-install-diagram .ti-catwalk-line {
    stroke: #334155;
    stroke-width: 0.75;
    opacity: 0.5;
}

.tire-install-diagram .ti-hitch-beam {
    fill: #475569;
    stroke: #334155;
    stroke-width: 1;
}

.tire-install-diagram .ti-hitch {
    fill: #cbd5e1;
    stroke: #94a3b8;
    stroke-width: 1.5;
}

.tire-install-diagram .ti-hitch-pin {
    fill: #f8fafc;
    stroke: #475569;
    stroke-width: 1.5;
}

.tire-install-diagram .ti-semi-body {
    fill: #f8fafc;
    stroke: #cbd5e1;
    stroke-width: 1.5;
}

.tire-install-diagram .ti-taillight-left,
.tire-install-diagram .ti-taillight-right {
    fill: #ef4444;
    stroke: #b91c1c;
    stroke-width: 0.5;
}

.tire-install-diagram .ti-axle {
    fill: #64748b;
    stroke: #475569;
    stroke-width: 1;
}

.tire-install-diagram .ti-section-label {
    font-size: 7px;
    font-weight: 800;
    letter-spacing: 0.08em;
    fill: #94a3b8;
}

.tire-install-diagram .ti-wheel {
    stroke-width: 3.5;
    rx: 6;
}

.tire-install-diagram .ti-wheel.tp-disabled {
    fill: #cbd5e1;
    stroke: #334155;
}

.tire-install-diagram .ti-wheel.tp-occupied {
    fill: #6ee7b7;
    stroke: #064e3b;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
    .icon-btn {
        display: inline-flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 15;
        background: rgba(18, 17, 22, 0.5);
    }

    .topbar {
        padding: 12px 16px;
        flex-wrap: wrap;
    }

    .topbar-context {
        order: 3;
        flex-basis: 100%;
    }

    .content {
        padding: 20px 16px;
    }
}
