/* =======================================================
   MEDTRACKER 2026 — DESIGN SYSTEM
   Custom CSS. No external framework dependencies.
   Dark mode by default. Light mode via html.light-mode.
   ======================================================= */

/* -------------------------------------------------------
   DESIGN TOKENS
   ------------------------------------------------------- */
:root {
    /* Typography */
    --font:      'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: ui-monospace, 'Cascadia Code', 'Fira Code', Consolas, monospace;

    /* Spacing (4px base) */
    --s-1:  4px;   --s-2:  8px;   --s-3: 12px;  --s-4: 16px;
    --s-5: 20px;  --s-6: 24px;  --s-8: 32px;  --s-10: 40px;
    --s-12: 48px; --s-16: 64px;

    /* Border radius */
    --r-sm:   6px;  --r-md: 10px;  --r-lg:  14px;
    --r-xl:  20px;  --r-2xl: 28px; --r-full: 9999px;

    /* Easing */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --t-1: 120ms var(--ease);
    --t-2: 220ms var(--ease);
    --t-3: 360ms var(--ease);

    /* Layout */
    --max-w:          1280px;
    --nav-h:            64px;
    --mobile-nav-h:     60px;
}

/* -------------------------------------------------------
   DARK MODE (DEFAULT)
   ------------------------------------------------------- */
:root {
    /* Surfaces */
    --bg:         #060C16;
    --surface:    #0D1827;
    --surface-2:  #152132;
    --surface-3:  #1B2C40;
    --surface-4:  #223550;

    /* Borders */
    --border:   rgba(100, 160, 230, 0.09);
    --border-2: rgba(100, 160, 230, 0.18);
    --border-3: rgba(100, 160, 230, 0.32);

    /* Accent — Cyan */
    --accent:      #22D3EE;
    --accent-2:    #38BDF8;
    --accent-fg:   #040C18;
    --accent-bg:   rgba(34, 211, 238, 0.10);
    --accent-bg-2: rgba(34, 211, 238, 0.18);

    /* Status */
    --green:      #34D399;
    --green-bg:   rgba(52,  211, 153, 0.10);
    --green-bd:   rgba(52,  211, 153, 0.22);
    --yellow:     #FBBF24;
    --yellow-bg:  rgba(251, 191,  36, 0.10);
    --yellow-bd:  rgba(251, 191,  36, 0.22);
    --red:        #F87171;
    --red-bg:     rgba(248, 113, 113, 0.10);
    --red-bd:     rgba(248, 113, 113, 0.22);

    /* Text */
    --text:     #C8D8EC;
    --text-2:   #7898B8;
    --text-3:   #3A5570;
    --heading:  #FFFFFF;

    /* Shadows */
    --shadow-1: 0 1px 4px rgba(0,0,0,.55);
    --shadow-2: 0 4px 16px rgba(0,0,0,.60);
    --shadow-3: 0 8px 32px rgba(0,0,0,.65);
    --shadow-accent: 0 4px 24px rgba(34, 211, 238, .18);

    /* Table rows */
    --row-alt:   rgba(255,255,255,.018);
    --row-hover: rgba(255,255,255,.04);

    /* Inputs */
    --input-bg: rgba(255,255,255,.04);

    /* Calendar */
    --cal-today-bg: rgba(251, 191, 36, .12);
    --cal-today-bd: #FBBF24;
    --cal-empty:    rgba(0,0,0,.30);

    /* Header / mobile nav */
    --header-bg:     rgba(8, 16, 32, .92);
    --mob-nav-bg:    rgba(9, 18, 36, .95);
}

/* -------------------------------------------------------
   LIGHT MODE
   ------------------------------------------------------- */
