:root {
    /* Sci‑fi research theme: dark space with neon green + slate gray accents */
    --color-bg: #0a0f1a;              /* deep space */
    --color-surface: #0e1626;         /* dark panel */
    --color-header: #020617;          /* almost black-blue */
    --color-border: rgba(148, 163, 184, 0.22); /* slate border */

    --color-accent: #22c55e;          /* neon green */
    --color-accent-soft: rgba(34, 197, 94, 0.15);
    --color-accent-strong: #16a34a;   /* stronger green */
    --color-gray: #94a3b8;            /* slate-400 */
    --color-text: #e5e7eb;            /* light text */

    --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.35);
    --radius-lg: 0.9rem;
    --radius-md: 0.6rem;

    --font-sans: system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

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

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    color: var(--color-text);
    line-height: 1.5;
    background:
      radial-gradient(circle at 20% 0%, rgba(34,197,94,0.18), rgba(34,197,94,0) 35%),
      radial-gradient(circle at 80% 10%, rgba(16,185,129,0.12), rgba(16,185,129,0) 35%),
      linear-gradient(180deg, #0a0f1a, #0b1220);
    background-attachment: fixed;
}

/* subtle holographic grid overlay */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
      linear-gradient(rgba(100,116,139,0.07) 1px, transparent 1px),
      linear-gradient(90deg, rgba(100,116,139,0.07) 1px, transparent 1px);
    background-size: 40px 40px, 40px 40px;
    mix-blend-mode: overlay;
    z-index: 0;
}


header, header * {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

a {
    color: var(--color-accent-strong);
    text-decoration: none;
    transition: color 0.15s ease, opacity 0.15s ease;
}

a:hover {
    color: #15803d;
}

.container {
    width: min(1120px, 100% - 2.5rem);
    margin-inline: auto;
}

main {
    padding-top: 88px;
    padding-bottom: 48px;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    background: linear-gradient(90deg, #020617 0%, #022c22 40%, #020617 100%);
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.7);
    border-bottom: 1px solid #0f172a;
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-block: 0.6rem;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    cursor: default;
}

.logo-img {
    height: 40px;
    -webkit-user-drag: none;
    user-drag: none;
}

.nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.nav a {
    position: relative;
    font-size: 0.95rem;
    color: #e5e7eb;
    cursor: pointer;
    letter-spacing: 0.01em;
}

.nav a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -0.3rem;
    width: 0;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--color-accent-soft), var(--color-accent));
    transition: width 0.18s ease-out;
}

.nav a:hover {
    color: #ffffff;
    text-shadow: 0 0 8px rgba(34,197,94,0.45);
}

.nav a:hover::after {
    width: 100%;
}

.nav a.nav-current {
    color: #ffffff;
    font-weight: 600;
}

.nav a.nav-current::after {
    width: 100%;
}

