:root {
    --sidebar-w: 240px;
    --topbar-h: 58px;

    /* Surfaces */
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;

    /* Sidebar */
    --sb-bg: #0f172a;
    --sb-text: #94a3b8;
    --sb-text-active: #f8fafc;
    --sb-hover: rgba(255, 255, 255, 0.05);
    --sb-active: rgba(255, 255, 255, 0.10);

    /* Text */
    --t1: #0f172a;
    --t2: #475569;
    --t3: #94a3b8;

    /* Border */
    --border: #e2e8f0;

    /* Accent - blue */
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;

    /* Status colors */
    --green: #059669;
    --green-light: #ecfdf5;
    --amber: #d97706;
    --amber-light: #fffbeb;
    --red: #dc2626;
    --red-light: #fef2f2;
    --purple: #7c3aed;
    --purple-light: #f5f3ff;
    --orange: #ea580c;
    --orange-light: #fff7ed;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 10px 24px rgba(0, 0, 0, 0.10), 0 4px 8px rgba(0, 0, 0, 0.05);

    /* Radius */
    --r-sm: 6px;
    --r: 10px;
    --r-lg: 14px;

    --font: 'Inter', 'Noto Sans JP', system-ui, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--t1);
    min-height: 100vh;
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════
   APP SHELL
═══════════════════════════════════════ */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ═══════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sb-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

/* Logo */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 18px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    cursor: pointer;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.logo-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.logo-name {
    font-size: 14.5px;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.logo-sub {
    font-size: 10.5px;
    color: var(--sb-text);
    letter-spacing: 0.01em;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 10px 7px;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 9.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(148, 163, 184, 0.45);
    padding: 8px 9px 5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    background: transparent;
    color: var(--sb-text);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font);
    font-weight: 450;
    transition: background 0.13s, color 0.13s;
    text-align: left;
    margin-bottom: 1px;
}

.nav-item svg {
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--sb-hover);
    color: #e2e8f0;
}

.nav-item.active {
    background: var(--sb-active);
    color: var(--sb-text-active);
    font-weight: 550;
}

/* Footer */
.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.sidebar-stats {
    display: flex;
    gap: 18px;
}

.sidebar-stat {
    display: flex;
    flex-direction: column;
}

.sidebar-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #f8fafc;
    line-height: 1.1;
}

.sidebar-stat-label {
    font-size: 10px;
    color: var(--sb-text);
    margin-top: 2px;
}

/* ═══════════════════════════════════════
   MAIN WRAPPER
═══════════════════════════════════════ */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ═══════════════════════════════════════
   TOP BAR
═══════════════════════════════════════ */
.top-bar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    flex-shrink: 0;
    gap: 14px;
}

.page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--t1);
    flex-shrink: 0;
    letter-spacing: -0.01em;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: flex-end;
}

/* Search box */
.search-box {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 5px 11px;
    color: var(--t3);
    transition: border-color 0.15s;
}

.search-box:focus-within {
    border-color: var(--accent);
}

.search-box input {
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--t1);
    font-family: var(--font);
    width: 210px;
    outline: none;
}

.search-box input::placeholder {
    color: var(--t3);
}

/* Filter tabs */
.filter-tabs {
    display: flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 3px;
    gap: 2px;
}

.filter-tab {
    padding: 4px 12px;
    border: none;
    background: transparent;
    border-radius: 4px;
    font-size: 12px;
    font-family: var(--font);
    color: var(--t2);
    cursor: pointer;
    transition: background 0.13s, color 0.13s, box-shadow 0.13s;
    font-weight: 450;
    white-space: nowrap;
}

.filter-tab.active {
    background: var(--surface);
    color: var(--t1);
    font-weight: 550;
    box-shadow: var(--shadow-xs);
}

/* ═══════════════════════════════════════
   CONTENT AREA
═══════════════════════════════════════ */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* ═══════════════════════════════════════
   DASHBOARD
═══════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-blue .stat-icon {
    background: var(--accent-light);
    color: var(--accent);
}

.stat-green .stat-icon {
    background: var(--green-light);
    color: var(--green);
}

.stat-purple .stat-icon {
    background: var(--purple-light);
    color: var(--purple);
}