html.light-mode {
    /* Surfaces */
    --bg:        #EDF3FA;
    --surface:   #FFFFFF;
    --surface-2: #F4F8FC;
    --surface-3: #E8F0F9;
    --surface-4: #DAE5F3;

    /* Borders */
    --border:   rgba(0, 0, 0, 0.08);
    --border-2: rgba(0, 0, 0, 0.14);
    --border-3: rgba(0, 0, 0, 0.24);

    /* Accent — Ocean Blue */
    --accent:      #0284C7;
    --accent-2:    #0369A1;
    --accent-fg:   #FFFFFF;
    --accent-bg:   rgba(2, 132, 199, 0.08);
    --accent-bg-2: rgba(2, 132, 199, 0.15);

    /* Status */
    --green:      #059669;
    --green-bg:   rgba(5,   150, 105, 0.08);
    --green-bd:   rgba(5,   150, 105, 0.22);
    --yellow:     #D97706;
    --yellow-bg:  rgba(217, 119,   6, 0.08);
    --yellow-bd:  rgba(217, 119,   6, 0.22);
    --red:        #DC2626;
    --red-bg:     rgba(220,  38,  38, 0.08);
    --red-bd:     rgba(220,  38,  38, 0.22);

    /* Text */
    --text:     #1E293B;
    --text-2:   #475569;
    --text-3:   #94A3B8;
    --heading:  #0F172A;

    /* Shadows */
    --shadow-1: 0 1px 4px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
    --shadow-2: 0 4px 12px rgba(0,0,0,.09), 0 2px 6px rgba(0,0,0,.05);
    --shadow-3: 0 8px 24px rgba(0,0,0,.10);
    --shadow-accent: 0 4px 24px rgba(2, 132, 199, .15);

    /* Table rows */
    --row-alt:   rgba(0,0,0,.022);
    --row-hover: rgba(0,0,0,.04);

    /* Inputs */
    --input-bg: #FFFFFF;

    /* Calendar */
    --cal-today-bg: rgba(245, 158, 11, .14);
    --cal-today-bd: #F59E0B;
    --cal-empty:    rgba(0,0,0,.035);

    /* Header / mobile nav */
    --header-bg:  rgba(255,255,255,.93);
    --mob-nav-bg: rgba(255,255,255,.95);
}

/* -------------------------------------------------------
   GLOBAL RESET & BASE
   ------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    height: 100%;
}

body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.65;
    min-height: 100vh;
    padding-top: var(--nav-h);
    padding-bottom: var(--mobile-nav-h);
    transition: background-color var(--t-3), color var(--t-2);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

@media (min-width: 768px) {
    body { padding-bottom: 0; }
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    color: var(--heading);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.015em;
    transition: color var(--t-2);
}

h1 { font-size: clamp(1.4rem, 4vw, 1.85rem); margin-bottom: var(--s-4); }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem);  margin-bottom: var(--s-3); }
h3 { font-size: 1.15rem; margin-bottom: var(--s-3); }
h4 { font-size: 1.05rem; font-weight: 600; margin-bottom: var(--s-2); }
h5 {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-2);
    margin-bottom: var(--s-2);
}

p { margin-bottom: var(--s-4); }
p:last-child { margin-bottom: 0; }

a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--t-1);
}
a:hover { color: var(--accent-2); text-decoration: underline; }

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--s-6) 0;
}

code {
    font-family: var(--font-mono);
    font-size: .875em;
    background: var(--surface-3);
    padding: 2px 6px;
    border-radius: var(--r-sm);
}

/* -------------------------------------------------------
   LAYOUT
   ------------------------------------------------------- */
.page-container {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: var(--s-5) var(--s-4);
}
@media (min-width: 640px)  { .page-container { padding: var(--s-6) var(--s-6);  } }
@media (min-width: 1024px) { .page-container { padding: var(--s-8) var(--s-10); } }

/* Two-column grid */
.row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-5);
    margin-bottom: var(--s-5);
}
@media (min-width: 768px) {
    .row { grid-template-columns: 1fr 1fr; }
}

/* Skeleton compat */
.one-half.column { width: 100%; }

/* -------------------------------------------------------
   SITE HEADER
   ------------------------------------------------------- */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    height: var(--nav-h);
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    transition: background var(--t-3), border-color var(--t-2);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 var(--s-4);
    gap: var(--s-4);
}
@media (min-width: 640px)  { .header-inner { padding: 0 var(--s-6);  } }
@media (min-width: 1024px) { .header-inner { padding: 0 var(--s-10); } }

/* Brand */
.site-brand {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    color: var(--heading);
    text-decoration: none;
    flex-shrink: 0;
}
.site-brand:hover { color: var(--heading); text-decoration: none; opacity: .88; }

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-accent);
}
.brand-icon svg { width: 20px; height: 20px; stroke: white; fill: none; flex-shrink: 0; }

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}
.brand-name {
    font-size: 1rem;
    font-weight: 800;
    color: var(--heading);
    letter-spacing: -0.025em;
}
.brand-sub {
    font-size: .62rem;
    font-weight: 500;
    color: var(--text-2);
    display: none;
}
@media (min-width: 480px) { .brand-sub { display: block; } }

