/* TerraPrims — sistema visual compartido */
:root {
    color-scheme: dark;
    --tp-bg: #101b2b;
    --tp-surface: #17263a;
    --tp-surface-2: #1d3045;
    --tp-text: #f1f6f8;
    --tp-muted: #aab8c9;
    --tp-accent: #75c8bd;
    --tp-accent-strong: #3caa9b;
    --tp-border: rgba(117,200,189,.22);
    --tp-shadow: 0 15px 45px rgba(0,0,0,.18);
}

:root[data-theme="light"] {
    color-scheme: light;
    --tp-bg: #f3f7fb;
    --tp-surface: #ffffff;
    --tp-surface-2: #eaf1f7;
    --tp-text: #172b3d;
    --tp-muted: #5e7184;
    --tp-accent: #087f78;
    --tp-accent-strong: #06665f;
    --tp-border: #d7e2eb;
    --tp-shadow: 0 12px 32px rgba(25,55,80,.08);
}

/* Control de tema */
.tp-theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 0 0 auto;
    min-height: 36px;
    margin-left: 12px;
    padding: 7px 11px;
    border: 1px solid var(--tp-border);
    border-radius: 9px;
    background: var(--tp-surface-2);
    color: var(--tp-text);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease;
}
.tp-theme-toggle:hover {
    border-color: var(--tp-accent);
}
.tp-theme-toggle:focus-visible {
    outline: 3px solid var(--tp-accent);
    outline-offset: 3px;
}

/* Base común */
:root[data-theme="light"] body {
    background: var(--tp-bg);
    color: var(--tp-text);
}

/* Accounts */
:root[data-theme="light"] .site-header,
:root[data-theme="light"] .site-footer {
    background: var(--tp-surface);
    border-color: var(--tp-border);
    color: var(--tp-muted);
}
:root[data-theme="light"] .brand,
:root[data-theme="light"] .tp-auth-card,
:root[data-theme="light"] .tp-profile-card,
:root[data-theme="light"] .tp-profile-actions,
:root[data-theme="light"] .tp-legal-document {
    color: var(--tp-text);
}
:root[data-theme="light"] .tp-auth-card,
:root[data-theme="light"] .tp-profile-card,
:root[data-theme="light"] .tp-profile-actions {
    background: var(--tp-surface);
    border-color: var(--tp-border);
    box-shadow: var(--tp-shadow);
}
:root[data-theme="light"] .tp-auth-card h1,
:root[data-theme="light"] .tp-profile-welcome h1,
:root[data-theme="light"] .tp-profile-card-heading h2,
:root[data-theme="light"] .tp-profile-actions h2,
:root[data-theme="light"] .tp-profile-field strong,
:root[data-theme="light"] .tp-profile-field code,
:root[data-theme="light"] .tp-inventory-heading h2,
:root[data-theme="light"] .tp-inventory-folder,
:root[data-theme="light"] .tp-inventory-item-content strong,
:root[data-theme="light"] .tp-groups-title h2,
:root[data-theme="light"] .tp-groups-role-heading strong,
:root[data-theme="light"] .tp-groups-notice h4 {
    color: var(--tp-text);
}
:root[data-theme="light"] .tp-auth-card .tp-auth-description,
:root[data-theme="light"] .tp-profile-welcome p,
:root[data-theme="light"] .tp-profile-actions p,
:root[data-theme="light"] .tp-profile-card-heading p,
:root[data-theme="light"] .tp-profile-field span,
:root[data-theme="light"] .tp-profile-note,
:root[data-theme="light"] .tp-inventory-heading p,
:root[data-theme="light"] .tp-inventory-summary,
:root[data-theme="light"] .tp-inventory-item-content p,
:root[data-theme="light"] .tp-inventory-item-meta,
:root[data-theme="light"] .tp-inventory-empty,
:root[data-theme="light"] .tp-groups-nav-item small,
:root[data-theme="light"] .tp-groups-role-heading span,
:root[data-theme="light"] .tp-groups-role small,
:root[data-theme="light"] .tp-groups-notice-meta,
:root[data-theme="light"] .tp-groups-role p,
:root[data-theme="light"] .tp-groups-notice p,
:root[data-theme="light"] .tp-groups-table th,
:root[data-theme="light"] .tp-legal-section p {
    color: var(--tp-muted);
}
:root[data-theme="light"] .tp-auth-card label,
:root[data-theme="light"] .tp-groups-table td {
    color: var(--tp-text);
}
:root[data-theme="light"] .tp-auth-card input {
    background: #fff;
    color: #172b3d;
    border-color: #bdcbd8;
}
:root[data-theme="light"] .tp-auth-card input::placeholder {
    color: #718397;
}
:root[data-theme="light"] .tp-auth-brand,
:root[data-theme="light"] .tp-auth-back,
:root[data-theme="light"] .tp-auth-languages a,
:root[data-theme="light"] .tp-dashboard-header-right a,
:root[data-theme="light"] .tp-dashboard-footer a,
:root[data-theme="light"] .tp-inventory-back,
:root[data-theme="light"] .tp-legal-links a,
:root[data-theme="light"] .tp-legal-back {
    color: var(--tp-accent-strong);
}
:root[data-theme="light"] .tp-dashboard-header {
    border-color: var(--tp-border);
}
:root[data-theme="light"] .tp-inventory-folder,
:root[data-theme="light"] .tp-inventory-item,
:root[data-theme="light"] .tp-groups-nav-item,
:root[data-theme="light"] .tp-groups-role,
:root[data-theme="light"] .tp-groups-notice {
    background: var(--tp-surface);
    border-color: var(--tp-border);
}
:root[data-theme="light"] .tp-groups-charter {
    background: #eaf5f3;
    color: #315c59;
}
:root[data-theme="light"] .tp-groups-section h3,
:root[data-theme="light"] .tp-inventory-section h3,
:root[data-theme="light"] .tp-profile-eyebrow,
:root[data-theme="light"] .tp-legal-section h2 {
    color: var(--tp-accent-strong);
}
:root[data-theme="light"] .tp-groups-section h3 span {
    background: #e0f2ef;
    color: #17645e;
}
:root[data-theme="light"] .tp-legal-banner {
    background: #edf5f8;
    border-color: #c8dce5;
    color: var(--tp-text);
}
:root[data-theme="light"] .tp-legal-banner-copy p {
    color: var(--tp-muted);
}
:root[data-theme="light"] .tp-logout-button {
    color: var(--tp-accent-strong);
    border-color: var(--tp-border);
}
:root[data-theme="light"] .tp-logout-button:hover {
    background: #e4f3f0;
}
:root[data-theme="light"] .tp-profile-card-heading,
:root[data-theme="light"] .tp-inventory-heading,
:root[data-theme="light"] .tp-groups-table th,
:root[data-theme="light"] .tp-groups-table td {
    border-color: var(--tp-border);
}

