body {
    font-family: Arial, sans-serif;
    background: #eef1f5;
    margin: 0;
    padding: 15px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: auto;
}

.oculto {
    display: none !important;
}

.brand-header {
    display: grid;
    justify-items: center;
    gap: 8px;
    margin: 0 auto 24px;
    padding: 10px 0 2px;
}

.brand-logo {
    display: block;
    width: min(100%, 520px);
    height: auto;
    max-height: 128px;
    object-fit: contain;
}

.brand-title {
    color: #2c3e50;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
}

h2 {
    margin-top: 0;
    color: #34495e;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    border-left: 5px solid #3498db;
}

.login-card {
    max-width: 420px;
    margin: 0 auto;
}

input,
select,
textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    margin: 8px 0 15px 0;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 15px;
}

.password-field {
    position: relative;
    margin: 8px 0 15px;
}

.password-field input {
    margin: 0;
    padding-right: 52px;
}

button.password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    min-width: 40px;
    margin: 0;
    padding: 0;
    background: transparent;
    border-radius: 50%;
    color: #607d8b;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

button.password-toggle:hover {
    background: #edf2f6;
}

button.password-toggle span {
    position: relative;
    width: 22px;
    height: 14px;
    border: 2px solid currentColor;
    border-radius: 50% / 55%;
    display: block;
}

button.password-toggle span::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    transform: translate(-50%, -50%);
}

button.password-toggle span::after {
    content: "";
    position: absolute;
    left: -3px;
    top: 50%;
    width: 28px;
    height: 2px;
    background: currentColor;
    transform: rotate(-38deg);
    opacity: 0;
}

button.password-toggle.visible {
    color: #1565c0;
}

button.password-toggle.visible span::after {
    opacity: 1;
}

#iot_chart {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: 260px;
    margin-top: 10px;
    border: 1px solid #d8e0e8;
    border-radius: 6px;
    background: #fff;
}

.iot-state-panel {
    margin-top: 12px;
    padding: 14px;
    border: 1px solid #d8e0e8;
    border-radius: 6px;
    background: #f7f9fb;
}

.iot-state-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    color: #34495e;
    margin-bottom: 12px;
}

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

.iot-state-box {
    min-width: 0;
    padding: 12px;
    border: 1px solid #d8e0e8;
    border-radius: 6px;
    background: #fff;
}

.iot-state-box h3 {
    margin: 0 0 8px;
    font-size: 16px;
    color: #2c3e50;
}

.iot-state-box p {
    margin: 5px 0;
}

.iot-state-box dl {
    display: grid;
    gap: 6px;
    margin: 8px 0 0;
}

.iot-state-box dl div {
    display: grid;
    grid-template-columns: minmax(90px, 0.8fr) minmax(0, 1.2fr);
    gap: 8px;
    align-items: start;
}

.iot-state-box dt {
    font-weight: 700;
    color: #34495e;
}

.iot-state-box dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.muted {
    color: #607d8b;
}

.field-label {
    display: block;
    margin: 2px 0 6px;
    color: #34495e;
    font-weight: bold;
}

.field-hint {
    margin: -8px 0 14px;
    color: #607d8b;
    font-size: 13px;
}

select[multiple] {
    min-height: 120px;
}

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

button {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 18px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    width: 100%;
    margin-bottom: 10px;
    transition: 0.2s;
}

button:hover {
    background: #2980b9;
}

button.inline {
    width: auto;
    margin: 0;
    padding: 8px 12px;
    font-size: 14px;
}

button.secondary {
    background: #607d8b;
}

button.danger {
    background: #c62828;
}

button.danger:hover {
    background: #a61f1f;
}

button.link-button {
    width: auto;
    margin: 0;
    padding: 0;
    background: transparent;
    color: #1565c0;
    text-align: left;
}

button.link-button:hover {
    background: transparent;
    text-decoration: underline;
}

.session-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    color: #2c3e50;
    font-weight: bold;
}

.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.tabs button {
    width: auto;
    margin: 0;
    background: #ffffff;
    color: #2c3e50;
    border: 1px solid #cfd8dc;
}

.tabs button.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.work-grid,
.detail-grid,
.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.search-row input,
.search-row button {
    margin: 0;
}

.summary-card {
    background: white;
    border-left: 5px solid #607d8b;
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    color: #333;
    cursor: pointer;
    margin: 0;
    text-align: left;
    width: 100%;
}

.summary-card strong {
    display: block;
    font-size: 28px;
    color: #2c3e50;
}

.summary-card:hover {
    background: #f7f9fb;
}

.quick-create {
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #d8dee3;
    border-radius: 6px;
    background: #f7f9fb;
}

.error {
    color: #b00020;
    font-weight: bold;
}

.ok {
    color: #207245;
    font-weight: bold;
}

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

.table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.filter-row select,
.filter-row button {
    width: auto;
    min-width: 180px;
}

.admin-filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.admin-filter-grid input,
.admin-filter-grid select {
    margin: 0;
}

.admin-metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.admin-metric {
    padding: 12px;
    border: 1px solid #d8e0e8;
    border-radius: 6px;
    background: #f7f9fb;
    text-align: center;
}

.admin-metric strong {
    display: block;
    color: #2c3e50;
    font-size: 24px;
}

.admin-metric span {
    color: #607d8b;
    font-size: 13px;
}

