/* ============================================================
   pxlab – Stylesheet
   Dark theme / minimalist / Cal Sans + Vollkorn
   Palette: #333E38 #1097A7 #FBCF00 #CD78BC #01A985
            #978BA1 #ED7139 #2741A7 #E6DCC5 #C3C2B5
   ============================================================ */

@font-face {
    font-family: "Cal Sans";
    font-weight: 600;
    font-display: swap;
    src: url("https://cdn.jsdelivr.net/npm/cal-sans@1.0.1/fonts/webfonts/CalSans-SemiBold.woff2") format("woff2");
}

:root {
    --bg-primary: #1a201d;
    --bg-secondary: #222926;
    --bg-card: #2a312d;
    --bg-card-hover: #323a35;
    --bg-input: #2e3532;
    --bg-modal: #232a26;
    --border: #3d453f;
    --border-subtle: #333b36;
    --accent: #1097a7;
    --accent-hover: #12b3c5;
    --accent-light: rgba(16, 151, 167, 0.12);
    --accent-muted: rgba(16, 151, 167, 0.06);
    --text-primary: #e6dcc5;
    --text-secondary: #c3c2b5;
    --text-muted: #7a7a6e;
    --success: #01a985;
    --warning: #fbcf00;
    --danger: #ed7139;
    --top-note: #ed7139;
    --heart-note: #cd78bc;
    --base-note: #2741a7;
    --purple: #978ba1;
    --teal: #1097a7;
    --gold: #fbcf00;
    --mauve: #cd78bc;
    --emerald: #01a985;
    --orange: #ed7139;
    --blue: #2741a7;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --radius: 8px;
    --radius-sm: 5px;
    --radius-lg: 12px;
    --transition: 0.18s ease;
    --sidebar-w: 220px;
    --mobile-nav-h: 68px;
    --font-display: "Cal Sans", "SF Pro Display", system-ui, sans-serif;
    --font-body: "Vollkorn", Georgia, "Times New Roman", serif;
    --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}
body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}
a {
    color: var(--accent);
    text-decoration: none;
}
img {
    max-width: 100%;
    display: block;
}
button {
    cursor: pointer;
    font-family: var(--font-body);
}
input,
select,
textarea {
    font-family: var(--font-body);
    font-size: 0.95rem;
}

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

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}
.sidebar-header {
    padding: 28px 20px 20px;
}
.sidebar-header h1 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.5px;
}
.nav-list {
    list-style: none;
    padding: 8px 10px;
    flex: 1;
}
.nav-item {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 400;
    color: var(--text-muted);
    transition: all var(--transition);
    margin-bottom: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}
.nav-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.6;
    flex-shrink: 0;
}
.nav-item:hover {
    color: var(--text-secondary);
    background: var(--bg-card);
}
.nav-item:hover svg {
    opacity: 0.85;
}
.nav-item.active {
    color: var(--accent);
    background: var(--accent-light);
    font-weight: 600;
}
.nav-item.active svg {
    opacity: 1;
}
.sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sidebar-footer button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    transition: all var(--transition);
    text-align: left;
    letter-spacing: 0.3px;
}
.sidebar-footer button:hover {
    color: var(--text-secondary);
    background: var(--bg-card);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 32px 40px 100px;
    max-width: 1200px;
    width: 100%;
}