/* Session toggle (header) */
.session-toggle {
    margin-left: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.session-toggle .session-label {
    font-size: 0.85rem;
    color: #cbd5e1;
    cursor: pointer;
}

.switch {
    --switch-width: 46px;
    --switch-height: 24px;
    --switch-padding: 3px;
    --thumb-size: 18px;
    position: relative;
    width: var(--switch-width);
    height: var(--switch-height);
    display: inline-block;
}

.switch input {
    appearance: none;
    -webkit-appearance: none;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
}

.switch-track {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #0b1220, #0b1322);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 999px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
    transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.switch-track::before {
    content: "";
    position: absolute;
    top: var(--switch-padding);
    left: var(--switch-padding);
    width: var(--thumb-size);
    height: var(--thumb-size);
    background: #e5e7eb;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.45), inset 0 -1px 0 rgba(0,0,0,0.15);
    transition: transform 0.18s ease, background-color 0.18s ease;
}

.switch input:checked + .switch-track {
    background: linear-gradient(90deg, rgba(34,197,94,0.22), rgba(34,197,94,0.45));
    border-color: rgba(34,197,94,0.7);
    box-shadow: 0 0 0 2px rgba(34,197,94,0.18);
}

.switch input:checked + .switch-track::before {
    transform: translateX(calc(var(--switch-width) - var(--thumb-size) - var(--switch-padding) * 2));
    background: #ffffff;
}

.switch input:focus-visible + .switch-track {
    outline: none;
    border-color: rgba(34,197,94,0.8);
    box-shadow: 0 0 0 3px rgba(34,197,94,0.28);
}

.switch:hover .switch-track {
    border-color: rgba(148, 163, 184, 0.55);
}

@media (max-width: 680px) {
    header .container {
        flex-direction: column;
        align-items: flex-start;
        padding-block: 0.5rem 0.7rem;
    }

    .nav {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
}

h1, h2, h3 {
    color: #e5e7eb;
    margin-top: 0;
}

h1 {
    font-size: clamp(1.9rem, 3vw, 2.3rem);
    margin-bottom: 0.4rem;
}

h2 {
    font-size: 1.3rem;
    margin-bottom: 0.35rem;
}

p {
    margin-top: 0.2rem;
    margin-bottom: 0.75rem;
    color: var(--color-gray);
    max-width: 70ch;
}

.section {
    margin: 2.2rem 0;
    padding: 1.4rem 1.6rem;
    border-radius: var(--radius-lg);
    background: rgba(14, 22, 38, 0.85);
    border: 1px solid var(--color-border);
    box-shadow: 0 10px 28px rgba(2, 6, 23, 0.55);
}

.section h2 {
    margin-top: 0.1rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border-radius: 999px;
    background: rgba(34,197,94,0.14);
    color: #bbf7d0;
    padding: 0.12rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.home-hero {
    margin-top: 0.8rem;
    margin-bottom: 1.8rem;
    padding: 1.5rem 1.6rem 1.6rem;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(22, 163, 74, 0.08), rgba(15, 23, 42, 0.95));
    color: #e5e7eb;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(15, 118, 110, 0.35);
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.1fr);
    gap: 1.5rem;
}

.home-hero h1 {
    color: #f9fafb;
}

.home-hero p {
    color: #e5e7eb;
}

.home-hero-highlight {
    font-size: 0.9rem;
    color: #bbf7d0;
}

.hero-stats {
    display: grid;
    gap: 0.6rem;
    align-content: start;
    font-size: 0.85rem;
}

.hero-stat-card {
    background: rgba(15, 23, 42, 0.92);
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
    border: 1px solid rgba(55, 65, 81, 0.9);
}

.hero-stat-label {
    color: #9ca3af;
    font-size: 0.75rem;
}

.hero-stat-value {
    color: #f9fafb;
    font-weight: 600;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-top: 1.25rem;
}

.card {
    background: rgba(8, 13, 24, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 1.1rem 1.35rem 1.3rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(34, 197, 94, 0.18);
    box-shadow: 0 8px 26px rgba(2, 6, 23, 0.6);
}


.card h2 {
    margin-bottom: 0.4rem;
}

.card p:last-child {
    margin-bottom: 0;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.7rem;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.28);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-accent-strong);
}

.btn-link:hover {
    background: rgba(34, 197, 94, 0.16);
    border-color: rgba(34, 197, 94, 0.5);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 1.2rem;
    border-radius: 999px;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: #eafff3;
    text-shadow: 0 0 10px rgba(34,197,94,0.45);
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.35), inset 0 0 0 1px rgba(255,255,255,0.08);
    transition: transform 0.08s ease-out, box-shadow 0.08s ease-out, filter 0.08s ease-out;
}

.btn-primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
    box-shadow: 0 10px 22px rgba(34, 197, 94, 0.5), 0 0 14px rgba(34,197,94,0.25);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 5px 12px rgba(34, 197, 94, 0.35);
}

.table-wrapper {
    margin-top: 1rem;
    overflow-x: auto;
}

/* Dual library layout */
.dual-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.2rem;
}

@media (min-width: 980px) {
    .dual-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* KPI grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.65rem;
    margin-bottom: 0.75rem;
}

.kpi-card {
    border: 1px solid var(--color-border);
    background: linear-gradient(180deg, rgba(2,6,23,0.6), rgba(2,6,23,0.35));
    border-radius: var(--radius-md);
    padding: 0.65rem 0.75rem;
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.45);
}

.kpi-title {
    font-size: 0.78rem;
    color: #cbd5e1;
    margin-bottom: 0.15rem;
}

.kpi-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: #e5e7eb;
}

.kpi-sub {
    font-size: 0.75rem;
    color: var(--color-gray);
}

/* Charts layout */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 980px) {
    .charts-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.chart-card {
    border: 1px solid var(--color-border);
    background: linear-gradient(180deg, rgba(2,6,23,0.6), rgba(2,6,23,0.35));
    border-radius: var(--radius-md);
    padding: 0.6rem 0.75rem 0.9rem;
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.5);
    overflow: hidden; /* prevent any canvas growth from affecting layout */
}

.chart-card h4 {
    margin: 0.1rem 0 0.6rem;
    font-size: 0.95rem;
    color: #e5e7eb;
}

.chart-card canvas {
    width: 100% !important;
    display: block; /* avoid inline-canvas baseline spacing issues */
}

/* Diet tabs (browser-like) */
.diet-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
}

.diet-tab {
    appearance: none;
    border: 1px solid var(--color-border);
    background: linear-gradient(180deg, rgba(2,6,23,0.7), rgba(2,6,23,0.45));
    color: var(--color-text);
    padding: 6px 12px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    border-bottom: 1px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
}

.diet-tab:hover { opacity: 0.9; }

.diet-tab.active {
    background: linear-gradient(180deg, rgba(34,197,94,0.18), rgba(2,6,23,0.6));
    border-color: var(--color-accent-strong);
}

.diet-tab.plus {
    width: 36px;
    text-align: center;
    font-weight: 600;
}

.diet-tab.plus.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: rgba(8, 13, 24, 0.7);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.5);
}

.table thead {
    background: #0b1220;
}

.table th,
.table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
    text-align: left;
}

