:root {
    color-scheme: light;
    font-family:
        Arial,
        "Noto Sans Thai",
        sans-serif;
    background: #f3f6fb;
    color: #172033;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(
            180deg,
            #eef4ff 0%,
            #f7f9fc 45%,
            #f3f6fb 100%
        );
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-wrapper {
    width: 100%;
    max-width: 430px;
}

.login-card,
.error-card {
    background: #ffffff;
    border: 1px solid #dfe6f1;
    border-radius: 20px;
    box-shadow:
        0 20px 55px
        rgba(27, 47, 82, 0.12);
    padding: 38px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin: 0 auto 18px;
    border-radius: 16px;
    background: #195bd8;
    color: #ffffff;
    font-weight: 800;
    letter-spacing: 1px;
}

.login-card h1 {
    margin: 0;
    text-align: center;
    font-size: 28px;
}

.subtitle {
    margin: 10px 0 28px;
    text-align: center;
    color: #63708a;
}

.login-form {
    display: grid;
    gap: 10px;
}

.login-form label {
    margin-top: 8px;
    font-weight: 700;
    font-size: 14px;
}

.login-form input {
    width: 100%;
    min-height: 46px;
    border: 1px solid #cfd8e8;
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
}

.login-form input:focus {
    border-color: #195bd8;
    box-shadow:
        0 0 0 3px
        rgba(25, 91, 216, 0.12);
}

.login-form button {
    min-height: 48px;
    margin-top: 14px;
    border: 0;
    border-radius: 10px;
    background: #195bd8;
    color: #ffffff;
    font-weight: 700;
}

.login-form button:hover {
    background: #104ebf;
}

.security-note {
    margin: 24px 0 0;
    text-align: center;
    color: #7b879d;
    font-size: 12px;
}

.alert {
    margin-bottom: 16px;
    border-radius: 10px;
    padding: 12px 14px;
}

.alert-error {
    border: 1px solid #f3b8b8;
    background: #fff1f1;
    color: #a22626;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    padding: 12px 28px;
    background: #ffffff;
    border-bottom: 1px solid #dfe6f1;
}

.environment-label {
    margin-left: 10px;
    border-radius: 999px;
    background: #e8f0ff;
    color: #195bd8;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 700;
}

.button-secondary {
    border: 1px solid #ccd6e7;
    border-radius: 9px;
    background: #ffffff;
    color: #263249;
    padding: 9px 14px;
}

.dashboard-container {
    width: min(1180px, calc(100% - 36px));
    margin: 34px auto;
}

.welcome-panel,
.content-panel {
    background: #ffffff;
    border: 1px solid #dfe6f1;
    border-radius: 18px;
    padding: 28px;
    box-shadow:
        0 12px 30px
        rgba(27, 47, 82, 0.07);
}

.welcome-panel h1 {
    margin: 6px 0 8px;
}

.welcome-panel p {
    color: #63708a;
}

.eyebrow {
    margin: 0;
    color: #195bd8 !important;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1.5px;
}

.summary-grid {
    display: grid;
    grid-template-columns:
        repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin: 22px 0;
}

.summary-card {
    display: grid;
    gap: 9px;
    min-height: 150px;
    background: #ffffff;
    border: 1px solid #dfe6f1;
    border-radius: 16px;
    padding: 22px;
}

.summary-card span {
    color: #63708a;
    font-size: 14px;
}

.summary-card strong {
    font-size: 34px;
}

.summary-card small {
    color: #8b96a9;
}

.content-panel h2 {
    margin-top: 0;
}

.feature-grid {
    display: grid;
    grid-template-columns:
        repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.feature-grid div {
    border: 1px solid #dfe6f1;
    border-radius: 12px;
    background: #f8faff;
    padding: 18px;
    font-weight: 700;
}

.error-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.error-card {
    width: min(500px, 100%);
    text-align: center;
}

.error-card a {
    display: inline-block;
    margin-top: 12px;
    color: #195bd8;
    font-weight: 700;
}

@media (max-width: 850px) {
    .summary-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .feature-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .login-card {
        padding: 28px 22px;
    }

    .topbar {
        padding: 12px 16px;
    }

    .dashboard-container {
        width: min(
            100% - 24px,
            1180px
        );
        margin: 20px auto;
    }

    .summary-grid,
    .feature-grid {
        grid-template-columns: 1fr;
    }

    .welcome-panel,
    .content-panel {
        padding: 22px;
    }
}

.welcome-row,
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.refresh-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid #cbd6e8;
    border-radius: 10px;
    background: #ffffff;
    color: #195bd8;
    padding: 9px 16px;
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
}

.refresh-button:hover {
    background: #f1f6ff;
}

.dashboard-alert {
    margin: 22px 0 0;
}

.section-heading {
    margin-bottom: 20px;
}

.section-heading h2 {
    margin: 6px 0 0;
}

.record-count {
    border-radius: 999px;
    background: #edf3ff;
    color: #195bd8;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 700;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.members-table {
    width: 100%;
    min-width: 850px;
    border-collapse: collapse;
}

.members-table th,
.members-table td {
    border-bottom: 1px solid #e2e8f2;
    padding: 15px 13px;
    text-align: left;
    vertical-align: middle;
}

.members-table th {
    background: #f7f9fd;
    color: #65718a;
    font-size: 13px;
    font-weight: 700;
}

