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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e0e0e0;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; margin-bottom: 0.75rem; color: #555; }

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.range-buttons { display: flex; gap: 0.25rem; }

.tab {
    padding: 0.4rem 0.8rem;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}
.tab.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.tab:hover:not(.active) { background: #e8e8e8; }

.date-range {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.date-range input[type="date"] {
    padding: 0.35rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.82rem;
}
.date-range span { color: #999; font-size: 0.85rem; }

.btn-small {
    padding: 0.35rem 0.6rem;
    border: 1px solid #3b82f6;
    background: #3b82f6;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82rem;
}
.btn-small:hover { background: #2563eb; }

.toggle-label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.82rem;
    color: #555;
    cursor: pointer;
    white-space: nowrap;
}

.btn-icon {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-size: 1.1rem;
}
.btn-icon:hover { background: #e8e8e8; }

.btn-primary {
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.5rem 1.2rem;
    cursor: pointer;
    font-size: 0.9rem;
}
.btn-primary:hover { background: #2563eb; }

.btn-secondary {
    background: #fff;
    color: #3b82f6;
    border: 1px solid #3b82f6;
    border-radius: 4px;
    padding: 0.5rem 1.2rem;
    cursor: pointer;
    font-size: 0.9rem;
}
.btn-secondary:hover { background: #eff6ff; }

select {
    padding: 0.4rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.85rem;
    background: #fff;
}

#chart-section {
    background: #fff;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#log-section, #events-section, #period-section {
    background: #fff;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.form-row {
    display: flex;
    gap: 1rem;
    align-items: end;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: #666;
}
label.full-width { flex: 1; }
label.checkbox-label { flex-direction: row; align-items: center; gap: 0.5rem; }

input[type="text"], input[type="email"], input[type="number"], input[type="datetime-local"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
}

input[type="range"] { width: 100%; }

#entries, #period-entries { list-style: none; }
#entries li, #period-entries li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}
#entries li:last-child, #period-entries li:last-child { border-bottom: none; }

.entry-info { display: flex; gap: 1rem; align-items: center; }
.entry-intensity {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    line-height: 2rem;
    text-align: center;
    border-radius: 50%;
    background: #fee2e2;
    color: #dc2626;
    font-weight: bold;
    font-size: 0.85rem;
}
.tag {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 3px;
    font-size: 0.72rem;
    font-weight: 500;
}
.tag-headache { background: #fef3c7; color: #92400e; }
.tag-pill { background: #dbeafe; color: #1e40af; }
.tag-vomiting { background: #fce7f3; color: #9d174d; }

.entry-delete {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0.25rem;
}
.entry-delete:hover { color: #dc2626; }

dialog {
    border: none;
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
dialog::backdrop { background: rgba(0,0,0,0.4); }
dialog label { margin-bottom: 0.75rem; }

.dialog-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.no-data {
    text-align: center;
    color: #999;
    padding: 2rem;
    font-size: 0.9rem;
}

/* Header layout */
.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.user-info {
    font-size: 0.85rem;
    color: #888;
    font-weight: normal;
}

.chart-hint {
    text-align: center;
    font-size: 0.75rem;
    color: #aaa;
    margin-top: 0.5rem;
}

/* Auth page */
.auth-container {
    max-width: 380px;
    margin: 4rem auto;
}
.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-header h1 {
    margin-top: 0.5rem;
    font-size: 1.5rem;
}
.auth-icon { display: block; margin: 0 auto; }

.auth-form {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.auth-form h2 {
    text-align: center;
    margin-bottom: 1rem;
    color: #333;
}
.auth-form label { margin-bottom: 0.75rem; }
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
    width: 100%;
    padding: 0.5rem 0.6rem;
}

.btn-full { width: 100%; margin-top: 0.5rem; padding: 0.6rem; }

.auth-switch {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #888;
}
.auth-switch a { color: #3b82f6; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

.auth-error {
    background: #fee2e2;
    color: #dc2626;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}