.table th {
    font-weight: 600;
    font-size: 0.8rem;
    color: #e5e7eb;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr.highlight {
    background: rgba(34, 197, 94, 0.12);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.9rem 1.2rem;
    margin-top: 0.8rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-field label {
    font-size: 0.8rem;
    color: #cbd5e1;
    font-weight: 500;
}

.form-field input,
.form-field select {
    padding: 0.4rem 0.55rem;
    border-radius: 0.45rem;
    border: 1px solid rgba(148, 163, 184, 0.28);
    font-size: 0.85rem;
    font-family: inherit;
    background: #0b1220;
    color: #e5e7eb;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: rgba(34,197,94,0.7);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
    background: #0d1628;
}

/* Global input/select styling so fields outside .form-field look consistent */
input[type="text"],
input[type="number"],
input[type="file"],
input[type="search"],
input[type="email"],
input[type="password"],
select,
textarea {
    appearance: none;
    padding: 0.4rem 0.55rem;
    border-radius: 0.45rem;
    border: 1px solid rgba(148, 163, 184, 0.28);
    font-size: 0.9rem;
    font-family: inherit;
    background: #0b1220;
    color: #e5e7eb;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="file"]:focus,
input[type="search"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(34,197,94,0.7);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.25);
    background: #0d1628;
}

input::placeholder,
textarea::placeholder {
    color: rgba(203, 213, 225, 0.6);
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Compact inputs inside tables */
.table input[type="text"],
.table input[type="number"],
.table select, .table textarea {
    width: 100%;
    padding: 0.32rem 0.5rem;
    font-size: 0.84rem;
    background: #081021;
    border-color: rgba(148, 163, 184, 0.26);
}

.table input[type="text"]:focus,
.table input[type="number"]:focus,
.table select:focus,
.table textarea:focus {
    background: #0c162a;
}

/* Diet tab rename input refine */
#diet-tab-name-input {
    min-width: 180px;
    background: #0b1220;
    border: 1px solid rgba(148, 163, 184, 0.28);
}

/* File input tweaks */
input[type="file"] {
    padding: 0.3rem;
    background: transparent;
}

.muted {
    color: #94a3b8;
    font-size: 0.85rem;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.8rem;
    background: rgba(2, 6, 23, 0.6);
    padding: 0.12rem 0.3rem;
    border-radius: 0.3rem;
    border: 1px solid rgba(148,163,184,0.2);
}

.icon-button {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0.15rem 0.35rem;
    color: #6b7280;
}

.icon-button:hover {
    color: #b91c1c;
    transform: translateY(-0.5px);
}

.diet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.diet-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 10% 0%, rgba(15,23,42,0.8), rgba(15,23,42,0.55) 40%, rgba(15,23,42,0.8));
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-backdrop.open {
    display: flex;
}

.modal-panel {
    background: #020617;
    color: #e5e7eb;
    padding: 1.5rem 1.6rem;
    border-radius: 0.9rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.45);
}

.modal-panel.modal-panel-wide {
    max-width: 720px;
    max-height: 80vh;
    overflow: auto;
}

.modal-panel h3 {
    margin-top: 0;
    margin-bottom: 0.4rem;
    color: #e5e7eb;
}

.modal-panel p {
    color: #cbd5f5;
    max-width: none;
}

.modal-actions {
    margin-top: 1.25rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.modal-panel .form-field input,
.modal-panel .form-field select {
    background: #020617;
    color: #e5e7eb;
    border-color: rgba(148, 163, 184, 0.8);
}

.modal-panel .form-field input::placeholder,
.modal-panel .form-field select::placeholder {
    color: #6b7280;
}

.modal-panel .form-field input:focus,
.modal-panel .form-field select:focus {
    background: #020617;
}

.modal-panel .table {
    background: #020617;
    box-shadow: none;
}

.modal-panel .table thead {
    background: #020617;
    border-bottom: 1px solid rgba(148, 163, 184, 0.6);
}

.modal-panel .table th {
    color: #e5e7eb;
    border-bottom-color: rgba(148, 163, 184, 0.6);
}

.modal-panel .table td {
    border-bottom-color: rgba(30, 64, 175, 0.5);
    color: #e5e7eb;
}

.modal-panel .table tr:nth-child(even) td {
    background: rgba(15, 23, 42, 0.7);
}

.modal-panel .table input[type="number"] {
    width: 100%;
    padding: 0.25rem 0.4rem;
    font-size: 0.78rem;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 1.1rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    background: rgba(15, 23, 42, 0.85);
    color: #e5e7eb;
    transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.08s ease-out;
}

.btn-secondary:hover {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(209, 213, 219, 0.9);
    transform: translateY(-0.5px);
}

.btn-secondary:active {
    transform: translateY(0);
}

#formulate-status {
    font-size: 0.78rem;
    color: #4b5563;
}

.modal-panel .muted {
    font-size: 0.8rem;
}

.modal-panel.modal-panel-wide::-webkit-scrollbar {
    width: 6px;
}
.modal-panel.modal-panel-wide::-webkit-scrollbar-track {
    background: #020617;
}
.modal-panel.modal-panel-wide::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.7);
    border-radius: 999px;
}
