:root {
    --bg: #0b0b0b;
    --surface: #141414;
    --border: #2a2a2a;
    --text: #f4f4f4;
    --muted: #8a8a8a;
    --accent: #f54e00;
    --accent-hover: #ff6a22;
    --glow: rgba(245, 78, 0, 0.35);
    --header-h: 64px;
    --footer-h: 56px;
}

[data-theme="light"] {
    --bg: #f6f6f4;
    --surface: #ffffff;
    --border: #e4e4e4;
    --text: #111111;
    --muted: #6b6b6b;
    --accent: #f54e00;
    --accent-hover: #d94400;
    --glow: rgba(245, 78, 0, 0.22);
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    letter-spacing: 0.01em;
}

.app-main {
    min-height: calc(100vh - var(--header-h) - var(--footer-h));
}

/* Header / footer */

.app-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.app-footer {
    height: var(--footer-h);
    display: flex;
    align-items: center;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.82rem;
}

.footer-mark,
.footer-ver,
.mono,
.mono-label,
.mono-input {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.footer-ver {
    opacity: 0.7;
}

/* Brand */

.brand-logo {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    text-decoration: none;
    color: inherit;
}

.brand-word {
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
}

.brand-logo-sm .brand-word {
    font-size: 1.35rem;
}

.brand-logo-hero .brand-word {
    font-size: clamp(3.4rem, 9vw, 6.4rem);
}

.brand-agent {
    color: var(--text);
}

.brand-do,
.brand-dot {
    color: var(--accent);
}

.brand-underline {
    display: block;
    height: 3px;
    width: 100%;
    margin-top: 0.28em;
    background: var(--accent);
    transform: scaleX(1);
    transform-origin: left center;
    box-shadow: 0 0 16px var(--glow);
}

.brand-logo-sm .brand-underline {
    height: 2px;
    margin-top: 0.18em;
}

.brand-logo-hero.js-brand-hero:not(.is-ready) .brand-word {
    letter-spacing: 0.28em;
    opacity: 0;
}

.brand-logo-hero.js-brand-hero:not(.is-ready) .brand-underline {
    transform: scaleX(0);
}

.brand-logo-hero.is-animate .brand-word {
    animation: brand-in 0.95s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.brand-logo-hero.is-animate .brand-do,
.brand-logo-hero.is-animate .brand-dot {
    animation: do-glow 1.15s ease 0.28s both;
}

.brand-logo-hero.is-animate .brand-underline {
    animation: underline-draw 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.42s both;
}

@keyframes brand-in {
    from {
        letter-spacing: 0.32em;
        opacity: 0;
    }
    to {
        letter-spacing: -0.03em;
        opacity: 1;
    }
}

@keyframes do-glow {
    0% {
        text-shadow: 0 0 0 transparent;
    }
    45% {
        text-shadow: 0 0 18px var(--glow), 0 0 42px var(--glow);
    }
    100% {
        text-shadow: 0 0 8px var(--glow);
    }
}

@keyframes underline-draw {
    from {
        transform: scaleX(0);
        opacity: 0.2;
    }
    to {
        transform: scaleX(1);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .brand-logo-hero.js-brand-hero:not(.is-ready) .brand-word,
    .brand-logo-hero.js-brand-hero:not(.is-ready) .brand-underline,
    .brand-logo-hero.is-animate .brand-word,
    .brand-logo-hero.is-animate .brand-do,
    .brand-logo-hero.is-animate .brand-dot,
    .brand-logo-hero.is-animate .brand-underline {
        animation: none;
        letter-spacing: -0.03em;
        opacity: 1;
        transform: none;
        text-shadow: none;
    }
}

/* Hero */

.hero {
    padding: 8vh 0 10vh;
}

.hero-logo {
    margin-bottom: 1.6rem;
}

.hero-lead {
    max-width: 34rem;
    font-size: clamp(1.15rem, 2.4vw, 1.45rem);
    font-weight: 500;
    line-height: 1.45;
    margin-bottom: 2rem;
}

.hero-points {
    list-style: none;
    padding: 0;
    margin: 0 0 2.4rem;
    max-width: 36rem;
}

.hero-points li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    color: var(--muted);
    margin-bottom: 0.7rem;
}

.hero-points i {
    color: var(--accent);
    margin-top: 0.15rem;
}

.hero-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* Buttons */

.btn {
    border-radius: 8px;
    font-weight: 500;
}

.btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-accent:hover,
.btn-accent:focus {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

.btn-outline-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline-ghost:hover,
.btn-outline-ghost:focus {
    background: var(--surface);
    border-color: var(--text);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text);
}

.btn-ghost:hover,
.btn-ghost:focus {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.btn-theme {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 8px;
}

.btn-theme:hover {
    border-color: var(--accent);
    color: var(--accent);
}

[data-theme="dark"] .theme-icon-light,
[data-theme="light"] .theme-icon-dark {
    display: none;
}

/* Forms / cards */

.section-narrow {
    padding: 6vh 0 8vh;
}

.page-title {
    font-family: "Space Grotesk", sans-serif;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}

.mono-label {
    color: var(--accent);
    font-size: 0.75rem;
    text-transform: lowercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.4rem;
}

.muted {
    color: var(--muted);
}

.app-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 28rem;
}

.app-form .form-label {
    font-size: 0.85rem;
    color: var(--muted);
}

.app-form .form-control,
.app-form .form-select {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.app-form .form-control:focus,
.app-form .form-select:focus {
    background: var(--bg);
    color: var(--text);
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem var(--glow);
}

.app-form .form-check-input {
    background-color: var(--bg);
    border-color: var(--border);
}

.app-form .form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.app-form .form-check-label {
    color: var(--text);
}

.header-user {
    color: var(--muted);
    font-size: 0.8rem;
}

.form-hint {
    margin-top: 0.45rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.input-secret {
    display: flex;
    gap: 0.4rem;
}

.input-secret .form-control {
    flex: 1;
}

.alert-app {
    max-width: 28rem;
    background: var(--surface);
    border: 1px solid var(--accent);
    color: var(--text);
}

.app-card-wide {
    max-width: none;
}

/* Admin table (clientes) */

.admin-table {
    padding: 0;
    overflow: hidden;
}

.admin-table-head,
.admin-table-row {
    display: grid;
    grid-template-columns: minmax(72px, 0.9fr) minmax(120px, 2fr) minmax(110px, 1.1fr) 72px minmax(140px, 1.2fr);
    gap: 0.75rem;
    align-items: center;
    padding: 0.85rem 1rem;
}

.admin-table-head {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    background: rgba(245, 78, 0, 0.04);
}

.admin-table-row {
    border-bottom: 1px solid var(--border);
}

.admin-table-row:last-child {
    border-bottom: 0;
}

.admin-table-row:hover {
    background: rgba(245, 78, 0, 0.04);
}

.admin-code {
    color: var(--accent);
}

.admin-name {
    font-weight: 500;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    justify-content: flex-end;
}

.admin-actions form {
    margin: 0;
}

.admin-table-operadores .admin-table-head,
.admin-table-operadores .admin-table-row {
    grid-template-columns: minmax(72px, 0.85fr) minmax(100px, 1.2fr) minmax(120px, 1.4fr) minmax(90px, 1fr) 56px minmax(110px, 1fr) minmax(160px, 1.3fr);
}

.btn.text-danger {
    color: #ff6b6b !important;
}

.btn.text-danger:hover {
    color: #ff8787 !important;
    border-color: #ff6b6b;
}

@media (max-width: 768px) {
    .admin-table-head {
        display: none;
    }

    .admin-table-row {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }

    .admin-actions {
        justify-content: flex-start;
        margin-top: 0.35rem;
    }
}

/* Panel hub */

.project-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.project-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.15rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.project-row:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--glow), 0 8px 24px rgba(0, 0, 0, 0.25);
    color: inherit;
}

.project-row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.project-title {
    font-family: "Space Grotesk", sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
}

.project-meta {
    color: var(--muted);
    font-size: 0.8rem;
}

.project-row-date {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

.project-row-arrow {
    color: var(--muted);
}

/* Workspace */

body.page-workspace {
    overflow: hidden;
}

body.page-workspace .app-header .container-xl {
    max-width: none;
    padding-left: 1rem;
    padding-right: 1rem;
}

body.page-workspace .app-main {
    min-height: calc(100vh - var(--header-h));
    height: calc(100vh - var(--header-h));
    display: flex;
    flex-direction: column;
}

.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0.75rem 1rem 1rem;
}

.workspace-top {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.workspace-back {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.85rem;
}

.workspace-back:hover {
    color: var(--accent);
}

.workspace-crumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem 0.55rem;
}

.workspace-crumb strong {
    font-family: "Space Grotesk", sans-serif;
}

.workspace-json {
    letter-spacing: 0.04em;
}

.workspace-flash {
    max-width: none;
    margin-bottom: 0.75rem;
}

.workspace-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(260px, 320px) 1fr;
    gap: 1rem;
}

.workspace-rail {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow: auto;
    padding-right: 0.15rem;
}

.rail-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-rail {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    font-weight: 500;
}

.btn-rail:hover,
.btn-rail.is-active {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 12px var(--glow);
}

.rail-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
}

