:root {
    --bg: #0f0f0f;
    --bg-card: #1a1a1a;
    --bg-input: #252525;
    --border: #333;
    --text: #e0e0e0;
    --text-muted: #888;
    --accent: #e63946;
    --accent-hover: #ff4d5a;
    --success: #2ecc71;
    --warning: #f39c12;
    --error: #e74c3c;
    --radius: 8px;
}

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

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

/* --- Navbar --- */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Rubik Burned', cursive;
    font-size: 1.3rem;
    font-weight: 400;
    color: var(--accent);
    text-decoration: none;
    text-shadow:
        0 0 8px rgba(230, 57, 70, 0.8),
        0 0 20px rgba(230, 57, 70, 0.4);
    letter-spacing: 1px;
    transition: text-shadow 0.3s;
}

.nav-brand:hover {
    text-shadow:
        0 0 12px rgba(255, 100, 60, 1),
        0 0 30px rgba(230, 57, 70, 0.7),
        0 0 50px rgba(230, 57, 70, 0.3);
}

.nav-logo {
    height: 36px;
    width: auto;
}

/* --- Auth logo --- */
.auth-logo {
    text-align: center;
    margin-bottom: 1.25rem;
}

.auth-logo img {
    width: 140px;
    height: auto;
}

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

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.nav-links a:hover { color: var(--text); }

.nav-user {
    color: var(--text);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-input);
    border-radius: var(--radius);
}

/* --- Layout --- */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* --- Auth --- */
.auth-container {
    max-width: 420px;
    margin: 4rem auto;
    padding: 2rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.auth-container h1 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    text-align: center;
}

.auth-link {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-link a { color: var(--accent); text-decoration: none; }
.auth-link a:hover { text-decoration: underline; }

/* --- Forms --- */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}

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

/* Role selector */
.role-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 0.35rem;
}

.role-option input[type="radio"] { display: none; }

.role-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 1rem;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    text-align: center;
}

.role-card small { color: var(--text-muted); font-size: 0.8rem; }
.role-option input:checked + .role-card { border-color: var(--accent); background: rgba(230, 57, 70, 0.1); }
.role-card:hover { border-color: var(--text-muted); }

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-primary { background: var(--accent); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    transition: background 0.2s;
}
.btn-sm:hover { background: var(--border); color: var(--text); }

/* --- Flash messages --- */
.flash-messages { margin-bottom: 1.5rem; }

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.flash-error { background: rgba(231, 76, 60, 0.15); border: 1px solid var(--error); color: var(--error); }
.flash-success { background: rgba(46, 204, 113, 0.15); border: 1px solid var(--success); color: var(--success); }
.flash-warning { background: rgba(243, 156, 18, 0.15); border: 1px solid var(--warning); color: var(--warning); }

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card h2, .card h3 { margin-bottom: 0.75rem; }

/* --- Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover { background: rgba(255, 255, 255, 0.03); }

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

.dashboard-header h1 { font-size: 1.5rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}

.stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }

/* --- Exercise grid (workout logging) --- */
.exercise-log {
    display: grid;
    grid-template-columns: 2fr repeat(3, 1fr);
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.exercise-log input[type="number"] {
    width: 100%;
    padding: 0.4rem;
    text-align: center;
}

.exercise-name { font-weight: 600; }
.exercise-meta { font-size: 0.8rem; color: var(--text-muted); }

/* --- Section headers --- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.section-header h2 { font-size: 1.25rem; }

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state p { margin-bottom: 1rem; }

/* --- Badge --- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-trainer { background: rgba(230, 57, 70, 0.2); color: var(--accent); }
.badge-gymbro { background: rgba(46, 204, 113, 0.2); color: var(--success); }
.badge-muscle { background: var(--bg-input); color: var(--text-muted); }

/* --- Responsive --- */
@media (max-width: 600px) {
    .navbar { flex-direction: column; gap: 0.5rem; }
    .nav-links { flex-wrap: wrap; justify-content: center; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .exercise-log { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════ */

/* Full-page wrapper */
.login-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #080808;
    position: relative;
    overflow: hidden;
}

/* Animated grid */
.login-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(230,57,70,.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(230,57,70,.04) 1px, transparent 1px);
    background-size: 48px 48px;
    animation: grid-drift 18s linear infinite;
    pointer-events: none;
}

/* Pulsing center glow */
.login-bg::before {
    content: '';
    position: absolute;
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, rgba(230,57,70,.13) 0%, transparent 65%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: bg-pulse 5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes grid-drift {
    from { background-position: 0 0; }
    to   { background-position: 48px 48px; }
}

@keyframes bg-pulse {
    0%, 100% { opacity: .5; transform: translate(-50%,-50%) scale(1); }
    50%       { opacity: 1;  transform: translate(-50%,-50%) scale(1.12); }
}

/* Card */
.login-card {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 420px;
    margin: 1rem;
    padding: 2.75rem 2.25rem 2rem;
    background: rgba(20, 20, 20, 0.88);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(230,57,70,.22);
    border-radius: 18px;
    box-shadow:
        0 0 0 1px rgba(255,255,255,.03),
        0 0 50px rgba(230,57,70,.12),
        0 24px 64px rgba(0,0,0,.6);
    animation: card-in .65s cubic-bezier(.16,1,.3,1) both;
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(28px) scale(.97); }
    to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

/* Top accent line */
.login-card::before {
    content: '';
    position: absolute;
    top: 0; left: 10%; right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    border-radius: 999px;
}

/* Logo */
.login-logo {
    text-align: center;
    margin-bottom: 1rem;
    animation: logo-in .7s cubic-bezier(.16,1,.3,1) .08s both;
}

.login-logo img {
    width: 170px;
    height: auto;
    filter: drop-shadow(0 0 24px rgba(230,57,70,.45));
    transition: filter .3s;
}

.login-logo img:hover {
    filter: drop-shadow(0 0 36px rgba(230,57,70,.7));
}

@keyframes logo-in {
    from { opacity: 0; transform: scale(.82) translateY(-8px); }
    to   { opacity: 1; transform: scale(1)   translateY(0);    }
}

/* Title */
.login-title {
    text-align: center;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: .5px;
    margin-bottom: 1.75rem;
    background: linear-gradient(135deg, #fff 30%, rgba(230,57,70,.9));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fade-up .55s .15s both;
}

/* Shared entrance */
@keyframes fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0);    }
}

/* Input fields */
.login-form { display: flex; flex-direction: column; gap: .85rem; }

.login-field {
    position: relative;
    animation: fade-up .55s both;
}

.login-field-icon {
    position: absolute;
    left: .9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    pointer-events: none;
    transition: color .2s;
}

.login-field input {
    width: 100%;
    padding: .78rem .85rem .78rem 2.65rem;
    background: rgba(30,30,30,.9);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 10px;
    color: var(--text);
    font-size: .95rem;
    transition: border-color .2s, box-shadow .2s, background .2s;
}

.login-field input::placeholder { color: #444; }

.login-field input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(35,35,35,1);
    box-shadow: 0 0 0 3px rgba(230,57,70,.18), 0 0 18px rgba(230,57,70,.08);
}

.login-field:focus-within .login-field-icon { color: var(--accent); }

/* Submit button */
.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    padding: .82rem 1rem;
    margin-top: .25rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: .4px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: background .2s, transform .12s, box-shadow .2s;
    animation: fade-up .55s both;
}

