*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #111827;
    background: #f3f4f6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

.page-header {
    background: linear-gradient(135deg, #1d4ed8, #6366f1);
    color: #f9fafb;
    padding: 16px 0;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.35);
}

.page-title {
    margin: 0 0 4px;
    font-size: 24px;
    font-weight: 600;
}

.page-subtitle {
    margin: 0;
    opacity: 0.9;
}

.page-main {
    padding: 16px 0 32px;
}

.page-footer {
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    font-size: 12px;
    color: #6b7280;
}

.filters {
    margin-bottom: 16px;
    background: #ffffff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
}

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

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
}

.filters-row-secondary {
    margin-top: 8px;
}

.field-inline {
    min-width: 120px;
}

.field {
    display: flex;
    flex-direction: column;
    min-width: 140px;
}

.field label {
    font-size: 12px;
    color: #4b5563;
    margin-bottom: 4px;
}

.field-hint {
    display: block;
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

.field input,
.field select {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.35);
}

.field-submit {
    align-self: flex-end;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    padding: 8px 18px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #f9fafb;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #4338ca);
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.4);
}

.btn-primary:disabled,
.btn-primary[disabled] {
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.btn-secondary {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 999px;
    border: 1px solid #2563eb;
    background: #fff;
    color: #2563eb;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #eff6ff;
}

.btn-secondary:disabled,
.btn-secondary[disabled] {
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.alert {
    margin-bottom: 16px;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13px;
}

.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.summary-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
}

.summary-card h2 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 18px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px 16px;
}

.summary-item {
    padding: 10px 12px;
    border-radius: 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
}

.summary-item-wide {
    grid-column: 1 / -1;
}

.summary-label {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}

.summary-value {
    font-size: 16px;
    font-weight: 600;
}

.summary-value-accent {
    color: #047857;
}

.summary-note {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #6b7280;
}

.table-section {
    margin-bottom: 20px;
}

.table-section h2 {
    margin: 0 0 8px;
    font-size: 16px;
}

.table-wrapper {
    background: #ffffff;
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead {
    background: #f3f4f6;
}

th,
td {
    padding: 8px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    white-space: nowrap;
}

th {
    font-weight: 600;
    font-size: 12px;
    color: #4b5563;
}

tbody tr:nth-child(even) {
    background: #f9fafb;
}

tbody tr:hover {
    background: #eef2ff;
}

.num {
    text-align: right;
}

.strong {
    font-weight: 600;
}

.hint {
    margin-top: 12px;
    font-size: 13px;
    color: #4b5563;
}

.hidden {
    display: none !important;
}

.api-key-panel {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
    border: 1px solid #e5e7eb;
}

.api-key-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.api-key-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.api-key-status {
    font-size: 12px;
    color: #6b7280;
}

.api-key-actions {
    display: flex;
    gap: 8px;
}

.api-key-note {
    margin: 8px 0 0;
    font-size: 11px;
    color: #6b7280;
}

.api-key-editor {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #e5e7eb;
}

.api-key-textarea {
    width: 100%;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
}

.api-key-editor-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

.field-label {
    display: block;
    font-size: 12px;
    color: #4b5563;
    margin-bottom: 4px;
}

.btn-danger {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid #b91c1c;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

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

.summary-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
}

.summary-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #4b5563;
    font-size: 11px;
    font-weight: 600;
    cursor: default;
    position: relative;
}

.summary-help:hover {
    background: #d1d5db;
}

.summary-help[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    z-index: 30;
    left: 50%;
    transform: translateX(-50%);
    bottom: 120%;
    max-width: 260px;
    padding: 6px 8px;
    border-radius: 6px;
    background: #111827;
    color: #f9fafb;
    font-size: 11px;
    line-height: 1.3;
    white-space: normal;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.4);
}

.invite-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 40;
}

.invite-modal {
    width: 100%;
    max-width: 360px;
    background: #ffffff;
    border-radius: 16px;
    padding: 20px 18px 16px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.4);
}

.invite-title {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 600;
}

.invite-text {
    margin: 0 0 12px;
    font-size: 13px;
    color: #4b5563;
}

.invite-field input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    font-size: 14px;
}

.invite-submit-btn {
    width: 100%;
    margin-top: 12px;
}

.invite-error {
    margin-top: 8px;
    font-size: 12px;
    color: #b91c1c;
}

.cooldown-label {
    margin-left: 12px;
    font-size: 12px;
    color: #6b7280;
}

.loading {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #4b5563;
}

.spinner {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 2px solid #d1d5db;
    border-top-color: #2563eb;
    animation: spinner-spin 0.75s linear infinite;
}

@keyframes spinner-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 768px) {
    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }

    .field-submit {
        align-self: stretch;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .btn-primary {
        width: 100%;
        text-align: center;
    }

    .field-submit .btn-secondary {
        margin-left: 0;
        width: 100%;
        text-align: center;
    }
}