:root {
    --bg-color: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --accent: #14b8a6;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    background-size: cover;
}

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.login-panel {
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}
textarea {
    resize: vertical;
    min-height: 80px;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 0.85rem;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}
.btn-primary:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}
.error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-align: center;
    min-height: 20px;
}

/* App Header */
.top-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    background: rgba(15,23,42,0.4);
    border-bottom: 1px solid var(--glass-border);
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
}

/* Container */
.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    padding-bottom: 90px; /* Space for bottom nav */
}

/* Tabs System */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}
.tab-content.active {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-around;
    padding: 0.75rem 0;
    z-index: 1000;
}
.nav-item {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: all 0.2s;
    flex: 1;
}
.nav-item.active {
    color: var(--primary);
}
.nav-item:hover {
    color: white;
}
.nav-icon {
    font-size: 1.4rem;
    margin-bottom: 0.2rem;
}

/* Cards & Layout */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
}
.card-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.section-title {
    font-size: 1rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
    margin: 1.5rem 0 1rem;
}
.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Injection Toggle Switch */
.injection-toggle {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}
.toggle-label {
    font-weight: 500;
    font-size: 1rem;
    color: var(--accent);
}
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255,255,255,0.1);
  transition: .4s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--primary);
}
input:checked + .slider:before {
  transform: translateX(22px);
}
.hidden { display: none !important; }

/* Stats Grid in Reports */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-box {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.25rem;
    text-align: center;
}
.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}
.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
}
.stat-diff {
    font-size: 0.8rem;
    margin-top: 0.5rem;
}
.stat-diff.positive { color: var(--danger); } 
.stat-diff.negative { color: var(--accent); } 

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    margin-bottom: 1rem;
}
.chart-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.tabs-chart {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}
.chart-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 0;
    position: relative;
    transition: color 0.2s;
}
.chart-tab-btn:hover, .chart-tab-btn.active {
    color: var(--text-main);
}
.chart-tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -0.5rem;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
}

/* History List */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 10px; }
.history-list::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }

.history-item {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.history-info { flex: 1; }
.history-info h4 {
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.history-info .date {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: normal;
}
.history-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}
.history-details span { color: var(--text-muted); }
.history-full-width {
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-size: 0.85rem;
    background: rgba(0,0,0,0.2);
    padding: 0.5rem;
    border-radius: 6px;
    margin-top: 0.5rem;
}
.history-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    margin-left: 1rem;
}
.history-dose {
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}
.btn-delete {
    background: transparent;
    color: var(--danger);
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    opacity: 0.7;
}
.btn-delete:hover {
    opacity: 1;
    text-decoration: underline;
}

@media (max-width: 600px) {
    .two-cols {
        grid-template-columns: 1fr;
    }
}
