/* PMTA Manager — design system (Bootstrap 5 shell) */
:root {
    --sidebar-width: 15.5rem;
    --app-topbar-height: 3.25rem;
    --app-bg: #f4f6f9;
    --app-bg-subtle: #eef1f6;
    --app-surface: #ffffff;
    --sidebar-text: rgba(255, 255, 255, 0.82);
    --sidebar-accent: #2dd4bf;
    --sidebar-accent-dim: rgba(45, 212, 191, 0.18);
    --app-border: #e2e8f0;
    --app-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
    --app-shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.08);
    --app-radius: 12px;
    --app-radius-sm: 8px;
    --app-accent: #0d9488;
    --app-accent-hover: #0f766e;
    --primary-color: var(--app-accent);
    --secondary-color: #64748b;
    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --app-text: #0f172a;
    --app-text-muted: #64748b;
    --app-font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --app-mono: "JetBrains Mono", ui-monospace, monospace;
    /* Bootstrap 5.3 theme bridge */
    --bs-primary: #0f766e;
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: #0d9488;
    --bs-link-hover-color: #0f766e;
    --bs-border-radius: var(--app-radius-sm);
    --bs-body-font-family: var(--app-font);
}

body.app-body {
    font-family: var(--app-font);
    background-color: var(--app-bg);
    color: var(--app-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
}

.app-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(2px);
    z-index: 1030;
}

@media (max-width: 991.98px) {
    .app-sidebar-backdrop.show {
        display: block;
    }

    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        z-index: 1040;
        box-shadow: var(--app-shadow-lg);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }
}

@media (min-width: 992px) {
    .app-sidebar-mobile-bar {
        display: none !important;
    }

    body.sidebar-collapsed .app-sidebar .nav-section-label {
        opacity: 0;
        height: 0;
        margin: 0;
        overflow: hidden;
        padding: 0;
        border: none;
        pointer-events: none;
        display: none;
    }

    body.sidebar-collapsed .app-brand-text {
        display: none !important;
    }

    body.sidebar-collapsed .app-sidebar {
        width: 4rem;
        align-items: center;
        padding-inline: 0.5rem !important;
    }

    body.sidebar-collapsed .app-sidebar .sidebar-nav-link span.nav-text {
        display: none !important;
    }

    body.sidebar-collapsed .app-sidebar .sidebar-nav-link i {
        margin-right: 0 !important;
    }

    body.sidebar-collapsed .app-sidebar .sidebar-brand {
        justify-content: center;
        padding-inline: 0 !important;
    }

    body.sidebar-collapsed .app-sidebar .sidebar-brand .app-brand-text {
        display: none !important;
    }

    body.sidebar-collapsed .app-sidebar .sidebar-brand i {
        margin-inline: auto !important;
    }

    body.sidebar-collapsed .app-sidebar .sidebar-collapse-btn {
        display: none !important;
    }

    body.sidebar-collapsed .app-sidebar .sidebar-expand-btn-desktop {
        display: flex !important;
    }

    body.sidebar-collapsed .app-sidebar .sidebar-brand {
        gap: 0;
    }

    body.sidebar-collapsed #sidebarLogoutFooter {
        display: none !important;
    }
}

.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: linear-gradient(165deg, #0c1222 0%, #1e293b 48%, #0f172a 100%);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 0.5rem;
    font-weight: 600;
    color: white;
}

.sidebar-expand-btn-desktop {
    display: none !important;
    justify-content: center;
    align-items: center;
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
}

.sidebar-expand-btn-desktop .btn-outline-light {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 2.125rem;
    height: 2.125rem;
    padding: 0 !important;
    border-radius: var(--app-radius-sm) !important;
    border-color: rgba(255, 255, 255, 0.28) !important;
    font-size: 1rem !important;
    line-height: 1 !important;
}

.sidebar-nav {
    overflow-y: auto;
    overflow-x: hidden;
    flex-grow: 1;
    padding: 0.5rem;
}

.sidebar-footer {
    flex-shrink: 0;
}

