/* =========================================================================
   Listado de clientes v2 · Damos
   Marca: navy #112C3E · azul #009DD5 (extraídos del logotipo oficial)
   ========================================================================= */

:root {
    --brand-navy: #112C3E;
    --brand-blue: #009DD5;
    --brand-blue-strong: #0083B3;

    --bg: #F4F7FA;
    --surface: #FFFFFF;
    --surface-2: #EEF3F7;
    --border: #DCE4EB;
    --text: #112C3E;
    --text-muted: #5B7083;
    --primary: #007AA8;          /* azul con contraste AA (≥4.5:1) sobre blanco */
    --primary-hover: #006E97;
    --primary-contrast: #FFFFFF;
    --focus: #009DD5;
    --link: #0077A3;

    --ok-bg: #E3F6EC; --ok-text: #126B3D;
    --info-bg: #E2F3FA; --info-text: #075B7C;
    --warn-bg: #FFF4DB; --warn-text: #7A5300;
    --err-bg: #FDE7E7; --err-text: #9B1C1C;

    --shadow: 0 1px 2px rgba(17, 44, 62, .06), 0 8px 24px rgba(17, 44, 62, .06);
    --radius: 12px;
    --radius-sm: 8px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0B1A25;
    --surface: #10232F;
    --surface-2: #163040;
    --border: #23404F;
    --text: #E6EEF3;
    --text-muted: #93A9B8;
    --primary: #12A9E0;
    --primary-hover: #3BBBE9;
    --primary-contrast: #062030;
    --focus: #45C2EE;
    --link: #5CC8F0;

    --ok-bg: #0F3324; --ok-text: #7FE0AE;
    --info-bg: #0B3347; --info-text: #8DD6F3;
    --warn-bg: #3A2C08; --warn-text: #F5CF72;
    --err-bg: #3D1414; --err-text: #FFA8A8;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .86em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; word-break: break-all; }
h1, h2 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 750; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
.muted { color: var(--text-muted); }
.small { font-size: .82rem; }
.strong { font-weight: 600; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.eyebrow { margin: 0 0 4px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.req { color: var(--err-text); }

/* ---------- Logo ---------- */
.brand-logo { display: inline-flex; }
.brand-logo img { height: 33px; width: auto; display: block; }
.brand-logo .logo-dark { display: none; }
:root[data-theme="dark"] .brand-logo .logo-light { display: none; }
:root[data-theme="dark"] .brand-logo .logo-dark { display: block; }
.brand-logo-lg img { height: 55px; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 8px 16px;
    font: inherit; font-weight: 600; line-height: 1;
    border-radius: var(--radius-sm); border: 1px solid transparent;
    cursor: pointer; text-decoration: none !important; white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--link); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { background: transparent; color: var(--err-text); border-color: var(--border); }
.btn-danger-ghost:hover { background: var(--err-bg); }
.btn-sm { min-height: 32px; padding: 6px 10px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; }
.inline { display: inline; }

/* ---------- Conmutador de tema ---------- */
.theme-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    height: 36px; padding: 0 10px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 999px;
    font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--primary); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; display: none; }
.theme-toggle svg .fill { fill: currentColor; stroke: none; }
:root[data-theme-pref="light"] .theme-toggle .i-sun,
:root[data-theme-pref="dark"] .theme-toggle .i-moon,
:root[data-theme-pref="system"] .theme-toggle .i-auto,
:root:not([data-theme-pref]) .theme-toggle .i-auto { display: block; }

/* ---------- Barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1440px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none !important; }
.brand-sub { font-size: .8rem; font-weight: 600; color: var(--text-muted); padding-left: 12px; border-left: 1px solid var(--border); white-space: nowrap; }
.mainnav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.mainnav a { padding: 8px 12px; border-radius: 8px; color: var(--text-muted); font-weight: 600; font-size: .9rem; white-space: nowrap; text-decoration: none; }
.mainnav a:hover { background: var(--surface-2); color: var(--text); }
.mainnav a[aria-current="page"] { color: var(--primary); background: var(--info-bg); }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.usermenu { position: relative; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 6px; border-radius: 999px; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--brand-navy); color: #fff; font-weight: 700; font-size: .85rem; }
:root[data-theme="dark"] .avatar { background: var(--brand-blue); color: #062030; }
.usermenu-name { font-weight: 600; font-size: .9rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu-panel {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 12px; display: grid; gap: 8px;
}
.usermenu-panel a, .usermenu-panel .linklike { padding: 6px 4px; text-align: left; }
.usermenu-meta { margin: 0 0 4px; font-size: .82rem; color: var(--text-muted); word-break: break-all; }
.badge { display: inline-block; margin-top: 6px; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--info-bg); color: var(--info-text); }

/* ---------- Contenido ---------- */
.container { max-width: 1440px; margin: 0 auto; padding: 24px 20px 40px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead-actions { display: flex; gap: 8px; }
.count { display: inline-block; vertical-align: middle; margin-left: 6px; font-size: .9rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a { padding: 10px 14px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--brand-blue); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.search { position: relative; flex: 1; max-width: 420px; }
.search svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--text-muted); stroke-width: 2; stroke-linecap: round; }
.search input[type="search"] { padding-left: 40px; }

/* ---------- Alertas y chips ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-weight: 500; font-size: .92rem; }
.alert-success { background: var(--ok-bg); color: var(--ok-text); }
.alert-info { background: var(--info-bg); color: var(--info-text); }
.alert-warning { background: var(--warn-bg); color: var(--warn-text); }
.alert-error { background: var(--err-bg); color: var(--err-text); }
.chip { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); white-space: nowrap; }
.chip-ok { background: var(--ok-bg); color: var(--ok-text); }
.chip-info { background: var(--info-bg); color: var(--info-text); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.table thead th { position: sticky; top: 0; background: var(--surface-2); font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; z-index: 1; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--brand-blue) 6%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.truncate { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table-compact th, .table-compact td { padding: 6px 10px; }
.sort-btn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.sort-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sort-btn::after { content: "↕"; opacity: .35; font-size: .9em; }
th[aria-sort="ascending"] .sort-btn::after { content: "↑"; opacity: 1; color: var(--primary); }
th[aria-sort="descending"] .sort-btn::after { content: "↓"; opacity: 1; color: var(--primary); }

.servers { padding: 0; margin-bottom: 16px; }
.servers > summary { padding: 14px 16px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.servers > *:not(summary) { margin-left: 16px; margin-right: 16px; }
.servers .table-wrap { margin: 0; }
.ip-updater { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding-bottom: 16px; }

/* ---------- Formularios ---------- */
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: .88rem; }
input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="date"], input[type="search"], input:not([type]), select {
    width: 100%; min-height: 42px; padding: 9px 12px;
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent); }
input::placeholder { color: var(--text-muted); opacity: .8; }
.has-error input, .has-error select { border-color: var(--err-text); }
.field-error { margin: 0; font-size: .8rem; color: var(--err-text); font-weight: 600; }
.help { margin: 0; font-size: .8rem; color: var(--text-muted); }
.input-group { display: flex; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-addon { flex: none; padding: 0 12px; font: inherit; font-size: .8rem; font-weight: 600; color: var(--link); background: var(--surface-2); border: 1px solid var(--border); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; cursor: pointer; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.switch input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px 22px; padding: 22px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border); padding-top: 16px; }

