:root {
    --bg: #f4f5f2;
    --surface: #ffffff;
    --surface-alt: #eef3ef;
    --text: #17211c;
    --muted: #607066;
    --border: #d8ded8;
    --accent: #0f766e;
    --accent-strong: #0b5f59;
    --warning: #b7791f;
    --danger: #b42318;
    --danger-bg: #fff1f0;
    --success-bg: #e9f7ee;
    --success-text: #166534;
    --shadow: 0 18px 42px rgba(23, 33, 28, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
    font: inherit;
}

button {
    border: 0;
}

h1,
h2,
p {
    margin: 0;
}

h1:focus {
    outline: none;
}

.dashboard-page {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 28px;
}

.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 100vh;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(246, 249, 244, 0.96), rgba(235, 242, 232, 0.96)),
        var(--bg);
}

.login-page .alert-message,
.login-page .notice-message {
    width: min(430px, 100%);
    margin-top: 0;
}

.workspace-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.eyebrow {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.workspace-header h1 {
    margin-top: 4px;
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1;
    letter-spacing: 0;
}

.session-strip {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    color: var(--muted);
    font-size: 0.9rem;
}

.session-strip span,
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    white-space: nowrap;
}

.login-panel {
    margin-top: 24px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.login-card {
    position: relative;
    overflow: hidden;
    width: min(430px, 100%);
    padding: 34px 30px 30px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: var(--accent);
}

.login-brand {
    display: grid;
    gap: 16px;
    justify-items: center;
    margin-bottom: 28px;
    text-align: center;
}

.login-brand img {
    width: min(280px, 100%);
    height: auto;
    display: block;
}

.login-brand .login-company-logo {
    width: auto;
    max-width: min(280px, 100%);
    height: auto;
    max-height: 120px;
    object-fit: contain;
}

.login-brand h1 {
    font-size: 1.75rem;
    line-height: 1.05;
    font-weight: 900;
}

.login-powered {
    display: grid;
    justify-items: center;
    gap: 5px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-align: center;
}

.login-powered img {
    display: block;
    width: auto;
    max-width: 150px;
    height: auto;
    max-height: 58px;
    object-fit: contain;
}

.login-form {
    display: grid;
    gap: 16px;
}

.login-form .actions,
.login-form .primary-button {
    width: 100%;
}

.form-grid {
    display: grid;
    grid-template-columns: minmax(240px, 1.4fr) repeat(3, minmax(170px, 1fr)) auto;
    gap: 16px;
    align-items: end;
}

.field {
    display: grid;
    gap: 7px;
}

.field label,
.muted-label,
.metric-card span,
.section-heading span {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
}

.form-input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    color: var(--text);
    background: #fbfcfb;
    border: 1px solid var(--border);
    border-radius: 7px;
    outline: none;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.password-control {
    position: relative;
}

.password-control .form-input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    color: var(--muted);
    background: transparent;
    border-radius: 7px;
    cursor: pointer;
    transform: translateY(-50%);
}

.password-toggle:hover,
.password-toggle:focus {
    color: var(--accent-strong);
    background: #eef5f0;
    outline: none;
}

.password-toggle svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentcolor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.validation-message {
    color: var(--danger);
    font-size: 0.82rem;
}

.actions {
    display: flex;
}

.primary-button,
.secondary-button,
.ghost-button {
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 7px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 120ms ease, background-color 120ms ease, color 120ms ease;
}

.primary-button {
    color: #ffffff;
    background: var(--accent);
}

.primary-button:hover,
.secondary-button:hover {
    transform: translateY(-1px);
}

.primary-button:hover {
    background: var(--accent-strong);
}

.secondary-button {
    color: var(--accent-strong);
    background: #dff3ef;
}

