* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #142033;
    --muted: #64748b;
    --line: #d7e0ea;
    --primary: #1d4ed8;
    --primary-dark: #1e40af;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: radial-gradient(circle at top left, #e8f0ff 0, var(--bg) 36%, #eef4f8 100%);
    color: var(--text);
    min-height: 100vh;
}

.page-center {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 16px;
}

.container {
    width: 100%;
    max-width: 1060px;
    margin: 0 auto;
    padding: 22px;
}

.card {
    background: var(--card);
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 18px;
    padding: 22px;
    margin-bottom: 18px;
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

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

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 18px;
}

h1,
h2 {
    margin: 0 0 8px;
    line-height: 1.2;
}

h1 {
    font-size: clamp(26px, 4vw, 38px);
}

h2 {
    font-size: clamp(20px, 3vw, 25px);
}

p {
    line-height: 1.6;
}

.muted {
    color: var(--muted);
    margin-top: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 7px 11px;
    border-radius: 999px;
    color: #1e3a8a;
    background: #dbeafe;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
}

label {
    display: block;
    font-weight: 700;
    margin-top: 15px;
    margin-bottom: 7px;
}

input,
textarea {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 15px;
    background: #fff;
    color: var(--text);
    outline: none;
}

input:focus,
textarea:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.18);
}

textarea {
    resize: vertical;
}

button,
.button-link,
.button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 12px 16px;
    border: 0;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
}

button,
.button-link {
    width: 100%;
    margin-top: 18px;
    background: var(--primary);
    color: white;
}

button:hover,
.button-link:hover {
    background: var(--primary-dark);
}

.button-secondary {
    background: #e0ecff;
    color: #1e3a8a;
}

.logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 12px;
    color: #1d4ed8;
    background: #dbeafe;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

a {
    color: var(--primary);
    overflow-wrap: anywhere;
}

.alert {
    padding: 13px 14px;
    border-radius: 13px;
    margin-bottom: 14px;
    font-weight: 700;
}

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

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

code {
    display: inline-block;
    max-width: 100%;
    padding: 2px 5px;
    border-radius: 6px;
    background: #f1f5f9;
    color: #0f172a;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.grid.two {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
    gap: 18px;
}

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

.details {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 10px 14px;
    margin: 16px 0 0;
}

.details dt {
    color: var(--muted);
    font-weight: 700;
}

.details dd {
    margin: 0;
    min-width: 0;
}

.status-list,
.info-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.status-list > div,
.info-list > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfdff;
}

.status-list span,
.info-list span {
    color: var(--muted);
    font-weight: 700;
}

.ok {
    color: var(--success-text);
}

.bad {
    color: var(--error-text);
}

.hint {
    margin-bottom: 0;
    color: var(--muted);
}

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

.check-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-weight: 600;
}

.check-row input {
    width: auto;
    margin-top: 4px;
}

.actions-inline {
    margin-top: 18px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 840px;
}

th,
td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.hash-cell {
    display: grid;
    gap: 4px;
    min-width: 260px;
}

.hash-cell span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.hash-cell code,
.edit-current-file code {
    white-space: normal;
}

@media (max-width: 780px) {
    .container {
        padding: 14px;
    }

    .topbar,
    .grid.two,
    .form-grid {
        display: block;
    }

    .topbar .logout {
        margin-top: 12px;
    }

    .details {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .details dd {
        margin-bottom: 10px;
    }

    .status-list > div,
    .info-list > div {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .card {
        padding: 17px;
        border-radius: 15px;
    }

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

.col-actions {
    width: 92px;
    text-align: center;
}

.history-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 92px;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.icon-btn {
    width: 38px;
    min-height: 38px;
    margin: 0;
    padding: 8px;
    border: 1px solid #bfdbfe;
    border-radius: 11px;
    background: #eff6ff;
    color: #1d4ed8;
}

.icon-btn:hover {
    background: #dbeafe;
}

.icon-btn.danger {
    border-color: #fecaca;
    background: #fff1f2;
    color: #dc2626;
}

.icon-btn.danger:hover {
    background: #fee2e2;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    pointer-events: none;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.58);
}

.modal-backdrop.is-open {
    display: flex;
}

.modal-card {
    width: min(100%, 720px);
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    background: var(--card);
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.32);
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.modal-close {
    width: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0;
    border-radius: 999px;
    background: #f1f5f9;
    color: #334155;
    font-size: 28px;
    line-height: 1;
}

.modal-close:hover {
    background: #e2e8f0;
}

.modal-file-hint {
    margin-top: 8px;
}

.edit-current-file {
    display: grid;
    gap: 6px;
    padding: 12px;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfdff;
}

.edit-current-file span {
    color: var(--muted);
    font-weight: 700;
    font-size: 13px;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 18px;
}

.modal-actions button,
.modal-actions .button-secondary {
    width: 100%;
    margin-top: 0;
}

@media (max-width: 780px) {
    .history-actions {
        justify-content: flex-start;
    }

    .modal-backdrop {
        align-items: flex-end;
        padding: 10px;
    }

    .modal-card {
        width: 100%;
        max-height: calc(100vh - 20px);
        padding: 17px;
        border-radius: 16px;
    }

    .modal-actions {
        grid-template-columns: 1fr;
    }
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.card-head h2 {
    margin: 0;
}

.accordion-card {
    padding: 0;
    overflow: hidden;
}

.accordion-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 76px;
    padding: 22px;
    cursor: pointer;
    list-style: none;
}

.accordion-summary::-webkit-details-marker {
    display: none;
}

.accordion-summary::marker {
    content: '';
}

.accordion-summary h2 {
    margin: 0;
}

.accordion-summary:focus-visible {
    outline: 3px solid rgba(96, 165, 250, 0.45);
    outline-offset: -6px;
    border-radius: 18px;
}

.accordion-arrow {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef4ff;
    color: var(--primary);
    line-height: 1;
}

.accordion-arrow svg {
    display: block;
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.accordion-content {
    padding: 0 22px 22px;
}

.history-head {
    margin-bottom: 14px;
}

.bulk-delete-form {
    margin: 0;
}

.button-danger {
    background: #dc2626;
    color: #ffffff;
}

.button-danger:hover {
    background: #b91c1c;
}

.button-danger:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.bulk-delete-btn {
    width: auto;
    min-height: 42px;
    margin-top: 0;
    padding: 10px 14px;
    font-size: 14px;
    white-space: nowrap;
}

.col-check,
.history-check {
    width: 48px;
    text-align: center;
}

.table-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin: 0;
    cursor: pointer;
}

.table-check input {
    width: 18px;
    height: 18px;
    margin: 0;
    padding: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 780px) {
    .accordion-summary {
        min-height: 66px;
        padding: 17px;
    }

    .accordion-content {
        padding: 0 17px 17px;
    }

    .accordion-arrow {
        flex-basis: 38px;
        width: 38px;
        height: 38px;
    }

    .accordion-arrow svg {
        width: 21px;
        height: 21px;
    }

    .history-head {
        align-items: stretch;
        flex-direction: column;
    }

    .bulk-delete-btn {
        width: 100%;
    }
}
