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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    color: #333;
}

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

/* Header */
.admin-header {
    background: white;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    flex: 1;
}

.admin-logo {
    height: 80px;
    width: auto;
    display: block;
    margin: 0 auto;
}

.admin-header h1 {
    font-size: 28px;
    color: #1a1a1a;
    margin-bottom: 4px;
    font-weight: 600;
    text-align: center;
}

.admin-header p {
    color: #666;
    font-size: 14px;
    text-align: center;
}

.admin-header p {
    color: #666;
    font-size: 14px;
}

.header-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-refresh, .btn-back, .btn-export {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-export {
    background: #059669;
    color: white;
    border: none;
}

.btn-export:hover {
    background: #047857;
    transform: translateY(-1px);
}

.btn-refresh {
    background: #1a1a1a;
    color: white;
    border: none;
}

.btn-refresh:hover {
    background: #333;
    transform: translateY(-1px);
}

.btn-back {
    background: #f3f4f6;
    color: #333;
    border: 1px solid #e5e7eb;
}

.btn-back:hover {
    background: #e5e7eb;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #1a1a1a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 16px;
    color: #666;
    font-size: 16px;
}

/* Error Banner */
.error-banner {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 24px;
}

/* Dashboard Content */
.dashboard-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.metrics-section {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
}

.metrics-section h2 {
    font-size: 20px;
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f3f4f6;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.metric-card {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    color: #1a1a1a;
    transition: all 0.2s ease;
}

.metric-card:hover {
    border-color: #d1d5db;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.metric-icon {
    font-size: 32px;
    opacity: 0.6;
}

.metric-content {
    flex: 1;
}

.metric-label {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 28px;
    font-weight: 600;
    color: #1a1a1a;
}

.metric-change {
    font-size: 12px;
    margin-top: 4px;
    color: #6b7280;
}

.metric-change.positive {
    color: #059669;
}

.metric-change.negative {
    color: #dc2626;
}

/* Period Stats */
.period-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.period-card {
    background: #f9fafb;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #e5e7eb;
}

.period-card h3 {
    font-size: 16px;
    color: #1a1a1a;
    margin-bottom: 16px;
    font-weight: 600;
}

.period-metrics {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.period-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.period-label {
    color: #666;
    font-size: 14px;
}

.period-value {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

/* Chart */
.chart-container {
    background: #f9fafb;
    border-radius: 8px;
    padding: 20px;
    height: 300px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    border: 1px solid #e5e7eb;
}

.chart-bar {
    flex: 1;
    background: #1a1a1a;
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: all 0.2s ease;
    min-height: 20px;
}

.chart-bar:hover {
    background: #333;
}

.chart-bar-label {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: #666;
    white-space: nowrap;
}

.chart-bar-value {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: 600;
    color: #333;
}

/* Peak Hours */
.peak-hours-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.peak-hour-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.peak-hour-time {
    font-weight: 600;
    color: #1a1a1a;
}

.peak-hour-count {
    color: #666;
    font-size: 14px;
}

/* Questions List */
.questions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.question-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.question-text {
    flex: 1;
    color: #333;
    font-size: 14px;
}

.question-count {
    background: #1a1a1a;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* Table */
.table-container {
    overflow-x: auto;
}

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

.queries-table th {
    background: #f9fafb;
    padding: 12px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid #e5e7eb;
}

.queries-table td {
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
}

.queries-table tbody tr:hover {
    background: #f9fafb;
}

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

.status-success {
    background: #d1fae5;
    color: #065f46;
}

.status-error {
    background: #fee2e2;
    color: #991b1b;
}

/* Footer */
.admin-footer {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-top: 24px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
}

.admin-footer p {
    margin: 4px 0;
}

/* Responsive */
@media (max-width: 768px) {
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .period-stats {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 200px;
    }
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-box {
    background: white;
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.login-logo {
    max-width: 200px;
    height: auto;
    margin: 0 auto 24px;
    display: block;
}

.login-box h2 {
    font-size: 24px;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.login-box p {
    color: #6b7280;
    margin-bottom: 24px;
    font-size: 14px;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#admin-password {
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

#admin-password:focus {
    outline: none;
    border-color: #1a1a1a;
}

#login-form button {
    padding: 12px 24px;
    background: #1a1a1a;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

#login-form button:hover {
    background: #333;
}

.login-error {
    color: #dc2626;
    font-size: 13px;
    padding: 8px;
    background: #fee2e2;
    border-radius: 4px;
    border: 1px solid #fecaca;
}

.back-link {
    display: inline-block;
    margin-top: 16px;
    color: #6b7280;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.back-link:hover {
    color: #1a1a1a;
}

/* Budget Metrics */
.budget-overview {
    margin-bottom: 20px;
}

.budget-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 24px;
    color: white;
}

.budget-card h3 {
    font-size: 18px;
    margin-bottom: 16px;
    opacity: 0.95;
}

.budget-amount {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 16px;
}

.budget-used {
    font-size: 36px;
    font-weight: 700;
}

.budget-separator {
    font-size: 24px;
    opacity: 0.7;
}

.budget-total {
    font-size: 24px;
    font-weight: 500;
    opacity: 0.9;
}

.budget-progress-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.budget-progress-bar {
    flex: 1;
    height: 12px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    overflow: hidden;
}

.budget-progress-fill {
    height: 100%;
    background: white;
    border-radius: 6px;
    transition: width 0.5s ease, background-color 0.3s ease;
}

.budget-progress-text {
    font-size: 16px;
    font-weight: 600;
    min-width: 50px;
    text-align: right;
}

.budget-period {
    font-size: 13px;
    opacity: 0.85;
}

.metric-subtext {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

/* Skeleton Loading */
@keyframes shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 800px 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 4px;
    color: transparent !important;
    user-select: none;
    pointer-events: none;
}

.skeleton * {
    visibility: hidden;
}

.skeleton-value {
    display: inline-block;
    min-width: 60px;
    height: 1.2em;
    vertical-align: middle;
}

.skeleton-bar {
    height: 100%;
    width: 100%;
    border-radius: 4px;
}

.skeleton-row {
    height: 40px;
    width: 100%;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-block {
    height: 200px;
    width: 100%;
    border-radius: 8px;
}

.metric-card.skeleton .metric-value,
.metric-card.skeleton .metric-subtext,
.metric-card.skeleton .metric-change {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 800px 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 4px;
    color: transparent !important;
    min-width: 80px;
    display: inline-block;
}

.budget-card.skeleton {
    background: linear-gradient(135deg, #d0d5e8 0%, #c4b0d4 100%);
}

.budget-card.skeleton .budget-used,
.budget-card.skeleton .budget-total,
.budget-card.skeleton .budget-progress-text,
.budget-card.skeleton .budget-period span {
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
    color: transparent !important;
    min-width: 60px;
    display: inline-block;
}

.period-card.skeleton .period-value {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 800px 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 4px;
    color: transparent !important;
    min-width: 60px;
    display: inline-block;
}