.webmail-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.webmail-button img {
    display: block;
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.ghost-button {
    color: var(--text);
    background: transparent;
    border: 1px solid var(--border);
}

button:disabled {
    cursor: progress;
    opacity: 0.68;
    transform: none;
}

.alert-message {
    margin-top: 18px;
    padding: 12px 14px;
    color: var(--danger);
    background: var(--danger-bg);
    border: 1px solid #ffd0cc;
    border-radius: 7px;
}

.notice-message {
    margin-top: 18px;
    padding: 12px 14px;
    color: var(--success-text);
    background: var(--success-bg);
    border: 1px solid #ccebd5;
    border-radius: 7px;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-top: 22px;
    padding: 12px 0;
}

.toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.personal-toolbar-summary {
    display: flex;
    align-items: center;
    gap: 18px;
}

.personal-toolbar-summary > div {
    display: grid;
    gap: 3px;
}

.personal-company-logo {
    display: block;
    width: auto;
    max-width: min(320px, 45vw);
    height: auto;
    max-height: 100px;
    object-fit: contain;
}

.automation-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 8px;
    padding: 12px 14px;
    color: var(--muted);
    background: #fbfcfb;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.automation-status div {
    display: grid;
    gap: 4px;
}

.automation-status strong {
    color: var(--text);
    font-size: 0.95rem;
}

.app-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 18px;
    margin-top: 34px;
    padding: 20px 0 4px;
    color: var(--muted);
    border-top: 1px solid var(--border);
    font-size: 0.82rem;
    font-weight: 700;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(170px, 1fr));
    gap: 14px;
    margin-top: 10px;
}

