:root {
    --bg: #f3f5f7;
    --surface: #ffffff;
    --surface-soft: #f8fafb;
    --text: #17202a;
    --text-soft: #6b7280;
    --line: #e5e7eb;
    --accent: #1f6f5f;
    --accent-hover: #185b4f;
    --accent-soft: #e9f5f1;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --shadow: 0 24px 60px rgba(23, 32, 42, 0.12);
    --radius-xl: 28px;
    --radius-lg: 18px;
    --radius-md: 12px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    color: var(--text);
    background: var(--bg);
}

button,
input {
    font: inherit;
}

/* =========================================================
   LOGIN
   ========================================================= */

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px;
    background:
        radial-gradient(
            circle at 15% 20%,
            rgba(31, 111, 95, 0.10),
            transparent 34%
        ),
        radial-gradient(
            circle at 85% 80%,
            rgba(23, 32, 42, 0.06),
            transparent 30%
        ),
        var(--bg);
}

.login-shell {
    width: min(1120px, 100%);
    min-height: 680px;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(420px, 0.95fr);
    background: var(--surface);
    border: 1px solid rgba(229, 231, 235, 0.9);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.login-brand-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 56px;
    color: #ffffff;
    background:
        linear-gradient(
            145deg,
            rgba(255, 255, 255, 0.04),
            transparent 55%
        ),
        #173f38;
}

.login-brand-panel::before,
.login-brand-panel::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    pointer-events: none;
}

.login-brand-panel::before {
    width: 260px;
    height: 260px;
    top: -90px;
    right: -80px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.login-brand-panel::after {
    width: 150px;
    height: 150px;
    right: 70px;
    bottom: 60px;
    background: rgba(255, 255, 255, 0.035);
}

.brand-badge {
    position: relative;
    z-index: 1;
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.brand-content {
    position: relative;
    z-index: 1;
    max-width: 480px;
}

.brand-eyebrow {
    display: inline-block;
    margin-bottom: 18px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.16em;
    opacity: 0.72;
}

.brand-content h1 {
    margin: 0 0 22px;
    font-size: clamp(42px, 5vw, 66px);
    line-height: 0.98;
    letter-spacing: -0.045em;
    font-weight: 720;
}

.brand-content p {
    max-width: 420px;
    margin: 0;
    color: rgba(255, 255, 255, 0.72);
    font-size: 18px;
    line-height: 1.65;
}

.brand-footer {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.72);
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #69d4a7;
    box-shadow: 0 0 0 6px rgba(105, 212, 167, 0.12);
}

.login-form-panel {
    display: grid;
    place-items: center;
    padding: 56px;
    background: var(--surface);
}

.login-card {
    width: min(410px, 100%);
}

.login-header {
    margin-bottom: 34px;
}

.login-kicker {
    display: inline-block;
    margin-bottom: 10px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-header h2 {
    margin: 0 0 10px;
    font-size: 38px;
    line-height: 1.1;
    letter-spacing: -0.035em;
}

.login-header p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.6;
}

.alert {
    margin-bottom: 22px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
}

.alert-error {
    color: var(--danger);
    background: var(--danger-bg);
    border: 1px solid #fecdca;
}

.login-form {
    display: grid;
    gap: 22px;
}

.form-group {
    display: grid;
    gap: 9px;
}

.form-group label {
    font-size: 14px;
    font-weight: 650;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-group input {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    color: var(--text);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    outline: none;
    transition:
        border-color 160ms ease,
        box-shadow 160ms ease,
        background 160ms ease;
}

.form-group input::placeholder {
    color: #9ca3af;
}

.form-group input:focus {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(31, 111, 95, 0.10);
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 52px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    width: 36px;
    height: 36px;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 10px;
    color: var(--text-soft);
    background: transparent;
    cursor: pointer;
}

.password-toggle:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.primary-button {
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 4px;
    padding: 0 20px;
    color: #ffffff;
    background: var(--accent);
    border: 0;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(31, 111, 95, 0.22);
    transition:
        transform 160ms ease,
        background 160ms ease,
        box-shadow 160ms ease;
}

.primary-button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(31, 111, 95, 0.26);
}

.primary-button:active {
    transform: translateY(0);
}

.primary-button svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.login-card-footer {
    display: flex;
    justify-content: center;
    gap: 9px;
    margin-top: 28px;
    color: var(--text-soft);
    font-size: 13px;
}

.separator {
    color: #c7cbd1;
}

/* =========================================================
   ADMIN PANEL
   ========================================================= */

.admin-page {
    min-height: 100vh;
    background: #f4f6f8;
}

.admin-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 28px 22px;
    color: #ffffff;
    background: #173f38;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 8px 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand .brand-badge {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    font-size: 15px;
}