.stat-orange .stat-icon {
    background: var(--orange-light);
    color: var(--orange);
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--t1);
    line-height: 1;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 12px;
    color: var(--t2);
    margin-top: 3px;
}

/* Dashboard grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 14px;
}

.dashboard-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.panel-header h2 {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--t1);
}

.text-btn {
    background: none;
    border: none;
    font-size: 12px;
    color: var(--accent);
    cursor: pointer;
    font-family: var(--font);
    font-weight: 500;
    transition: color 0.13s;
    padding: 2px 4px;
    border-radius: 4px;
}

.text-btn:hover {
    color: var(--accent-hover);
}

/* Recent list */
.recent-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background 0.13s, border-color 0.13s;
}

.recent-item:hover {
    background: var(--surface-2);
    border-color: var(--accent);
}

.recent-item-icon {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ri-exp {
    background: var(--accent-light);
    color: var(--accent);
}

.ri-reagent {
    background: var(--green-light);
    color: var(--green);
}

.recent-item-info {
    flex: 1;
    min-width: 0;
}

.recent-item-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--t1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-item-meta {
    font-size: 11.5px;
    color: var(--t2);
    margin-top: 1px;
}

.empty-state-sm {
    text-align: center;
    color: var(--t3);
    font-size: 13px;
    padding: 20px 0;
}

/* Quick actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: transparent;
    cursor: pointer;
    transition: background 0.13s, border-color 0.13s;
    text-align: left;
    font-family: var(--font);
    width: 100%;
}

.quick-action-btn:hover {
    background: var(--surface-2);
    border-color: var(--accent);
}

.qa-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.qa-blue {
    background: var(--accent-light);
    color: var(--accent);
}

.qa-green {
    background: var(--green-light);
    color: var(--green);
}

.qa-purple {
    background: var(--purple-light);
    color: var(--purple);
}

.qa-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--t1);
    line-height: 1.3;
}

.qa-desc {
    font-size: 11.5px;
    color: var(--t2);
    margin-top: 1px;
}

/* ═══════════════════════════════════════
   FORMS
═══════════════════════════════════════ */
.form-container {
    max-width: 800px;
    margin: 0 auto;
}

.form-header {
    margin-bottom: 20px;
}

.form-header h2 {
    font-size: 19px;
    font-weight: 700;
    color: var(--t1);
    letter-spacing: -0.02em;
    margin-bottom: 3px;
}

.form-header p {
    font-size: 13px;
    color: var(--t2);
}

.lab-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 22px;
    box-shadow: var(--shadow-sm);
}

.form-card-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--t3);
    margin-bottom: 15px;
    padding-bottom: 11px;
    border-bottom: 1px solid var(--border);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 13px;
}

.full-width {
    grid-column: 1 / -1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

label {
    font-size: 12px;
    font-weight: 550;
    color: var(--t2);
    letter-spacing: 0.01em;
}

.required {
    color: var(--red);
}

input[type="text"],
input[type="date"],
input[type="time"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 8px 11px;
    font-size: 13.5px;
    font-family: var(--font);
    color: var(--t1);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

input::placeholder,
textarea::placeholder {
    color: var(--t3);
    font-size: 13px;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
    cursor: pointer;
}

textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.65;
}

.time-range {
    display: flex;
    align-items: center;
    gap: 7px;
}

.time-range input {
    flex: 1;
}

.time-sep {
    color: var(--t3);
    font-size: 13px;
    flex-shrink: 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 4px;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--r-sm);
    padding: 9px 22px;
    font-size: 13.5px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
    background: var(--surface);
    color: var(--t2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 9px 18px;
    font-size: 13.5px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.13s, color 0.13s;
}

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

/* ═══════════════════════════════════════
   RECORDS LIST
═══════════════════════════════════════ */
.records-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.record-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 18px 20px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow-sm);
}

.record-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.record-card-header {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    margin-bottom: 10px;
}

.record-type-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.record-type-exp {
    background: var(--accent-light);
    color: var(--accent);
}

.record-type-reagent {
    background: var(--green-light);
    color: var(--green);
}

.record-card-info {
    flex: 1;
    min-width: 0;
}

.record-card-title {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--t1);
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.record-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--t2);
}

.record-card-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* Status badges */
.status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 100px;
    white-space: nowrap;
}

.status-完了 {
    background: var(--green-light);
    color: var(--green);
}