/* ---------- Modal ---------- */
.modal { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow); width: min(520px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(6, 20, 30, .55); }
.modal-body { padding: 22px; display: grid; gap: 10px; }
.creds { display: grid; grid-template-columns: max-content 1fr; gap: 10px 14px; margin: 6px 0; align-items: center; }
.creds dt { font-size: .82rem; font-weight: 600; color: var(--text-muted); }
.creds dd { margin: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.modal-actions { display: flex; justify-content: flex-end; }

.empty-state { padding: 40px; text-align: center; }

/* ---------- Pie ---------- */
.footer { max-width: 1440px; margin: 0 auto; padding: 16px 20px 28px; display: flex; justify-content: space-between; gap: 10px; color: var(--text-muted); font-size: .8rem; flex-wrap: wrap; }

/* =========================================================================
   Pantalla de login
   ========================================================================= */
body.auth { background: var(--bg); }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-art {
    position: relative; overflow: hidden;
    background: var(--brand-navy);
    background-image: radial-gradient(circle at 85% 15%, rgba(0, 157, 213, .35), transparent 45%),
                      radial-gradient(circle at 10% 90%, rgba(0, 157, 213, .22), transparent 40%);
    color: #fff; display: flex; align-items: flex-end; padding: 56px;
}
.auth-art .pixels { position: absolute; inset: 0; pointer-events: none; }
.auth-art .pixels span { position: absolute; background: var(--brand-blue); border-radius: 4px; opacity: .9; }
/* Composición inspirada en los "píxeles" del isotipo */
.auth-art .pixels span:nth-child(1) { width: 120px; height: 120px; left: 14%; top: 18%; }
.auth-art .pixels span:nth-child(2) { width: 120px; height: 120px; left: calc(14% - 120px); top: calc(18% + 120px); }
.auth-art .pixels span:nth-child(3) { width: 60px; height: 60px; left: calc(14% + 180px); top: calc(18% - 60px); opacity: .55; }
.auth-art .pixels span:nth-child(4) { width: 36px; height: 36px; right: 18%; top: 44%; opacity: .7; }
.auth-art .pixels span:nth-child(5) { width: 220px; height: 220px; right: -60px; bottom: -60px; opacity: .14; }
.auth-art .pixels span:nth-child(6) { width: 18px; height: 18px; right: 30%; top: 24%; opacity: .5; }
.auth-art-copy { position: relative; max-width: 460px; }
.auth-art .eyebrow { color: rgba(255, 255, 255, .7); }
.auth-art-title { font-size: clamp(1.6rem, 2.6vw, 2.3rem); font-weight: 750; line-height: 1.15; letter-spacing: -.02em; margin: 0; }

.auth-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; position: relative; }
.auth-top { position: absolute; top: 20px; right: 20px; }
.auth-card { width: 100%; max-width: 400px; display: grid; gap: 16px; }
.auth-card .brand-logo { margin-bottom: 12px; }
.auth-card h1 { font-size: 1.7rem; }
.auth-card > .muted { margin: -8px 0 4px; }
.fineprint { margin: 0; font-size: .8rem; color: var(--text-muted); text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-art { display: none; }
    .brand-sub { display: none; }
}
@media (max-width: 720px) {
    .topbar-inner { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
    .mainnav { order: 3; width: 100%; flex: none; }
    .theme-label, .usermenu-name { display: none; }
    .container { padding: 18px 14px 32px; }
    h1 { font-size: 1.35rem; }
    .search { max-width: none; }
    .creds { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* =========================================================================
   Identidad visual Damos (kit: ~/Documents/Sites/damos/docs/identidad-visual), 16-nov-2026
   Letra Jost servida desde el panel (la CSP solo admite fuentes propias), tinta de marca AA y selector de paneles.
   ========================================================================= */
@font-face { font-family: "Jost"; src: url("../fonts/jost-latin-var.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
:root { --font: "Jost", "Futura", "Century Gothic", "Avenir Next", "Segoe UI", system-ui, sans-serif; --primary: #00729F; --primary-hover: #005F85; --link: #00729F; }
.apps { position: relative; }
.apps summary { list-style: none; cursor: pointer; padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; color: var(--text); white-space: nowrap; }
.apps summary::-webkit-details-marker { display: none; }
.apps[open] summary, .apps summary:hover { background: var(--surface-2); }
.apps-menu { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; width: min(300px, calc(100vw - 32px)); display: grid; gap: 2px; z-index: 40; }
.apps-menu a { display: grid; gap: 2px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); font-weight: 600; text-decoration: none; }
.apps-menu a:hover { background: var(--surface-2); text-decoration: none; }
.apps-menu a small { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.apps-menu a[aria-current] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--focus); }
/* Piso de 12 px (kit): insignias, encabezados de tabla y etiquetas que estaban entre .7 y .74rem */
.badge, .table thead th { font-size: 12px; }

/* ---------- Estados y vigencia de proyectos (v2.1) ---------- */
.chip-warn { background: var(--warn-bg); color: var(--warn-text); }
.tab-count { display: inline-block; margin-left: 4px; font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-muted); }
.tabs a[aria-selected="true"] .tab-count { background: var(--info-bg); color: var(--info-text); }
.bulkbar { display: inline-flex; align-items: center; gap: 8px; }
.table th.check, .table td.check { width: 34px; padding-right: 0; }
.table td.check input, .table th.check input { width: 16px; height: 16px; }
.row-off td { opacity: .78; }
.actions .btn-row { margin-top: 0; flex-wrap: nowrap; justify-content: flex-end; }
.help code, .servers code { font-size: 12px; }
.help code { white-space: nowrap; }
