/* ===== Reset & Base ===================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:      #3A86A8;
    --primary-dark: #2C6882;
    --primary-light:#EBF4F8;
    --accent:       #5BAD83;
    --warning:      #E8A838;
    --danger:       #D95F4B;
    --bg:           #F2F5F7;
    --surface:      #FFFFFF;
    --border:       #DDE3E8;
    --text:         #1E2D3A;
    --text-muted:   #6B7E8E;
    --radius:       12px;
    --radius-sm:    8px;
    --shadow:       0 2px 8px rgba(0,0,0,0.08);
    --nav-h:        64px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

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

/* ===== Layout =========================================================== */
.container {
    max-width: 540px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ===== Top Bar ========================================================== */
.topbar {
    background: var(--primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.topbar h1 { font-size: 1.1rem; font-weight: 600; letter-spacing: 0.02em; }
.topbar .topbar-sub { font-size: 0.8rem; opacity: 0.85; }
.topbar-right a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.85rem;
}
.topbar-right a:hover { color: #fff; }

/* ── Account switcher (topbar) ────────────────────────────────────────── */
.topbar-right { display: flex; align-items: center; gap: 14px; }
.acct-switcher { position: relative; }
.acct-switcher summary {
    list-style: none;
    cursor: pointer;
    color: rgba(255,255,255,0.85);
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,0.15);
    user-select: none;
}
.acct-switcher summary::-webkit-details-marker { display: none; }
.acct-switcher summary:hover { color: #fff; background: rgba(255,255,255,0.25); }
.acct-switcher[open] summary { background: rgba(255,255,255,0.25); }
.acct-switcher-menu {
    position: absolute; right: 0; top: calc(100% + 6px);
    background: #fff; border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.14);
    min-width: 180px; z-index: 200; overflow: hidden;
}
.acct-switcher-item {
    display: block; width: 100%; text-align: left;
    padding: 12px 16px; border: none; background: none; cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}
.acct-switcher-item:last-child { border-bottom: none; }
.acct-switcher-item:hover { background: #F2F5F7; }
.acct-switcher-name { display: block; font-weight: 700; font-size: 0.9rem; color: #1E2D3A; }
.acct-switcher-role { display: block; font-size: 0.75rem; color: #6B7E8E; text-transform: capitalize; margin-top: 1px; }

/* ===== Bottom Nav ======================================================= */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 200;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    transition: color 0.15s;
}
.bottom-nav a.active,
.bottom-nav a:hover { color: var(--primary); }
.bottom-nav .nav-icon { font-size: 1.4rem; line-height: 1; }

/* ===== Cards ============================================================ */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
}
.card-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* ===== Alerts / Flashes ================================================= */
.flash-list { list-style: none; margin: 12px 0; }
.flash {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 6px;
}
.flash.success { background: #E6F4EC; color: #2D7A4A; border-left: 4px solid var(--accent); }
.flash.error   { background: #FDECEA; color: #B03020; border-left: 4px solid var(--danger); }
.flash.info    { background: var(--primary-light); color: var(--primary-dark); border-left: 4px solid var(--primary); }
.flash.warning { background: #FEF5E6; color: #9A6700; border-left: 4px solid var(--warning); }

/* ===== Buttons ========================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-accent   { background: var(--accent); color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-outline  { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-sm       { padding: 8px 14px; font-size: 0.85rem; }
.btn-block    { width: 100%; }

/* ===== Forms ============================================================ */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text);
}
.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s;
    appearance: none;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(58,134,168,0.15);
}
.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== Quick Log Grid =================================================== */
.log-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}
.log-tile {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 8px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 600;
    transition: border-color 0.15s, background 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.log-tile:hover, .log-tile:focus {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
}
.log-tile .tile-icon { font-size: 1.6rem; line-height: 1; }

/* ===== Med Badge ======================================================== */
.med-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.med-row:last-child { border-bottom: none; }
.med-name { font-weight: 600; font-size: 0.9rem; }
.med-detail { font-size: 0.8rem; color: var(--text-muted); }
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}
.badge-done    { background: #E6F4EC; color: #2D7A4A; }
.badge-due     { background: #FEF5E6; color: #9A6700; }
.badge-missed  { background: #FDECEA; color: #B03020; }

/* ===== Event Feed ======================================================= */
.event-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.event-item:last-child { border-bottom: none; }
.event-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    margin-top: 5px;
    flex-shrink: 0;
}
.event-type {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
}
.event-meta { font-size: 0.78rem; color: var(--text-muted); }

/* ===== Flag Banner ====================================================== */
.flag-banner {
    background: #FEF5E6;
    border: 1.5px solid var(--warning);
    border-radius: var(--radius);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #7A5000;
}

/* ===== Auth Pages ======================================================= */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: var(--primary);
}
.auth-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}
.auth-logo .logo-icon { font-size: 3rem; }
.auth-logo h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 8px;
}
.auth-logo p { font-size: 0.9rem; color: var(--text-muted); margin-top: 4px; }

/* ===== Checkboxes & Radios ============================================== */
.checkbox-group,
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 0;
}
.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 6px 0;
}
.checkbox-label input[type="checkbox"],
.radio-label input[type="radio"] {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ===== List Links (admin/settings rows) ================================= */
.list-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    transition: color 0.15s;
}
.list-link:last-child { border-bottom: none; }
.list-link:hover { color: var(--primary); }

/* ===== Trial / Status Banner =========================================== */
.trial-banner {
    padding: 10px 16px;
    font-size: 0.85rem;
    text-align: center;
    line-height: 1.4;
    position: sticky;
    top: var(--nav-h);
    z-index: 90;
}
.trial-banner.trial {
    background: var(--warning);
    color: #fff;
}
.trial-banner.read-only {
    background: var(--danger);
    color: #fff;
}

/* ===== Google Sign-in Button ============================================ */
.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 13px 20px;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.btn-google:hover {
    border-color: #4285F4;
    box-shadow: 0 2px 8px rgba(66,133,244,0.18);
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.auth-footer {
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 20px;
    line-height: 1.6;
}
.auth-footer a { color: var(--primary); }

/* ===== Utility ========================================================== */
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-0  { margin-bottom: 0; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); font-size: 0.85rem; }
.section-gap { margin-top: 20px; }