.status-実施中 {
    background: var(--accent-light);
    color: var(--accent);
}

.status-計画中 {
    background: var(--amber-light);
    color: var(--amber);
}

.status-失敗 {
    background: var(--red-light);
    color: var(--red);
}

.category-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 9px;
    border-radius: 100px;
    background: var(--bg);
    color: var(--t2);
    border: 1px solid var(--border);
    white-space: nowrap;
}

/* Delete button */
.delete-record-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 5px;
    cursor: pointer;
    color: var(--t3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.13s, color 0.13s, border-color 0.13s;
    opacity: 0;
}

.record-card:hover .delete-record-btn {
    opacity: 1;
}

.delete-record-btn:hover {
    background: var(--red-light);
    border-color: #fca5a5;
    color: var(--red);
}

/* Card preview text */
.record-card-preview {
    font-size: 13px;
    color: var(--t2);
    line-height: 1.55;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    white-space: pre-wrap;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 64px 20px;
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    color: var(--t3);
}

.empty-state-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--t1);
    margin-bottom: 4px;
}

.empty-state-desc {
    font-size: 13px;
    color: var(--t2);
}

/* ═══════════════════════════════════════
   MODAL
═══════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px;
    backdrop-filter: blur(4px);
}

.modal-box {
    background: var(--surface);
    border-radius: var(--r-lg);
    max-width: 680px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

.modal-close {
    position: sticky;
    top: 14px;
    float: right;
    margin: 14px 14px 0 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px;
    cursor: pointer;
    color: var(--t2);
    display: flex;
    align-items: center;
    transition: background 0.13s, color 0.13s, border-color 0.13s;
    z-index: 1;
}

.modal-close:hover {
    background: var(--red-light);
    color: var(--red);
    border-color: #fca5a5;
}

.modal-header {
    padding: 20px 22px 16px;
    border-bottom: 1px solid var(--border);
    clear: both;
}

.modal-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--t3);
    margin-bottom: 6px;
}

.modal-title {
    font-size: 19px;
    font-weight: 700;
    color: var(--t1);
    margin-bottom: 9px;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.modal-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
}

.modal-body {
    padding: 18px 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 4px;
}


.modal-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--t3);
    margin-bottom: 6px;
}

.modal-section-content {
    font-size: 13.5px;
    color: var(--t1);
    white-space: pre-wrap;
    line-height: 1.7;
    background: var(--surface-2);
    border-radius: var(--r-sm);
    padding: 11px 13px;
    border: 1px solid var(--border);
}

.modal-section-content.mono {
    font-family: 'Consolas', 'Menlo', 'Monaco', monospace;
    font-size: 12.5px;
    line-height: 1.75;
}

.modal-info-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 9px 12px;
}

.modal-info-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--t3);
    margin-bottom: 3px;
}

.modal-info-value {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--t1);
}

/* ═══════════════════════════════════════
   TOAST
═══════════════════════════════════════ */
.toast {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--t1);
    color: #fff;
    padding: 9px 18px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font);
    box-shadow: var(--shadow-md);
    opacity: 0;
    transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.32s ease;
    z-index: 1000;
    white-space: nowrap;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--green);
}

.toast.error {
    background: var(--red);
}

/* ═══════════════════════════════════════
   TOP BAR LEFT (mobile brand)
═══════════════════════════════════════ */
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-shrink: 0;
}

.mobile-brand {
    display: none;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    cursor: pointer;
}

.mobile-logo-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.mobile-brand-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--t1);
    letter-spacing: -0.02em;
}

/* ═══════════════════════════════════════
   CALENDAR WIDGET
═══════════════════════════════════════ */
.cal-panel {
    display: flex;
    flex-direction: column;
}

.cal-nav-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.cal-nav-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--t2);
    transition: background 0.13s, color 0.13s, border-color 0.13s;
    flex-shrink: 0;
}

.cal-nav-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.cal-month-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--t1);
    white-space: nowrap;
    min-width: 84px;
    text-align: center;
}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin: 10px 0 3px;
}

.cal-weekdays span {
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--t3);
    padding: 3px 0;
    letter-spacing: 0.03em;
}

.cal-sun {
    color: var(--red) !important;
}

