:root {
    font-family: "Segoe UI", Arial, sans-serif;
    color: #172230;
    background: #f3f5f7;
    --red: #d71920;
}

* { box-sizing: border-box; }
body { margin: 0; }

.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 28px;
    color: #fff;
    background: #20242a;
}

.top h1,
.top p { margin: 0; }
.top p { margin-top: 4px; color: #bec6cf; }
.top-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.top-actions form { margin: 0; }
.top-actions .button-link { color: #1d2a36; background: #fff; }

.layout {
    padding: 22px;
}

.modal-open { overflow: hidden; }
.summary { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; }

.summary article,
.panel {
    padding: 18px;
    background: #fff;
    border: 1px solid #dce3e9;
    border-radius: 11px;
    box-shadow: 0 2px 8px #1020300b;
}

.summary article.emergency { background: #fff1f2; border-color: #e48b8f; }
.summary span { color: #607080; }
.summary b { display: block; margin-top: 7px; font-size: 28px; }
.panel { margin-bottom: 16px; }
.panel h2 { margin: 0 0 14px; }
.emergency-panel { background: #fffafb; border: 2px solid var(--red); }
.table { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th,
td { padding: 9px 7px; text-align: left; border-bottom: 1px solid #e8edf1; }
th { color: #5d7081; }
code { font-family: Consolas, monospace; }
.installation-note { min-width: 180px; max-width: 360px; white-space: normal; overflow-wrap: anywhere; }
.muted,
.field-meta { color: #6b7884; }
.field-meta { margin: 9px 0 0; font-size: 12px; }

.uid {
    display: block;
    padding: 10px;
    overflow-wrap: anywhere;
    user-select: all;
    background: #f4f7f9;
    border-radius: 6px;
}

dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; }
dt { font-weight: 700; }
dd { margin: 0; }

button {
    padding: 9px 13px;
    color: #fff;
    cursor: pointer;
    background: var(--red);
    border: 0;
    border-radius: 7px;
}

.secondary { color: #1d2a36; background: #fff; }
.app-version {
    display: inline-block;
    padding: 3px 8px;
    color: #263746;
    font-size: 13px;
    vertical-align: middle;
    background: #fff;
    border-radius: 999px;
}
.badge { display: inline-block; padding: 4px 9px; font-size: 12px; font-weight: 700; border-radius: 999px; }
.badge.safe { color: #17652d; background: #e6f5e9; }
.badge.danger { color: #fff; background: var(--red); }
.management-form { display: grid; gap: 12px; margin-top: 16px; }
.license-duration-shortcuts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.license-duration-shortcuts button { width: auto; padding: 8px 14px; }
.license-duration-shortcuts small { color: #5f6f82; }
.management-form label { display: grid; gap: 5px; font-weight: 650; }
.management-form label.check { display: flex; align-items: center; gap: 8px; }

.management-form input[type="datetime-local"],
.management-form input[type="password"],
.management-form input[type="text"],
.management-form input[type="number"],
.management-form select,
.management-form textarea {
    width: 100%;
    padding: 9px;
    font: inherit;
    border: 1px solid #bcc8d2;
    border-radius: 7px;
}
.button-link { display: inline-block; padding: 9px 13px; color: #fff; text-decoration: none; background: var(--red); border-radius: 7px; }

.management-form textarea { min-height: 80px; resize: vertical; }
.narrow-layout { max-width: 1450px; margin: 0 auto; }
.two-column-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
.row-actions { min-width: 260px; }
.row-actions form { display: inline-block; margin: 0 7px 7px 0; }
.row-actions details { margin-top: 5px; }
.row-actions summary { color: #42596c; font-weight: 650; cursor: pointer; }
.inline-reset { display: grid !important; grid-template-columns: 1fr 1fr auto; gap: 7px; margin-top: 8px !important; }
.inline-reset input,
.audit-filters input,
.audit-filters select { width: 100%; min-width: 150px; padding: 9px; font: inherit; border: 1px solid #bcc8d2; border-radius: 7px; }
.audit-filters { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.audit-filters label { display: grid; gap: 5px; color: #40566d; font-size: 13px; }
.audit-details { display: block; min-width: 180px; max-width: 420px; white-space: pre-wrap; overflow-wrap: anywhere; }
.notice { padding: 10px; background: #fff7df; border-left: 4px solid #d89400; }
.success { padding: 10px; background: #eaf8ef; border-left: 4px solid #198742; }
.inline-import { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }

.collapsible-panel { padding: 0; }
.collapsible-list > summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px;
    font-size: 24px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}
.collapsible-list > summary::-webkit-details-marker { display: none; }
.collapsible-list > summary small { margin-left: auto; color: #697886; font-size: 13px; font-weight: 600; }
.collapsible-list > summary::after {
    content: '›';
    color: #5d7081;
    font-size: 30px;
    line-height: 1;
    transform: rotate(90deg);
    transition: transform .18s ease;
}
.collapsible-list[open] > summary::after { transform: rotate(-90deg); }
.collapsible-list > summary:hover,
.collapsible-list > summary:focus-visible { background: #f7f9fb; outline: none; }
.collapsible-content { padding: 0 18px 18px; }
.reports-panel .reports-list { margin-top: 16px; border-top: 1px solid #e2e8ed; }
.reports-panel .reports-list > summary { padding-right: 0; padding-left: 0; font-size: 18px; }
.reports-panel .reports-list .collapsible-content { padding: 0; }

.chart-description { margin: -5px 0 14px; color: #5d7081; }
.report-chart { padding: 14px 16px 10px; background: #f7f9fb; border: 1px solid #dce4ea; border-radius: 10px; }
.report-chart-summary,
.report-chart-range { display: flex; justify-content: space-between; gap: 15px; color: #5d7081; font-size: 13px; }
.report-chart-summary strong { color: #172230; font-size: 17px; }
.report-chart svg { display: block; width: 100%; height: auto; max-height: 230px; margin: 8px 0 2px; overflow: visible; }
.chart-grid { stroke: #ccd6de; stroke-width: 1.5; }
.chart-line { fill: none; stroke: var(--red); stroke-linecap: round; stroke-linejoin: round; stroke-width: 4; }
.chart-point { fill: #fff; stroke: var(--red); stroke-width: 3; }

.details-backdrop {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: grid;
    padding: 16px;
    background: #10182099;
    place-items: center;
}

.details-modal {
    display: flex;
    width: min(1100px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow: hidden;
    background: #f3f5f7;
    border: 1px solid #cbd5dd;
    border-radius: 13px;
    box-shadow: 0 24px 80px #0007;
    flex-direction: column;
}

.details-modal-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    background: #fff;
    border-bottom: 1px solid #dce3e9;
}

.details-modal-header h2 { margin: 0 0 4px; }
.details-modal-header code { color: #5d7081; overflow-wrap: anywhere; }
.details-modal-body { min-height: 0; padding: 18px; overflow-y: auto; overscroll-behavior: contain; }
.modal-close {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    color: #253442;
    font-size: 28px;
    line-height: 1;
    text-decoration: none;
    background: #eef2f5;
    border-radius: 50%;
    place-items: center;
}
.modal-close:hover,
.modal-close:focus-visible { color: #fff; background: var(--red); outline: none; }

.auth {
    display: grid;
    min-height: 100vh;
    place-items: center;
    background: linear-gradient(135deg, #252a31, #4a515a);
}

.auth-card {
    width: min(430px, calc(100% - 30px));
    padding: 28px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 65px #0005;
}

.auth-card h1 { margin-top: 0; }
.auth-card form { display: grid; gap: 15px; }
.auth-card label { display: grid; gap: 6px; font-weight: 650; }
.auth-card input { width: 100%; padding: 10px; border: 1px solid #bcc8d2; border-radius: 7px; }
.auth-card small { color: #617182; font-weight: 400; }
.portal-version { color: #617182; font-size: 13px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.settings-card { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 12px; min-height: 170px; padding: 30px 65px 30px 30px; border: 1px solid #dce3eb; border-top: 4px solid var(--red); border-radius: 14px; background: #fff; color: #172b46; text-decoration: none; box-shadow: 0 4px 16px #172b4608; }
.settings-card:hover { background: #fff5f6; border-color: var(--red); }
.settings-card:focus-visible { outline: 3px solid var(--red); outline-offset: 4px; }
.settings-card-title { font-size: 25px; font-weight: 700; }
.settings-card-description { color: #617182; line-height: 1.5; }
.settings-card-arrow { position: absolute; right: 28px; font-size: 30px; color: var(--red); }
@media (max-width: 650px) {
    .settings-grid { grid-template-columns: 1fr; gap: 14px; }
    .settings-card { min-height: 140px; padding: 24px 55px 24px 24px; }
    .settings-card-title { font-size: 22px; }
}
.error { padding: 10px; color: #8e1118; background: #fff0f1; border-left: 4px solid var(--red); }

@media (max-width: 1100px) {
    .details-modal { width: calc(100vw - 24px); max-height: calc(100vh - 24px); }
}

@media (max-width: 650px) {
    .layout { padding: 12px; }
    .top { padding: 15px; }
    .summary { grid-template-columns: 1fr; }
    .table table { min-width: 700px; }
    .details-backdrop { padding: 6px; }
    .details-modal { width: calc(100vw - 12px); max-height: calc(100vh - 12px); }
    .details-modal-body { padding: 10px; }
    .collapsible-list > summary { font-size: 20px; }
    .report-chart { padding: 10px; }
    .top { align-items: flex-start; flex-direction: column; gap: 12px; }
    .two-column-panels { grid-template-columns: 1fr; }
    .inline-reset { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .collapsible-list > summary::after { transition: none; }
}
