:root {
    --ink: #17181c;
    --ink-dim: #5b5f68;
    --paper: #ffffff;
    --bg: #f4f5f7;
    --line: #e2e4e9;
    --red: #c41e2c;
    --red-dark: #9c1621;
    --ok: #1a7f37;
    --warn: #a15c00;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
    line-height: 1.5;
}

a { color: var(--red-dark); }

.topbar {
    background: var(--ink);
    color: #fff;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 8px;
}

.topbar .brand {
    font-weight: 700;
    letter-spacing: .02em;
}

.topbar .brand span { color: var(--red); }

.topbar nav a {
    color: #fff;
    text-decoration: none;
    margin-left: 18px;
    font-size: .9rem;
    opacity: .85;
}

.topbar nav a:hover { opacity: 1; }

.wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 28px 20px 60px;
}

.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 20px;
}

h1 { font-size: 1.5rem; margin: 0 0 6px; }
h2 { font-size: 1.15rem; margin: 0 0 14px; }
p.lead { color: var(--ink-dim); margin-top: 0; }

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--ink-dim); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    background: #eef0f3;
    color: var(--ink-dim);
}
.badge.informe { background: #e8f0fe; color: #1a56c4; }
.badge.cotizacion { background: #fef3e0; color: var(--warn); }
.badge.certificacion { background: #e6f4ea; color: var(--ok); }
.badge.contrato { background: #eee9fe; color: #5b32ad; }
.badge.factura { background: #e1f5f5; color: #0c646a; }
.badge.mantencion { background: #e6f4ea; color: var(--ok); }
.badge.otro { background: #eef0f3; color: var(--ink-dim); }
.badge.sin-asignar { background: #fde8e8; color: var(--red-dark); }

.btn {
    display: inline-block;
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 9px 16px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--red-dark); }
.btn.secondary { background: #eef0f3; color: var(--ink); }
.btn.secondary:hover { background: #e2e4e9; }
.btn.small { padding: 5px 11px; font-size: .8rem; }

form.inline { display: inline; }

/* Botón "ojo" para mostrar/ocultar contraseña (assets/password-eye.js) */
.pw-wrap { display: flex; gap: 8px; align-items: stretch; margin-bottom: 14px; }
.pw-wrap > input[type=text],
.pw-wrap > input[type=password] { flex: 1; margin-bottom: 0; }
.pw-toggle {
    flex: 0 0 auto;
    width: 44px;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink-dim);
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.pw-toggle:hover { background: var(--bg); color: var(--ink); border-color: #cfd3da; }
.pw-toggle:active { background: #e2e4e9; }
.pw-toggle:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }
.pw-toggle.is-on { color: var(--red); border-color: var(--red); }
.pw-toggle svg { width: 18px; height: 18px; display: block; }

.pw-wrap-inline { display: inline-flex; margin-bottom: 0; vertical-align: middle; }
.pw-wrap-inline > input[type=text],
.pw-wrap-inline > input[type=password] { flex: 0 0 auto; }
.pw-wrap-inline .pw-toggle { width: 36px; }

label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; color: var(--ink-dim); }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=datetime-local], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    font-size: .95rem;
    margin-bottom: 14px;
}

.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > div { flex: 1; min-width: 180px; }

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: .9rem;
}
.alert.error { background: #fde8e8; color: var(--red-dark); }
.alert.success { background: #e6f4ea; color: var(--ok); }
.alert.info { background: #e8f0fe; color: #1a56c4; }

.login-wrap {
    max-width: 380px;
    margin: 8vh auto;
    padding: 0 20px;
}

.muted { color: var(--ink-dim); font-size: .85rem; }

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

/* Fila desplegable para editar los datos de contacto de un cliente (admin) */
.edit-row td { padding: 0 8px 10px; }
.edit-row details summary { cursor: pointer; font-size: .8rem; color: var(--ink-dim); padding: 6px 0; }
.edit-row details[open] summary { margin-bottom: 8px; }
.datos-form { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: flex-end; }
.datos-form label { font-size: .7rem; font-weight: 600; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .03em; display: flex; flex-direction: column; gap: 3px; }
.datos-form input { margin-bottom: 0; width: 190px; }

/* ---- Portal de cliente: fondo sutil, cabecera con datos del cliente ---- */
.client-body {
    background:
        linear-gradient(rgba(244, 245, 247, .945), rgba(244, 245, 247, .965)),
        url("bg.jpg") center / cover no-repeat fixed;
    background-color: var(--bg);
}

.client-header {
    background: var(--paper);
    border-top: 3px solid var(--red);
    border-bottom: 1px solid var(--line);
}
.client-header .inner { max-width: 960px; margin: 0 auto; padding: 18px 20px; }
.client-header .ch-company {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: .01em;
}
.client-header .ch-data {
    margin-top: 9px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 26px;
    font-size: .85rem;
}
.client-header .ch-data .k {
    color: var(--ink-dim);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-right: 6px;
}
.client-header .ch-data .v { color: var(--ink); }
.client-header .ch-data a { color: var(--red-dark); text-decoration: none; }

.topbar .brand-logo { height: 38px; width: auto; display: block; }
.topbar .client-name {
    font-size: .9rem;
    opacity: .9;
    padding-right: 16px;
    margin-right: 16px;
    border-right: 1px solid rgba(255, 255, 255, .25);
}

.page-head { margin-bottom: 22px; }
.page-head h1 { margin-bottom: 4px; }

.info-card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 20px 24px; margin-bottom: 20px; }
.info-card h2 { font-size: 1rem; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 28px; font-size: .9rem; }
.info-grid .k { color: var(--ink-dim); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; display: block; margin-bottom: 1px; }
.info-grid .v { color: var(--ink); }
.info-grid a { color: var(--red-dark); text-decoration: none; }
.info-grid a:hover { text-decoration: underline; }

.site-footer {
    border-top: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink-dim);
    font-size: .8rem;
    line-height: 1.7;
}
.site-footer .inner { max-width: 960px; margin: 0 auto; padding: 22px 20px 30px; }
.site-footer .company { color: var(--ink); font-weight: 600; font-size: .85rem; }
.site-footer .rows { margin-top: 4px; }
.site-footer .sep::before { content: "·"; margin: 0 8px; opacity: .5; }
.site-footer a { color: var(--red-dark); text-decoration: none; }

/* ---- Elemento 2: secciones de documentos ---- */
.doc-section h2 .muted { font-weight: 400; font-size: .9rem; }

/* ---- Elemento 1: estado de sistemas ---- */

/* Panel del cliente (dashboard.php) */
.sys-status td { vertical-align: middle; }
.sys-status .dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}
.sys-status .dot.ok   { background: var(--ok); }
.sys-status .dot.warn { background: #d99000; }
.sys-status .dot.crit { background: var(--red); }
.sys-status .dot.na   { background: #c2c7d0; }
.sys-status .sys-estado { font-weight: 600; }
.sys-status .sys-nota { margin-top: 2px; }

/* Grilla de edición en el admin (fila desplegable del cliente) */
.estado-sistemas { margin-top: 6px; }
.estado-sistemas > summary { cursor: pointer; font-size: .8rem; color: var(--ink-dim); padding: 6px 0; }
.estado-sistemas[open] > summary { margin-bottom: 6px; }
.estado-grid { font-size: .85rem; margin: 4px 0 12px; }
.estado-grid th { font-size: .7rem; }
.estado-grid td { padding: 6px 8px; }
.estado-grid select,
.estado-grid input[type=date],
.estado-grid input[type=text] { margin-bottom: 0; width: auto; min-width: 150px; }

.login-header {
    background: var(--ink);
    border-radius: 10px 10px 0 0;
    padding: 22px 24px;
    text-align: center;
}
.login-header img { height: 46px; width: auto; }
.login-wrap .card { border-radius: 0 0 10px 10px; border-top: none; }
.login-foot { text-align: center; margin-top: 20px; }
.login-foot .muted a { color: var(--red-dark); }

.check-label { display:flex; align-items:center; gap:8px; margin: 4px 0 16px; font-weight:400; }
.check-label input { width:auto; margin:0; }
.operations-client strong { display:block; }
