:root {
    --bg: #f2f6f4;
    --bg-soft: #ffffff;
    --ink: #1b2b2e;
    --muted: #5c6b6f;
    --line: #d7e0dd;
    --primary: #0f766e;
    --primary-strong: #0a5a54;
    --success: #0f9d58;
    --danger: #c0392b;
    --warning: #f59e0b;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: "Manrope", sans-serif;
    background: radial-gradient(circle at 10% 10%, #d6efea 0%, #f2f6f4 35%, #eef2f7 100%);
    color: var(--ink);
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, #0d3f47 0%, #0f766e 100%);
    color: #f4fffc;
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.brand strong {
    display: block;
    font-size: 16px;
}

.brand small {
    display: block;
    opacity: 0.8;
    font-size: 12px;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu a {
    padding: 11px 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    opacity: 0.9;
}

.menu a:hover,
.menu a.active {
    background: rgba(255, 255, 255, 0.18);
    opacity: 1;
}

.content {
    padding: 24px;
}

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

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

.topbar p {
    margin: 4px 0 0;
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    padding: 8px 12px;
    border-radius: 999px;
}

.page-card {
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(13, 63, 71, 0.08);
}

.section-header {
    margin-bottom: 12px;
}

.section-header h2 {
    margin: 0;
    font-size: 21px;
}

.section-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.mt-24 {
    margin-top: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.stat-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    background: #fff;
}

.stat-card .icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #e7f8f5;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.stat-card h3 {
    margin: 0;
    font-size: 22px;
}

.stat-card p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 14px 0;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}

textarea {
    resize: vertical;
}

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
}

.inline-check input {
    width: auto;
}

.btn {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 10px 13px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: all 0.2s ease;
}

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

.btn-primary:hover {
    background: var(--primary-strong);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover {
    filter: brightness(0.92);
}

.btn-danger {
    background: #fff2f0;
    border-color: #f7c8c3;
    color: var(--danger);
}

.btn-danger:hover {
    background: #ffe4e1;
}

.btn-ghost {
    background: #fff;
    border-color: var(--line);
    color: #243c40;
}

.btn-ghost:hover {
    border-color: #b9c9c3;
}

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

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

th,
td {
    border-bottom: 1px solid #edf2f0;
    text-align: left;
    padding: 11px 10px;
    vertical-align: top;
    font-size: 14px;
}

th {
    background: #f9fcfb;
    color: #2f4a4f;
    font-size: 13px;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 700;
}

.badge-ok {
    background: #e7f9f0;
    color: #166c42;
}

.badge-off {
    background: #f3f4f7;
    color: #5d6671;
}

.badge-key-ok {
    background: #e7f9f0;
    color: #166c42;
}

.badge-key-warning {
    background: #fff6dd;
    color: #946200;
}

.badge-key-expired {
    background: #fff1ef;
    color: #a72f22;
}

.badge-key-none {
    background: #eef2f7;
    color: #4f6470;
}

.badge-key-off {
    background: #ebedf2;
    color: #59606a;
}

.license-alert-box {
    border: 1px solid #ffd7a1;
    background: linear-gradient(180deg, #fffaf0 0%, #fff4df 100%);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 12px;
}

.license-alert-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.license-alert-header strong {
    color: #7a4d00;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.license-alert-header span {
    color: #8a5f17;
    font-size: 13px;
    font-weight: 700;
}

.license-alert-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.license-alert-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 6px;
}

.license-alert-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid #f6d9a8;
    border-radius: 10px;
    padding: 8px 10px;
}

.license-alert-list strong {
    color: #5f3a00;
}

.license-alert-list span {
    color: #6f4f13;
    font-weight: 700;
}

.license-alert-list small {
    color: #7d6b4c;
}

tr.row-key-warning td {
    background: #fffbf1;
}

tr.row-key-expired td {
    background: #fff3f1;
}

tr.row-key-missing td {
    background: #f6f9fc;
}

tr.row-inactive td {
    background: #f5f7fa;
}

.actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.actions form {
    margin: 0;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    color: var(--muted);
    font-size: 14px;
}

.pager-links {
    display: flex;
    gap: 8px;
}

.pager-links a {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 10px;
    color: #224447;
    font-weight: 600;
}

