:root {
    --bg: #06090b;
    --panel: #0d1317;
    --panel-hover: #111a1f;
    --sidebar: #080c0f;
    --border: #1a2930;
    --border-soft: #122027;
    --text: #f3f7f8;
    --muted: #7d919b;
    --muted-2: #52646d;
    --cyan: #00d9ff;
    --cyan-soft: rgba(0, 217, 255, .08);
    --cyan-line: rgba(0, 217, 255, .28);
    --green: #4be19a;
    --sidebar-width: 272px;

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
}

body {
    min-height: 100vh;
}

button,
input {
    font: inherit;
}


/* APP */

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
}


/* SIDEBAR */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    height: 100vh;

    display: flex;
    flex-direction: column;

    padding: 28px 18px 20px;

    background:
        linear-gradient(
            180deg,
            rgba(0, 217, 255, .025),
            transparent 28%
        ),
        var(--sidebar);

    border-right: 1px solid var(--border);
}

.brand {
    padding: 0 12px 28px;
    border-bottom: 1px solid var(--border-soft);
}

.brand-logo,
.login-logo {
    font-family: "Courier New", ui-monospace, monospace;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -2px;
    color: #fff;
}

.brand-logo span,
.login-logo span {
    color: var(--cyan);
    text-shadow: 0 0 15px rgba(0, 217, 255, .8);
}

.brand-subtitle,
.login-core {
    margin-top: 4px;
    color: var(--muted);
    font-family: "Courier New", ui-monospace, monospace;
    font-size: 11px;
    letter-spacing: 4px;
}

.nav {
    flex: 1;
    margin-top: 21px;
}

.nav-label {
    margin: 24px 12px 8px;
    color: var(--muted-2);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.nav-item {
    min-height: 42px;

    display: flex;
    align-items: center;
    gap: 12px;

    margin: 3px 0;
    padding: 0 12px;

    border-radius: 7px;

    color: #a8b7bd;
    text-decoration: none;
    font-size: 14px;

    transition: .18s ease;
}

a.nav-item:hover {
    background: var(--panel-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--cyan-soft);
    color: var(--cyan);
    box-shadow: inset 2px 0 0 var(--cyan);
}

.nav-item.disabled {
    color: #56666d;
    cursor: default;
}

.nav-icon {
    width: 20px;
    text-align: center;
    font-family: ui-monospace, monospace;
    font-size: 16px;
}

.sidebar-bottom {
    padding-top: 12px;
    border-top: 1px solid var(--border-soft);
}

.version {
    margin: 18px 12px 0;
    color: #39494f;
    font-size: 10px;
    letter-spacing: 1px;
}


/* MAIN */

.main {
    grid-column: 2;
    min-width: 0;
    min-height: 100vh;
}

.topbar {
    min-height: 96px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;

    padding: 22px 38px;

    border-bottom: 1px solid var(--border);

    background: rgba(6, 9, 11, .94);
}

.eyebrow,
.section-kicker,
.panel-kicker {
    color: var(--cyan);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.7px;
}

.topbar h1 {
    margin: 4px 0 0;
    font-size: 24px;
    font-weight: 600;
}

.user-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-copy {
    display: grid;
    text-align: right;
}

.user-copy strong {
    font-size: 13px;
    font-weight: 600;
}

.user-copy span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

.avatar {
    width: 38px;
    height: 38px;

    display: grid;
    place-items: center;

    border: 1px solid var(--cyan-line);
    border-radius: 50%;

    background: var(--cyan-soft);
    color: var(--cyan);

    font-weight: 700;
}

.logout-button {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
}

.logout-button:hover {
    color: #fff;
}

.content {
    padding: 34px 38px 60px;
}


/* WELCOME */

.welcome {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 30px;

    margin-bottom: 28px;
}

.welcome h2 {
    margin: 8px 0 7px;

    font-size: clamp(26px, 3vw, 38px);
    font-weight: 600;
    letter-spacing: -1.2px;
}

.welcome p {
    max-width: 680px;
    margin: 0;

    color: var(--muted);
    line-height: 1.6;
}

.system-status,
.login-security {
    display: flex;
    align-items: center;
    gap: 8px;

    color: #92a4ac;
    font-size: 12px;
}

.system-status {
    margin-top: 9px;
    white-space: nowrap;
}

.status-dot {
    width: 7px;
    height: 7px;

    border-radius: 50%;

    background: var(--green);

    box-shadow:
        0 0 12px rgba(75, 225, 154, .65);
}


/* METRICS */

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;

    margin-bottom: 18px;
}

.metric-card {
    min-height: 142px;

    padding: 21px;

    background:
        linear-gradient(
            145deg,
            rgba(0, 217, 255, .025),
            transparent 50%
        ),
        var(--panel);

    border: 1px solid var(--border);
    border-radius: 10px;
}

