@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500&display=swap');

:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-hover: #f8fafc;
    --text: #0f172a;
    --text-heading: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #eff6ff;

    --accent: #fbbf24;
    --accent-dark: #f59e0b;
    --accent-text: #1f2937;

    --success: #10b981;
    --success-light: #ecfdf5;
    --danger: #ef4444;
    --danger-light: #fef2f2;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow: 0 4px 20px -4px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: #ffffff;
    border-right: 1px solid var(--border);
    color: var(--text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 200;
}

.sidebar-logo {
    padding: 22px 24px;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-heading);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo img {
    width: 100%;
    height: auto;
    display: block;
}

.sidebar-section {
    padding: 20px 24px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 2px 12px;
    padding: 10px 12px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
    background: var(--surface-hover);
    color: var(--text-heading);
}

.sidebar-link.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}

.sidebar-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

/* Main area */
.main {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--muted);
    font-size: 14px;
}

.page-content {
    padding: 32px;
    flex: 1;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: 26px;
    font-weight: 700;
    margin: 0;
    color: var(--text-heading);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-yellow {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
    box-shadow: 0 2px 8px -2px rgba(251, 191, 36, 0.35);
}

.btn-yellow:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.btn-blue {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-blue:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline {
    background: #ffffff;
    color: var(--text);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.btn-outline:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

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

.icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: #fff;
    color: var(--muted);
    cursor: pointer;
    text-decoration: none;
    font-size: 16px;
    box-shadow: var(--shadow-sm);
}

.icon-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* Stats / dashboard cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.stat-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s;
}

.stat-link:hover {
    transform: translateY(-3px);
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: box-shadow 0.15s;
}

.stat-link:hover .stat-card {
    box-shadow: var(--shadow-lg);
}

.stat-card .icon {
    font-size: 28px;
    margin-bottom: 12px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--surface-hover);
}

.stat-card .label {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 6px;
}

.stat-card .value {
    font-size: 30px;
    font-weight: 800;
    color: var(--text-heading);
    margin-bottom: 6px;
}

.stat-card .value span {
    font-size: 16px;
    color: var(--muted);
    font-weight: 600;
}

.stat-card .footer {
    font-size: 13px;
    color: var(--muted);
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 18px;
    color: var(--text-heading);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.card-sparkline {
    width: 90px;
    height: 44px;
    flex-shrink: 0;
}

.card-subtitle {
    font-size: 14px;
    color: var(--muted);
    margin: -10px 0 18px;
}

/* Lists */
.list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.list-item-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.15s;
}

.list-item-row:hover {
    box-shadow: var(--shadow-lg);
}

.list-item-row .title {
    font-weight: 700;
    font-size: 16px;
    margin: 0 0 4px;
    color: var(--text-heading);
}

.list-item-row .meta {
    color: var(--muted);
    font-size: 14px;
}

.list-item-row .actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.project-info {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.project-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary-light), #fff);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    color: var(--primary-dark);
    flex-shrink: 0;
}

@media (max-width: 900px) {
    .project-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .project-row .actions {
        flex-wrap: wrap;
        width: 100%;
    }
}

.work-info {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
}

.work-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, #fef3c7, #fffbeb);
    border: 1px solid #fde68a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

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

.form-group label {
    display: block;
    margin-bottom: 7px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-heading);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    background: var(--surface-hover);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.form-group input[type="file"] {
    padding: 9px 12px;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-ready { background: var(--success-light); color: #047857; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-error { background: var(--danger-light); color: #b91c1c; }
.badge-default { background: var(--surface-hover); color: var(--muted); }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error { background: var(--danger-light); color: #b91c1c; }
.alert-success { background: var(--success-light); color: #047857; }
.alert-warning { background: #fef3c7; color: #92400e; }

.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* Empty state */
.empty-state {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    color: var(--muted);
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.empty-state a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.empty-state a:hover {
    text-decoration: underline;
}

/* Action bar */
.action-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

/* Tariff banner */
.tariff-banner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.tariff-banner .title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 8px;
}

.tariff-banner .expires {
    color: var(--danger);
    margin-bottom: 16px;
}

.tariff-banner .actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 28px;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.modal h2 {
    margin-top: 0;
    font-size: 20px;
}

.modal-close {
    float: right;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--muted);
}

.modal-wide {
    max-width: 760px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-weight: 600;
    font-size: 14px;
    color: var(--muted);
}

.tab.active {
    border-color: var(--primary);
    color: var(--primary-dark);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.inline-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.help-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-list li {
    border-bottom: 1px solid var(--border);
}

.help-list a {
    display: block;
    padding: 14px 0;
    color: var(--primary);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
}

.help-list a:hover {
    text-decoration: underline;
}

/* Group cards in forms */
.group-card {
    background: var(--surface-hover) !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}

.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Report readability helpers */
table td, table th {
    word-break: break-word;
    overflow-wrap: break-word;
}

.chart img {
    max-width: 100%;
    height: auto;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .main {
        margin-left: 0;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .page-content {
        padding: 20px;
    }
}


/* Source icons in project list */
.source-icons {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}
.source-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 13px;
    cursor: help;
}