.members-table tbody tr:hover {
    background: #fafcff;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.status-active {
    background: #e9f8ef;
    color: #16723a;
}

.status-revoked {
    background: #fff0f0;
    color: #ac2929;
}

.status-unknown {
    background: #f0f2f5;
    color: #596274;
}

.expiry-note,
.expiry-warning {
    display: block;
    margin-top: 5px;
}

.expiry-note {
    color: #7c879b;
}

.expiry-warning {
    color: #b65a00;
    font-weight: 700;
}

.empty-state {
    border: 1px dashed #ccd6e7;
    border-radius: 12px;
    background: #fafcff;
    color: #69758d;
    padding: 30px;
    text-align: center;
}

@media (max-width: 650px) {
    .welcome-row,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .refresh-button {
        width: 100%;
    }
}

.license-result {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        minmax(360px, 1fr);
    gap: 24px;
    margin: 22px 0;
    border: 1px solid #9dd9b5;
    border-radius: 18px;
    background: #f1fbf5;
    padding: 26px;
}

.license-result h2 {
    margin: 6px 0 12px;
}

.license-result p {
    margin: 7px 0;
}

.license-key-box {
    border: 1px solid #b9dfc8;
    border-radius: 14px;
    background: #ffffff;
    padding: 18px;
}

.license-key-box > span {
    display: block;
    margin-bottom: 9px;
    color: #65718a;
    font-size: 13px;
    font-weight: 700;
}

.license-key-row {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.license-key-row code {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
    border: 1px solid #d4ddeb;
    border-radius: 9px;
    background: #f7f9fc;
    padding: 11px 12px;
    font-family:
        Consolas,
        monospace;
    font-size: 15px;
    font-weight: 700;
}

.license-key-box small {
    display: block;
    margin-top: 10px;
    color: #7b6854;
}

.copy-button {
    border: 0;
    border-radius: 9px;
    background: #16723a;
    color: #ffffff;
    padding: 10px 15px;
    font-weight: 700;
    white-space: nowrap;
}

.create-member-panel {
    margin-bottom: 22px;
}

.create-member-form {
    display: grid;
    grid-template-columns:
        minmax(240px, 2fr)
        minmax(130px, 0.7fr)
        minmax(145px, 0.8fr)
        auto;
    align-items: end;
    gap: 14px;
}

.form-field {
    display: grid;
    gap: 7px;
}

.form-field label {
    color: #3d4960;
    font-size: 13px;
    font-weight: 700;
}

.form-field input,
.form-field select {
    width: 100%;
    min-height: 44px;
    border: 1px solid #ccd6e7;
    border-radius: 10px;
    background: #ffffff;
    padding: 9px 11px;
    outline: none;
    font: inherit;
}

.form-field input:focus,
.form-field select:focus {
    border-color: #195bd8;
    box-shadow:
        0 0 0 3px
        rgba(25, 91, 216, 0.12);
}

.primary-button {
    min-height: 44px;
    border: 0;
    border-radius: 10px;
    background: #195bd8;
    color: #ffffff;
    padding: 10px 19px;
    font-weight: 700;
    white-space: nowrap;
}

.primary-button:hover {
    background: #104ebf;
}

.form-note {
    margin: 14px 0 0;
    color: #7c879b;
    font-size: 13px;
}

@media (max-width: 900px) {
    .create-member-form {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .form-field-email {
        grid-column:
            1 / -1;
    }

    .form-action {
        display: grid;
    }
}

@media (max-width: 700px) {
    .license-result {
        grid-template-columns: 1fr;
    }

    .license-key-row {
        flex-direction: column;
    }

    .create-member-form {
        grid-template-columns: 1fr;
    }

    .form-field-email {
        grid-column: auto;
    }

    .primary-button {
        width: 100%;
    }
}

.alert-success {
    border: 1px solid #9dd9b5;
    background: #eefaf3;
    color: #146936;
}

.actions-cell {
    min-width: 285px;
}

.member-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}

.inline-action-form {
    display: inline-flex;
    margin: 0;
}

.action-button {
    min-height: 34px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.action-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.action-extend {
    border-color: #b9cdf4;
    background: #edf3ff;
    color: #195bd8;
}

.action-enable {
    border-color: #a9d9bc;
    background: #eaf8ef;
    color: #16723a;
}

.action-disable {
    border-color: #f0b5b5;
    background: #fff0f0;
    color: #a72a2a;
}

.action-reset {
    border-color: #d6c7a6;
    background: #fff9eb;
    color: #815d13;
}

.admin-dialog {
    width: min(480px, calc(100% - 30px));
    border: 0;
    border-radius: 18px;
    padding: 0;
    box-shadow:
        0 24px 70px
        rgba(18, 35, 66, 0.28);
}

.admin-dialog::backdrop {
    background:
        rgba(16, 27, 48, 0.55);
}

.dialog-form {
    display: grid;
    gap: 20px;
    padding: 28px;
}

.dialog-heading h2 {
    margin: 6px 0 10px;
}

.dialog-heading p:last-child {
    margin-bottom: 0;
    color: #63708a;
    overflow-wrap: anywhere;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}

@media (max-width: 560px) {
    .actions-cell {
        min-width: 245px;
    }

    .member-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .inline-action-form,
    .action-button {
        width: 100%;
    }

    .dialog-actions {
        flex-direction: column-reverse;
    }

    .dialog-actions button {
        width: 100%;
    }
}