.metric-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.4px;
}

.metric-value {
    margin-top: 17px;

    font-family:
        "Courier New",
        ui-monospace,
        monospace;

    font-size: 30px;
    font-weight: 700;
    letter-spacing: -1px;
}

.metric-note {
    margin-top: 8px;

    color: var(--muted-2);
    font-size: 12px;
}


/* PANELS */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.45fr 1fr;
    gap: 18px;
}

.panel {
    min-width: 0;
    min-height: 310px;

    padding: 22px;

    border: 1px solid var(--border);
    border-radius: 10px;

    background: var(--panel);
}

.panel-wide {
    grid-column: 1 / -1;
    min-height: 185px;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;

    padding-bottom: 18px;

    border-bottom: 1px solid var(--border-soft);
}

.panel h3 {
    margin: 5px 0 0;
    font-size: 17px;
    font-weight: 600;
}

.panel-count {
    color: var(--muted);
    font-size: 11px;
}

.empty-state {
    min-height: 215px;

    display: grid;
    place-items: center;
    align-content: center;

    text-align: center;
}

.empty-symbol {
    width: 42px;
    height: 42px;

    display: grid;
    place-items: center;

    margin-bottom: 13px;

    border: 1px solid var(--cyan-line);
    border-radius: 50%;

    background: var(--cyan-soft);
    color: var(--cyan);
}

.empty-state h4 {
    margin: 0;
    font-size: 15px;
}

.empty-state p {
    max-width: 410px;
    margin: 7px auto 0;

    color: var(--muted);

    font-size: 13px;
    line-height: 1.5;
}

.pipeline {
    margin-top: 7px;
}

.pipeline-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;

    padding: 14px 2px;

    border-bottom: 1px solid var(--border-soft);

    color: #a8b7bd;
    font-size: 13px;
}

.pipeline-row strong {
    color: #fff;
    font-family: ui-monospace, monospace;
}

.panel-footnote {
    margin: 16px 0 0;

    color: var(--muted-2);

    font-size: 11px;
    line-height: 1.5;
}

.empty-activity {
    min-height: 90px;

    display: flex;
    align-items: center;
    gap: 14px;

    color: var(--muted);
    font-size: 13px;
}

.empty-activity > span {
    display: block;

    width: 30px;
    height: 1px;

    background: var(--cyan);

    box-shadow:
        0 0 10px rgba(0, 217, 255, .45);
}


/* LOGIN */

.login-body {
    min-height: 100vh;

    background:
        radial-gradient(
            circle at 20% 40%,
            rgba(0, 217, 255, .07),
            transparent 28%
        ),
        linear-gradient(
            135deg,
            #06090b,
            #080d10
        );
}

.login-grid {
    min-height: 100vh;

    display: grid;
    grid-template-columns: 1.15fr .85fr;
}

.login-brand {
    position: relative;

    display: flex;
    flex-direction: column;
    justify-content: center;

    padding: 8vw;

    overflow: hidden;

    border-right: 1px solid var(--border);
}

.login-brand::after {
    content: "";

    position: absolute;
    inset: 0;

    pointer-events: none;

    opacity: .14;

    background-image:
        linear-gradient(
            rgba(255,255,255,.03) 1px,
            transparent 1px
        ),
        linear-gradient(
            90deg,
            rgba(255,255,255,.03) 1px,
            transparent 1px
        );

    background-size: 34px 34px;
}

.login-logo {
    position: relative;
    z-index: 1;

    font-size: 44px;
}

.login-core {
    position: relative;
    z-index: 1;

    font-size: 12px;
}

.login-brand h1 {
    position: relative;
    z-index: 1;

    margin: 64px 0 18px;

    font-size: clamp(38px, 5vw, 68px);
    line-height: 1.02;
    letter-spacing: -3px;
    font-weight: 500;
}

.login-brand p {
    position: relative;
    z-index: 1;

    color: var(--muted);
}

.login-terminal {
    position: relative;
    z-index: 1;

    display: flex;
    gap: 8px;

    margin-top: 58px;

    color: #61747c;

    font-family:
        "Courier New",
        ui-monospace,
        monospace;

    font-size: 12px;
}

.login-terminal strong,
.login-terminal span {
    color: var(--cyan);
}

.login-panel {
    display: grid;
    place-items: center;

    padding: 40px;
}

.login-box {
    width: min(420px, 100%);
}

.login-box h2 {
    margin: 8px 0;

    font-size: 30px;
    letter-spacing: -1px;
}

.login-intro {
    margin: 0 0 32px;

    color: var(--muted);
    font-size: 14px;
}

.login-box form {
    display: grid;
}

