:root {
    --blue: #00c1d5;        /* cian corporativo (botones y acentos, como el login) */
    --blue-dark: #00a7b8;   /* hover de botón */
    --brand: #003746;       /* tono oscuro del login (navbar / superficies de marca) */
    --brand-2: #004756;     /* segundo tono del degradado del login */
    --link: #0a6f7e;        /* enlaces legibles sobre blanco */
    --bg: #eef5f7;          /* fondo con leve tinte teal, como el login */
    --card: #ffffff;
    --border: #dbe4ec;
    --text: #172233;
    --muted: #6b7a89;
    --green: #3a9d5d;
    --amber: #d99a1c;
    --red: #d1495b;
    --gray: #8a98a6;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }

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

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Navbar ---------- */
.navbar {
    background: linear-gradient(135deg, #002735 0%, #004756 100%);
    color: #fff;
}
.navbar__inner {
    position: relative;
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 20px;
    height: 56px;
}
.navbar__brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-weight: 600;
    font-size: 18px;
}
.navbar__brand:hover { text-decoration: none; }
.navbar__logo { font-size: 20px; }
.navbar__logo-img { height: 30px; display: block; }
.navbar__tag {
    color: rgba(255, 255, 255, .8);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .3px;
    padding-left: 14px;
    margin-left: 2px;
    border-left: 1px solid rgba(255, 255, 255, .4);
}
.login-platform {
    text-align: center;
    color: var(--blue);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: .3px;
    margin: 0 0 6px;
}
.login-version {
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    vertical-align: middle;
}
/* Navegación como menú desplegable (PC y móvil): se abre con el botón ☰.
   position:fixed para que NO aumente el alto de la página (no añade scroll).
   La posición exacta (bajo el ☰) la fija chrome.js al abrir. */
.navbar__nav {
    display: none;
    position: fixed;
    top: 56px;
    right: 20px;
    left: auto;
    min-width: 220px;
    flex-direction: column;
    gap: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 0;
    z-index: 60;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}
.navbar.open .navbar__nav { display: flex; }
.navbar__nav a { color: var(--text); padding: 11px 18px; }
.navbar__nav a:hover { background: #f3f6f9; text-decoration: none; }
.navbar__nav-logout {
    display: block;
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 12px;
}
.navbar__user { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.navbar__username { color: rgba(255, 255, 255, .9); font-size: 14px; }

/* ---------- Layout ---------- */
.container {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 20px;
}

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

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--blue);
    background: var(--blue);
    color: #fff;
    cursor: pointer;
    font-size: 14px;
}
.btn:hover { background: var(--blue-dark); text-decoration: none; }
.btn--ghost { background: transparent; border-color: rgba(255, 255, 255, .6); color: #fff; }
.btn--sm { padding: 4px 10px; font-size: 13px; }

/* ---------- Forms ---------- */
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 14px; margin-bottom: 4px; color: var(--muted); }
.form-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
}
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 14px; }
.alert--error { background: #fdecec; color: var(--red); border: 1px solid #f5c2c7; }

/* Foco cian unificado con el login */
.form-field input:focus, .form-field select:focus, .form-field textarea:focus,
.search:focus, .admin-bar input:focus, .admin-bar select:focus,
.ss__input:focus, .inline-select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0, 193, 213, .15);
    outline: none;
}

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.table th { color: var(--muted); font-weight: 600; }
.table tr:hover td { background: #fafbfc; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: var(--gray);
    white-space: nowrap;
}
.badge--ok, .badge--finished, .badge--applied { background: var(--green); }
.badge--busy, .badge--queued, .badge--started, .badge--pending { background: var(--amber); }
.badge--failed, .badge--stopped, .badge--conflict, .badge--error { background: var(--red); }

