:root {
    --primary-color: #4361ee;
    --primary-hover: #3a0ca3;
    --secondary-color: #7209b7;
    --success-color: #4cc9f0;
    --success-dark: #0eb1d2;
    --warning-color: #f72585;
    --warning-light: rgba(247, 37, 133, 0.1);
    
    --bg-main: #f8f9fa;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-sidebar: #ffffff;
    
    --text-primary: #2b2d42;
    --text-secondary: #8d99ae;
    --text-light: #edf2f4;
    
    --border-color: rgba(141, 153, 174, 0.2);
    --border-radius-lg: 24px;
    --border-radius-md: 16px;
    --border-radius-sm: 8px;
    
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 40px rgba(67, 97, 238, 0.15);
    --shadow-glow: 0 0 20px rgba(67, 97, 238, 0.4);
    
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

html {
    font-size: 14px !important; /* Khóa kích thước gốc để UI luôn thon gọn, không bị ảnh hưởng bởi cài đặt font trình duyệt */
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    /* Soft ambient background */
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,0.03) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.03) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.03) 0, transparent 50%);
}

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

/* --- Sidebar --- */
.sidebar {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    flex-shrink: 0;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    z-index: 10;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 3rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: var(--shadow-sm);
}

.logo-area h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-area h1 span {
    color: var(--primary-color);
}

.main-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.nav-item:hover {
    background-color: rgba(67, 97, 238, 0.05);
    color: var(--primary-color);
}

.nav-item.active {
    background-color: rgba(67, 97, 238, 0.1);
    color: var(--primary-color);
}

.sidebar-bottom {
    margin-top: auto;
}

.health-widget {
    background-color: var(--bg-main);
    padding: 16px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}

.health-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-dot.green {
    background-color: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(76, 201, 240, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(76, 201, 240, 0); }
    100% { box-shadow: 0 0 0 0 rgba(76, 201, 240, 0); }
}

.health-widget p {
    font-weight: 600;
    font-size: 0.95rem;
}

/* --- Main Content --- */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 3rem;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 5;
}

.top-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.user-profile img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.content-wrapper {
    padding: 0.75rem 1rem;
    max-width: 100%;
    margin: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Sections */
section {
    display: none;
    animation: fadeIn 0.5s ease;
}
section.active {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

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

/* --- Cards & Containers --- */
.upload-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* --- Drop Zone --- */
.drop-zone {
    padding: 1.25rem 2.5rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(67,97,238,0.03), rgba(114,9,183,0.03));
    transition: var(--transition);
    position: relative;
}

.drop-zone.dragover {
    background: rgba(67, 97, 238, 0.08);
    border-bottom: 2px dashed var(--primary-color);
}

.drop-zone-content {
    display: flex;
    align-items: center;
    gap: 20px;
    text-align: left;
    margin-bottom: 0;
}

.upload-icon-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--primary-color);
    margin: 0 auto 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.drop-zone:hover .upload-icon-wrapper {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.drop-zone h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.drop-zone p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.supported-formats {
    display: inline-block;
    padding: 4px 12px;
    background-color: rgba(141, 153, 174, 0.1);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* --- Buttons --- */
.btn {
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn-outline:hover {
    background-color: rgba(0,0,0,0.02);
    border-color: var(--text-secondary);
}

.btn-large {
    padding: 16px 32px;
    font-size: 1.1rem;
    width: 100%;
}

.btn-glow {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: var(--shadow-glow);
}
.btn-glow:hover {
    box-shadow: 0 0 30px rgba(67, 97, 238, 0.6);
    transform: translateY(-2px);
}
.btn-glow:disabled {
    background: #ccc;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* --- Configuration Area --- */
.configuration-area {
    padding: 1.25rem 2.5rem 1rem 2.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}
.config-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}
.config-header h3 {
    font-size: 1.25rem;
}

.preset-selector {
    margin-bottom: 2rem;
}
.preset-selector label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.select-wrapper {
    position: relative;
}
.form-select {
    width: 100%;
    padding: 14px 16px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background-color: white;
    font-size: 1rem;
    color: var(--text-primary);
    appearance: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
}
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}
.select-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* --- Pagination & Pages --- */
.pages-container {
    position: relative;
    flex-grow: 1;
    min-height: 190px;
}
.page {
    display: none;
    animation: fadeIn 0.3s ease;
}
.page.active {
    display: block;
}
.category-group {
    margin-bottom: 24px;
}
.category-group h4 {
    margin-bottom: 20px;
    font-size: 1.05rem;
    color: var(--primary-color);
    border-bottom: 1px solid rgba(67, 97, 238, 0.1);
    padding-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    row-gap: 22px;
    column-gap: 16px;
}

.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}
.pagination-reset {
    flex: 1;
    display: flex;
    justify-content: flex-start;
}
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}
.page-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}
.page-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(67, 97, 238, 0.05);
}
.page-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