.login-box label {
    margin: 15px 0 7px;

    color: #9fb0b8;
    font-size: 12px;
}

.login-box input {
    width: 100%;
    height: 48px;

    padding: 0 14px;

    outline: none;

    border: 1px solid var(--border);
    border-radius: 7px;

    background: #080d10;
    color: #fff;

    transition: .18s ease;
}

.login-box input:focus {
    border-color: var(--cyan);

    box-shadow:
        0 0 0 3px rgba(0, 217, 255, .06);
}

.primary-button {
    height: 50px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-top: 24px;
    padding: 0 17px;

    border: 1px solid var(--cyan);
    border-radius: 7px;

    background: var(--cyan);
    color: #001014;

    cursor: pointer;

    font-weight: 700;
}

.primary-button:hover {
    filter: brightness(1.08);
}

.login-security {
    margin-top: 22px;
}

.form-error {
    padding: 11px 13px;

    border: 1px solid rgba(255, 89, 89, .3);
    border-radius: 7px;

    background: rgba(255, 89, 89, .06);
    color: #ff9b9b;

    font-size: 12px;
}


/* RESPONSIVE */

@media (max-width: 1100px) {

    :root {
        --sidebar-width: 230px;
    }

    .metric-grid {
        grid-template-columns: repeat(2, 1fr);
    }

}

@media (max-width: 820px) {

    .app-shell {
        display: block;
    }

    .sidebar {
        display: none;
    }

    .main {
        min-height: 100vh;
    }

    .topbar,
    .content {
        padding-left: 22px;
        padding-right: 22px;
    }

    .dashboard-grid,
    .metric-grid,
    .login-grid {
        grid-template-columns: 1fr;
    }

    .login-brand {
        display: none;
    }

    .login-panel {
        min-height: 100vh;
    }

    .welcome {
        display: block;
    }

    .system-status {
        margin-top: 18px;
    }

}

@media (max-width: 540px) {

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

    .user-copy {
        display: none;
    }

    .topbar {
        min-height: 80px;
    }

}

/* ==========================================================
   T-IO BRAND LOCK
   Fuente: identidad corporativa aprobada de t-io.es.
   No modificar sin aprobación expresa.
   ========================================================== */

.brand-logo,
.login-logo {
    font-family: Inter, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 62px;
    font-weight: 500;
    letter-spacing: .04em;
    line-height: 1;
    color: #f5f7f8;
}

.brand-logo .brand-t,
.brand-logo .brand-i,
.brand-logo .brand-o,
.login-logo .brand-t,
.login-logo .brand-i,
.login-logo .brand-o {
    color: #f5f7f8;
    text-shadow: none;
}

.brand-logo .cursor,
.login-logo .cursor {
    color: #67d8ff;
    text-shadow: 0 0 14px rgba(103, 216, 255, .8);
}


/* ==========================================================
   CRM / EMPRESAS
   Extensión del shell visual aprobado de T-IO CORE.
   ========================================================== */

.crm-page-heading {
    align-items: center;
}

.core-action-button {
    min-height: 42px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    padding: 0 16px;

    border: 1px solid var(--cyan);
    border-radius: 7px;

    background: var(--cyan);
    color: #001014;

    font-size: 13px;
    font-weight: 700;
    text-decoration: none;

    white-space: nowrap;
}

.core-action-button strong {
    font-size: 17px;
    line-height: 1;
}

.core-action-button-disabled {
    opacity: .55;
    cursor: default;
}

.crm-list-panel {
    min-height: 320px;
}

.crm-empty-state {
    min-height: 230px;
}

.crm-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.crm-table {
    width: 100%;
    border-collapse: collapse;

    font-size: 13px;
}

.crm-table th {
    padding: 15px 10px;

    border-bottom: 1px solid var(--border-soft);

    color: var(--muted-2);

    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-align: left;
}

.crm-table td {
    padding: 16px 10px;

    border-bottom: 1px solid var(--border-soft);

    color: #a8b7bd;

    vertical-align: middle;
}

.crm-table tbody tr:last-child td {
    border-bottom: 0;
}

.crm-table td strong {
    display: block;

    color: var(--text);

    font-weight: 600;
}

.crm-table td > span:not(.crm-status) {
    display: block;

    margin-top: 4px;

    color: var(--muted-2);
    font-size: 11px;
}

.crm-status {
    display: inline-flex;

    padding: 5px 8px;

    border: 1px solid var(--cyan-line);
    border-radius: 999px;

    background: var(--cyan-soft);
    color: var(--cyan);

    font-size: 10px;
    font-weight: 700;
}


@media (max-width: 820px) {

    .crm-page-heading {
        align-items: flex-start;
    }

    .crm-page-heading .core-action-button {
        margin-top: 18px;
    }

}


