:root {
    --bg-1: #f0f7ff;
    --bg-2: #fff9f2;
    --ink: #172033;
    --ink-soft: #576076;
    --line: #d4deee;
    --card: #ffffffee;
    --brand: #1f6feb;
    --brand-2: #2ea043;
    --danger: #d1242f;
    --accent: #0ea5a8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: "Manrope", "Segoe UI", sans-serif;
    min-height: 100vh;
    background: linear-gradient(130deg, var(--bg-1), var(--bg-2));
}

.bg-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 10% 10%, #1f6feb1f, transparent 45%),
        radial-gradient(circle at 90% 80%, #2ea0432a, transparent 40%);
}

.shell {
    position: relative;
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 16px 44px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: end;
    margin-bottom: 18px;
}

.header-sub {
    margin-top: 6px;
}

.eyebrow {
    margin: 0;
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

h1,
h2,
h3,
p {
    margin: 0;
}

.card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    background: var(--card);
    backdrop-filter: blur(6px);
    box-shadow: 0 16px 34px #17203312;
}

.login-card {
    max-width: 460px;
}

.stack {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    color: var(--ink);
    background: #fff;
}

textarea {
    resize: vertical;
}

.btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 700;
    font: inherit;
    transition: transform 0.12s ease, filter 0.15s ease;
}

.btn:hover {
    filter: brightness(0.97);
}

.btn:active {
    transform: translateY(1px);
}

.btn.solid {
    color: #fff;
    background: linear-gradient(120deg, var(--brand), #0f57c6);
}

.btn.ghost {
    color: var(--ink);
    background: #edf2fb;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn.warn {
    background: var(--danger);
    color: #fff;
}

.dashboard-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.api-hint {
    margin-bottom: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.stat-card {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: linear-gradient(135deg, #ffffff, #f6f9ff);
}

.stat-label {
    color: var(--ink-soft);
    font-size: 12px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 18px;
    font-weight: 800;
}

.table-wrap {
    overflow-x: auto;
    max-height: 66vh;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.search-group {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 280px;
}

.search-group input {
    flex: 1;
}

.pager-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

#resultSummary {
    margin-bottom: 8px;
}

.loading-text {
    margin: 6px 0 10px;
    color: var(--accent);
    font-weight: 700;
}

.pagination {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#jumpPageInput {
    width: 100px;
}

.inline-input,
.inline-textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 8px;
    font: inherit;
    font-size: 13px;
}

.inline-textarea {
    min-height: 56px;
    resize: vertical;
}

.inline-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-actions .btn.saving {
    background: linear-gradient(120deg, #5d7fb6, #4d6ea8);
}

.row-saving-badge {
    display: inline-block;
    margin-top: 8px;
    font-size: 12px;
    color: var(--accent);
    font-weight: 700;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f3f7ff;
    border-bottom: 1px solid var(--line);
}

th,
td {
    border-bottom: 1px solid var(--line);
    text-align: left;
    padding: 10px;
    font-size: 14px;
    vertical-align: top;
}

tbody tr:nth-child(2n) {
    background: #f8fbff;
}

tbody tr:hover {
    background: #eef5ff;
}

.virtual-spacer td {
    padding: 0;
    border: 0;
    background: transparent;
}

td code {
    font-size: 12px;
    color: var(--ink-soft);
}

.muted {
    color: var(--ink-soft);
    font-size: 13px;
}

dialog {
    border: none;
    border-radius: 12px;
    width: min(680px, 96vw);
    padding: 0;
}

dialog::backdrop {
    background: #17203380;
}

#editForm {
    padding: 18px;
}

.dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 8px;
}

.toast {
    position: fixed;
    right: 14px;
    bottom: 14px;
    color: #fff;
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: 0 8px 24px #17203333;
    background: var(--brand-2);
}

.toast.error {
    background: var(--danger);
}

@media (max-width: 768px) {
    .shell {
        padding: 14px 12px 20px;
    }

    .card {
        padding: 14px;
    }

    .topbar {
        align-items: center;
    }

    .pagination {
        justify-content: space-between;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

body[data-density="compact"] th,
body[data-density="compact"] td {
    padding: 7px 8px;
    font-size: 12px;
}

body[data-density="compact"] .inline-input,
body[data-density="compact"] .inline-textarea {
    font-size: 12px;
    padding: 5px 6px;
}

.days-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
}

.days-ok {
    color: #0f5132;
    background: #d1f2de;
}

.days-soon {
    color: #7a4f01;
    background: #ffe8b5;
}

.days-urgent {
    color: #842029;
    background: #f8d7da;
}

.days-expired {
    color: #842029;
    background: #f5c2c7;
}

.days-neutral {
    color: #374151;
    background: #e5e7eb;
}

.advanced-row td {
    background: #f7faff;
}

.advanced-panel {
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 1px dashed var(--line);
    border-radius: 10px;
}