* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Segoe UI, Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: #f5f7fb;
    color: #333;
}

.app-loader {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 247, 251, 0.88);
    backdrop-filter: blur(2px);
}

.app-loader.hidden {
    display: none;
}

.app-loader-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    color: #1f2937;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(17, 24, 39, 0.12);
    font-size: 14px;
    font-weight: 600;
}

.page {
    width: 100%;
    min-height: 100vh;
}

.login-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.card {
    width: 100%;
    max-width: 450px;
    background: #ffffff;
    padding: 35px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.10);
}

.card h2 {
    text-align: center;
    margin-bottom: 10px;
}

.subtitle {
    text-align: center;
    color: #777;
    margin-bottom: 25px;
}

.card input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #d5d5d5;
    border-radius: 6px;
    font-size: 14px;
}

.card input:focus {
    outline: none;
    border-color: #2563eb;
}

.card button {
    width: 100%;
    padding: 12px;
    border: none;
    background: #2563eb;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
}

.card button:hover {
    background: #1d4ed8;
}

.password-rules {
    margin: 15px 0;
    background: #f8fafc;
    padding: 12px;
    border-radius: 6px;
}

.password-rules ul {
    margin-left: 20px;
}

.password-rules li {
    margin-bottom: 4px;
    font-size: 13px;
    color: #555;
}

.message {
    margin-top: 15px;
    text-align: center;
    color: #dc2626;
    font-weight: 600;
    min-height: 20px;
}

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 240px;
    height: 100vh;
    background: #111827;
    color: white;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar h3 {
    margin-bottom: 0;
    word-break: break-word;
    font-size: 15px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-client-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.admin-badge {
    background: #dc2626;
    color: #ffffff;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.admin-client-selector {
    margin-bottom: 16px;
}

.admin-client-selector label {
    display: block;
    margin-bottom: 5px;
    color: #9ca3af;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-client-selector select {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #374151;
    border-radius: 6px;
    background: #1f2937;
    color: #ffffff;
    font-size: 13px;
    cursor: pointer;
}

.sidebar a {
    display: block;
    text-decoration: none;
    color: white;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 4px;
    transition: background 0.2s;
    font-size: 14px;
}

.sidebar a:hover {
    background: #1f2937;
}

.content {
    margin-left: 240px;
    padding: 30px;
}

.content h1 {
    margin-bottom: 25px;
    font-size: 22px;
}

.content h2 {
    margin-bottom: 15px;
    font-size: 17px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.metric-card h3 {
    color: #6b7280;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.metric-card h2 {
    color: #2563eb;
    font-size: 28px;
    font-weight: 700;
}

.usage-breakdown {
    display: flex;
    gap: 28px;
}

.usage-breakdown > div {
    min-width: 0;
}

.usage-breakdown span {
    display: block;
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 4px;
}

.remaining-percent {
    font-size: 13px;
    color: #6b7280;
    margin-top: 6px;
}

/* Quota Warning */
.quota-warning {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 600;
    font-size: 14px;
}
.quota-warning.warning {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
}
.quota-warning.danger {
    background: #fee2e2;
    border: 1px solid #ef4444;
    color: #991b1b;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}
.chart-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.chart-card h3 {
    font-size: 14px;
    color: #374151;
    margin-bottom: 15px;
}
.chart-card canvas {
    max-height: 280px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    background: white;
    padding: 16px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.filters input {
    padding: 10px;
    border: 1px solid #d5d5d5;
    border-radius: 6px;
    font-size: 14px;
    min-width: 140px;
}

.filters input:focus {
    outline: none;
    border-color: #2563eb;
}

.filters button {
    padding: 10px 20px;
    border: none;
    background: #2563eb;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}

.filters button:hover {
    background: #1d4ed8;
}

table {
    width: 100%;
    background: white;
    border-collapse: collapse;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

table th {
    background: #2563eb;
    color: white;
    padding: 14px 16px;
    text-align: left;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
}

table tr:last-child td {
    border-bottom: none;
}

table tr:hover td {
    background: #f8fafc;
}

.record-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
}

.record-summary-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.record-count {
    font-size: 15px;
    font-weight: 700;
    color: #1e40af;
}

.record-shown {
    font-size: 12px;
    color: #6b7280;
}

.table-loading-cell {
    height: 160px;
    text-align: center;
    vertical-align: middle;
    background: #ffffff;
}

.loader-spinner {
    display: block;
    width: 28px;
    height: 28px;
    margin: 0 auto;
    border: 3px solid #dbeafe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: loader-spin 0.8s linear infinite;
}

@keyframes loader-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.pagination button {
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.pagination button.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}
.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-card {
    background: white;
    border-radius: 12px;
    padding: 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.modal-card h2 {
    margin-bottom: 6px;
    font-size: 18px;
}

.modal-card .subtitle {
    text-align: left;
    margin-bottom: 20px;
    font-size: 13px;
}

.modal-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 8px;
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.modal-field label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.modal-field input {
    padding: 10px;
    border: 1px solid #d5d5d5;
    border-radius: 6px;
    font-size: 14px;
}

.modal-field input:focus {
    outline: none;
    border-color: #2563eb;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.modal-actions .btn {
    flex: 1;
}

.btn-export {
    background: #059669;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-export:hover {
    background: #047857;
}

.btn-cancel {
    background: #6b7280;
}

.btn-cancel:hover {
    background: #4b5563;
}

.btn {
    border: none;
    background: #2563eb;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.btn:hover {
    background: #1d4ed8;
}

@media (max-width: 900px) {
    .metrics {
        grid-template-columns: 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 15px;
        gap: 8px;
    }

    .sidebar h3 {
        width: 100%;
        margin-bottom: 8px;
    }

    .sidebar a {
        margin-bottom: 0;
    }

    .content {
        margin-left: 0;
        padding: 20px 15px;
    }

    .filters {
        flex-direction: column;
        align-items: flex-start;
    }

    .filters input,
    .filters button {
        width: 100%;
    }

    table {
        display: block;
        overflow-x: auto;
    }
}