/* ---------- Project detail ---------- */
.project-layout { display: flex; gap: 24px; align-items: flex-start; }
.project-tabs {
    width: 200px;
    flex-shrink: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.project-tabs a {
    display: block;
    padding: 10px 16px;
    color: var(--text);
    border-left: 3px solid transparent;
}
.project-tabs a:hover { background: #f3f6f9; text-decoration: none; }
.project-tabs a.active { background: #e6f7fa; border-left-color: var(--blue); color: var(--brand); font-weight: 600; }
.project-main { flex: 1; min-width: 0; }

/* ---------- Overview tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tile { text-align: center; }
.tile__num { font-size: 32px; font-weight: 700; color: var(--blue); }
.tile__label { color: var(--muted); font-size: 14px; }

/* ---------- Projects grid ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.search {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    min-width: 240px;
}

/* ---------- Map ---------- */
#delta-map { height: 420px; border-radius: var(--radius); border: 1px solid var(--border); }

/* Id de capa (puede ser muy largo y sin espacios): su propia línea, recorta con ellipsis */
.cn-meta { min-width: 0; }
.cn-layer {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    margin-top: 2px;
}
.map-toggle { display: inline-flex; margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.map-toggle button { padding: 6px 14px; border: 0; background: #fff; cursor: pointer; font-size: 13px; }
.map-toggle button.active { background: var(--blue); color: #fff; }

.spinner { color: var(--muted); padding: 20px 0; }
.loader-center { color: var(--muted); text-align: center; padding: 56px 0; }
.empty { color: var(--muted); padding: 16px 0; }

details.raw { margin-top: 16px; }
details.raw pre {
    background: #1e2733; color: #d6e1ec; padding: 14px;
    border-radius: var(--radius); overflow: auto; font-size: 12px;
}

/* ---------- Responsive ---------- */
html, body { max-width: 100%; overflow-x: hidden; }

/* Botón de menú ☰ (PC y móvil) */
.navbar__menu-btn {
    display: inline-block;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .6);
    color: #fff;
    border-radius: var(--radius);
    font-size: 18px;
    line-height: 1;
    padding: 6px 11px;
    cursor: pointer;
}

@media (max-width: 760px) {
    /* En móvil: barra más compacta y se ocultan el tag y el almacenamiento por espacio */
    .navbar__inner { height: auto; gap: 10px; padding: 10px 16px; }
    .navbar__tag { display: none; }
    #nav-storage { display: none; }

    /* Pestañas de proyecto: una sola fila con scroll horizontal */
    .project-layout { flex-direction: column; align-items: stretch; }
    .project-main { width: 100%; max-width: 100%; }
    .project-tabs {
        width: 100%;
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .project-tabs a {
        white-space: nowrap;
        border-left: 0;
        border-bottom: 3px solid transparent;
    }
    .project-tabs a.active { border-left: 0; border-bottom-color: var(--blue); background: #e6f7fa; }

    .tiles { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
    .search { min-width: 0; width: 100%; }
    #delta-map { height: 320px; }
    .navbar__logo-img { height: 26px; }
    .container { padding: 0 14px; }
}

/* ---------- Administración (v1.1) ---------- */
/* Variantes de botón sobre fondo claro */
.btn--secondary { background: #fff; border-color: var(--border); color: var(--text); }
.btn--secondary:hover { background: #f3f6f9; }
.btn--danger { background: var(--red); border-color: var(--red); }
.btn--danger:hover { background: #b53a4b; }

/* select y textarea con el mismo aspecto que los inputs */
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    background: #fff;
    color: var(--text);
}
.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 14px; }
.form-check input { width: auto; }

/* Formulario "añadir" en línea (colaboradores, miembros, teams) */
.admin-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
}
.admin-bar input, .admin-bar select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}
.admin-bar input { min-width: 200px; }

/* Acciones por fila y selects pequeños dentro de tablas */
.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.inline-select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: #fff;
}

/* Tarjetas del hub de administración */
.admin-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.admin-cards .card { margin: 0; }
.admin-card h2 { margin-bottom: 6px; }
.admin-card p { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

/* Desplegable con buscador (combobox) */
.ss { position: relative; display: inline-block; min-width: 240px; }
.ss__input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}
.ss__menu {
    /* position:fixed para que NO aumente el alto de la página; lo coloca el JS junto al campo */
    position: fixed;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
    /* ~5 filas visibles; el resto con scroll dentro del propio menú */
    max-height: 196px;
    overflow-y: auto;
    z-index: 80;
}
.ss__opt { padding: 6px 12px; cursor: pointer; font-size: 14px; line-height: 1.4; }
.ss__opt:hover { background: #e6f7fa; }
.ss__empty, .ss__more { padding: 8px 12px; color: var(--muted); font-size: 13px; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 32, .45);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    z-index: 100;
    overflow-y: auto;
}
.modal {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
    width: 100%;
    max-width: 460px;
    padding: 22px 22px 18px;
}
.modal h2 { margin-bottom: 16px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@media (max-width: 760px) {
    .admin-bar { flex-direction: column; align-items: stretch; }
    .admin-bar input, .admin-bar select { min-width: 0; width: 100%; }
    .ss { width: 100%; min-width: 0; }
}

/* Contenedor con scroll horizontal para tablas (sobre todo en móvil) */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
@media (max-width: 760px) {
    /* En pantallas estrechas la tabla mantiene un ancho mínimo legible y se desplaza */
    .table-wrap .table { min-width: 560px; }
    .table-wrap .table th, .table-wrap .table td { white-space: nowrap; }
}
