:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --accent: #2f80ed;
    --success: #16a34a;
    --danger: #dc2626;
    --muted: #6b7280;
    --border: #e6e9ee;
    --type-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --type-regular: 400;
    --type-medium: 500;
    --type-semibold: 600;
    --type-bold: 700;
    --type-heavy: 800;
    --action-primary: linear-gradient(90deg, #2f80ed, #4f46e5);
    --action-primary-hover: linear-gradient(90deg, #1e40af, #3730a3);
    --action-success: linear-gradient(90deg, #16a34a, #38bdf8);
    --action-success-hover: linear-gradient(90deg, #15803d, #0284c7);
    --action-secondary-bg: #ffffff;
    --action-secondary-text: #0f172a;
    --action-secondary-border: #dbe4ee;
    --action-danger-bg: #fef2f2;
    --action-danger-text: #b91c1c;
    --action-danger-border: #fecaca;
    --action-warning-bg: #fffbeb;
    --action-warning-text: #92400e;
    --action-warning-border: #fde68a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg);
    color: #1f2937;
    font-family: var(--type-family);
    font-weight: var(--type-regular);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Shared type hierarchy. Page styles may change spacing and color, not label weight. */
button,
input,
select,
textarea {
    font-family: var(--type-family);
}

button,
input[type="button"],
input[type="submit"],
input[type="reset"],
.btn {
    font-weight: var(--type-semibold);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: #0f172a;
    font-weight: var(--type-heavy);
}

label,
legend {
    font-weight: var(--type-semibold);
}

small,
.help-text,
.helper-text,
.muted {
    font-weight: var(--type-regular);
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    background: linear-gradient(135deg, var(--accent) 0%, #1e40af 100%);
    color: white;
    padding: 16px 18px;
    border-radius: 14px;
    margin-bottom: 18px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.header h1 {
    font-size: 18px;
    font-weight: var(--type-heavy);
    color: #ffffff;
    margin-bottom: 0;
    line-height: 1.1;
}

.header p {
    opacity: 0.9;
    font-size: 11px;
    line-height: 1.35;
    font-weight: var(--type-regular);
}

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    max-width: 100%;
    flex-wrap: nowrap;
}

.header-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    flex: 1 1 auto;
}

.header-actions {
    display: flex;
    gap: 7px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    flex: 0 0 auto;
    max-width: none;
    min-width: 0;
}

.header-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.16);
    color: white;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
    font-size: 11px;
    border: 1px solid rgba(255,255,255,0.24);
    transition: all 0.25s ease;
    white-space: nowrap;
    flex: 0 0 auto;
}

.header-link:hover {
    background: rgba(255,255,255,0.24);
    transform: translateY(-1px);
}

.header-link.is-strong {
    background: rgba(255,255,255,0.22);
}

.top-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
    text-decoration: none;
}

.btn:hover {
    background: #1e40af;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(47, 128, 237, 0.3);
}

.btn-blue {
    background: var(--action-primary);
}

.btn-blue:hover {
    background: var(--action-primary-hover);
    transform: translateY(-2px);
}

.btn-green {
    background: var(--action-success);
}

.btn-green:hover {
    background: var(--action-success-hover);
    transform: translateY(-2px);
}

.btn-grey {
    background: #6b7280;
    color: white;
    border: none;
}

.btn-grey:hover {
    background: #4b5563;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(107, 114, 128, 0.3);
}

.controls {
    background: var(--card);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.controls > div {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
}

.controls label {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 8px;
    color: #374151;
}

.controls select,
.controls input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: border-color 0.3s;
}

.controls select:focus,
.controls input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.1);
}

.controls button {
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
}

.controls button:hover {
    background: #1e40af;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(47, 128, 237, 0.3);
}

.table-container {
    background: var(--card);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background-color: #f9fafb;
    padding: 14px;
    text-align: left;
    font-weight: var(--type-heavy);
    font-size: 13px;
    color: #374151;
    border-bottom: 2px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody td {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

tbody tr {
    transition: background-color 0.2s;
}

tbody tr:hover {
    background-color: #f9fafb;
}

tbody tr:last-child td {
    border-bottom: none;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.action-btn {
    padding: 6px 12px;
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.action-btn:hover {
    background-color: #1e40af;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(47, 128, 237, 0.3);
}

.back-btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--muted);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    margin-top: 20px;
    cursor: pointer;
    border: none;
    font-size: 14px;
    transition: all 0.3s;
}

.back-btn:hover {
    background: #4b5563;
    transform: translateY(-2px);
}

.wa-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(circle at top left, rgba(47, 128, 237, 0.16), transparent 28%),
        radial-gradient(circle at bottom right, rgba(22, 163, 74, 0.14), transparent 24%),
        rgba(244, 246, 248, 0.84);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.wa-loading-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.wa-loading-panel {
    width: min(100%, 360px);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(230, 233, 238, 0.96);
    border-radius: 22px;
    box-shadow: 0 28px 60px rgba(30, 64, 175, 0.16);
    padding: 28px 24px;
    text-align: center;
}

.wa-loading-mark {
    width: 68px;
    height: 68px;
    margin: 0 auto 18px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(47, 128, 237, 0.12), rgba(22, 163, 74, 0.16));
}

.wa-loading-spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(47, 128, 237, 0.16);
    border-top-color: var(--accent);
    border-right-color: var(--success);
    animation: waSpin 0.85s linear infinite;
}

.wa-loading-title {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
}

.wa-loading-text {
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
}

body.wa-is-loading {
    overflow: hidden;
}

@keyframes waSpin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 800px) {
    .header {
        padding: 14px;
    }

    .header-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .header h1 {
        font-size: 16px;
    }

    .header-main,
    .header-actions {
        max-width: 100%;
        width: 100%;
    }

    .header-actions {
        justify-content: flex-start;
    }

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

    .controls {
        flex-direction: column;
    }

    .controls > div {
        width: 100%;
    }

    table {
        font-size: 12px;
    }

    thead th,
    tbody td {
        padding: 10px;
    }

    .action-btn {
        padding: 5px 10px;
        font-size: 11px;
    }

    .wa-loading-panel {
        padding: 24px 20px;
        border-radius: 18px;
    }

    .wa-loading-mark {
        width: 60px;
        height: 60px;
        border-radius: 18px;
    }
}