/* Desktop nav */
.site-nav {
    display: none;
    align-items: center;
    gap: 2px;
    flex: 1;
    justify-content: center;
}
@media (min-width: 768px) { .site-nav { display: flex; } }

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    font-size: .84rem;
    font-weight: 500;
    color: var(--text-2);
    text-decoration: none;
    transition: background var(--t-1), color var(--t-1);
    white-space: nowrap;
}
.nav-link:hover {
    background: var(--accent-bg);
    color: var(--accent);
    text-decoration: none;
}
.nav-link svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    flex-shrink: 0;
}

/* Header actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    flex-shrink: 0;
}

/* Theme toggle */
.theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: var(--r-full);
    background: transparent;
    border: 1px solid var(--border-2);
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t-1);
    flex-shrink: 0;
    padding: 0;
}
.theme-toggle:hover {
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--accent);
}
.theme-toggle svg {
    width: 17px;
    height: 17px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* Show sun icon in dark mode (to switch to light), moon in light mode */
html:not(.light-mode) .icon-sun  { display: block; }
html:not(.light-mode) .icon-moon { display: none;  }
html.light-mode       .icon-sun  { display: none;  }
html.light-mode       .icon-moon { display: block; }

/* -------------------------------------------------------
   MOBILE BOTTOM NAV
   ------------------------------------------------------- */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    height: var(--mobile-nav-h);
    background: var(--mob-nav-bg);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    display: flex;
    align-items: stretch;
    transition: background var(--t-3);
}
@media (min-width: 768px) { .mobile-nav { display: none; } }

.mobile-nav-items {
    display: flex;
    width: 100%;
    justify-content: space-around;
    align-items: center;
    padding: 0 var(--s-2);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    color: var(--text-3);
    text-decoration: none;
    font-size: .58rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    min-width: 52px;
    transition: color var(--t-1), background var(--t-1);
}
.mobile-nav-item:hover,
.mobile-nav-item:focus {
    color: var(--accent);
    background: var(--accent-bg);
    text-decoration: none;
}
.mobile-nav-item svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    flex-shrink: 0;
}

/* -------------------------------------------------------
   FLASH MESSAGES
   ------------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-md);
    border: 1px solid;
    font-size: .875rem;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: var(--s-3);
    animation: alertIn 200ms var(--ease) both;
}

@keyframes alertIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0);    }
}

.alert-success { background: var(--green-bg);  border-color: var(--green-bd);  color: var(--green);  }
.alert-error   { background: var(--red-bg);    border-color: var(--red-bd);    color: var(--red);    }
.alert-warning { background: var(--yellow-bg); border-color: var(--yellow-bd); color: var(--yellow); }
.alert-info    { background: var(--accent-bg); border-color: var(--border-2);  color: var(--accent); }

/* -------------------------------------------------------
   CARDS
   ------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    box-shadow: var(--shadow-1);
    transition: background var(--t-2), border-color var(--t-2), box-shadow var(--t-2);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--s-4);
    margin-bottom: var(--s-4);
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--heading);
    letter-spacing: -0.01em;
    margin: 0;
}

/* summary-box (legacy compat) */
.summary-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    box-shadow: var(--shadow-1);
    height: 100%;
    transition: background var(--t-2), border-color var(--t-2);
}

.summary-box h4 {
    font-size: .95rem;
    font-weight: 700;
    color: var(--heading);
    letter-spacing: -0.01em;
    margin-bottom: var(--s-4);
    padding-bottom: var(--s-3);
    border-bottom: 1px solid var(--border);
}

.summary-box p { font-size: .875rem; }

/* -------------------------------------------------------
   STAT CARDS
   ------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: var(--s-3);
    margin-bottom: var(--s-5);
}

.stat-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-4);
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: transform var(--t-1), box-shadow var(--t-1), border-color var(--t-1);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    opacity: .65;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-2);
    border-color: var(--border-2);
}

.stat-card h5 {
    color: var(--text-2);
    margin-bottom: var(--s-2);
    font-size: .62rem;
}

.stat-card .count {
    display: block;
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    margin-bottom: var(--s-2);
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.stat-card > a {
    font-size: .75rem;
    display: block;
    color: var(--text-2);
    font-weight: 500;
}
.stat-card > a:hover { color: var(--accent); text-decoration: none; }

/* -------------------------------------------------------
   BUTTONS
   ------------------------------------------------------- */

