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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: #f5f5f5;
    color: #1a1a1a;
    line-height: 1.5;
}

/* Navbar */
.navbar {
    background: #1a1a2e;
    color: white;
    padding: 0 24px;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 32px;
}

.nav-brand {
    font-weight: 700;
    font-size: 18px;
}

.nav-links {
    display: flex;
    gap: 4px;
}

.nav-links a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
}

.nav-links a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-links a.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Environment Selector */
.env-selector {
    display: flex;
    align-items: center;
    gap: 6px;
}

.env-selector select {
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 14px;
    cursor: pointer;
    max-width: 200px;
}

.env-selector select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
}

.env-selector select option {
    background: #1a1a2e;
    color: white;
}

.env-manage-btn {
    color: rgba(255, 255, 255, 0.6) !important;
    font-size: 16px !important;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
}

.env-manage-btn:hover {
    color: white !important;
}

.env-list {
    margin-bottom: 16px;
}

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

.env-item:last-child {
    border-bottom: none;
}

.env-desc {
    color: #666;
    font-size: 13px;
    margin-left: 8px;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.subtitle {
    color: #666;
    font-size: 14px;
    margin-top: 4px;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

/* Competitor sections */
.competitor-section {
    background: white;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.competitor-section.own-company {
    border-left: 4px solid #3b82f6;
}

.competitor-section h2 {
    font-size: 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.url-matrix-wrapper {
    max-height: 70vh;
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid #e5e5e5;
    font-weight: 600;
    color: #555;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table th.num,
.data-table td.num {
    text-align: right;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}

.data-table tbody tr:hover {
    background: #fafafa;
}

.course-name {
    font-weight: 500;
}

.vat-note {
    font-size: 11px;
    color: #888;
    margin-left: 2px;
}

.na {
    color: #bbb;
    font-style: italic;
}

.inactive-row {
    opacity: 0.5;
}

/* Course details (expandable) */
.course-details {
    background: #f9fafb;
}

.course-details td {
    padding: 0 12px;
}

.course-details.hidden td {
    padding: 0;
    border: 0;
}

.details-content {
    padding: 12px 0;
}

.detail-item {
    margin-bottom: 8px;
}

.detail-item ul {
    margin-left: 20px;
    margin-top: 4px;
}

.detail-item li {
    margin-bottom: 2px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-green {
    background: #dcfce7;
    color: #15803d;
}

.badge-orange {
    background: #fff7ed;
    color: #c2410c;
}

.badge-gray {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-red {
    background: #fef2f2;
    color: #dc2626;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    color: #374151;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.btn:hover {
    background: #f9fafb;
}

.btn-primary {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-primary:disabled {
    background: #93c5fd;
    border-color: #93c5fd;
    cursor: not-allowed;
}

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

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

.btn-small {
    padding: 4px 10px;
    font-size: 13px;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #999;
    padding: 4px 8px;
    transition: transform 0.2s;
}

.btn-icon:hover {
    color: #333;
}

.actions-cell {
    display: flex;
    gap: 6px;
}

/* Forms */
.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    margin-bottom: 4px;
}

.form-group input[type="text"],
.form-group input[type="url"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-top: 22px;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-content h2 {
    margin-bottom: 16px;
}

.modal-content .form-group {
    margin-bottom: 12px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* Scrape status */
.scrape-status {
    background: white;
    border-radius: 8px;
    padding: 16px 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.scrape-status.loading {
    border-left: 4px solid #f59e0b;
}

.scrape-result {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.scrape-result.success {
    color: #15803d;
}

.scrape-result.error {
    color: #dc2626;
}

/* Charts */
.charts-section {
    margin-top: 32px;
}

.charts-section h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.chart-container {
    background: white;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #666;
}

.empty-state a {
    color: #3b82f6;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* Course comparison sections (dashboard) */
.course-comparison-section {
    background: white;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.course-comparison-section h2 {
    font-size: 18px;
    margin-bottom: 16px;
    color: #1a1a2e;
}

.own-company-row {
    background: #eff6ff;
}

.own-company-row:hover {
    background: #dbeafe !important;
}

/* URL Matrix */
.url-matrix-table {
    border-collapse: separate;
    border-spacing: 0;
}

.url-matrix-table th {
    min-width: 200px;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    border-bottom: 2px solid #e5e5e5;
}

.url-matrix-table th:first-child {
    position: sticky;
    left: 0;
    z-index: 20;
    background: #fff;
    min-width: 160px;
}

.url-matrix-table td.course-name {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 5;
    font-weight: 500;
    border-right: 2px solid #e5e5e5;
}

.url-matrix-table th:first-child {
    border-right: 2px solid #e5e5e5;
}

.url-matrix-table tbody tr:hover td.course-name {
    background: #fafafa;
}

.url-matrix-table td.url-cell {
    padding: 6px 8px;
}

.url-input-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.url-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    transition: border-color 0.15s;
}

.url-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.url-input:not(:placeholder-shown) {
    border-color: #22c55e;
    background: #f0fdf4;
}

.url-link {
    color: #3b82f6;
    text-decoration: none;
    font-size: 16px;
    flex-shrink: 0;
}

.url-status {
    font-size: 11px;
    height: 16px;
    margin-top: 2px;
}

.url-status.saved {
    color: #15803d;
}

.url-status.saving {
    color: #d97706;
}

.url-status.removed {
    color: #6b7280;
}

.url-status.error {
    color: #dc2626;
}

/* Chart controls */
.chart-controls {
    margin-bottom: 12px;
}

.chart-controls label {
    font-size: 13px;
    color: #555;
    margin-right: 8px;
}

.chart-controls select {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
}

.chart-controls select:focus {
    outline: none;
    border-color: #3b82f6;
}

/* Recommendations */
.recommendations-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
}

.btn-secondary {
    background: #f8fafc;
    color: #475569;
    border: 1px solid #cbd5e1;
}

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

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

.recommendations-output {
    margin-top: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
}

.recommendations-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    cursor: pointer;
    user-select: none;
}

.recommendations-header:hover {
    opacity: 0.8;
}

.rec-toggle {
    font-size: 12px;
    margin-right: 6px;
    display: inline-block;
    transition: transform 0.2s;
}

.recommendations-content.collapsed {
    display: none;
}

.recommendations-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

.recommendations-date {
    font-size: 12px;
    color: #94a3b8;
}

.recommendations-content {
    font-size: 14px;
    line-height: 1.7;
    color: #334155;
}

.recommendations-content h2 {
    font-size: 16px;
    margin: 16px 0 8px;
    color: #1e293b;
}

.recommendations-content h3 {
    font-size: 15px;
    margin: 14px 0 6px;
    color: #1e293b;
}

.recommendations-content h4 {
    font-size: 14px;
    margin: 12px 0 4px;
    color: #334155;
}

.recommendations-content p {
    margin-bottom: 8px;
}

.recommendations-content ul {
    margin: 8px 0 8px 20px;
    list-style: disc;
}

.recommendations-content li {
    margin-bottom: 4px;
}

.recommendations-content strong {
    color: #1e293b;
}

.loading-text {
    color: #64748b;
    font-style: italic;
}

.recommendations-content .error {
    color: #dc2626;
}

/* Strategic Next Steps */
.strategic-next-steps-section {
    margin-top: 24px;
}

.next-steps-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.next-steps-header h2 {
    margin: 0;
}

.next-steps-output {
    margin-top: 16px;
    background: #f0f7ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 24px;
}

.next-steps-content {
    font-size: 14px;
    line-height: 1.7;
    color: #334155;
}

.next-steps-content h2 {
    font-size: 16px;
    margin: 16px 0 8px;
    color: #1e293b;
}

.next-steps-content h3 {
    font-size: 15px;
    margin: 14px 0 6px;
    color: #1e293b;
}

.next-steps-content h4 {
    font-size: 14px;
    margin: 12px 0 4px;
    color: #334155;
}

.next-steps-content p {
    margin-bottom: 8px;
}

.next-steps-content ul {
    margin: 8px 0 8px 20px;
    list-style: disc;
}

.next-steps-content li {
    margin-bottom: 4px;
}

.next-steps-content strong {
    color: #1e293b;
}

.next-steps-content .error {
    color: #dc2626;
}

/* Login */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
}

.login-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.login-card h1 {
    font-size: 22px;
    margin-bottom: 24px;
    text-align: center;
    color: #1a1a2e;
}

.login-card .form-group {
    margin-bottom: 20px;
}

.login-card input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 15px;
}

.login-card input[type="password"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.login-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
}

/* Logout button in navbar */
.nav-logout a {
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.nav-logout a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Inline cell editing */
.editable-cell {
    cursor: pointer;
    position: relative;
}

.editable-cell:hover {
    background: rgba(59, 130, 246, 0.05);
}

.inline-edit-input {
    width: 100%;
    padding: 4px 8px;
    border: 2px solid #3b82f6;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    text-align: inherit;
    background: white;
    outline: none;
}

.inline-edit-input:focus {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.edit-saved {
    animation: editFlash 1s ease;
}

@keyframes editFlash {
    0% { background: #dcfce7; }
    100% { background: transparent; }
}
