:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --card-alt: #f8fbff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #dbe5f0;
    --accent: #1e73be;
    --accent-dark: #155a96;
    --accent-soft: #eaf4ff;
    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --danger-soft: #fff5f5;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --warning-bg: #fff7ed;
    --warning-text: #9a3412;
    --queued-bg: #fef3c7;
    --queued-text: #92400e;
    --toggle-on-bg: #dcfce7;
    --toggle-on-text: #166534;
    --toggle-off-bg: #e5e7eb;
    --toggle-off-text: #374151;
    --highlight: #eef6ff;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: Inter, Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a {
    color: var(--accent-dark);
}

.site-header {
    background: linear-gradient(135deg, #14548e 0%, #1e73be 55%, #3089d6 100%);
    color: white;
    padding: 1.5rem 0 1.25rem;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18);
}

.container {
    width: min(1480px, calc(100% - 2rem));
    margin: 0 auto;
}

.header-shell {
    display: grid;
    gap: 1rem;
}

.header-row {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    align-items: flex-start;
}

.header-bottom {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-logo {
    height: 58px;
    width: auto;
    background: white;
    border-radius: 12px;
    padding: 0.35rem 0.55rem;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.1);
}

.brand-text h1 {
    margin: 0;
    font-size: clamp(1.45rem, 2.4vw, 2rem);
}

.subtitle {
    margin: 0.35rem 0 0;
    opacity: 0.92;
}

.user-box {
    display: grid;
    gap: 0.5rem;
    min-width: 260px;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(4px);
}

.user-box form {
    margin-top: 0.25rem;
}

.main-nav {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.main-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.72rem 1rem;
    color: white;
    text-decoration: none;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.main-nav a:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
}

.main-nav a.active {
    background: white;
    color: var(--accent-dark);
    border-color: white;
}

.global-filter-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(4px);
}

.global-filter-form label {
    margin: 0;
    color: white;
    font-weight: 600;
    white-space: nowrap;
}

.global-filter-form select {
    min-width: 280px;
}

.header-inline-link {
    color: white;
    font-size: 0.92rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    white-space: nowrap;
}