/* Native submit + button (non-toggle) */
input[type="submit"],
button:not(.theme-toggle):not(.mobile-nav-item) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    padding: 11px 22px;
    font-family: var(--font);
    font-size: .875rem;
    font-weight: 600;
    line-height: 1;
    border: none;
    border-radius: var(--r-md);
    cursor: pointer;
    background: var(--accent);
    color: var(--accent-fg);
    box-shadow: 0 2px 8px var(--accent-bg-2);
    transition: all var(--t-1);
    width: 100%;
    margin-bottom: var(--s-3);
    -webkit-appearance: none;
    appearance: none;
}

input[type="submit"]:hover,
button:not(.theme-toggle):not(.mobile-nav-item):hover {
    background: var(--accent-2);
    transform: translateY(-1px);
    box-shadow: var(--shadow-accent);
}

input[type="submit"]:active,
button:not(.theme-toggle):not(.mobile-nav-item):active {
    transform: scale(0.98);
    box-shadow: none;
}

@media (min-width: 640px) {
    input[type="submit"],
    button:not(.theme-toggle):not(.mobile-nav-item) {
        width: auto;
        margin-bottom: 0;
    }
}

/* .button class (anchor links styled as buttons) */
a.button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    padding: 11px 22px;
    font-family: var(--font);
    font-size: .875rem;
    font-weight: 600;
    line-height: 1;
    border-radius: var(--r-md);
    background: var(--accent);
    color: var(--accent-fg) !important;
    text-decoration: none !important;
    box-shadow: 0 2px 8px var(--accent-bg-2);
    transition: all var(--t-1);
    border: none;
    cursor: pointer;
}

a.button:hover, .button:hover {
    background: var(--accent-2);
    transform: translateY(-1px);
    box-shadow: var(--shadow-accent);
    text-decoration: none !important;
}

a.button:active, .button:active {
    transform: scale(0.98);
    box-shadow: none;
}

.button-small    { padding: 6px 14px !important; font-size: .8rem !important; }
.button-full-width { width: 100%; justify-content: center; }

/* Inline button pair */
.two-buttons-inline {
    display: flex;
    gap: var(--s-3);
    flex-wrap: wrap;
    margin-top: var(--s-4);
}
.two-buttons-inline > * { flex: 1; min-width: 120px; justify-content: center; }

/* -------------------------------------------------------
   FORMS
   ------------------------------------------------------- */

/* Strip the original card-like form styling */
form {
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    margin-top: 0 !important;
}

label {
    display: block;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-2);
    margin-bottom: var(--s-2);
    transition: color var(--t-2);
}

/* Checkbox label override */
label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    text-transform: none;
    letter-spacing: 0;
    font-size: .9rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    margin-bottom: var(--s-4);
}

.label-body { font-weight: 500; }

/* Text inputs, selects, textareas */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="time"],
textarea,
select {
    display: block;
    width: 100%;
    padding: 11px 14px;
    font-family: var(--font);
    font-size: .9rem;
    line-height: 1.4;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    transition: border-color var(--t-1), box-shadow var(--t-1), background var(--t-2), color var(--t-2);
    margin-bottom: var(--s-4);
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

textarea { min-height: 100px; resize: vertical; line-height: 1.6; }

select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237898B8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}

input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--accent);
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}

.dose-time-input { margin-bottom: var(--s-3) !important; }

/* Form card wrapper */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--s-8) var(--s-6);
    max-width: 580px;
    margin: 0 auto;
    box-shadow: var(--shadow-2);
}
@media (max-width: 479px) {
    .form-card { padding: var(--s-5) var(--s-4); border-radius: var(--r-lg); }
}

/* Auth page centering wrapper */
.auth-form-wrapper {
    max-width: 440px;
    margin: var(--s-8) auto 0;
}

/* -------------------------------------------------------
   TABLES
   ------------------------------------------------------- */
.table-container {
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    overflow-x: auto;
    background: var(--surface);
    box-shadow: var(--shadow-1);
    margin-bottom: var(--s-5);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
    background: transparent;
    color: var(--text);
}
table.u-full-width { width: 100%; }

thead { background: var(--surface-2); }

th {
    padding: 11px 16px;
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-2);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

td {
    padding: 13px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    line-height: 1.4;
}

tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: var(--row-hover); }

/* Action links inside tables */
.td-actions {
    display: flex;
    gap: var(--s-2);
    align-items: center;
    white-space: nowrap;
}

