:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --critical: #991b1b;
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 0.75rem;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.hidden {
    display: none !important;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header & Tabs */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0 0 0;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 2.5rem;
    height: 2.5rem;
    color: var(--primary);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-badges {
    display: flex;
    gap: 0.5rem;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: var(--danger); }
.badge-critical { background: #fecaca; color: var(--critical); }

.nav-tabs {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    gap: 2rem;
}

.nav-tab {
    background: none;
    border: none;
    padding: 0.75rem 0.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-tab svg {
    width: 1.25rem;
    height: 1.25rem;
}

.nav-tab:hover {
    color: var(--primary);
}

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

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Search Card */
.search-card {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
    border: 1px solid var(--border);
}

.search-header h1 {
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: #0f172a;
}

.search-subtitle {
    color: var(--text-muted);
    font-size: 1.125rem;
    margin-bottom: 2.5rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.search-form {
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

.input-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.5rem;
    height: 1.5rem;
    color: var(--text-muted);
    pointer-events: none;
}

#search-input {
    width: 100%;
    padding: 1.25rem 3.5rem 1.25rem 3.5rem;
    border: 2px solid var(--border);
    border-radius: 1rem;
    font-size: 1.125rem;
    transition: all 0.2s;
    background: #fdfdfd;
}

#search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
    background: white;
}

.clear-btn {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    display: none;
}

.clear-btn:hover {
    background: var(--border);
    color: var(--text-main);
}

.search-options {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--text-muted);
    user-select: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-lg {
    padding: 1rem 3rem;
    font-size: 1.125rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: white;
    border-color: var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: var(--bg-app);
    border-color: var(--secondary);
}

.spinner {
    animation: rotate 2s linear infinite;
    width: 1.5rem;
    height: 1.5rem;
}

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

/* Results Section */
.results-area {
    margin-top: 3rem;
}

.result-card {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0, 0, 0.2, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-status-banner {
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.banner-safe { background-color: #ecfdf5; border-bottom: 4px solid var(--success); }
.banner-warning { background-color: #fffbeb; border-bottom: 4px solid var(--warning); }
.banner-danger { background-color: #fef2f2; border-bottom: 4px solid var(--danger); }
.banner-critical { background-color: #fef2f2; border-bottom: 4px solid var(--critical); }
.banner-medium { background-color: #fff7ed; border-bottom: 4px solid #f97316; }

.status-icon {
    width: 3.5rem;
    height: 3.5rem;
    padding: 0.75rem;
    border-radius: 1rem;
}

.icon-safe { background: #d1fae5; color: var(--success); }
.icon-warning { background: #fef3c7; color: var(--warning); }
.icon-danger { background: #fee2e2; color: var(--danger); }
.icon-critical { background: #fee2e2; color: var(--critical); }
.icon-medium { background: #ffedd5; color: #f97316; }

.status-title {
    flex: 1;
}

.status-title h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.status-label {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.score-display {
    text-align: right;
}

.score-value {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
}

.score-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.result-content {
    padding: 2rem;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.journal-info-card {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
    background: #fcfcfc;
}

.info-row {
    display: flex;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.info-row:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.info-label {
    width: 140px;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.info-value {
    font-weight: 500;
    color: var(--text-main);
}

.recommendation-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
}

.rec-title {
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rec-text {
    font-size: 0.9375rem;
    color: var(--text-main);
    margin-bottom: 1.5rem;
}

.rec-list {
    padding-left: 1.25rem;
    font-size: 0.875rem;
}

.rec-list li {
    margin-bottom: 0.5rem;
}


.detail-section {
    grid-column: 1 / -1;
    margin-top: 1rem;
    padding-top: 2rem;
    border-top: 1px dashed var(--border);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.indicator-card {
    padding: 1.25rem;
    border-radius: 0.5rem;
    background: #fff;
    border: 1px solid var(--border);
}


.table-container {
    overflow-x: auto;
    margin-top: 2rem;
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

.data-table th {
    background: #f8fafc;
    padding: 1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

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


.footer {
    background: white;
    border-top: 1px solid var(--border);
    padding: 3rem 1.5rem;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-disclaimer {
    max-width: 1200px;
    margin: 0 auto;
    padding-top: 1.5rem;
    border-top: 1px solid #f1f5f9;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}


@media (max-width: 768px) {
    .header-content { flex-direction: column; gap: 1rem; text-align: center; }
    .search-options { flex-direction: column; gap: 0.75rem; align-items: center; }
    .result-content { grid-template-columns: 1fr; }
    .footer-content { flex-direction: column; text-align: center; }
    .footer-links { justify-content: center; }
}


.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-container {
    background: white;
    border-radius: 1rem;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.modal-close:hover {
    background: #f1f5f9;
}


.score-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: bold;
    margin-right: 10px;
    min-width: 60px;
    text-align: center;
    display: inline-block;
}

.score-critical { background-color: #7f1d1d; color: white; }
.score-high { background-color: #ef4444; color: white; }
.score-warning { background-color: #f59e0b; color: white; }
.score-medium { background-color: #fcd34d; color: #92400e; }
.score-safe { background-color: #10b981; color: white; }

.recommendation {
    font-weight: bold;
    margin-left: 10px;
    text-transform: uppercase;
}

.score-item {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding: 10px;
    border-radius: 8px;
    background: #f8fafc;
}

/* Utility Classes for Dynamic HTML */
.mb-6 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-4 { margin-top: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.p-12 { padding: 3rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
@media (min-width: 768px) { .md-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.gap-4 { gap: 1rem; }
.text-2xl { font-size: 1.5rem; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.small { font-size: 0.75rem; }
.text-xs { font-size: 0.7rem; }
.border-danger { border: 1px solid var(--danger); }
.border-success { border: 1px solid var(--success); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-primary { color: var(--primary); }

/* Toast Styles */
.toast-container { 
    position: fixed; 
    bottom: 2rem; 
    right: 2rem; 
    z-index: 1000; 
    display: flex; 
    flex-direction: column; 
    gap: 0.5rem; 
}
.toast { 
    background: white; 
    padding: 1rem 1.5rem; 
    border-radius: 0.5rem; 
    box-shadow: var(--shadow-lg); 
    border-left: 4px solid var(--primary); 
    animation: slideIn 0.3s ease-out; 
    transition: opacity 0.5s; 
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--primary); }
@keyframes slideIn { 
    from { transform: translateX(100%); opacity: 0; } 
    to { transform: translateX(0); opacity: 1; } 
}

/* Guide styles */
.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.guide-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.guide-card h3 {
    margin: 1rem 0 0.75rem 0;
    font-size: 1.125rem;
    color: var(--text-main);
}

.guide-card p {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-bottom: 0.5rem;
}

.guide-card ul, .guide-card ol {
    padding-left: 1.25rem;
    color: var(--text-main);
    font-size: 0.875rem;
}

.guide-card li {
    margin-bottom: 0.375rem;
}

.guide-icon {
    width: 3rem;
    height: 3rem;
    padding: 0.5rem;
    border-radius: 0.75rem;
}

.guide-icon.danger { background: #fee2e2; color: var(--danger); }
.guide-icon.warning { background: #fef3c7; color: var(--warning); }
.guide-icon.info { background: var(--primary-light); color: var(--primary); }

.guide-section {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-top: 1.5rem;
}

.guide-section h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.setup-guide {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 0.5rem;
}

.setup-guide h4 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.sheet-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.sheet-tab {
    background: white;
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
}

.sheet-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.sheet-panel {
    display: none;
}

.sheet-panel.active {
    display: block;
}

.schema-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: white;
}

.schema-table th {
    background: #f1f5f9;
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.schema-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f1f5f9;
}

/* Quick Examples */
.quick-examples {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.examples-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.75rem;
}

.example-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.example-chip {
    background: var(--bg-app);
    border: 1px solid var(--border);
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-main);
}

.example-chip:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* Database Controls */
.database-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1.5rem 0;
}

.filter-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.select-input, .search-input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: white;
}

.database-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    text-align: center;
    border: 1px solid var(--border);
}

.stat-number {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.database-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.database-header p {
    color: var(--text-muted);
}