.view {
    display: none;
}
.view.active {
    display: block;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 12px;
}
.view-header h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--text-primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 600;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: var(--font-body);
    letter-spacing: 0.2px;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover {
    background: var(--accent-hover);
}
.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--accent);
}
.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    opacity: 0.85;
}
.btn-sm {
    padding: 5px 11px;
    font-size: 0.8rem;
}
.btn-lg {
    padding: 12px 24px;
    font-size: 0.95rem;
}
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 5px 10px;
    font-size: 0.84rem;
}
.btn-ghost:hover {
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.form-control {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: border-color var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}
.form-control::placeholder {
    color: var(--text-muted);
}
textarea.form-control {
    min-height: 72px;
    resize: vertical;
    field-sizing: content;
}
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%237a7a6e' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}
.form-hint {
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 20px;
    transition: all var(--transition);
}
.card:hover {
    border-color: var(--border);
    box-shadow: var(--shadow);
}
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 9px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--accent-muted);
    color: var(--accent);
    margin: 0;
    min-height: 30px;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.tag-top {
    background: rgba(237, 113, 57, 0.12);
    color: var(--top-note);
}
.tag-heart {
    background: rgba(205, 120, 188, 0.12);
    color: var(--heart-note);
}
.tag-base {
    background: rgba(39, 65, 167, 0.15);
    color: #5b7de8;
}
.tag-note-symbol,
.tag-origin-symbol {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
    min-height: 30px;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    color: var(--text-secondary);
    transform: translateY(1px);
}
.tag-icon {
    display: block;
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
}
.tag-natural {
    color: var(--text-secondary);
}
.tag-synthetic {
    color: var(--text-secondary);
}
.tag-note-symbol.tag-top,
.tag-note-symbol.tag-heart,
.tag-note-symbol.tag-base {
    background: transparent;
    color: var(--text-secondary);
}
.tag-category {
    background: var(--category-bg, var(--bg-input));
    color: var(--category-color, var(--text-muted));
    border: 1px solid var(--category-border, var(--border-subtle));
}
.tag-accord {
    background: rgba(151, 139, 161, 0.15);
    color: var(--purple);
    border: 1px solid rgba(151, 139, 161, 0.2);
}

.material-card {
    cursor: pointer;
}
.material-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}
.material-card-header h3 {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
}
.material-card .cas {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
.material-card .tags {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 6px 0;
}
.material-card .meta {
    display: flex;
    gap: 14px;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 8px;
}
.material-card .stock-bar {
    height: 3px;
    background: var(--bg-input);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}
.material-card .stock-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}
.stock-ok {
    background: var(--success);
}
.stock-low {
    background: var(--warning);
}
.stock-critical {
    background: var(--danger);
}

.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}
.filter-bar .search-input {
    flex: 1;
    min-width: 180px;
    padding: 8px 12px 8px 34px;
    background: var(--bg-input)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%237a7a6e' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.44.856a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E")
        no-repeat 11px center;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.88rem;
}
.filter-bar .search-input:focus {
    outline: none;
    border-color: var(--accent);
}
.filter-bar select {
    padding: 8px 28px 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.82rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%237a7a6e' d='M5 7L1 3h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.formula-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 20px;
}
.formula-ingredients {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    overflow: visible;
}
.formula-ingredients-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
}
.formula-ingredients-header h3 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
}
.ingredient-table {
    width: 100%;
    border-collapse: collapse;
}
.ingredient-table th {
    padding: 8px 12px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-muted);
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}
.ingredient-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.85rem;
}
.ingredient-table tr:hover {
    background: var(--bg-card-hover);
}
.ingredient-table .amount-input {
    width: 72px;
    padding: 5px 7px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-align: right;
    font-size: 0.85rem;
}
.ingredient-table .amount-input:focus {
    outline: none;
    border-color: var(--accent);
}
.ingredient-table .pct {
    color: var(--accent);
    font-weight: 600;
}
.ingredient-table .delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 4px;
}
.ingredient-table .delete-btn:hover {
    color: var(--danger);
}
.ingredient-empty {
    padding: 36px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.ingredient-name-link {
    cursor: pointer;
    color: var(--text-primary);
    transition: color var(--transition);
    border-bottom: 1px dotted var(--border);
}
.ingredient-name-link:hover {
    color: var(--accent);
}
.accord-indicator {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.65rem;
    color: var(--purple);
    margin-left: 6px;
    opacity: 0.8;
}

.formula-add-row {
    padding: 10px 16px;
    border-top: 1px solid var(--border-subtle);
}
.formula-add-row input {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.88rem;
}
.formula-add-row input:focus {
    outline: none;
    border-color: var(--accent);
}
.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: var(--shadow-lg);
}
.autocomplete-item {
    padding: 9px 14px;
    cursor: pointer;
    font-size: 0.88rem;
    display: flex;
    justify-content: space-between;
    transition: background var(--transition);
}
.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--accent-light);
    color: var(--accent);
}
.autocomplete-item .accord-badge {
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(151, 139, 161, 0.15);
    color: var(--purple);
    margin-right: 6px;
}

