:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #667085;
    --line: #d9e0e7;
    --blue: #2563eb;
    --blue-dark: #1e40af;
    --red: #dc2626;
    --red-soft: #fee2e2;
    --black-soft: #111827;
    --green: #15803d;
    --green-soft: #dcfce7;
    --gray-soft: #eef2f7;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: var(--app-font-size, 14px)/1.45 Arial, Helvetica, sans-serif;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    padding: 18px 24px;
    background: #172033;
    color: #fff;
}

.topbar h1 {
    margin: 0 0 2px;
    font-size: 22px;
}

.topbar span {
    color: #b9c3d2;
}

.topbar nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.topbar a,
.top-button {
    color: #fff;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 6px;
    background: transparent;
    min-height: 0;
}

.layout {
    padding: 20px;
}

.is-hidden {
    display: none;
}

.panel,
.content {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.form-panel {
    padding: 18px;
    align-self: start;
    position: sticky;
    top: 14px;
}

.content {
    padding: 16px;
    min-width: 0;
}

h2 {
    margin: 0 0 16px;
    font-size: 20px;
}

.section-title {
    margin-top: 24px;
}

.stack {
    display: grid;
    gap: 12px;
}

.grid2,
.grid3 {
    display: grid;
    gap: 12px;
}

.grid2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid3 {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
}

label {
    display: grid;
    gap: 6px;
    color: #344054;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #c9d3df;
    border-radius: 6px;
    padding: 9px 10px;
    color: var(--text);
    background: #fff;
    font: inherit;
}

textarea {
    resize: vertical;
}

fieldset {
    border: 1px solid var(--line);
    border-radius: 6px;
    margin: 0;
    padding: 12px;
}

legend {
    padding: 0 6px;
    font-weight: 700;
}

.checks {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.checks label,
.check {
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 400;
}

.checks input,
.check input {
    width: auto;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border: 1px solid #c9d3df;
    border-radius: 6px;
    padding: 8px 12px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    white-space: nowrap;
}

.primary {
    border-color: var(--blue);
    background: var(--blue);
    color: #fff;
}

.primary:hover {
    background: var(--blue-dark);
}

.danger {
    border-color: #fecaca;
    background: #fff1f2;
    color: #b91c1c;
}

.small {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 12px;
}

.actions,
.row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-view {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 20px;
    gap: 3px;
    align-items: start;
}

.inline-view > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pencil {
    min-width: 20px;
    min-height: 20px;
    width: 20px;
    height: 20px;
    padding: 0;
    border-radius: 50%;
    font-size: 11px;
    line-height: 1;
    color: #344054;
}

.inline-form {
    display: none;
    gap: 6px;
    min-width: 180px;
}

td.is-editing .inline-view {
    display: none;
}

td.is-editing .inline-form {
    display: grid;
}

.notice,
.alert {
    padding: 10px 12px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.notice {
    background: var(--green-soft);
    color: #14532d;
}

.alert {
    background: var(--red-soft);
    color: #991b1b;
}

.filters {
    display: grid;
    grid-template-columns: repeat(6, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

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

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

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #eef2f7;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .02em;
}

tr.expires-soon td {
    background: #fff1f2;
}

tr.expired td {
    background: #e5e7eb;
    color: #000;
    font-weight: 800;
}

.name {
    min-width: 190px;
    font-weight: 700;
}

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

.status {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status-active {
    color: var(--green);
    background: var(--green-soft);
}

.status-not_found,
.status-revoked {
    color: #b91c1c;
    background: var(--red-soft);
}

.status-draft {
    color: #475467;
    background: var(--gray-soft);
}

.file-chip,
.file-preview {
    display: inline-grid;
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: center;
    gap: 7px;
}

.file-chip {
    max-width: 180px;
    padding: 4px 7px;
    border-radius: 6px;
    background: #eef6ff;
    vertical-align: top;
}

.file-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 0 6px 6px 0;
    vertical-align: top;
}

.download-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid #c9d3df;
    border-radius: 6px;
    background: #fff;
    font-weight: 800;
}

.danger-icon {
    color: #b91c1c;
    border-color: #fecaca;
    background: #fff1f2;
    min-height: 30px;
    padding: 0;
}

.file-chip img,
.file-preview img,
.file-chip span,
.file-preview span {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    background: #dbeafe;
}

.file-chip span,
.file-preview span {
    display: grid;
    place-items: center;
    color: #1d4ed8;
    font-size: 9px;
    font-weight: 800;
}

.file-chip b,
.file-preview b {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 400;
}

.files-list {
    display: grid;
    gap: 8px;
}

.file-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.empty {
    padding: 40px;
    text-align: center;
    color: var(--muted);
}

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

.login-box,
.error-box {
    width: min(420px, calc(100vw - 32px));
    padding: 24px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.login-box h1,
.error-box h1 {
    margin: 0 0 18px;
}

.login-box form {
    display: grid;
    gap: 12px;
}

pre {
    overflow: auto;
    padding: 12px;
    background: #111827;
    color: #fff;
    border-radius: 6px;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 14px 0 0;
}

.pagination a,
.pagination strong,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.pagination strong {
    color: #fff;
    border-color: var(--blue);
    background: var(--blue);
}

.pagination > span:first-child {
    min-width: auto;
    color: var(--muted);
    border: 0;
    background: transparent;
}

.pagination .dots {
    border: 0;
    background: transparent;
}

.modal-open {
    overflow: hidden;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, .56);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    width: min(840px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    overflow: auto;
    padding: 18px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, .28);
}

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

.modal-head h2 {
    margin: 0;
}

.modal-close {
    width: 36px;
    min-height: 36px;
    padding: 0;
    font-size: 24px;
}

@media (max-width: 1100px) {
    .layout {
        padding: 14px;
    }

    .form-panel {
        position: static;
    }

    .filters {
        grid-template-columns: repeat(3, minmax(130px, 1fr));
    }
}

@media (max-width: 720px) {
    .topbar,
    .layout {
        padding: 14px;
    }

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

    .grid2,
    .grid3,
    .filters {
        grid-template-columns: 1fr;
    }
}
