:root {
    --brand: #0f766e;
    --brand-2: #0ea5a4;
    --brand-soft: #ccfbf1;
    --accent: #d97706;
    --danger: #b91c1c;
    --bg: #f4f7f4;
    --panel: #ffffff;
    --panel-2: #f8fafc;
    --text: #0f172a;
    --muted: #516171;
    --line: #dbe4ea;
    --shadow: 0 18px 45px rgba(8, 47, 73, 0.10);
}

* {
    box-sizing: border-box;
}

*::selection {
    background: rgba(13, 148, 136, 0.22);
    color: #052e2b;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Raleway", "Avenir Next", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 8% 5%, rgba(13, 148, 136, 0.18), transparent 26%),
        radial-gradient(circle at 92% 12%, rgba(217, 119, 6, 0.16), transparent 22%),
        linear-gradient(180deg, #ecf5f2 0%, var(--bg) 52%, #edf2f8 100%);
    position: relative;
}

body::before,
body::after {
    content: "";
    position: fixed;
    border-radius: 999px;
    pointer-events: none;
    z-index: -1;
}

body::before {
    width: 460px;
    height: 460px;
    left: -140px;
    top: 90px;
    background: radial-gradient(circle, rgba(14, 165, 164, 0.18), rgba(14, 165, 164, 0));
}

body::after {
    width: 420px;
    height: 420px;
    right: -120px;
    bottom: -30px;
    background: radial-gradient(circle, rgba(217, 119, 6, 0.18), rgba(217, 119, 6, 0));
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #5eead4, #14b8a6);
    border-radius: 10px;
}

::-webkit-scrollbar-track {
    background: #e7f2f2;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.4rem;
    padding: 1rem 1.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.55);
    background: linear-gradient(102deg, rgba(15, 118, 110, 0.93), rgba(14, 165, 164, 0.88));
    box-shadow: 0 10px 34px rgba(13, 58, 91, 0.22);
    backdrop-filter: blur(8px);
    overflow: hidden;
}

.topbar::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(240, 253, 250, 0.9), rgba(255, 255, 255, 0));
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
}

.brand img {
    height: 42px;
    width: auto;
    filter: drop-shadow(0 2px 8px rgba(9, 30, 66, 0.35));
    background: rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    padding: 0.24rem 0.45rem;
}