/* Custom Checkbox */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 32px;
    margin-bottom: 0;
    cursor: pointer;
    font-size: 0.92rem;
    user-select: none;
    color: var(--text-primary);
    transition: var(--transition);
    min-height: 28px;
}
.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}
.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 22px;
    width: 22px;
    background-color: rgba(141, 153, 174, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: var(--transition);
}
.checkbox-container:hover input ~ .checkmark {
    background-color: rgba(141, 153, 174, 0.2);
}
.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}
.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}
.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}
.checkbox-container .checkmark:after {
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.ai-feature {
    color: var(--secondary-color);
    font-weight: 600;
}
.ai-feature input:checked ~ .checkmark {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.action-bar {
    margin-top: 2rem;
}

/* --- Processing Section --- */
.processing-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-md);
    padding: 5rem;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto 2rem;
    animation: rotate 2s linear infinite;
}
.spinner circle {
    stroke: url(#gradient);
    stroke-width: 4;
    stroke-dasharray: 1, 200;
    stroke-dashoffset: 0;
    animation: dash 1.5s ease-in-out infinite, color 6s ease-in-out infinite;
    stroke-linecap: round;
    fill: none;
}
/* SVG definition inside CSS - standard fallback */
.spinner svg circle {
    stroke: var(--primary-color);
}

@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes dash {
  0% { stroke-dasharray: 1, 200; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 89, 200; stroke-dashoffset: -35; }
  100% { stroke-dasharray: 89, 200; stroke-dashoffset: -124; }
}

.processing-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}
.processing-detail {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.progress-container {
    width: 100%;
    height: 8px;
    background-color: rgba(141, 153, 174, 0.2);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* --- Results Section --- */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.doc-info {
    display: flex;
    align-items: center;
    gap: 16px;
}
.doc-icon {
    width: 48px;
    height: 48px;
    background: rgba(67, 97, 238, 0.1);
    color: var(--primary-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}
.doc-icon.success {
    background: rgba(76, 201, 240, 0.1);
    color: var(--success-dark);
}

.doc-details h3 {
    font-size: 1.25rem;
}
.doc-details p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.results-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.health-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.health-score-circle {
    width: 150px;
    height: 150px;
    margin-bottom: 1.5rem;
}

.circular-chart {
    display: block;
    margin: 0 auto;
    max-width: 80%;
    max-height: 250px;
}
.circle-bg {
    fill: none;
    stroke: rgba(141, 153, 174, 0.2);
    stroke-width: 2.5;
}
.circle {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    animation: progress 1s ease-out forwards;
}
.circular-chart.orange .circle { stroke: #ff9f1c; }
.circular-chart.success .circle { stroke: var(--success-color); }

@keyframes progress {
    0% { stroke-dasharray: 0 100; }
}
.percentage {
    fill: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: 8px;
    text-anchor: middle;
}
.subtext {
    fill: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 3px;
    text-anchor: middle;
}

.health-summary h4 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}
.health-summary p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}
.issue-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}
.issue-pill.warning {
    background: var(--warning-light);
    color: var(--warning-color);
}
.issue-pill.success {
    background: rgba(76, 201, 240, 0.1);
    color: var(--success-dark);
}

.issue-categories {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    align-content: start;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: var(--border-radius-md);
    background: white;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}
.category-item:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}
.category-item.warning {
    border-left: 4px solid var(--warning-color);
}
.category-item.ai-suggestion {
    border-left: 4px solid var(--secondary-color);
    background: linear-gradient(to right, rgba(114, 9, 183, 0.02), transparent);
}