/* Maps */
:root[data-theme="dark"] body {
    background: var(--tp-bg);
    color: var(--tp-text);
}
:root[data-theme="dark"] header,
:root[data-theme="dark"] footer {
    background: var(--tp-surface);
    border-color: var(--tp-border);
    color: var(--tp-muted);
}
:root[data-theme="dark"] .brand,
:root[data-theme="dark"] h1,
:root[data-theme="dark"] .map-heading h2,
:root[data-theme="dark"] .side-title,
:root[data-theme="dark"] .meta-value {
    color: var(--tp-text);
}
:root[data-theme="dark"] .header-right,
:root[data-theme="dark"] .subtitle,
:root[data-theme="dark"] .status,
:root[data-theme="dark"] .map-heading p,
:root[data-theme="dark"] .meta-label,
:root[data-theme="dark"] .side-note {
    color: var(--tp-muted);
}
:root[data-theme="dark"] .map-card,
:root[data-theme="dark"] .side-card {
    background: var(--tp-surface);
    border-color: var(--tp-border);
    box-shadow: var(--tp-shadow);
}
:root[data-theme="dark"] .map-heading,
:root[data-theme="dark"] .map-tools,
:root[data-theme="dark"] .region-meta,
:root[data-theme="dark"] .share-block {
    border-color: var(--tp-border);
    background: var(--tp-surface);
}
:root[data-theme="dark"] .map-tools input,
:root[data-theme="dark"] .share-row input {
    background: #102131;
    color: var(--tp-text);
    border-color: #40586b;
}
:root[data-theme="dark"] .map-tools .tool-group button,
:root[data-theme="dark"] .share-row button,
:root[data-theme="dark"] .tool {
    background: #20364a;
    color: var(--tp-text);
    border-color: #40586b;
}
:root[data-theme="dark"] .map-tools .tool-group button:hover,
:root[data-theme="dark"] .share-row button:hover,
:root[data-theme="dark"] .tool:hover {
    background: #29465c;
}
:root[data-theme="dark"] .map-viewport {
    background-color: #142638;
}
:root[data-theme="dark"] .free-cell {
    background: #1b3044;
    color: #c1d0dc;
    border-color: #526b80;
}
:root[data-theme="dark"] .free-cell strong {
    color: #e7f0f5;
}
:root[data-theme="dark"] .free-cell:hover,
:root[data-theme="dark"] .free-cell:focus-visible {
    background: #29465c;
}
:root[data-theme="dark"] .region-label,
:root[data-theme="dark"] .map-hint {
    background: rgba(16,27,43,.92);
    color: #f1f6f8;
    border-color: #536a7e;
}
:root[data-theme="dark"] .cookie-banner,
:root[data-theme="dark"] .dialog,
:root[data-theme="dark"] .dialog-backdrop > div {
    background: var(--tp-surface);
    color: var(--tp-text);
    border-color: var(--tp-border);
}
:root[data-theme="dark"] footer a,
:root[data-theme="dark"] footer button {
    color: var(--tp-accent);
}
:root[data-theme="light"] .map-card,
:root[data-theme="light"] .side-card {
    background: var(--tp-surface);
    border-color: var(--tp-border);
}
:root[data-theme="light"] .map-heading,
:root[data-theme="light"] .map-tools,
:root[data-theme="light"] .region-meta {
    background: var(--tp-surface);
    border-color: var(--tp-border);
}
:root[data-theme="light"] .cookie-banner {
    background: var(--tp-surface);
    color: var(--tp-text);
    border-color: var(--tp-border);
}
@media (max-width: 620px) {
    .tp-theme-toggle {
        margin-left: 5px;
        padding: 7px 9px;
    }
}

/* Accounts: mejorar contraste del estado en tema claro */
:root[data-theme="light"] .status {
    color: var(--tp-text);
}