.nav-section-label {
    padding: 0.75rem 0.625rem 0.35rem 0.75rem;
    color: rgba(255, 255, 255, 0.42);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-size: 0.625rem;
    font-weight: 700;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-section:first-of-type .nav-section-label {
    border-top: 0;
    padding-top: 0;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.625rem !important;
    border-radius: var(--app-radius-sm) !important;
    color: rgba(255, 255, 255, 0.92) !important;
    gap: 0;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.sidebar-nav-link:hover {
    background: rgba(255, 255, 255, 0.07) !important;
    color: #fff !important;
}

.sidebar-nav-link.active {
    background: var(--sidebar-accent-dim) !important;
    border-left: 3px solid var(--sidebar-accent) !important;
    padding-left: 0.5rem !important;
    color: #fff !important;
    font-weight: 600 !important;
}

.sidebar-nav-link i {
    opacity: 0.9;
}

.app-brand-icon {
    color: var(--sidebar-accent) !important;
}

.app-main-wrap {
    flex-grow: 1;
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--app-bg);
}

body.sidebar-collapsed .app-main-wrap {
    width: calc(100% - 4rem);
}

@media (max-width: 991.98px) {
    .app-main-wrap {
        width: 100%;
        min-height: unset;
        padding-top: 0;
    }
}

.app-sidebar-mobile-bar {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: linear-gradient(90deg, #1e293b 0%, #0f172a 100%);
    color: rgba(255, 255, 255, 0.95);
}

.app-toolbar {
    display: none;
}

@media (min-width: 992px) {
    .app-toolbar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 1rem;
        margin: 0 0 0.75rem 0;
        background: var(--app-surface);
        border: 1px solid var(--app-border);
        border-radius: var(--app-radius);
        box-shadow: var(--app-shadow);
    }
}

.toolbar-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--app-text-muted);
    margin: 0;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.toolbar-actions .btn-outline-secondary {
    border-color: var(--app-border);
    background: var(--app-surface);
}

.density-toggle .btn {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.65rem;
}

.density-toggle .btn.active {
    background: var(--app-accent) !important;
    border-color: var(--app-accent) !important;
    color: #fff !important;
}

.app-main-content {
    padding: 1.25rem 1.75rem calc(88px + 1rem) 1.75rem;
    flex-grow: 1;
    max-width: 100vw;
}

body.app-density-compact .app-main-content {
    padding: 0.85rem 1.1rem calc(72px + 0.65rem) 1.1rem;
}

@media (max-width: 991.98px) {
    .app-main-content {
        padding: 1rem 1rem calc(88px + 1rem) 1rem;
    }

    body.app-density-compact .app-main-content {
        padding: 0.65rem 0.85rem calc(72px + 0.5rem) 0.85rem;
    }
}

body.app-density-compact .card {
    margin-bottom: 0.9rem;
}

body.app-density-compact .card-body {
    padding: 0.9rem 1.1rem;
}

body.app-density-compact .card-header {
    padding: 0.65rem 1.1rem;
}

body.app-density-compact .page-header {
    margin-bottom: 0.85rem;
}

body.app-density-compact .table > :not(caption) > * > * {
    padding: 0.4rem 0.55rem;
}

body.app-density-compact .stat-card-modern {
    padding: 1rem 1.1rem;
}

body.app-density-compact .stat-number-modern {
    font-size: 1.55rem;
}