.cat-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(141, 153, 174, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}
.category-item.warning .cat-icon {
    color: var(--warning-color);
    background: var(--warning-light);
}
.category-item.ai-suggestion .cat-icon {
    color: var(--secondary-color);
    background: rgba(114, 9, 183, 0.1);
}

.cat-details {
    display: flex;
    flex-direction: column;
}
.cat-name {
    font-weight: 600;
    font-size: 0.95rem;
}
.cat-count {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.fix-actions {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fix-summary {
    display: flex;
    gap: 2rem;
}
.fix-stat {
    display: flex;
    flex-direction: column;
}
.fix-stat .num {
    font-size: 1.5rem;
    font-weight: 700;
}
.fix-stat .label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.fix-stat.safe .num { color: var(--success-color); }
.fix-stat.smart .num { color: var(--primary-color); }
.fix-stat.ai .num { color: var(--secondary-color); }

.action-buttons {
    display: flex;
    gap: 16px;
}

/* --- Fixed Results Extra --- */
.fix-summary-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: center;
}
.summary-card {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 1.1rem;
    font-weight: 500;
}
.summary-card.success i {
    color: var(--success-dark);
    font-size: 1.5rem;
}
.center-actions {
    display: flex;
    justify-content: center;
}
.mt-4 {
    margin-top: 2rem;
}

/* --- Settings Section --- */
.settings-section {
    display: none;
    animation: fadeIn 0.5s ease;
}
.settings-section.active {
    display: block;
}

.settings-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-md);
    padding: 3rem;
}

.settings-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}
.settings-header-actions {
    display: flex;
    gap: 10px;
}
.template-selection {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}
.settings-header h3 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
}
.settings-header h3 i {
    color: var(--primary-color);
}

/* --- Settings UI Grid --- */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
.settings-panel {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 24px;
}
.settings-panel h4 {
    color: var(--secondary-color);
    margin-bottom: 16px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}
.form-row.align-top {
    align-items: flex-start;
}
.form-row > label {
    width: 120px;
    flex-shrink: 0;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}
.input-with-link {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-grow: 1;
}
.input-with-link.align-top {
    align-items: flex-start;
}
.input-with-link.align-top .detail-link {
    margin-top: 8px;
}
.input-with-link .select-wrapper, .input-with-link .form-input {
    flex-grow: 1;
    width: 100%;
}
.input-with-link .form-input {
    padding: 10px 12px;
}
.input-with-link .select-wrapper .form-select {
    padding: 10px 12px;
}

.detail-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
}
.detail-link:hover {
    text-decoration: underline;
}

.fallback-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px 20px;
    flex-grow: 1;
    padding-top: 4px;
}
.fallback-grid .checkbox-container {
    font-size: 0.9rem;
    margin-bottom: 0;
    padding-left: 28px;
}
.fallback-grid .checkmark {
    width: 18px;
    height: 18px;
}
.fallback-grid .checkmark:after {
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
}

.link-text {
    font-size: 0.85rem;
    margin-bottom: 12px;
}
.link-text a {
    color: #4361ee;
    text-decoration: none;
}
.link-text a:hover {
    text-decoration: underline;
}

.form-textarea {
    width: 100%;
    padding: 12px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background-color: white;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-family: monospace;
    resize: vertical;
    margin-bottom: 16px;
    transition: var(--transition);
}
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.api-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}
.btn-warning {
    background-color: #e76f51;
    color: white;
    border: none;
}
.btn-warning:hover {
    background-color: #f4a261;
}
.key-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* --- System Log --- */
.log-container {
    background: white;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    overflow: hidden;
}