.cal-sat {
    color: var(--accent) !important;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    flex: 1;
}

.cal-day {
    min-height: 38px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border-radius: 6px;
    cursor: default;
    transition: background 0.13s;
    position: relative;
}

.cal-day.cal-has-records {
    cursor: pointer;
}

.cal-day.cal-has-records:hover {
    background: var(--accent-light);
}

.cal-day.cal-today .cal-day-num {
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
}

.cal-day.cal-today.cal-has-records:hover .cal-day-num {
    background: var(--accent-hover);
}

.cal-day-num {
    font-size: 12px;
    font-weight: 450;
    color: var(--t1);
    line-height: 1;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cal-day.cal-empty {
    pointer-events: none;
}

.cal-day.cal-empty .cal-day-num {
    opacity: 0;
}

/* Dots for records */
.cal-dots {
    display: flex;
    gap: 2px;
    justify-content: center;
    height: 6px;
    align-items: center;
}

.cal-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cal-dot-exp {
    background: var(--accent);
}

.cal-dot-reagent {
    background: var(--green);
}

/* Legend */
.cal-legend {
    display: flex;
    gap: 14px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--t2);
}

.legend-item .cal-dot {
    width: 6px;
    height: 6px;
}

/* ═══════════════════════════════════════
   MOBILE BOTTOM NAV
═══════════════════════════════════════ */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 4px 8px env(safe-area-inset-bottom, 4px);
    z-index: 150;
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.07);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--t3);
    font-size: 10px;
    font-family: var(--font);
    transition: color 0.13s;
    flex: 1;
    border-radius: 8px;
}

.mobile-nav-item span {
    font-weight: 500;
}

.mobile-nav-item.active {
    color: var(--accent);
}

.mobile-nav-item.active svg {
    stroke-width: 2.5;
}

/* ═══════════════════════════════════════
   RECORDS CONTROLS BAR
═══════════════════════════════════════ */
.records-controls {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 11px 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.rc-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--t2);
    white-space: nowrap;
}

.rc-date-group {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--t3);
}

.rc-date-group input[type="date"] {
    width: auto;
    font-size: 13px;
    padding: 5px 9px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--t1);
    font-family: var(--font);
    outline: none;
    cursor: pointer;
    box-shadow: none;
}

.rc-date-group input[type="date"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

.rc-clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 4px;
    color: var(--t3);
    cursor: pointer;
    transition: background 0.13s, color 0.13s, border-color 0.13s;
    line-height: 1;
}

.rc-clear-btn:hover {
    color: var(--red);
    background: var(--red-light);
    border-color: #fca5a5;
}

.rc-divider {
    width: 1px;
    height: 22px;
    background: var(--border);
    flex-shrink: 0;
}

.rc-alpha-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.alpha-btns {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.alpha-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 11px;
    font-size: 12.5px;
    font-weight: 700;
    font-family: 'Consolas', 'Menlo', 'Monaco', monospace;
    color: var(--t2);
    cursor: pointer;
    transition: background 0.13s, color 0.13s, border-color 0.13s;
    letter-spacing: 0.05em;
}

.alpha-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.alpha-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Experiment number badge */
.exp-num-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 5px;
    background: var(--t1);
    color: #fff;
    font-family: 'Consolas', 'Menlo', 'Monaco', monospace;
    letter-spacing: 0.06em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════ */
::-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(--t3);
}

/* ═══════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════ */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