.action-edit, .action-delete {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--r-sm);
    font-size: .78rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--t-1);
    white-space: nowrap;
}

.action-edit {
    background: var(--accent-bg);
    color: var(--accent);
}
.action-edit:hover {
    background: var(--accent);
    color: var(--accent-fg);
    text-decoration: none;
}

.action-delete {
    background: var(--red-bg);
    color: var(--red);
}
.action-delete:hover {
    background: var(--red);
    color: #fff;
    text-decoration: none;
}

/* -------------------------------------------------------
   EMPTY / NO-RECORDS STATE
   ------------------------------------------------------- */
.no-records {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    background: var(--surface-2);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    padding: var(--s-3) var(--s-4);
    font-size: .875rem;
    color: var(--text-2);
    font-style: italic;
    margin-top: var(--s-4);
}
.no-records p { margin: 0; font-style: normal; }

/* -------------------------------------------------------
   SECTION TITLE DIVIDERS
   ------------------------------------------------------- */
.section-title {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--text-3);
    padding-bottom: var(--s-3);
    margin-bottom: var(--s-4);
    border-bottom: 1px solid var(--border);
}

/* -------------------------------------------------------
   CALENDAR
   ------------------------------------------------------- */
.calendar-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-1);
    margin-bottom: var(--s-5);
}

.calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-4) var(--s-5);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: var(--s-3);
}

.calendar-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--heading);
    margin: 0;
    flex: 1;
    text-align: center;
}

.calendar-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-md);
    border: 1px solid var(--border-2);
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-2);
    text-decoration: none;
    background: transparent;
    cursor: pointer;
    transition: all var(--t-1);
    white-space: nowrap;
}
.calendar-nav-btn:hover {
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

.calendar-filters {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-5);
    background: var(--surface-3);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.calendar-filters form {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    flex-wrap: wrap;
    width: 100%;
}

.calendar-filters label {
    text-transform: none;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: 0;
    margin-bottom: 0;
    white-space: nowrap;
}

.calendar-filters select {
    margin-bottom: 0;
    padding: 7px 32px 7px 12px;
    font-size: .82rem;
    height: 36px;
}

/* Legacy calendar nav */
.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    margin-bottom: var(--s-4);
    flex-wrap: wrap;
}

.calendar-nav a {
    display: inline-flex;
    align-items: center;
    padding: var(--s-2) var(--s-3);
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-2);
    text-decoration: none;
    transition: all var(--t-1);
    white-space: nowrap;
}
.calendar-nav a:hover {
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}
.calendar-nav a.current-month-link {
    flex-grow: 1;
    justify-content: center;
    border-color: transparent;
    font-weight: 700;
    color: var(--heading);
    font-size: .95rem;
}

/* Calendar filter section (legacy) */
.filter-section {
    margin-bottom: var(--s-4);
    padding-bottom: var(--s-4);
    border-bottom: 1px solid var(--border);
}
.filter-section form {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}
@media (min-width: 640px) {
    .filter-section form {
        flex-direction: row;
        align-items: center;
    }
}
.filter-section label {
    text-transform: none;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: 0;
    margin-bottom: 0;
    white-space: nowrap;
}
.filter-section select {
    margin-bottom: 0;
    max-width: 220px;
    height: 38px;
    padding: 8px 36px 8px 12px;
    font-size: .85rem;
}

/* Calendar table */
table.calendar {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

table.calendar th {
    padding: var(--s-2);
    font-size: .62rem;
    text-align: center;
    border: none;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-2);
    font-weight: 700;
}

table.calendar td {
    padding: var(--s-1);
    height: 76px;
    vertical-align: top;
    border: 1px solid var(--border);
    position: relative;
    background: var(--surface);
    transition: background var(--t-2);
}
@media (min-width: 640px)  { table.calendar td { height: 104px; } }
@media (min-width: 1024px) { table.calendar td { height: 124px; } }

table.calendar td.empty-day { background: var(--cal-empty); }
table.calendar td.today     { background: var(--cal-today-bg); box-shadow: inset 0 0 0 2px var(--cal-today-bd); }

.day-number {
    display: block;
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-2);
    padding: var(--s-1) var(--s-2);
    line-height: 1;
}
table.calendar td.today .day-number { color: var(--cal-today-bd); }

.dose-summary {
    position: absolute;
    bottom: var(--s-1);
    right: var(--s-1);
}