.log-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-card);
    color: var(--text-color);
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

body.dark-mode .log-content {
    background: #121212;
    color: #e0e0e0;
}
.log-entry {
    margin-bottom: 8px;
    word-break: break-all;
}
.log-entry.error {
    color: #f44336;
}
.log-entry.success {
    color: #4caf50;
}
.log-entry.info {
    color: #64b5f6;
}
.log-time {
    color: #888;
    margin-right: 8px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.form-group label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}
.input-with-icon .icon-left {
    position: absolute;
    left: 16px;
    color: var(--text-secondary);
}
.input-with-icon .icon-right {
    position: absolute;
    right: 16px;
    color: var(--text-secondary);
    transition: color 0.2s;
}
.input-with-icon .icon-right:hover {
    color: var(--primary-color);
}
.form-input {
    width: 100%;
    padding: 14px 16px 14px 44px; /* padding-left for icon */
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background-color: white;
    font-size: 1rem;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
}
.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* --- Header Actions --- */
.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}
.icon-btn:hover {
    background: rgba(141, 153, 174, 0.1);
}

.lang-switcher {
    display: flex;
    background: rgba(141, 153, 174, 0.1);
    border-radius: 20px;
    padding: 4px;
}

.lang-btn {
    background: transparent;
    border: none;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}
.lang-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* --- Dark Mode Variables --- */
body.dark-mode {
    --bg-main: #121212;
    --bg-card: rgba(30, 30, 30, 0.85);
    --bg-sidebar: #1a1a1a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-light: #ffffff;
    --border-color: rgba(255, 255, 255, 0.1);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,20%,0.1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,40%,0.05) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,40%,0.05) 0, transparent 50%);
}
body.dark-mode .form-input, body.dark-mode .form-select, body.dark-mode .category-item {
    background-color: #242424;
    color: #e0e0e0;
}
body.dark-mode .top-header {
    background-color: rgba(26, 26, 26, 0.8);
}
body.dark-mode .drop-zone {
    background: linear-gradient(135deg, rgba(67,97,238,0.1), rgba(114,9,183,0.1));
}
body.dark-mode .summary-card, body.dark-mode .upload-icon-wrapper, body.dark-mode .settings-panel {
    background: #242424;
}

/* Responsive */
@media (max-width: 1024px) {
    .upload-card {
        grid-template-columns: 1fr;
    }
    .drop-zone {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 3rem 2rem;
    }
    .results-grid {
        grid-template-columns: 1fr;
    }
    .health-card {
        max-width: 400px;
        margin: 0 auto;
    }
}
@media (max-width: 768px) {
    .sidebar {
        display: none; /* simple mobile fallback */
    }
    .content-wrapper {
        padding: 1.5rem;
    }
    .fix-actions {
        flex-direction: column;
        gap: 1.5rem;
    }
    .action-buttons {
        width: 100%;
        flex-direction: column;
    }
    .settings-card {
        padding: 1.5rem;
    }
    .drop-zone {
        flex-direction: column;
        gap: 1.5rem;
        padding: 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .drop-zone-content {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    .config-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    .config-controls {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }
    .config-controls .preset-selector,
    .config-controls .btn-primary {
        width: 100%;
        min-width: 100% !important;
    }
    .options-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .template-selection {
        grid-template-columns: 1fr;
    }
    .pagination-wrapper {
        flex-direction: column;
        gap: 15px;
    }
    .pagination-reset {
        width: 100%;
        justify-content: center;
    }
    .pagination-reset .btn {
        width: 100%;
        justify-content: center;
    }
    .settings-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .settings-header-actions {
        width: 100%;
    }
    .settings-header-actions .btn {
        flex: 1;
        justify-content: center;
    }
    .results-header {
        flex-direction: column;
        align-items: center;
        gap: 15px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .options-grid {
        grid-template-columns: 1fr;
    }
}