.dropzone {
    position: relative;
    border: 1.5px dashed var(--accent);
    border-radius: 12px;
    background: rgba(245, 78, 0, 0.06);
    padding: 1.1rem 0.85rem;
    text-align: center;
    cursor: pointer;
    transition: box-shadow 0.15s ease, background 0.15s ease;
    box-shadow: inset 0 0 24px var(--glow);
}

.dropzone:hover,
.dropzone.is-drag {
    background: rgba(245, 78, 0, 0.12);
    box-shadow: 0 0 0 1px var(--accent), 0 0 28px var(--glow);
}

.dropzone i {
    font-size: 1.6rem;
    color: var(--accent);
    text-shadow: 0 0 12px var(--glow);
}

.dropzone p {
    margin: 0.4rem 0 0.25rem;
    font-size: 0.9rem;
}

.dropzone-hint {
    font-size: 0.68rem;
    color: var(--muted);
}

.dropzone-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.margen-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.margen-empty {
    font-size: 0.85rem;
    margin: 0.25rem 0;
}

.margen-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
}

.margen-card-head {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.margen-type {
    color: var(--accent);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.margen-date {
    font-size: 0.7rem;
}

.margen-body {
    margin: 0;
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.margen-link {
    color: var(--text);
    word-break: break-all;
    font-size: 0.85rem;
}

.margen-link:hover {
    color: var(--accent);
}

.margen-file {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.margen-delete {
    margin-top: 0.45rem;
    text-align: right;
}

.workspace-editor {
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(245, 78, 0, 0.08), 0 12px 40px rgba(0, 0, 0, 0.28);
}

.editor-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(245, 78, 0, 0.08), transparent);
}

.editor-clock {
    color: var(--muted);
    font-size: 0.82rem;
}

.status-chip {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    border: 1px solid transparent;
    letter-spacing: 0.02em;
}

.status-chip.status-writing {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent-hover);
    box-shadow: 0 0 16px var(--glow);
    animation: chip-pulse 1.1s ease-in-out infinite;
}

.status-chip.status-saving {
    color: #1a1200;
    background: #ffb020;
    border-color: #ffc857;
    box-shadow: 0 0 18px rgba(255, 176, 32, 0.45);
}

.status-chip.status-saved {
    color: #04140a;
    background: #2dde7a;
    border-color: #6affab;
    box-shadow: 0 0 18px rgba(45, 222, 122, 0.4);
}

@keyframes chip-pulse {
    0%, 100% { box-shadow: 0 0 10px var(--glow); }
    50% { box-shadow: 0 0 22px var(--glow); }
}

@media (prefers-reduced-motion: reduce) {
    .status-chip.status-writing {
        animation: none;
    }
}

.diario-textarea {
    flex: 1;
    min-height: 280px;
    width: 100%;
    border: 0;
    resize: none;
    padding: 1.15rem 1.25rem;
    background: transparent;
    color: var(--text);
    font-family: "IBM Plex Sans", system-ui, sans-serif;
    font-size: 1.02rem;
    line-height: 1.55;
    outline: none;
}

.diario-textarea:focus {
    box-shadow: inset 0 0 0 1px rgba(245, 78, 0, 0.35);
}

.diario-textarea[readonly] {
    opacity: 0.85;
    cursor: default;
}

@media (max-width: 900px) {
    body.page-workspace {
        overflow: auto;
    }

    body.page-workspace .app-main {
        height: auto;
        min-height: calc(100vh - var(--header-h));
    }

    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .workspace-rail {
        max-height: none;
        overflow: visible;
    }

    .diario-textarea {
        min-height: 50vh;
    }
}

/* Bootstrap overrides */

.container-xl {
    max-width: 1100px;
}