.dose-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 var(--s-1);
    background: var(--accent);
    color: var(--accent-fg);
    border-radius: var(--r-full);
    font-size: .75rem;
    font-weight: 700;
    text-decoration: none;
    box-shadow: var(--shadow-1);
    transition: all var(--t-1);
}
.dose-count:hover {
    background: var(--accent-2);
    transform: scale(1.1);
    text-decoration: none;
}

.dose-summary a { display: block; color: inherit; text-decoration: none; }
.dose-summary a:hover { text-decoration: none; }

/* Responsive calendar */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-1);
}

/* -------------------------------------------------------
   GENERAL NAV LINKS (footer of pages)
   ------------------------------------------------------- */
.general-navigation-links {
    padding: var(--s-5) 0 var(--s-3);
    margin-top: var(--s-6);
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: .875rem;
    color: var(--text-2);
}
.general-navigation-links p  { color: var(--text-2); margin-bottom: var(--s-2); }
.general-navigation-links a  { color: var(--text-2); margin: 0 var(--s-3); font-weight: 500; }
.general-navigation-links a:hover { color: var(--accent); text-decoration: none; }

/* -------------------------------------------------------
   FOOTER
   ------------------------------------------------------- */
.site-footer {
    padding: var(--s-8) 0 var(--s-6);
    margin-top: var(--s-10);
    border-top: 1px solid var(--border);
    text-align: center;
}
.site-footer p   { color: var(--text-3); font-size: .78rem; margin-bottom: var(--s-2); }
.site-footer a   { color: var(--text-2); font-size: .78rem; font-weight: 500; }
.site-footer a:hover { color: var(--accent); }

/* -------------------------------------------------------
   QR CODE & RECOVERY CODES
   ------------------------------------------------------- */
.qr-code { text-align: center; margin: var(--s-5) 0; }
.qr-code img {
    max-width: 180px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-2);
    background: white;
}
.qr-code p { margin-top: var(--s-2); font-size: .875rem; }

.recovery-codes {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: var(--s-4);
    font-family: var(--font-mono);
    font-size: .875rem;
    color: var(--text);
    max-height: 180px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    margin-bottom: var(--s-4);
}

/* -------------------------------------------------------
   NOTIFICATIONS
   ------------------------------------------------------- */
#notification-button-container { margin-top: var(--s-4); }
#notification-button-container button { width: 100%; }
#notification-button-container p { font-size: .875rem; color: var(--text-2); }

/* -------------------------------------------------------
   MISC
   ------------------------------------------------------- */
span[title="Estimated"],
.est-marker {
    font-size: .8em;
    color: var(--text-3);
    font-style: italic;
}

/* Page back links */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    color: var(--text-2);
    font-size: .85rem;
    font-weight: 500;
    margin-top: var(--s-5);
}
.back-link:hover { color: var(--accent); text-decoration: none; }

/* Notification note text */
.note-text {
    font-size: .8rem;
    color: var(--text-2);
    margin-top: var(--s-3);
    font-style: italic;
}

/* -------------------------------------------------------
   UTILITY
   ------------------------------------------------------- */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-2) !important; }
.text-small   { font-size: .82rem !important; }
.font-mono    { font-family: var(--font-mono); }

.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mt-3 { margin-top: var(--s-3); }
.mb-3 { margin-bottom: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mb-4 { margin-bottom: var(--s-4); }
.mt-5 { margin-top: var(--s-5); }
.mb-5 { margin-bottom: var(--s-5); }
.mt-6 { margin-top: var(--s-6); }
.mb-6 { margin-bottom: var(--s-6); }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-3 { gap: var(--s-3); }

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--r-full);
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .03em;
}
.badge-accent  { background: var(--accent-bg);  color: var(--accent); }
.badge-green   { background: var(--green-bg);   color: var(--green);  }
.badge-yellow  { background: var(--yellow-bg);  color: var(--yellow); }
.badge-red     { background: var(--red-bg);     color: var(--red);    }

/* Pill buttons on table (take dose) */
.pill-btn {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: var(--r-full);
    font-size: .78rem;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid var(--border-2);
    transition: all var(--t-1);
}
.pill-btn:hover {
    background: var(--accent);
    color: var(--accent-fg);
    text-decoration: none;
    transform: translateY(-1px);
}

/* -------------------------------------------------------
   CUSTOM SCROLLBAR
   ------------------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-2);
    border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-3); }

::selection { background: var(--accent-bg-2); color: var(--accent); }