.metric-card {
    display: grid;
    gap: 8px;
    min-height: 118px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.metric-card strong {
    font-size: clamp(1.45rem, 3vw, 2.2rem);
    line-height: 1.05;
}

.wrap-value {
    overflow-wrap: anywhere;
    font-size: clamp(1.1rem, 2vw, 1.55rem) !important;
}

.personal-overview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.personal-summary-card {
    display: grid;
    align-content: start;
    gap: 18px;
    min-height: 260px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.summary-card-header,
.summary-subheading,
.summary-inline-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.summary-card-header > span:first-child,
.summary-subheading > span,
.summary-inline-stat > span,
.space-summary-values span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.summary-card-header > strong,
.summary-subheading > strong {
    color: var(--muted);
    font-size: 0.82rem;
}

.personal-mailbox-name {
    overflow-wrap: anywhere;
    font-size: 1.55rem;
}

.mailbox-profile-details {
    display: grid;
    gap: 10px;
    margin: 0;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.mailbox-profile-details div {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 10px;
}

.mailbox-profile-details dt {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.mailbox-profile-details dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    font-weight: 800;
}

.summary-inline-stat {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.summary-inline-stat strong {
    font-size: 1.4rem;
}

.summary-notifications,
.quota-automation-summary {
    display: grid;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.space-summary-values {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
}

.space-summary-values div {
    display: grid;
    gap: 5px;
}

.space-summary-values strong,
.quota-total {
    font-size: 2rem;
    line-height: 1.05;
}

.personal-space-stack {
    width: 100%;
    max-width: none;
    gap: 4px;
}

.personal-space-stack .space-progress-row {
    grid-template-columns: minmax(180px, 1fr) 46px;
}

.dynamic-rule {
    display: grid;
    gap: 8px;
}

.dynamic-rule strong {
    font-size: 1.4rem;
}

.dynamic-rule p,
.dynamic-copy {
    color: var(--muted);
    line-height: 1.45;
}

.notification-list {
    display: grid;
    gap: 8px;
}

.notification-item {
    display: grid;
    gap: 3px;
    padding: 11px 12px;
    background: #fbfcfb;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.notification-item strong {
    overflow-wrap: anywhere;
}

.notification-item span,
.field-note {
    color: var(--muted);
    font-size: 0.86rem;
}

.data-section {
    margin-top: 30px;
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.section-heading h2 {
    font-size: 1.25rem;
}

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.table-wrap.compact {
    max-width: 980px;
}

.table-wrap.embedded {
    border: 0;
    border-radius: 0;
}

.table-wrap.embedded .data-table {
    min-width: 1540px;
}

.directory-table {
    min-width: 720px;
}

.data-table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: var(--muted);
    background: var(--surface-alt);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.data-table tbody tr:hover {
    background: #f8faf8;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.main-cell {
    font-weight: 800;
}

.number {
    text-align: right !important;
    white-space: nowrap;
}

.strong {
    font-weight: 800;
}

.action-cell {
    text-align: right !important;
    white-space: nowrap;
}

.table-action {
    min-height: 34px;
    padding: 7px 12px;
    color: var(--accent-strong);
    background: #e7f4f1;
    border-radius: 7px;
    font-weight: 800;
    cursor: pointer;
}

.badge.neutral {
    color: var(--muted);
}

.badge.success {
    color: var(--success-text);
    background: var(--success-bg);
    border-color: #ccebd5;
}

.badge.danger {
    color: var(--danger);
    background: var(--danger-bg);
    border-color: #ffd0cc;
}

.usage-cell {
    min-width: 160px;
}

.space-cell {
    min-width: 220px;
}

.space-stack {
    display: grid;
    gap: 2px;
    max-width: 260px;
}

.space-total {
    font-size: 12px;
    font-weight: 900;
    line-height: 1.05;
}

.space-progress-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) 42px;
    align-items: center;
    gap: 6px;
    line-height: 1;
}

.space-progress-row > span {
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
}

.space-detail {
    color: var(--muted);
    font-size: 10px;
    font-weight: 400;
    line-height: 1.05;
}

.usage-line {
    display: grid;
    grid-template-columns: minmax(82px, 1fr) 52px;
    align-items: center;
    gap: 10px;
}

.usage,
.meter {
    width: 100%;
    height: 8px;
    overflow: hidden;
    background: #e5ebe6;
    border-radius: 999px;
}

.usage span,
.meter span {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: inherit;
}

.usage.warning span {
    background: var(--warning);
}

.usage.danger span {
    background: var(--danger);
}

.empty-state {
    padding: 26px;
    color: var(--muted);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 8px;
}

.domain-accordion {
    display: grid;
    gap: 10px;
}

.domain-collapse-item {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 24px rgba(23, 33, 28, 0.05);
}

.domain-collapse-button {
    position: relative;
    display: grid;
    grid-template-columns: minmax(220px, 2fr) auto repeat(3, minmax(122px, 1fr));
    gap: 14px;
    align-items: center;
    width: 100%;
    min-height: 78px;
    padding: 14px 48px 14px 18px;
    color: var(--text);
    background: var(--surface);
    box-shadow: none;
}

.domain-collapse-button::after {
    position: absolute;
    top: 50%;
    right: 18px;
    margin-left: 0;
    transform: translateY(-50%);
}

.domain-collapse-button:not(.collapsed)::after {
    transform: translateY(-50%) rotate(-180deg);
}

.domain-collapse-button:not(.collapsed) {
    color: var(--text);
    background: #f8faf8;
    box-shadow: inset 0 -1px 0 var(--border);
}

.domain-collapse-button:focus {
    border-color: transparent;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.domain-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 1rem;
    font-weight: 900;
}

.domain-logo {
    flex: 0 0 auto;
    width: auto;
    height: 40px;
    object-fit: contain;
    background: transparent;
    border: 0;
    border-radius: 0;
}

.domain-stat {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.domain-stat span {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
}

.domain-stat strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 0.96rem;
}

.mailbox-count-value {
    display: flex;
    align-items: baseline;
    gap: 0.75em;
    max-width: none;
    overflow-wrap: normal;
    white-space: nowrap;
}

.domain-collapse-item .accordion-body {
    padding: 0;
}

.domain-meter {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) auto auto;
    gap: 14px;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: #fbfcfb;
}

.domain-meter strong {
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.domain-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.notify-check {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    cursor: pointer;
}

.notify-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.directory-checks {
    display: grid;
    gap: 7px;
    min-width: 112px;
}

.directory-checks label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
}

.directory-checks input {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--accent);
}

.embedded-empty {
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: 0;
}

.mailbox-input-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.mailbox-input-row span {
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 800;
    white-space: nowrap;
}

.editor-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(23, 33, 28, 0.36);
}

.editor-panel {
    width: min(760px, 100%);
    max-height: min(860px, calc(100vh - 40px));
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.compact-editor {
    width: min(520px, 100%);
}

.password-editor-grid {
    grid-template-columns: 1fr;
}

.editor-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.editor-header h2 {
    margin-top: 4px;
    overflow-wrap: anywhere;
    font-size: 1.35rem;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    color: var(--muted);
    background: #f1f4f1;
    border-radius: 7px;
    font-weight: 900;
    cursor: pointer;
}

.editor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 20px;
}

.editor-wide {
    grid-column: span 2;
}

.readonly-stat {
    display: grid;
    gap: 5px;
    min-height: 72px;
    padding: 12px;
    background: #fbfcfb;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.readonly-stat span {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 800;
}

.readonly-stat strong {
    overflow-wrap: anywhere;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    color: var(--text);
    font-weight: 800;
}

.check-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 20px 20px;
}