.bulk-action-bar {
    display: none;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.bulk-action-bar.show {
    display: flex !important;
}

.bulk-action-bar-fixed {
    position: fixed !important;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1025;
}

@media (min-width: 992px) {
    .bulk-action-bar-fixed {
        left: var(--sidebar-width);
        right: 1rem;
        width: calc(100% - var(--sidebar-width) - 2rem) !important;
        max-width: none;
    }

    body.sidebar-collapsed .bulk-action-bar-fixed {
        left: 4rem;
        width: calc(100% - 4rem - 2rem) !important;
    }
}

@media (max-width: 991.98px) {
    .bulk-action-bar-fixed {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
    }
}

.sidebar-brand-row {
    flex-wrap: nowrap;
}

body.sidebar-collapsed .sidebar-brand-row .sidebar-expand-btn-desktop {
    display: flex !important;
    margin-inline: auto;
}

.bulk-action-bar-fixed .bulk-action-inner {
    width: 100%;
    justify-content: space-between;
}

.page-header .breadcrumb {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.page-header .breadcrumb-item a {
    color: var(--app-accent);
    text-decoration: none;
}

.page-header .breadcrumb-item a:hover {
    text-decoration: underline;
}

.page-header .page-title {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 0.25rem 0;
    color: var(--app-text);
    line-height: 1.2;
}

.page-header .page-lead {
    margin: 0;
    color: var(--app-text-muted);
    font-size: 0.9375rem;
    max-width: 52rem;
    line-height: 1.5;
}

/* —— Surfaces —— */
.card {
    border: 1px solid var(--app-border);
    box-shadow: var(--app-shadow);
    border-radius: var(--app-radius);
    margin-bottom: 1.25rem;
    background: var(--app-surface);
    overflow: hidden;
}

.card-header {
    background: linear-gradient(180deg, #fafbfc 0%, var(--app-surface) 100%);
    border-bottom: 1px solid var(--app-border);
    border-radius: 0 !important;
    font-weight: 600;
    font-size: 0.9375rem;
    padding: 0.85rem 1.25rem;
}

.card-body {
    padding: 1.25rem;
}

/* —— KPI / dashboard —— */
.stat-card,
.stat-card-modern {
    background: var(--app-surface);
    border-radius: var(--app-radius);
    padding: 1.25rem 1.35rem;
    box-shadow: var(--app-shadow);
    border: 1px solid var(--app-border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.stat-card::before,
.stat-card-modern::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--app-accent), #14b8a6);
    opacity: 0.85;
}

.stat-card:hover,
.stat-card-modern:hover {
    transform: translateY(-2px);
    box-shadow: var(--app-shadow-lg);
}

.stat-card .stat-number,
.stat-number-modern {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.03em;
    color: var(--app-text);
}

.stat-card .stat-label,
.stat-meta {
    margin-top: 0.5rem;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--app-text-muted);
    font-weight: 700;
}

.kpi-accent {
    color: var(--app-accent);
}

/* —— Quick actions & chips —— */
.quick-actions-row .btn {
    border-radius: var(--app-radius-sm);
    font-weight: 600;
}

/* —— Tables —— */
.table {
    vertical-align: middle;
    --bs-table-bg: transparent;
}

.table thead th {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--app-text-muted);
    border-bottom-width: 1px;
    background: var(--app-bg-subtle);
}

.table-hover tbody tr {
    transition: background 0.12s ease;
}

.table-hover tbody tr:hover {
    background: rgba(13, 148, 136, 0.05) !important;
}

.table-responsive {
    border-radius: var(--app-radius-sm);
}

/* —— Forms —— */
.form-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--app-text);
}

.form-control,
.form-select {
    border-radius: var(--app-radius-sm);
    border-color: var(--app-border);
}

.form-control:focus,
.form-select:focus {
    border-color: #14b8a6;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.22);
}

.btn {
    font-weight: 600;
    border-radius: var(--app-radius-sm);
}

.btn-primary {
    --bs-btn-bg: var(--app-accent);
    --bs-btn-border-color: var(--app-accent);
    --bs-btn-hover-bg: var(--app-accent-hover);
    --bs-btn-hover-border-color: var(--app-accent-hover);
    --bs-btn-active-bg: var(--app-accent-hover);
    --bs-btn-active-border-color: var(--app-accent-hover);
}

.btn-success {
    --bs-btn-bg: #047857;
    --bs-btn-border-color: #047857;
}

.focus-ring:focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: 2px;
}

/* —— Alerts —— */
.alert {
    border: none;
    border-radius: var(--app-radius-sm);
    border-left: 4px solid currentColor;
}

.alert-info {
    background: rgba(13, 148, 136, 0.09);
    color: #0f766e;
}

.alert-warning {
    background: rgba(217, 119, 6, 0.12);
}

.alert-danger {
    background: rgba(220, 38, 38, 0.09);
}

/* —— Installation wizard —— */
.installation-wizard .wiz-step-indicator {
    border-radius: 999px !important;
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.35rem 0.75rem !important;
    border-color: var(--app-border) !important;
}