.sidebar-brand div:last-child {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.sidebar-brand strong {
    font-size: 15px;
}

.sidebar-brand span {
    color: rgba(255, 255, 255, 0.58);
    font-size: 12px;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
    margin-top: 28px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 13px;
    min-height: 46px;
    padding: 0 14px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 12px;
    transition:
        background 160ms ease,
        color 160ms ease,
        transform 160ms ease;
}

.nav-item:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(2px);
}

.nav-item.active {
    color: #173f38;
    background: #ffffff;
    font-weight: 700;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

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

.user-avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: #173f38;
    background: #ffffff;
    border-radius: 13px;
    font-weight: 800;
}

.user-info {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.user-info strong {
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-info span {
    overflow: hidden;
    color: rgba(255, 255, 255, 0.55);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-link {
    display: inline-block;
    margin-top: 18px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 13px;
    text-decoration: none;
}

.logout-link:hover {
    color: #ffffff;
}

.admin-content {
    min-width: 0;
    padding: 42px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    gap: 32px;
    align-items: flex-start;
    margin-bottom: 34px;
}

.page-eyebrow {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.admin-header h1 {
    margin: 0 0 8px;
    font-size: 38px;
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.admin-header p {
    margin: 0;
    color: var(--text-soft);
}

.server-status {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 270px;
    padding: 15px 18px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 16px;
}

.server-status div {
    display: grid;
    gap: 3px;
}

.server-status strong {
    font-size: 13px;
}

.server-status span:last-child {
    color: var(--text-soft);
    font-size: 12px;
}

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

.stat-card,
.panel-card {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(23, 32, 42, 0.04);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 144px;
    padding: 22px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 15px;
}

.stat-icon svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.stat-content {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.stat-content span {
    color: var(--text-soft);
    font-size: 13px;
}

.stat-content strong {
    font-size: 30px;
    letter-spacing: -0.04em;
}

.stat-content small {
    color: #9ca3af;
    font-size: 11px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 18px;
    margin-top: 18px;
}

.panel-card {
    padding: 24px;
}

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

.panel-header h2 {
    margin: 0 0 5px;
    font-size: 19px;
}

.panel-header p {
    margin: 0;
    color: var(--text-soft);
    font-size: 13px;
}

.quick-actions {
    display: grid;
    gap: 12px;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px;
    color: var(--text);
    text-decoration: none;
    background: var(--surface-soft);
    border: 1px solid transparent;
    border-radius: 14px;
    transition:
        border-color 160ms ease,
        background 160ms ease,
        transform 160ms ease;
}

.quick-action:hover {
    background: #ffffff;
    border-color: var(--accent);
    transform: translateY(-1px);
}

.quick-action-icon {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: #ffffff;
    background: var(--accent);
    border-radius: 11px;
    font-size: 22px;
    font-weight: 400;
}

.quick-action div {
    display: grid;
    gap: 3px;
}

.quick-action strong {
    font-size: 14px;
}

.quick-action small {
    color: var(--text-soft);
    font-size: 12px;
}

.system-list {
    display: grid;
}

.system-row {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 15px 0;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}

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

.system-row span {
    color: var(--text-soft);
}

.status-success {
    color: var(--accent);
}

.recent-panel {
    margin-top: 18px;
}

.secondary-link {
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.secondary-link:hover {
    text-decoration: underline;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 240px;
    padding: 40px;
    text-align: center;
    background: var(--surface-soft);
    border-radius: 15px;
}

.empty-icon {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    margin-bottom: 15px;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 16px;
}

.empty-icon svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.empty-state strong {
    margin-bottom: 7px;
}

.empty-state p {
    max-width: 430px;
    margin: 0;
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.6;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1180px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .login-shell {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .login-brand-panel {
        min-height: 300px;
        padding: 40px;
    }

    .brand-content h1 {
        font-size: 44px;
    }

    .brand-footer {
        margin-top: 40px;
    }

    .login-form-panel {
        padding: 44px 32px;
    }

    .admin-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .sidebar-nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .sidebar-footer {
        margin-top: 24px;
    }

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

@media (max-width: 680px) {
    .admin-content {
        padding: 24px 18px;
    }

    .admin-header {
        flex-direction: column;
    }

    .server-status {
        width: 100%;
        min-width: 0;
    }

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

    .sidebar-nav {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .login-page {
        padding: 14px;
    }

    .login-shell {
        border-radius: 20px;
    }

    .login-brand-panel {
        padding: 30px;
    }

    .login-brand-panel::before,
    .login-brand-panel::after {
        display: none;
    }

    .brand-content h1 {
        font-size: 38px;
    }

    .brand-content p {
        font-size: 16px;
    }

    .login-form-panel {
        padding: 36px 24px;
    }

    .login-header h2 {
        font-size: 32px;
    }
}
.alert-success {
    color: #166534;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.page-action-button {
    width: auto;
    min-width: 150px;
    padding: 0 20px;
    text-decoration: none;
}

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

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 16px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.admin-table th {
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.admin-table td {
    font-size: 13px;
}

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

.admin-table tbody tr:hover {
    background: var(--surface-soft);
}

.table-user {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 220px;
}

.table-avatar {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.table-user > div:last-child {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.table-user strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-user span {
    overflow: hidden;
    color: var(--text-soft);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-admin {
    color: #7c3aed;
    background: #f3e8ff;
}

.badge-user {
    color: #1d4ed8;
    background: #dbeafe;
}

.badge-active {
    color: #166534;
    background: #dcfce7;
}

.badge-inactive {
    color: #991b1b;
    background: #fee2e2;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.table-actions form {
    margin: 0;
}

.table-button {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 12px;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
}

.table-button:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
}

@media (max-width: 900px) {
    .admin-header .page-action-button {
        width: 100%;
    }

    .admin-table {
        min-width: 900px;
    }
}

.form-panel {
    max-width: 920px;
}

.admin-form {
    display: grid;
    gap: 26px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.form-group-wide {
    grid-column: 1 / -1;
}

.admin-form select {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    color: var(--text);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    outline: none;
}

.admin-form select:focus {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(31, 111, 95, 0.10);
}

.form-help {
    padding: 16px 18px;
    color: var(--text-soft);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.7;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 6px;
}

.secondary-button {
    min-height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    color: var(--text);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    font-weight: 700;
    text-decoration: none;
}

.secondary-button:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
}

@media (max-width: 680px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group-wide {
        grid-column: auto;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .secondary-button,
    .form-actions .primary-button {
        width: 100%;
    }
}

/* Rol gestor */
.badge-manager {
    color: #9a6700;
    background: #fff4ce;
}

.table-button-danger {
    color: #b42318;
    border-color: #f1c0bc;
    background: #fff7f6;
}

.table-button-danger:hover {
    color: #8f1b13;
    border-color: #e99d96;
    background: #ffefed;
}

/* Agrupación de licencias por producto */
.license-product-groups {
    display: grid;
    gap: 24px;
}

.license-product-card {
    overflow: hidden;
}

.license-product-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 22px 24px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
}

.license-product-header h2 {
    margin: 4px 0 0;
    font-size: 20px;
}

.license-product-count {
    flex: 0 0 auto;
    padding: 7px 11px;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}

@media (max-width: 680px) {
    .license-product-header {
        align-items: flex-start;
        flex-direction: column;
    }
}