.brand-title {
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.brand-sub {
    color: rgba(244, 255, 254, 0.90);
    font-size: 0.78rem;
    letter-spacing: 0.03em;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-links a {
    text-decoration: none;
    color: #f0fdfa;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    padding: 0.56rem 0.85rem;
    border-radius: 999px;
    transition: all 160ms ease;
    border: 1px solid transparent;
}

.nav-links a:hover {
    color: #042f2e;
    background: rgba(255, 255, 255, 0.90);
    border-color: rgba(255, 255, 255, 0.8);
}

.nav-links a.active {
    color: #083344;
    background: linear-gradient(160deg, #ecfeff, #d1fae5);
    box-shadow: inset 0 0 0 1px rgba(6, 95, 70, 0.32);
}

.nav-links a.logout {
    border: 1px solid rgba(255, 255, 255, 0.45);
    color: #fee2e2;
    margin-left: 0.35rem;
}

.current-user {
    display: inline-flex;
    align-items: center;
    padding: 0.44rem 0.75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #ecfeff;
    font-weight: 700;
    font-size: 0.82rem;
}

.nav-links a.logout:hover {
    background: #fee2e2;
    color: #7f1d1d;
    border-color: #fee2e2;
}

.main {
    padding: 2rem 1rem 1.3rem;
    animation: fade-in 420ms ease;
}

.container {
    max-width: 1220px;
    margin: 0 auto;
}

.card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(248, 250, 252, 0.96));
    border: 1px solid rgba(219, 228, 234, 0.92);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    overflow-x: auto;
    position: relative;
}

.card::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 4px;
    background: linear-gradient(90deg, #14b8a6, #f59e0b, #0ea5a4);
    opacity: 0.75;
}

h1,
h2,
h3,
h4,
h5 {
    color: #062f4f;
    font-family: "Raleway", "Avenir Next", "Segoe UI", sans-serif;
    letter-spacing: 0.01em;
}

h1 {
    margin-top: 0;
    margin-bottom: 1.1rem;
    font-size: clamp(1.55rem, 2vw, 2.1rem);
    font-weight: 800;
    position: relative;
    padding-bottom: 0.42rem;
}

h1::after {
    content: "";
    display: block;
    width: 82px;
    height: 4px;
    margin-top: 0.32rem;
    border-radius: 999px;
    background: linear-gradient(90deg, #0ea5a4, #f59e0b);
}

p {
    color: #334155;
}

a {
    color: #0b7285;
}

a:hover {
    color: #0f766e;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid #d7e4ec;
}

thead tr {
    background: linear-gradient(180deg, #e2f3f0, #eaf3fb);
}

th,
td {
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
    padding: 0.78rem 0.7rem;
}

th {
    color: #0f2f4a;

        animation: slide-down 260ms ease;
    }

    .message.default {
        color: #1e3a8a;
        background: #eff6ff;
        border-color: #bfdbfe;
    }

    .message.success {
        color: #14532d;
        background: #ecfdf5;
        border-color: #86efac;
    }

    .message.warning {
        color: #713f12;
        background: #fffbeb;
        border-color: #fde68a;
    }

    .message.error {
        color: #7f1d1d;
        background: #fef2f2;
        border-color: #fecaca;
    }

    .legend-row {
        display: flex;
        flex-wrap: wrap;
        gap: 0.45rem;
        margin: 0 0 0.9rem;
    }

    .legend-chip,
    .validity-chip {
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
        padding: 0.38rem 0.62rem;
        border-radius: 999px;
        font-size: 0.8rem;
        font-weight: 800;
        letter-spacing: 0.01em;
    }

    .validity-cell {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.35rem;
    }

    .validity-date {
        color: #64748b;
        font-size: 0.82rem;
        font-weight: 600;
    }

    .validity-good {
        color: #14532d;
        background: #dcfce7;
        border: 1px solid #86efac;
    }

    .validity-warning {
        color: #92400e;
        background: #ffedd5;
        border: 1px solid #fdba74;
    }

    .validity-danger {
        color: #7f1d1d;
        background: #fee2e2;
        border: 1px solid #fca5a5;
    }

    .validity-expired {
        color: #7c2d12;
        background: #fef3c7;
        border: 1px solid #fcd34d;
    }

    .table-clean td:first-child,
    .table-clean th:first-child {
        text-align: left;
    }

    .pagination {
        display: flex;
        justify-content: center;
        gap: 0.36rem;
        margin-top: 1rem;
    }

    .pagination li {
        list-style: none;
    }

    .pagination a,
    .pagination span {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 36px;
        min-height: 36px;
        border: 1px solid #cbd5e1;
        border-radius: 10px;
        background: #ffffff;
        font-weight: 700;
        text-decoration: none;
    }

    .pagination .current {
        background: #d1fae5;
        border-color: #6ee7b7;
        color: #065f46;
    }
input[type="submit"]:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(20, 184, 166, 0.22);
    outline-offset: 2px;
}

button:hover,
.button:hover,
input[type="submit"]:hover {
    transform: translateY(-1px);
    filter: brightness(1.02);
    box-shadow: 0 12px 24px rgba(13, 148, 136, 0.35);
    color: #ffffff;
}

.button.button-clear {
    background: #ffffff;
    color: #0f766e;
    border: 1px solid #99f6e4;
    box-shadow: none;
}

.button.button-clear:hover {
    color: #115e59;
    background: #f0fdfa;
    border-color: #5eead4;
}

.actions a,
td a {
    font-weight: 700;
}

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

.page-subtitle {
    margin: 0;
    color: #4b5e70;
    font-weight: 600;
}

.page-head-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.stat-card {
    border: 1px solid #d3e3ec;
    border-radius: 14px;
    padding: 0.95rem;
    background: linear-gradient(155deg, #f7fffe, #eef7ff);
}

.stat-label {
    display: block;
    color: #456;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-value {
    display: block;
    margin-top: 0.3rem;
    font-size: 1.6rem;
    font-weight: 800;
    color: #0f766e;
}

.form-shell {
    border: 1px solid #d7e4ec;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff, #f7fbff);
    padding: 1rem;
}

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

.form-grid .input,
.form-grid .select {
    width: 100%;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    margin-top: 0.4rem;
}

.table-clean td,
.table-clean th {
    text-align: center;
    vertical-align: middle;
}

.actions-inline {
    display: inline-flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.button.button-danger {
    background: linear-gradient(135deg, #b91c1c, #ef4444);
    box-shadow: 0 8px 20px rgba(185, 28, 28, 0.3);
}

.button.button-danger:hover {
    box-shadow: 0 12px 24px rgba(185, 28, 28, 0.36);
}

.badge-role {
    display: inline-flex;
    align-items: center;
    padding: 0.24rem 0.52rem;
    border-radius: 999px;
    background: #ccfbf1;
    color: #0f766e;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: lowercase;
}

.filter-grid {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(150px, 180px) minmax(130px, 170px) auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 0.9rem;
}

.warning {
    color: #856404;
    background-color: #fff3cd;
}

.error {
    color: #721c24;
    background-color: #f8d7da;
}

.success {
    color: #155724;
    background-color: #d4edda;
}

td.text-center input[type="checkbox"] {
    display: inline-block;
    margin: 0 auto;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 0.9rem;
}

.detail-card {
    border: 1px solid #d7e4ec;
    border-radius: 14px;
    padding: 0.95rem;
    background: #ffffff;
}

.detail-card h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.token-box {
    grid-column: 1 / -1;
}

.token-box p {
    margin: 0.35rem 0 0;
    padding: 0.55rem;
    border: 1px solid #cecece;
    border-radius: 8px;
    word-break: break-word;
    background: #ffffff;
}

.danger-zone {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-start;
}

.message {
    border-radius: 12px;
    padding: 0.8rem 0.95rem;
    margin-bottom: 1rem;
    border: 1px solid;
    animation: slide-down 260ms ease;
}

.message.default {
    color: #1e3a8a;
    background: #eff6ff;
    border-color: #bfdbfe;
}

.message.success {
    color: #14532d;
    background: #ecfdf5;
    border-color: #86efac;
}

.message.warning {
    color: #713f12;
    background: #fffbeb;
    border-color: #fde68a;
}

.message.error {
    color: #7f1d1d;
    background: #fef2f2;
    border-color: #fecaca;
}

.legend-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0 0 0.9rem;
}

.legend-chip,
.validity-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.8rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.legend-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 999px;
    background: currentColor;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.65);
}

.validity-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.validity-date {
    color: #64748b;
    font-size: 0.9rem;
    font-weight: 600;
}

.validity-good {
    color: #14532d;
    background: #dcfce7;
    border: 1px solid #86efac;
}

.validity-warning {
    color: #92400e;
    background: #ffedd5;
    border: 1px solid #fdba74;
}

.validity-danger {
    color: #7f1d1d;
    background: #fee2e2;
    border: 1px solid #fca5a5;
}

.validity-infinite {
    color: #1e3a8a;
    background: #e0e7ff;
    border: 1px solid #a5b4fc;
}

.validity-expired {
    color: #7c2d12;
    background: #fef3c7;
    border: 1px solid #fcd34d;
}

.table-clean td:first-child,
.table-clean th:first-child {
    text-align: left;
}

.clients-table {
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #d1dee8;
}

.clients-table thead th {
    background: linear-gradient(180deg, #e9f5f4, #eef4fb);
}

.clients-table tbody tr {
    transition: background-color 160ms ease;
}

.clients-table tbody tr:hover {
    background: #ecfdf8;
}

.clients-table .row-expired {
    background: #fff5f5;
}

.table-note {
    margin: 0 0 0.75rem;
    color: #607283;
    font-weight: 700;
    font-size: 0.95rem;
}

.table-note-dot {
    display: inline-block;
    width: 0.46rem;
    height: 0.46rem;
    border-radius: 999px;
    background: #14b8a6;
    margin-right: 0.35rem;
    vertical-align: middle;
}

.client-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 800;
}

.client-link::before {
    content: "◉";
    color: #14b8a6;
    font-size: 0.72rem;
}

.uuid-code {
    font-family: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.25;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.34rem 0.62rem;
    display: inline-block;
}

.version-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.74rem;
    border-radius: 999px;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
    color: #075985;
    font-weight: 800;
    font-size: 0.9rem;
}

.server-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.38rem 0.72rem;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.server-prod {
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #166534;
}

.server-dev {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
}

.server-none {
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    color: #334155;
}

.bool-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    padding: 0.34rem 0.62rem;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.bool-pill.yes {
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #14532d;
}

.bool-pill.no {
    background: #fee2e2;
    border: 1px solid #fca5a5;
    color: #7f1d1d;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.36rem;
    margin-top: 1rem;
}

.pagination li {
    list-style: none;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #ffffff;
    font-weight: 700;
    text-decoration: none;
}

.pagination .current {
    background: #d1fae5;
    border-color: #6ee7b7;
    color: #065f46;
}

footer {
    text-align: center;
    color: #536274;
    font-weight: 600;
    margin: 0.8rem auto 1.4rem;
    font-size: 0.79rem;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-down {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 880px) {
    .topbar {
        position: static;
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
    }

    .nav-links {
        width: 100%;
        justify-content: flex-start;
        gap: 0.45rem;
    }

    .nav-links a {
        font-size: 0.84rem;
        padding: 0.5rem 0.74rem;
    }

    .current-user {
        font-size: 0.77rem;
        padding: 0.42rem 0.6rem;
    }

    .main {
        padding: 1rem 0.7rem;
    }

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

    th,
    td {
        padding: 0.63rem 0.52rem;
        font-size: 0.88rem;
    }

    h1 {
        font-size: 1.42rem;
    }

    .form-grid,
    .detail-grid,
    .filter-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        justify-content: stretch;
    }

    .form-actions .button {
        width: 100%;
    }

    .brand img {
        height: 36px;
    }

    body::before,
    body::after {
        display: none;
    }
}