.preventivo-editor input,
.preventivo-editor select {
    min-width: 120px;
    margin: 0;
}

.preventivo-editor td:nth-child(2) input,
.preventivo-editor td:nth-child(5) input {
    min-width: 190px;
}

.preventivo-zona td {
    background: #edf2f7;
    color: #2c3e50;
    font-weight: 700;
}

.check-list {
    display: grid;
    gap: 8px;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #d8dee3;
    border-radius: 6px;
    background: #f7f9fb;
}

.check-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    min-height: 34px;
    font-weight: 600;
    cursor: pointer;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    font-weight: 600;
}

.check-row input {
    width: auto;
    margin: 0;
}

.check-list input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.check-list span {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #2c3e50;
}

.check-list span::before {
    content: "";
    display: inline-block;
    width: 22px;
    height: 22px;
    box-sizing: border-box;
    flex: 0 0 22px;
    margin: 0;
    border: 2px solid #607d8b;
    border-radius: 4px;
    background: #fff;
}

.check-list input:checked + span::before {
    border-color: #1565c0;
    background:
        linear-gradient(135deg, transparent 58%, #fff 58% 70%, transparent 70%) 5px 2px / 11px 15px no-repeat,
        #1565c0;
}

.check-list input:focus-visible + span::before {
    outline: 3px solid rgba(21, 101, 192, 0.25);
    outline-offset: 2px;
}

.check-list-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

th,
td {
    border-bottom: 1px solid #ddd;
    padding: 10px 8px;
    text-align: left;
    vertical-align: top;
}

th {
    color: #2c3e50;
    background: #f6f8fa;
}

.internal-note {
    max-width: 320px;
    color: #4b5563;
    white-space: pre-wrap;
}

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover {
    background: #f7f9fb;
}

.status-select {
    min-width: 150px;
    margin: 0;
    padding: 8px;
    font-weight: bold;
}

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: bold;
    line-height: 1.2;
}

.status-abierta,
.priority-media {
    background: #e3f2fd;
    color: #0d47a1;
}

.status-en_curso,
.priority-alta {
    background: #fff3e0;
    color: #a84300;
}

.status-pendiente_cliente {
    background: #ede7f6;
    color: #4527a0;
}

.status-cerrada,
.priority-baja {
    background: #e8f5e9;
    color: #1b5e20;
}

.priority-urgente {
    background: #ffebee;
    color: #b71c1c;
}

.comment {
    border-bottom: 1px solid #e4e7ea;
    padding: 10px 0;
}

.comment small {
    color: #607d8b;
}

.attachment {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #e4e7ea;
    padding: 10px 0;
}

.attachment small {
    color: #607d8b;
    display: block;
}

.attachment-info {
    min-width: 0;
}

.attachment-info .inline {
    margin-top: 8px;
}

.attachment-badge {
    display: inline-block;
    background: #eef7f1;
    color: #17633a;
    border: 1px solid #b7ddc5;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: bold;
}

.list-thumb {
    width: 64px;
    height: 48px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border-radius: 6px;
    background: #e9eef3;
    border: 1px solid #d4dde5;
}

.list-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumb-shell {
    width: 92px;
    height: 72px;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border-radius: 6px;
    background: #e9eef3;
    border: 1px solid #d4dde5;
}

.thumb-shell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.solution-box {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid #cfe3d6;
    border-radius: 6px;
    background: #f2fbf5;
}

.timeline-item {
    border-left: 3px solid #cfd8dc;
    padding: 8px 0 8px 12px;
    margin-bottom: 8px;
}

.timeline-item small {
    display: block;
    color: #607d8b;
    margin: 2px 0 4px;
}

.image-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(20, 28, 36, 0.88);
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.image-modal img {
    max-width: min(100%, 1100px);
    max-height: 78vh;
    object-fit: contain;
    background: #111;
    border-radius: 8px;
}

.image-modal .secondary {
    max-width: 260px;
}

.image-modal-bar {
    width: min(100%, 1100px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    color: white;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 24px;
        margin-bottom: 18px;
    }

    .brand-header {
        margin-bottom: 18px;
        padding-top: 4px;
    }

    .brand-logo {
        max-height: 92px;
    }

    .brand-title {
        font-size: 18px;
    }

    .card {
        padding: 15px;
    }

    .work-grid,
    .detail-grid,
    .summary-grid,
    .admin-filter-grid,
    .admin-metrics {
        grid-template-columns: 1fr;
    }

    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
    }

    .tabs button {
        flex: 0 0 auto;
    }

    .session-bar {
        align-items: stretch;
        flex-direction: column;
    }

    button {
        font-size: 16px;
    }

    table {
        min-width: 840px;
    }

    .list-thumb {
        width: 74px;
        height: 56px;
    }

    .status-select {
        min-width: 130px;
    }

    .attachment {
        align-items: flex-start;
        flex-direction: column;
    }

    .thumb-shell {
        width: 100%;
        height: auto;
        aspect-ratio: 4 / 3;
    }

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

    .iot-state-grid,
    .iot-state-box dl div {
        grid-template-columns: 1fr;
    }

    .image-modal {
        padding: 10px;
    }

    .image-modal-bar {
        align-items: stretch;
        flex-direction: column;
    }
}

@media print {
    body {
        background: white;
        padding: 0;
    }

    .session-bar,
    .tabs,
    button,
    input,
    select,
    textarea {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }
}
