:root {
    --primary: #60a5fa;
    --primary-dark: #3b82f6;
    --primary-light: #93c5fd;
    --accent: #34d399;
    --accent-light: #6ee7b7;
    --bg-body: #0f172a;
    --bg-primary: #1e293b;
    --bg-secondary: #334155;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --radius: 8px;
    --radius-lg: 12px;
    --max-width: 1200px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.875rem 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: var(--max-width);
}

.navbar-brand a {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.025em;
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: 0.25rem;
}

.navbar-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-nav a:hover {
    color: var(--primary);
    background: var(--bg-secondary);
}

.nav-icon {
    width: 1rem;
    height: 1rem;
    opacity: 0.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Container */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
    width: 100%;
}

/* Page header */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.page-header .subtitle {
    color: var(--text-secondary);
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

/* Condition grid */
.conditions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.condition-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all 0.25s ease;
    text-decoration: none;
    color: inherit;
    display: block;
    position: relative;
    overflow: hidden;
}

.condition-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: opacity 0.25s;
}

.condition-card:hover {
    border-color: var(--primary);
    background: var(--bg-secondary);
}

.condition-card:hover::before {
    opacity: 1;
}

.condition-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    word-break: break-word;
    color: var(--text-primary);
}

.condition-card .meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Category sections */
.category-section {
    margin-bottom: 2rem;
}

.category-section:last-child {
    margin-bottom: 0;
}

.category-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border-left: 3px solid var(--primary);
}

.category-count {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Parameter selector dropdown */
.param-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    background: var(--bg-body);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.param-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.param-dropdown {
    position: relative;
    flex: 1;
    max-width: 450px;
}

.param-search {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    background: var(--bg-primary);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

.param-dropdown::before {
    content: '';
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'/%3E%3C/svg%3E");
    background-size: contain;
    pointer-events: none;
    z-index: 1;
}

.param-search::placeholder {
    color: var(--text-secondary);
}

.param-search:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.2);
}

.param-dropdown.open .param-search {
    border-radius: var(--radius) var(--radius) 0 0;
}

.param-dropdown-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 350px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    z-index: 50;
    box-shadow: var(--shadow-md);
}

.param-dropdown-list.open {
    display: flex;
    flex-direction: column;
}

.param-dropdown-list.searching {
    flex-direction: column;
}

.param-dropdown-list.searching .param-option {
    border-left: none;
    padding-left: 1rem;
}

.param-category {
    display: contents;
}

.param-category-header {
    padding: 0.5rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-body);
    position: sticky;
    top: 0;
}

.param-option {
    padding: 0.5rem 1rem;
    padding-left: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    border-left: 2px solid transparent;
}

.param-option:hover,
.param-option.focused {
    background: var(--bg-body);
    color: var(--text-primary);
    border-left-color: var(--primary);
}

.param-option.active {
    color: var(--primary);
    font-weight: 500;
}

.param-option.highlight {
    border-left: none;
}

.param-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.param-placeholder {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: var(--primary-dark);
}

.breadcrumb span {
    color: var(--text-secondary);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.tab {
    padding: 0.5rem 1rem;
    border-radius: var(--radius) var(--radius) 0 0;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--primary);
    background: var(--bg-secondary);
}

.tab.active {
    color: var(--primary);
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--primary);
}

/* Figure frame */
.figure-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.figure-header .card-title {
    margin-bottom: 0;
}

.btn-back {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-back:hover {
    background: var(--primary);
    color: var(--bg-body);
    border-color: var(--primary);
}

.figure-container {
    background: var(--bg-primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.figure-frame {
    width: 100%;
    min-height: 400px;
    border: none;
    display: block;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.figure-frame.loading {
    opacity: 0.3;
}

/* Config YAML sections */
.config-file {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

.config-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1rem;
}

.config-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.config-badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-true {
    background: rgba(52, 211, 153, 0.2);
    color: #34d399;
}

.badge-false {
    background: rgba(248, 113, 113, 0.2);
    color: #f87171;
}

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

.config-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

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

.config-section-name {
    display: block;
    font-weight: 500;
    color: var(--primary);
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.config-description {
    color: var(--text-primary);
    line-height: 1.4;
}

.text-muted {
    color: var(--text-secondary);
    font-style: italic;
}

/* Footer */
.footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    text-align: center;
    padding: 1.25rem 2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: auto;
}

.footer-content {
    max-width: var(--max-width);
    margin: 0 auto;
}

/* Auth pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}

.auth-title {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.auth-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.auth-error {
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: #f87171;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.auth-form .form-group {
    margin-bottom: 1rem;
}

.auth-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.auth-form input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

.btn-login {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: var(--bg-body);
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.5rem;
}

.btn-login:hover {
    background: var(--primary-dark);
}

.auth-back {
    display: block;
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
}

.auth-back:hover {
    color: var(--primary);
}

/* Admin panel */
.admin-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--primary);
    color: var(--bg-body);
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-action:hover {
    background: var(--primary-dark);
}

.btn-action.loading {
    opacity: 0.7;
    pointer-events: none;
}

.btn-action svg {
    width: 1rem;
    height: 1rem;
}

.admin-result {
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 1rem;
}

.admin-result.success {
    background: rgba(52, 211, 153, 0.15);
    border: 1px solid rgba(52, 211, 153, 0.3);
    color: #34d399;
}

.admin-result.error {
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: #f87171;
}

.admin-result h4 {
    margin-bottom: 0.5rem;
}

.admin-result ul {
    margin: 0.5rem 0 0 1.25rem;
    padding: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }

    .container {
        padding: 1rem;
    }

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