/* ==========================================================
   CRM / FORMULARIOS
   Extensión del diseño aprobado.
   ========================================================== */

.core-secondary-button {
    min-height: 42px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0 16px;

    border: 1px solid var(--border);
    border-radius: 7px;

    background: var(--panel);
    color: #a8b7bd;

    font-size: 13px;
    font-weight: 600;
    text-decoration: none;

    transition: .18s ease;
}

.core-secondary-button:hover {
    border-color: var(--cyan-line);
    color: var(--text);
}

.crm-form {
    display: grid;
    gap: 18px;
}

.crm-form-panel {
    min-height: 0;
}

.crm-form-grid {
    display: grid;
    gap: 18px;

    padding-top: 22px;
}

.crm-form-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.crm-field {
    min-width: 0;
}

.crm-field-wide {
    grid-column: 1 / -1;
}

.crm-field label {
    display: block;

    margin-bottom: 8px;

    color: #a8b7bd;

    font-size: 11px;
    font-weight: 700;
    letter-spacing: .4px;
}

.crm-field input,
.crm-field select,
.crm-field textarea {
    width: 100%;

    border: 1px solid var(--border);
    border-radius: 7px;

    background: #080d10;
    color: var(--text);

    font: inherit;
    font-size: 13px;

    outline: none;

    transition: .18s ease;
}

.crm-field input,
.crm-field select {
    min-height: 44px;
    padding: 0 12px;
}

.crm-field textarea {
    min-height: 120px;

    padding: 12px;

    resize: vertical;
}

.crm-field input::placeholder,
.crm-field textarea::placeholder {
    color: var(--muted-2);
}

.crm-field input:focus,
.crm-field select:focus,
.crm-field textarea:focus {
    border-color: var(--cyan-line);

    box-shadow:
        0 0 0 3px rgba(0, 217, 255, .05);
}

.crm-field select {
    cursor: pointer;
}

.crm-field-error {
    margin-top: 7px;

    color: #ff9b9b;

    font-size: 11px;
}

.crm-form-alert {
    padding: 12px 14px;

    border: 1px solid rgba(255, 89, 89, .3);
    border-radius: 7px;

    background: rgba(255, 89, 89, .06);
    color: #ff9b9b;

    font-size: 12px;
}

.crm-form-alert ul,
.crm-field-error ul {
    margin: 0;
    padding-left: 18px;
}

.crm-form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;

    padding-top: 4px;
}

.crm-form-actions .core-action-button {
    cursor: pointer;
}


@media (max-width: 820px) {

    .crm-form-grid-2 {
        grid-template-columns: 1fr;
    }

    .crm-field-wide {
        grid-column: auto;
    }

    .crm-form-actions {
        justify-content: stretch;
    }

    .crm-form-actions > * {
        flex: 1;
    }

}


/* ==========================================================
   CRM / EMPRESAS · ACCIONES
   ========================================================== */

.crm-row-actions {
    display: flex;
    align-items: center;
    gap: 12px;

    white-space: nowrap;
}

.crm-row-action {
    color: var(--cyan);

    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
}

.crm-row-action:hover {
    text-decoration: underline;
}

.crm-row-action-danger {
    color: #ff9b9b;
}

.crm-delete-panel {
    min-height: 0;
}

.crm-delete-warning {
    display: flex;
    align-items: flex-start;
    gap: 16px;

    margin-top: 22px;
    padding: 18px;

    border: 1px solid rgba(255, 89, 89, .22);
    border-radius: 8px;

    background: rgba(255, 89, 89, .045);
}

.crm-delete-symbol {
    width: 38px;
    height: 38px;

    display: grid;
    place-items: center;

    flex: 0 0 auto;

    border: 1px solid rgba(255, 89, 89, .35);
    border-radius: 50%;

    color: #ff9b9b;

    font-weight: 800;
}

.crm-delete-warning h4 {
    margin: 1px 0 6px;

    font-size: 14px;
}

.crm-delete-warning p {
    max-width: 680px;

    margin: 0;

    color: var(--muted);

    font-size: 13px;
    line-height: 1.6;
}

.crm-delete-warning strong {
    color: var(--text);
}

.core-danger-button {
    min-height: 42px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0 16px;

    border: 1px solid rgba(255, 89, 89, .55);
    border-radius: 7px;

    background: rgba(255, 89, 89, .10);
    color: #ff9b9b;

    cursor: pointer;

    font: inherit;
    font-size: 13px;
    font-weight: 700;
}

.core-danger-button:hover {
    background: rgba(255, 89, 89, .16);
}


@media (max-width: 820px) {

    .crm-row-actions {
        gap: 10px;
    }

}