.installation-wizard .wiz-step-indicator.active {
    background: var(--app-accent) !important;
    color: #fff !important;
    border-color: var(--app-accent) !important;
}

.installation-wizard .wiz-server-box {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius-sm);
    padding: 0.75rem 1rem;
    background: var(--app-bg-subtle);
}

.installation-wizard .install-step h5 {
    font-weight: 700;
    font-size: 1.05rem;
}

/* —— Domains / filters —— */
.domain-toolbar {
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.06) 0%, var(--app-surface) 55%);
    border: 1px solid var(--app-border) !important;
    border-radius: var(--app-radius);
}

.domain-card .card-header {
    background: var(--app-surface);
}

/* —— Empty states —— */
.empty-state {
    text-align: center;
    padding: 2rem 1.5rem;
    color: var(--app-text-muted);
}

.empty-state i {
    font-size: 2.25rem;
    opacity: 0.35;
    margin-bottom: 0.75rem;
    display: block;
}

/* —— Logs —— */
.log-viewer {
    background: #0c1222;
    border-radius: var(--app-radius-sm);
    font-family: var(--app-mono);
    font-size: 0.8125rem;
    font-feature-settings: "liga" off;
}

/* —— Timeline / matrix —— */
.timeline-step {
    position: relative;
    padding-left: 1.85rem;
    padding-bottom: 1rem;
    border-left: 2px solid var(--app-border);
    margin-left: 0.4rem;
}

.timeline-step.done {
    border-left-color: var(--success-color);
}

.timeline-step.current {
    border-left-color: var(--app-accent);
}

.timeline-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 999px;
    background: var(--secondary-color);
    position: absolute;
    left: -0.4375rem;
    top: 0.05rem;
}

.timeline-step.done .timeline-dot {
    background: var(--success-color);
}

.timeline-step.pending .timeline-dot {
    opacity: 0.35;
}

.matrix-cell-good {
    background: rgba(5, 150, 105, 0.12) !important;
}

.matrix-cell-bad {
    background: rgba(220, 38, 38, 0.1) !important;
}

.matrix-cell-warn {
    background: rgba(217, 119, 6, 0.12) !important;
}

.matrix-cell-na {
    background: transparent !important;
}

.page-title {
    color: var(--app-text);
}

.badge-soft {
    font-weight: 600;
    padding: 0.35rem 0.55rem;
    border-radius: 6px;
}

code,
.table code {
    font-family: var(--app-mono);
    font-size: 0.84em;
    color: #0f766e;
}

/* —— Login (standalone) —— */
body.login-page {
    min-height: 100vh;
    margin: 0;
    font-family: var(--app-font);
    background:
        radial-gradient(ellipse 80% 55% at 20% 15%, rgba(45, 212, 191, 0.18), transparent 50%),
        radial-gradient(ellipse 60% 45% at 85% 80%, rgba(15, 118, 110, 0.14), transparent 45%),
        linear-gradient(160deg, #0f172a 0%, #1e293b 45%, #0c1222 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    -webkit-font-smoothing: antialiased;
}

.login-shell {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--app-surface);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 2.5rem 2.25rem;
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    margin-bottom: 1.75rem;
}

.login-brand i {
    font-size: 2rem;
    color: var(--app-accent);
}

.login-brand h1 {
    font-size: 1.4rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.02em;
    color: var(--app-text);
}

.login-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-header p {
    color: var(--app-text-muted);
    margin: 0.35rem 0 0 0;
    font-size: 0.9375rem;
}

.login-page .form-control {
    border-radius: var(--app-radius-sm);
    padding: 0.75rem 1rem;
}

.login-page .btn-login {
    border-radius: var(--app-radius-sm);
    padding: 0.75rem;
    font-weight: 700;
    width: 100%;
}

.login-page .alert {
    border-left-width: 4px;
}

/* Kumo operations: multi-line flash (journal excerpts) */
.kumo-flash-message {
    white-space: pre-wrap;
    max-height: 24rem;
    overflow-y: auto;
    font-size: 0.875rem;
}