.pager-links a:hover {
    border-color: #b9c9c3;
}

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

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

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    color: #274247;
    font-weight: 600;
    font-size: 14px;
}

.col-span-2 {
    grid-column: span 2;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}

.flash-stack {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.flash {
    border-radius: 10px;
    padding: 10px 12px;
    border: 1px solid;
    font-weight: 600;
}

.flash-success {
    background: #e9faf0;
    border-color: #b7eccf;
    color: #166c42;
}

.flash-error {
    background: #fff3f1;
    border-color: #ffd1ca;
    color: #a72f22;
}

.flash-warning {
    background: #fff9eb;
    border-color: #ffe3a1;
    color: #946200;
}

.flash-info {
    background: #eef6ff;
    border-color: #cadfff;
    color: #1f4f90;
}

.auth-body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 10% 20%, rgba(15, 118, 110, 0.28) 0%, rgba(15, 118, 110, 0) 35%),
        radial-gradient(circle at 90% 10%, rgba(18, 68, 109, 0.2) 0%, rgba(18, 68, 109, 0) 35%),
        linear-gradient(140deg, #0e2529 0%, #0f3f47 38%, #125f66 100%);
    color: #f5fffd;
}

.auth-wrapper {
    width: min(1040px, calc(100vw - 36px));
    margin: 28px auto;
}

.auth-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 22px;
    background: #fff;
    box-shadow: 0 20px 45px rgba(13, 63, 71, 0.08);
}

.auth-brand {
    text-align: left;
    margin-bottom: 18px;
}

.auth-brand h1 {
    margin: 10px 0 8px;
    font-size: 22px;
}

.auth-brand p {
    margin: 0;
    color: var(--muted);
}

.auth-shell {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 22px;
    align-items: stretch;
}

.auth-hero {
    border-radius: 22px;
    padding: 28px;
    background:
        linear-gradient(160deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.02) 100%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(5px);
}

.auth-hero h1 {
    margin: 14px 0 8px;
    font-size: 34px;
    line-height: 1.1;
    letter-spacing: -0.01em;
}

.auth-hero > p {
    margin: 0;
    color: rgba(240, 255, 251, 0.86);
    max-width: 42ch;
}

.auth-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.08);
}

.auth-feature-list {
    margin: 22px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 12px;
}

.auth-feature-list li {
    display: grid;
    grid-template-columns: 38px 1fr;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.auth-feature-list span {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.14);
}

.auth-card-elevated {
    background: #f8fffd;
    border: 1px solid #c5dad3;
    box-shadow: 0 28px 60px rgba(2, 26, 28, 0.34);
    padding: 28px 24px;
}

.auth-card-elevated .auth-brand .brand-mark {
    color: #fff;
    background: linear-gradient(150deg, #0f766e 0%, #0a5451 100%);
}

.auth-card-elevated .auth-brand h2 {
    margin: 10px 0 6px;
    color: #173035;
    font-size: 24px;
}

.auth-card-elevated .auth-brand p {
    color: #4f656a;
}

.auth-card-elevated label {
    color: #274247;
}

.auth-card-elevated input {
    border-color: #c9d8d3;
    background: #fff;
}

.auth-card-elevated input:focus {
    outline: none;
    border-color: #0f766e;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.btn-auth {
    justify-content: center;
    width: 100%;
    margin-top: 4px;
    padding: 12px 14px;
    font-size: 15px;
}

.auth-body .flash-stack {
    margin-bottom: 12px;
}

.auth-body .flash {
    background: rgba(255, 255, 255, 0.95);
}

@media (max-width: 1080px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        height: auto;
        position: static;
        border-bottom: 1px solid rgba(255, 255, 255, 0.22);
    }

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

    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-hero h1 {
        font-size: 30px;
    }
}

@media (max-width: 760px) {
    .content {
        padding: 14px;
    }

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

    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .col-span-2 {
        grid-column: auto;
    }

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

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .auth-wrapper {
        width: min(1040px, calc(100vw - 20px));
        margin: 12px auto;
    }

    .auth-hero,
    .auth-card-elevated {
        padding: 18px;
    }

    .auth-hero h1 {
        font-size: 26px;
    }

    .auth-feature-list li {
        grid-template-columns: 32px 1fr;
    }

    .auth-feature-list span {
        width: 32px;
        height: 32px;
    }

    .license-alert-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