/* Shimmer sweep */
.login-btn::after {
    content: '';
    position: absolute;
    top: 0; left: -120%;
    width: 60%;
    height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255,255,255,.22), transparent);
    animation: btn-shimmer 2.8s ease-in-out 1.2s infinite;
}

@keyframes btn-shimmer {
    0%    { left: -120%; }
    40%, 100% { left: 180%; }
}

.login-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 24px rgba(230,57,70,.45);
    transform: translateY(-1px);
}

.login-btn:active { transform: translateY(0); box-shadow: none; }

/* Register link */
.login-register {
    text-align: center;
    margin-top: 1.25rem;
    font-size: .875rem;
    color: var(--text-muted);
    animation: fade-up .55s both;
}

.login-register a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.login-register a:hover { text-decoration: underline; }

@media (max-width: 480px) {
    .login-card { padding: 2rem 1.5rem 1.75rem; }
    .login-logo img { width: 140px; }
}

/* ═══════════════════════════════════════════
   DIET / NUTRITION
   ═══════════════════════════════════════════ */

/* Macro pills (kcal / P / C / G) */
.macro-pills { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.pill {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 999px;
    white-space: nowrap;
}

.pill-kcal { background: rgba(230, 57, 70, 0.18); color: var(--accent); }
.pill-p    { background: rgba(46, 204, 113, 0.18); color: var(--success); }
.pill-c    { background: rgba(59, 154, 225, 0.18); color: #4aa8ec; }
.pill-f    { background: rgba(243, 156, 18, 0.18); color: var(--warning); }

/* Macro target/manual input grids */
.macro-inputs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

/* Cuadre panel */
.cuadre-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.cuadre-cell {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem;
}

.cuadre-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.cuadre-value strong { font-size: 1.35rem; }
.cuadre-target { font-size: 0.8rem; color: var(--text-muted); }

.cuadre-bar {
    height: 6px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
    margin: 0.5rem 0 0.4rem;
}

.cuadre-bar-fill { height: 100%; border-radius: 999px; transition: width 0.3s; }

.state-ok    { color: var(--success); }
.state-under { color: var(--text-muted); }
.state-over  { color: var(--warning); }

.cuadre-bar-fill.state-ok    { background: var(--success); }
.cuadre-bar-fill.state-under { background: var(--accent); }
.cuadre-bar-fill.state-over  { background: var(--warning); }

.cuadre-delta { font-size: 0.78rem; font-weight: 600; }

/* Add-item form (diet detail) */
.add-item-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.add-item-form .food-select { flex: 2 1 220px; }
.add-item-form .grams-input { flex: 0 1 110px; }
.item-preview { font-size: 0.82rem; color: var(--text-muted); flex: 1 1 140px; }

.btn-add {
    background: rgba(46, 204, 113, 0.15);
    border-color: var(--success);
    color: var(--success);
    cursor: pointer;
}
.btn-add:hover { background: rgba(46, 204, 113, 0.28); color: var(--success); }

/* Meal option block (diet detail) */
.option-block {
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
}

.option-block table td { border-bottom: 1px solid rgba(255,255,255,0.05); padding: 0.35rem 0.5rem; }

/* Open Food Facts results */
.off-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.off-result:last-child { border-bottom: none; }

@media (max-width: 600px) {
    .cuadre-grid { grid-template-columns: 1fr 1fr; }
    .macro-inputs { grid-template-columns: 1fr 1fr; }
}

/* --- Watch pairing page --- */
.badge-ok   { background: rgba(46, 204, 113, 0.2); color: var(--success); }
.badge-warn { background: rgba(255, 193, 7, 0.2);  color: #ffc107; }
.watch-pin-card { text-align: center; }
.watch-pin {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 3.5rem;
    letter-spacing: 0.4rem;
    margin: 1rem 0;
    color: var(--accent);
}