@media (max-width: 768px) {

    /* Show mobile UI */
    .sidebar {
        display: none;
    }

    .mobile-nav {
        display: flex;
    }

    .mobile-brand {
        display: flex;
    }

    /* Adjust top bar */
    .top-bar {
        padding: 0 14px;
    }

    .page-title {
        font-size: 14px;
    }

    /* Content padding for bottom nav */
    .content {
        padding: 14px 14px 80px;
    }

    /* Layouts */
    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal-info-grid {
        grid-template-columns: 1fr;
    }

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

    .form-container {
        max-width: 100%;
    }

    /* Search box */
    .search-box input {
        width: 130px;
    }

    /* Records controls wrap */
    .records-controls {
        gap: 10px;
    }

    .rc-divider {
        display: none;
    }

    /* Calendar compact on mobile */
    .cal-day {
        min-height: 34px;
    }

    .cal-day-num {
        font-size: 11px;
        width: 22px;
        height: 22px;
    }

    .cal-day.cal-today .cal-day-num {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }

    /* Modal full-screen on mobile */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal-box {
        max-width: 100%;
        max-height: 92vh;
        border-radius: var(--r-lg) var(--r-lg) 0 0;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card {
        padding: 14px 16px;
    }

    .stat-value {
        font-size: 22px;
    }

    .top-bar-actions {
        gap: 6px;
    }

    .filter-tabs {
        gap: 1px;
    }

    .filter-tab {
        padding: 4px 8px;
        font-size: 11px;
    }
}

/* ── Loading Overlay ── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(241, 245, 249, 0.92);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 14px;
    color: var(--t2);
    font-weight: 500;
    backdrop-filter: blur(2px);
}

.loading-spinner {
    animation: spin 1s linear infinite;
    color: var(--accent);
}

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

/* ── Template Bar ── */
.template-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    color: #0369a1;
}

.template-bar-label {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.template-bar select {
    flex: 1;
    min-width: 180px;
    padding: 6px 10px;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    color: var(--t1);
}

.btn-outline-sm {
    padding: 6px 14px;
    background: white;
    color: #0369a1;
    border: 1.5px solid #0369a1;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-outline-sm:hover {
    background: #0369a1;
    color: white;
}

/* ── Molecule Suggestion Bar ── */
.mol-bar {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.mol-bar-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    padding: 5px 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--t2);
    text-align: left;
    transition: background 0.1s;
}

.mol-bar-toggle:hover {
    background: #f0f9ff;
    color: #0369a1;
}

.mol-toggle-icon {
    transition: transform 0.2s;
}

.mol-bar-collapsed .mol-toggle-icon {
    transform: rotate(-90deg);
}

.mol-bar-body {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 6px 10px 8px;
    border-top: 1px solid var(--border);
}

.mol-bar-collapsed .mol-bar-body {
    display: none;
}

.mol-group {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-wrap: wrap;
}

.mol-group+.mol-group {
    padding-left: 8px;
    border-left: 1px solid var(--border);
    margin-left: 4px;
}

.mol-group-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 1px;
}

.mol-btn {
    padding: 2px 7px;
    background: white;
    color: #0369a1;
    border: 1px solid #bae6fd;
    border-radius: 100px;
    font-size: 12px;
    font-family: 'Courier New', 'Courier', monospace;
    cursor: pointer;
    transition: all 0.12s;
    line-height: 1.7;
}

.mol-btn:hover {
    background: #0369a1;
    color: white;
    border-color: #0369a1;
}

.mol-attached {
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
}

/* ── Molecule Autocomplete ── */
.mol-autocomplete {
    position: absolute;
    z-index: 2000;
    background: white;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    display: none;
}

.mol-ac-item {
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    font-family: 'Courier New', 'Courier', monospace;
    color: var(--t1);
    transition: background 0.1s;
}

.mol-ac-item:hover {
    background: #f0f9ff;
    color: #0369a1;
}

/* ── Component Row Form ── */
.components-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.component-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.component-row .comp-name {
    flex: 1;
    min-width: 0;
    width: auto;
    font-family: var(--font);
    font-size: 14.5px;
    font-weight: 500;
}

.component-row .comp-amount {
    width: 70px;
    flex-shrink: 0;
    font-size: 14px;
    text-align: right;
    padding-left: 8px;
    padding-right: 8px;
}

.component-row .comp-unit {
    width: 65px;
    flex-shrink: 0;
    font-size: 13.5px;
    padding-left: 4px;
    padding-right: 20px;
}

.comp-del-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: var(--t3);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
}

.comp-del-btn:hover {
    background: #fee2e2;
    color: #dc2626;
}

.btn-add-comp {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: var(--accent-light);
    color: var(--accent);
    border: 1px dashed var(--accent);
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-add-comp:hover {
    background: var(--accent);
    color: white;
    border-style: solid;
}

/* ── Edit mode ── */
.btn-cancel-edit {
    color: #dc2626;
    border-color: #dc2626;
}

.btn-cancel-edit:hover {
    background: #fee2e2;
}

.edit-record-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--t3);
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.edit-record-btn:hover {
    background: #e0f2fe;
    color: #0369a1;
}