.settings-editor {
    display: grid;
    gap: 16px;
    padding: 20px;
}

.logo-editor {
    display: grid;
    gap: 16px;
    padding: 20px;
}

.logo-preview {
    width: min(180px, 100%);
    height: 120px;
    object-fit: contain;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.file-input {
    padding: 9px 12px;
}

.danger-zone {
    display: grid;
    grid-template-columns: 1fr minmax(220px, 0.8fr) auto;
    gap: 14px;
    align-items: end;
    padding: 20px;
    border-top: 1px solid #ffd0cc;
    background: var(--danger-bg);
}

.danger-zone h3 {
    margin: 0 0 4px;
    color: var(--danger);
    font-size: 1rem;
}

.danger-zone p {
    color: #8d3b35;
    font-size: 0.9rem;
}

.danger-button {
    min-height: 44px;
    padding: 10px 16px;
    color: #ffffff;
    background: var(--danger);
    border-radius: 7px;
    font-weight: 900;
    cursor: pointer;
}

.blazor-error-boundary {
    padding: 1rem;
    color: #ffffff;
    background: var(--danger);
}

.blazor-error-boundary::after {
    content: "Ocurrio un error.";
}

@media (max-width: 1100px) {
    .form-grid,
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .field-wide,
    .actions {
        grid-column: span 2;
    }

    .domain-collapse-button {
        grid-template-columns: minmax(180px, 1.3fr) repeat(2, minmax(120px, 1fr));
    }

    .personal-overview-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .danger-zone {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .dashboard-page {
        padding: 18px;
    }

    .workspace-header,
    .toolbar,
    .automation-status,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .session-strip,
    .toolbar-actions {
        justify-content: flex-start;
    }

    .personal-toolbar-summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .personal-company-logo {
        max-width: 100%;
    }

    .form-grid,
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .personal-overview-grid {
        grid-template-columns: 1fr;
    }

    .field-wide,
    .actions {
        grid-column: auto;
    }

    .actions,
    .primary-button,
    .secondary-button,
    .ghost-button {
        width: 100%;
    }

    .toolbar-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .domain-collapse-button {
        grid-template-columns: minmax(0, 1fr) minmax(96px, 0.7fr);
        gap: 11px;
        padding: 13px 42px 13px 14px;
    }

    .domain-title {
        grid-column: 1;
    }

    .domain-stat {
        grid-column: span 1;
    }

    .domain-meter {
        grid-template-columns: 1fr;
    }

    .domain-actions {
        justify-content: stretch;
    }

    .domain-actions .table-action {
        flex: 1 1 150px;
    }

    .domain-meter strong {
        white-space: normal;
    }

    .editor-backdrop {
        align-items: end;
        padding: 10px;
    }

    .editor-panel {
        max-height: calc(100vh - 20px);
    }

    .editor-grid {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .editor-wide {
        grid-column: auto;
    }

    .editor-actions {
        display: grid;
        grid-template-columns: 1fr;
        padding: 0 16px 16px;
    }
}