main.container {
    padding: 2rem 0 2.5rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem 1.4rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.message-card {
    border-left: 4px solid var(--accent);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

h1,
 h2,
 h3,
 h4 {
    margin-top: 0;
    line-height: 1.2;
}

p {
    margin-top: 0;
}

ul,
ol {
    padding-left: 1.25rem;
}

li {
    margin-bottom: 0.45rem;
}

label {
    display: inline-block;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.35rem;
}

input,
textarea,
select {
    width: 100%;
    padding: 0.78rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #8bbef0;
    box-shadow: 0 0 0 3px rgba(30, 115, 190, 0.14);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

button,
.button-link,
.summary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.75rem 1rem;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--accent);
    color: white;
    cursor: pointer;
    font-size: 0.96rem;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

button:hover,
.button-link:hover,
.summary-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(30, 115, 190, 0.22);
}

button:disabled,
.button-link:disabled,
.summary-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.small-button {
    padding: 0.52rem 0.78rem;
    font-size: 0.88rem;
}

.secondary-button,
.summary-button {
    background: white;
    color: var(--text);
    border-color: var(--border);
}

.secondary-button:hover,
.summary-button:hover {
    background: #f8fafc;
    border-color: #c7d5e4;
}

.danger-button {
    background: var(--danger);
    color: white;
}

.danger-button:hover {
    box-shadow: 0 8px 18px rgba(185, 28, 28, 0.22);
}

.inline-button {
    margin-top: 0;
}

.inline-link {
    line-height: 1.2;
}

.toggle-button {
    min-width: 112px;
    padding: 0.52rem 0.78rem;
    font-size: 0.88rem;
}

.toggle-on {
    background: var(--toggle-on-bg);
    color: var(--toggle-on-text);
    border-color: rgba(22, 101, 52, 0.18);
}

.toggle-off {
    background: var(--toggle-off-bg);
    color: var(--toggle-off-text);
    border-color: rgba(55, 65, 81, 0.12);
}

.toggle-on:hover,
.toggle-off:hover {
    box-shadow: none;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0.62rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: capitalize;
}

.status-finished,
.status-ok {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-partial,
.status-running {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.status-failed,
.status-error {
    background: var(--danger-bg);
    color: var(--danger);
}

.status-queued {
    background: var(--queued-bg);
    color: var(--queued-text);
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 0.9rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-weight: 700;
}

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

.hint-text {
    color: var(--muted);
    font-size: 0.92rem;
}

.error {
    color: var(--danger);
    font-weight: 700;
}

.code-block {
    background: #0f172a;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 12px;
    overflow-x: auto;
}

.page-headline {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.page-headline-actions,
.action-bar,
.selection-meta,
.filter-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.selection-count {
    color: var(--muted);
    font-size: 0.95rem;
}

.selection-count strong {
    color: var(--text);
}

.bulk-form {
    display: grid;
    grid-template-columns: minmax(280px, 2fr) auto;
    gap: 1rem;
    align-items: end;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

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

.stat-card {
    margin-bottom: 0;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    margin: 0.3rem 0 0;
}

.stat-hint {
    margin-top: 0.35rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 1rem;
    align-items: end;
}

.filter-grid-customers {
    grid-template-columns: minmax(260px, 2fr) repeat(4, minmax(0, 1fr)) auto;
}

.compact-grid {
    grid-template-columns: minmax(260px, 2fr) auto;
}

.login-form {
    display: grid;
    gap: 0.9rem;
    max-width: 720px;
}

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

.form-grid .full-span {
    grid-column: 1 / -1;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    margin: 0.15rem 0;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
}

.table-wrapper {
    width: 100%;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: white;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.94rem;
    min-width: 1200px;
}

.data-table th,
.data-table td {
    padding: 0.85rem 0.9rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    white-space: normal;
    word-break: break-word;
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #eef5ff;
}

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

.data-table tbody tr:hover td {
    background: #fbfdff;
}

.highlight-row td {
    background: var(--highlight);
}

.selectable-row.is-selected td {
    background: #edf6ff;
}

.select-column {
    width: 56px;
    min-width: 56px;
    text-align: center;
}

.select-column input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
}

.cell-title {
    font-weight: 700;
    color: var(--text);
}

.cell-subtitle {
    margin-top: 0.25rem;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.4;
}

.cell-stack {
    display: grid;
    gap: 0.2rem;
}

.actions-cell {
    min-width: 200px;
}

.wide-actions {
    min-width: 360px;
}

.inline-form {
    display: inline-block;
    margin: 0 0.35rem 0.35rem 0;
}

.inline-form:last-child {
    margin-right: 0;
}

.row-actions-menu {
    position: relative;
}

.row-actions-menu summary {
    list-style: none;
}

.row-actions-menu summary::-webkit-details-marker {
    display: none;
}

.row-actions-panel {
    margin-top: 0.7rem;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: white;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.12);
    display: grid;
    gap: 0.55rem;
    min-width: 220px;
}

.row-actions-panel .inline-form,
.row-actions-panel .button-link {
    margin: 0;
    width: 100%;
}

.row-actions-panel button,
.row-actions-panel .button-link {
    width: 100%;
    justify-content: center;
}

.customers-table {
    min-width: 1260px;
}

.reports-table {
    min-width: 1080px;
}

.reports-table td:nth-child(2),
.reports-table td:nth-child(5),
.reports-table td:nth-child(6) {
    white-space: nowrap;
}

.threats-table {
    min-width: 1400px;
}

.empty-state {
    text-align: center;
    padding: 1.5rem 0.5rem;
}

.empty-state p {
    color: var(--muted);
    margin-bottom: 0;
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.sidebar-stack,
.quick-actions {
    display: grid;
    gap: 1rem;
}

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

.meta-card {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card-alt);
}

.meta-label {
    color: var(--muted);
    font-size: 0.86rem;
    margin-bottom: 0.35rem;
}

.meta-value {
    font-weight: 700;
    color: var(--text);
}

.quick-actions .inline-form,
.quick-actions .button-link {
    margin: 0;
    width: 100%;
}

.quick-actions button,
.quick-actions .button-link {
    width: 100%;
    justify-content: center;
}

@media (max-width: 1200px) {
    .stats-grid,
    .stats-grid-three,
    .filter-grid,
    .filter-grid-customers,
    .compact-grid,
    .bulk-form,
    .form-grid,
    .metadata-grid {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 960px) {
    .header-row,
    .header-bottom {
        flex-direction: column;
        align-items: stretch;
    }

    .user-box,
    .global-filter-form {
        width: 100%;
    }

    .global-filter-form {
        flex-direction: column;
        align-items: stretch;
    }

    .global-filter-form label {
        white-space: normal;
    }

    .main-nav {
        width: 100%;
    }

    .main-nav a {
        flex: 1 1 auto;
    }

    .page-headline,
    .page-headline-actions,
    .action-bar,
    .selection-meta,
    .filter-actions {
        align-items: stretch;
    }
}

@media (max-width: 640px) {
    .container {
        width: min(100%, calc(100% - 1rem));
    }

    .card {
        padding: 1rem;
        border-radius: 14px;
    }

    button,
    .button-link,
    .summary-button {
        width: 100%;
    }

    .action-bar .inline-form,
    .page-headline-actions .button-link {
        width: 100%;
    }

    .brand-block {
        align-items: flex-start;
    }
}