.formula-sidebar .card {
    margin-bottom: 14px;
}
.formula-sidebar h3 {
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    margin-bottom: 10px;
    color: var(--text-muted);
}
.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 0.85rem;
}
.stat-row .label {
    color: var(--text-muted);
}
.stat-row .value {
    font-weight: 600;
}
.pyramid-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 14px 0;
}
.pyramid-level {
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    transition: width 0.3s ease;
    min-width: 56px;
}

.log-timeline {
    position: relative;
    padding-left: 20px;
}
.log-timeline::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-subtle);
}
.log-entry {
    position: relative;
    margin-bottom: 16px;
}
.log-entry::before {
    content: "";
    position: absolute;
    left: -18px;
    top: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-primary);
}
.log-entry .card {
    padding: 14px 18px;
}
.log-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.log-entry-header .date {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.log-entry-header .formula-link {
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
}
.log-entry .evaluation {
    font-size: 0.88rem;
    line-height: 1.6;
}
.log-entry .photos {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    overflow-x: auto;
}
.log-entry .photos img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}
.rating-stars {
    display: inline-flex;
    gap: 1px;
    font-size: 1rem;
}
.rating-stars .star {
    cursor: pointer;
    color: var(--text-muted);
}
.rating-stars .star.active {
    color: var(--gold);
}

.impression-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    align-items: center;
}
.impression-time {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.impression-field {
    width: 100%;
    padding: 7px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: var(--font-body);
}
.impression-field:focus {
    outline: none;
    border-color: var(--accent);
}
.impression-row {
    display: contents;
}
.impressions-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.impression-chip {
    font-size: 0.78rem;
    color: var(--text-secondary);
    background: rgba(16, 151, 167, 0.06);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
}
.impression-summary {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 4px;
}
.impression-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 12, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.15s ease;
}
.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-subtle);
}
.modal-header h2 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
}
.modal-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}
.modal-close:hover {
    background: var(--danger);
    color: #fff;
}
.modal-body {
    padding: 22px;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 22px;
    border-top: 1px solid var(--border-subtle);
}

.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 12, 0.6);
    backdrop-filter: blur(6px);
    z-index: 2000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 14vh;
}
.search-overlay.hidden {
    display: none;
}
.search-modal {
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 520px;
    max-width: 95vw;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.search-modal input {
    width: 100%;
    padding: 16px 22px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-body);
}
.search-modal input:focus {
    outline: none;
}
.search-modal input::placeholder {
    color: var(--text-muted);
}
.search-results {
    max-height: 360px;
    overflow-y: auto;
}
.search-result-item {
    padding: 10px 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition);
}
.search-result-item:hover,
.search-result-item.selected {
    background: var(--accent-light);
}
.search-result-item .info {
    flex: 1;
}
.search-result-item .name {
    font-weight: 600;
}
.search-result-item .detail {
    font-size: 0.76rem;
    color: var(--text-muted);
}
.search-result-item .type-badge {
    font-size: 0.65rem;
    padding: 2px 7px;
    border-radius: 3px;
    background: var(--bg-input);
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.toast-container {
    position: fixed;
    bottom: 72px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.toast {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow);
    animation: slideIn 0.2s ease;
    max-width: 340px;
}
.toast-success {
    border-left: 3px solid var(--success);
}
.toast-warning {
    border-left: 3px solid var(--warning);
}
.toast-error {
    border-left: 3px solid var(--danger);
}
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin-bottom: 6px;
    color: var(--text-secondary);
}
.empty-state p {
    font-size: 0.88rem;
    margin-bottom: 16px;
}

.analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 18px;
}
.chart-card h3 {
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}
.compare-table th,
.compare-table td {
    padding: 8px 12px;
    border: 1px solid var(--border-subtle);
    text-align: left;
}
.compare-table th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.compare-table .changed {
    background: var(--accent-muted);
}

.alert-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.alert-badge.low {
    background: rgba(251, 207, 0, 0.12);
    color: var(--warning);
}
.alert-badge.critical {
    background: rgba(237, 113, 57, 0.12);
    color: var(--danger);
}
.maceration-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    background: rgba(39, 65, 167, 0.12);
    color: #5b7de8;
}
.version-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 0.68rem;
    font-weight: 700;
    background: var(--accent-light);
    color: var(--accent);
    text-transform: uppercase;
}

.cross-ref-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 180px;
    overflow-y: auto;
}
.cross-ref-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.82rem;
}
.cross-ref-item:hover {
    background: var(--accent-light);
}
.cross-ref-name {
    font-weight: 500;
    color: var(--accent);
}
.cross-ref-detail {
    font-size: 0.74rem;
    color: var(--text-muted);
}

.formula-card {
    cursor: pointer;
}
.formula-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}
.formula-card-header h3 {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
}
.formula-card .description {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.4;
}
.formula-meta {
    display: flex;
    gap: 14px;
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.pie-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    justify-content: center;
}
.pie-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.76rem;
    color: var(--text-secondary);
}
.pie-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.subject-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 14px;
}
.subject-tab {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition);
    background: transparent;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font-body);
}
.subject-tab:hover {
    color: var(--text-primary);
}
.subject-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-h);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    z-index: 100;
    justify-content: space-between;
    align-items: center;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    gap: 4px;
}
.mobile-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.64rem;
    font-weight: 600;
    padding: 8px 6px 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.mobile-nav button span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mobile-nav button.active {
    color: var(--accent);
}
.mobile-nav button:hover {
    color: var(--accent);
}
.mobile-nav button svg {
    width: 18px;
    height: 18px;
    margin-bottom: 1px;
}

@media print {
    .sidebar,
    .mobile-nav,
    .search-overlay,
    .toast-container,
    .modal-overlay {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    body {
        background: #fff;
        color: #000;
    }
    .card {
        border: 1px solid #ccc;
        box-shadow: none;
    }
    .btn {
        display: none;
    }
}
@media (max-width: 1024px) {
    .formula-layout {
        grid-template-columns: 1fr;
    }
    .analysis-grid {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    .main-content {
        margin-left: 0;
        padding: 16px 16px calc(var(--mobile-nav-h) + env(safe-area-inset-bottom) + 24px);
    }
    .mobile-nav {
        display: flex;
    }
    .card-grid {
        grid-template-columns: 1fr;
    }
    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
    }
    .view-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .modal-overlay {
        padding: 0;
        align-items: stretch;
    }
    .modal {
        max-width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
    }
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.hidden {
    display: none !important;
}
.text-accent {
    color: var(--accent);
}
.text-muted {
    color: var(--text-muted);
}
.text-center {
    text-align: center;
}
.mt-1 {
    margin-top: 8px;
}
.mt-2 {
    margin-top: 16px;
}
.mt-3 {
    margin-top: 24px;
}
.mb-1 {
    margin-bottom: 8px;
}
.mb-2 {
    margin-bottom: 16px;
}
.gap-1 {
    gap: 8px;
}
.flex {
    display: flex;
}
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.flex-wrap {
    flex-wrap: wrap;
}
.w-full {
    width: 100%;
}

/* Logbook subject label */
.log-subject-label {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--text);
}

/* Performance summary chips */
.performance-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 6px 0;
}
.perf-chip {
    font-size: 0.78rem;
    color: var(--text-muted);
    background: var(--surface-alt);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Logbook card clickable */
.log-entry .card[style*="cursor:pointer"]:hover {
    border-color: var(--accent);
}
