/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f8f9fa;
    line-height: 1.5;
}

a {
    text-decoration: none;
    color: inherit;
}

/* App Layout */
.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: #1B4F72;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: rgba(255, 255, 255, 0.7);
    transition: background 0.2s, color 0.2s;
    font-size: 14px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-right: 3px solid #fff;
}

.nav-icon {
    width: 24px;
    margin-right: 12px;
    text-align: center;
    font-size: 16px;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.plan-badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
}

/* Main Area */
.main {
    flex: 1;
    margin-left: 250px;
    display: flex;
    flex-direction: column;
}

/* Topbar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: #1a202c;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-name {
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

.btn-logout {
    padding: 6px 16px;
    background: transparent;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #555;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.btn-logout:hover {
    border-color: #e53e3e;
    color: #e53e3e;
}

/* Content */
.content {
    padding: 32px;
    flex: 1;
}

/* Cards */
.card {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 24px;
    margin-bottom: 24px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 16px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    padding: 20px 24px;
}

.stat-label {
    font-size: 12px;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1a202c;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
}

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

table th,
table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

table th {
    font-size: 12px;
    font-weight: 600;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f7fafc;
}

table td {
    font-size: 14px;
    color: #333;
}

table tr:hover td {
    background: #f7fafc;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: #1B4F72;
    color: #fff;
}

.btn-primary:hover {
    background: #154360;
}

.btn-secondary {
    background: #e2e8f0;
    color: #333;
}

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

.btn-danger {
    background: #e53e3e;
    color: #fff;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d2d6dc;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: #333;
    background: #fff;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: #1B4F72;
    box-shadow: 0 0 0 3px rgba(27, 79, 114, 0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #fed7d7;
}

.alert-success {
    background: #f0fff4;
    color: #276749;
    border: 1px solid #c6f6d5;
}

/* Auth Pages */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    padding: 40px;
}

.auth-card h1 {
    font-size: 24px;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 8px;
}

.auth-card p {
    color: #718096;
    margin-bottom: 28px;
}

.auth-card .btn {
    width: 100%;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #718096;
}

.auth-footer a {
    color: #1B4F72;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Overview Page */
.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-card--primary .stat-icon {
    background: rgba(27, 79, 114, 0.1);
    color: #1B4F72;
}

.stat-card--accent .stat-icon {
    background: rgba(46, 134, 193, 0.1);
    color: #2E86C1;
}

.stat-card--success .stat-icon {
    background: rgba(39, 174, 96, 0.1);
    color: #27AE60;
}

.stat-card--warning .stat-icon {
    background: rgba(243, 156, 18, 0.1);
    color: #F39C12;
}

.stat-info {
    flex: 1;
    min-width: 0;
}

.stat-sub {
    font-size: 16px;
    font-weight: 400;
    color: #718096;
}

/* Overview Grid */
.overview-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.chart-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.chart-card canvas {
    display: block;
    max-width: 100%;
}

/* Status Card */
.status-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.status-row:last-of-type {
    border-bottom: none;
}

.status-label {
    font-size: 13px;
    color: #718096;
}

.status-value {
    font-size: 14px;
    font-weight: 600;
    color: #1a202c;
}

.plan-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-tag--trial {
    background: #fef3cd;
    color: #856404;
}

.plan-tag--basic {
    background: #d1ecf1;
    color: #0c5460;
}

.plan-tag--pro {
    background: #d4edda;
    color: #155724;
}

.plan-tag--enterprise {
    background: #e2d5f1;
    color: #4a1d96;
}

/* Usage Bar */
.usage-bar-wrap {
    padding: 8px 0 12px;
}

.usage-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.usage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #27AE60, #2E86C1);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.usage-bar-text {
    font-size: 12px;
    color: #718096;
}

/* API Key */
.api-key-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.api-key-box {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.api-key-box code {
    flex: 1;
    padding: 8px 10px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    font-size: 12px;
    color: #555;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px;
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
}

.action-card:hover {
    border-color: #2E86C1;
    background: rgba(46, 134, 193, 0.03);
}

.action-icon {
    font-size: 28px;
    margin-bottom: 10px;
    color: #1B4F72;
}

.action-label {
    font-size: 15px;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: 4px;
}

.action-desc {
    font-size: 13px;
    color: #718096;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }

    .sidebar-header h2,
    .nav-label,
    .sidebar-footer {
        display: none;
    }

    .sidebar-header {
        padding: 16px;
        text-align: center;
    }

    .nav-item {
        padding: 14px;
        justify-content: center;
    }

    .nav-icon {
        margin-right: 0;
    }

    .main {
        margin-left: 60px;
    }

    .content {
        padding: 20px 16px;
    }

    .topbar {
        padding: 12px 16px;
    }

    .overview-grid {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }
}
