:root {
    color-scheme: dark;
    --surface: rgba(15, 23, 42, 0.76);
    --surface-strong: rgba(15, 23, 42, 0.96);
    --surface-muted: rgba(30, 41, 59, 0.58);
    --border: rgba(148, 163, 184, 0.14);
    --border-strong: rgba(148, 163, 184, 0.24);
    --text-muted: #94a3b8;
    --focus: #60a5fa;
}

* {
    box-sizing: border-box;
}

html {
    background: #020617;
}

body {
    min-width: 320px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 85% -10%, rgba(37, 99, 235, 0.16), transparent 30rem),
        radial-gradient(circle at 10% 100%, rgba(79, 70, 229, 0.10), transparent 27rem),
        #020617;
    color: #e2e8f0;
}

button, a, input, select {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.glass-card {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.82), rgba(15, 23, 42, 0.62));
    border: 1px solid var(--border);
    box-shadow: 0 20px 50px rgba(2, 6, 23, 0.25);
    backdrop-filter: blur(14px);
}

.animate-in {
    animation: fadeIn 0.35s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* General form and feedback styling */
input, select {
    width: 100%;
    padding: 0.7rem 0.8rem;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    color: #f8fafc;
    font-size: 0.875rem;
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

input::placeholder {
    color: #64748b;
}

input:hover, select:hover {
    border-color: var(--border-strong);
}

input:focus, select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

label {
    display: block;
    margin-bottom: 0.35rem;
    color: #cbd5e1;
    font-size: 0.8125rem;
    font-weight: 600;
}

/* Reusable server/client tables */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    padding: 0.9rem 1rem;
    color: #94a3b8;
    background: rgba(15, 23, 42, 0.5);
    border-bottom: 1px solid var(--border);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.09);
    color: #e2e8f0;
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background-color 150ms ease;
}

.data-table tbody tr:hover {
    background: rgba(30, 41, 59, 0.38);
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.table-panel {
    overflow-x: auto;
    border-radius: 1rem;
}

.server-url {
    display: block;
    max-width: 26rem;
    overflow: hidden;
    color: #94a3b8;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.server-action-grid {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.server-action {
    min-height: 2rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid transparent;
    border-radius: 0.55rem;
    background: transparent;
    font-size: 0.75rem;
    font-weight: 650;
    line-height: 1;
    transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.server-action:hover {
    transform: translateY(-1px);
}

.server-action-sync {
    color: #67e8f9;
    background: rgba(6, 182, 212, 0.08);
    border-color: rgba(6, 182, 212, 0.2);
}
.server-action-sync:hover { background: rgba(6, 182, 212, 0.16); }

.server-action-rebuild {
    color: #c4b5fd;
    background: rgba(139, 92, 246, 0.08);
    border-color: rgba(139, 92, 246, 0.2);
}
.server-action-rebuild:hover { background: rgba(139, 92, 246, 0.17); }

.server-action-clear {
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.2);
}
.server-action-clear:hover { background: rgba(245, 158, 11, 0.17); }

.server-action-edit {
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.18);
}
.server-action-edit:hover { background: rgba(59, 130, 246, 0.17); }

.server-action-danger {
    color: #fda4af;
    background: rgba(244, 63, 94, 0.08);
    border-color: rgba(244, 63, 94, 0.2);
}
.server-action-danger:hover { background: rgba(244, 63, 94, 0.17); }

.notice {
    padding: 0.8rem 0.95rem;
    border: 1px solid;
    border-radius: 0.8rem;
    font-size: 0.8125rem;
    line-height: 1.45;
}

.notice-error {
    color: #fecaca;
    background: rgba(127, 29, 29, 0.25);
    border-color: rgba(248, 113, 113, 0.25);
}

.notice-success {
    color: #bbf7d0;
    background: rgba(20, 83, 45, 0.25);
    border-color: rgba(74, 222, 128, 0.22);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-active { background: rgba(16, 185, 129, 0.1); color: #6ee7b7; }
.badge-inactive { background: rgba(239, 68, 68, 0.1); color: #fca5a5; }
.badge-expired { background: rgba(245, 158, 11, 0.1); color: #fcd34d; }
.badge-limit { background: rgba(139, 92, 246, 0.1); color: #c4b5fd; }

.toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 60;
    max-width: min(25rem, calc(100vw - 2rem));
    padding: 0.8rem 1rem;
    border-radius: 0.8rem;
    box-shadow: 0 16px 34px rgba(2, 6, 23, 0.38);
    font-size: 0.875rem;
    font-weight: 600;
    animation: slideIn 0.25s ease-out;
}
.toast-success { background: #047857; color: #ecfdf5; }
.toast-error { background: #b91c1c; color: #fff1f2; }

@keyframes slideIn {
    from { transform: translateY(0.6rem); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 767px) {
    body {
        background:
            radial-gradient(circle at 100% 0, rgba(37, 99, 235, 0.14), transparent 20rem),
            #020617;
    }

    .table-panel {
        overflow: visible;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .data-table, .data-table tbody, .data-table tr, .data-table td {
        display: block;
        width: 100%;
    }

    .data-table {
        min-width: 0 !important;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody {
        display: grid;
        gap: 0.75rem;
    }

    .data-table tbody tr {
        overflow: hidden;
        border: 1px solid var(--border);
        border-radius: 1rem;
        background: linear-gradient(145deg, rgba(15, 23, 42, 0.86), rgba(15, 23, 42, 0.64));
        box-shadow: 0 10px 24px rgba(2, 6, 23, 0.2);
    }

    .data-table tbody tr:hover {
        background: linear-gradient(145deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.7));
    }

    .data-table td {
        display: grid;
        grid-template-columns: 6.5rem minmax(0, 1fr);
        align-items: center;
        gap: 0.75rem;
        min-height: 2.8rem;
        padding: 0.7rem 0.9rem;
        border-bottom: 1px solid rgba(148, 163, 184, 0.09);
        text-align: left !important;
    }

    .data-table td::before {
        content: attr(data-label);
        color: #94a3b8;
        font-size: 0.68rem;
        font-weight: 700;
        letter-spacing: 0.07em;
        text-transform: uppercase;
    }

    .data-table td.table-primary {
        display: block;
        padding: 1rem 0.9rem 0.75rem;
    }

    .data-table td.table-primary::before {
        display: none;
    }

    .data-table td.table-actions {
        display: block;
        padding-bottom: 0.9rem;
    }

    .data-table td.table-actions::before {
        display: block;
        margin-bottom: 0.55rem;
    }

    .server-url {
        max-width: 100%;
        overflow-wrap: anywhere;
        text-overflow: clip;
        white-space: normal;
    }

    .server-action-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.45rem;
    }

    .server-action {
        width: 100%;
        min-height: 2.35rem;
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .toast {
        right: 0.75rem;
        bottom: 0.75rem;
        max-width: calc(100vw - 1.5rem);
    }
}

@media (max-width: 420px) {
    .data-table td {
        grid-template-columns: 5.7rem minmax(0, 1fr);
        gap: 0.5rem;
        padding-inline: 0.75rem;
    }
}
