/* ============================================================
   Milkify Donor Milk Bank — Design System V3
   Cohesive brand experience: Space Indigo, Steel Blue, Platinum
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

/* ---- CSS Custom Properties ---- */
:root {
    /* Core palette — Milkify Brand */
    --white:             #FFFFFF;
    --space-indigo:      #182B55;
    --steel-blue:        #84A5BC;
    --alabaster:         #D3E0E2;
    --platinum:          #EFEFEF;

    /* Extended palette (derived from brand) */
    --space-indigo-dark: #0F1D3D;
    --space-indigo-light:#2A3F6E;
    --space-indigo-faint:#E8EDF5;
    --steel-blue-light:  #B3CBDA;
    --steel-blue-faint:  #E5EEF3;

    /* Legacy aliases (mapped to new brand) */
    --terracotta:        var(--space-indigo);
    --terracotta-light:  var(--steel-blue);
    --terracotta-dark:   var(--space-indigo-dark);
    --terracotta-faint:  var(--space-indigo-faint);
    --linen:             var(--platinum);
    --cream:             var(--white);
    --parchment:         var(--alabaster);
    --charcoal:          var(--space-indigo);
    --warm-gray:         #5A6B82;
    --warm-gray-light:   #8E9BAA;

    /* Functional accents */
    --sage:              #5B8C5A;
    --sage-deep:         #3D6B3C;
    --sage-light:        #C5D8C2;
    --honey:             #D4A853;
    --honey-light:       #F0DEB3;
    --rose:              #C25B56;
    --rose-light:        #F0D0CE;
    --sky:               var(--steel-blue);
    --sky-light:         var(--steel-blue-faint);

    /* Semantic tokens */
    --color-primary:     var(--space-indigo);
    --color-primary-hover: var(--space-indigo-dark);
    --color-primary-faint: var(--space-indigo-faint);
    --color-success:     var(--sage-deep);
    --color-success-bg:  var(--sage-light);
    --color-warning:     var(--honey);
    --color-warning-bg:  var(--honey-light);
    --color-danger:      var(--rose);
    --color-danger-bg:   var(--rose-light);
    --color-info:        var(--steel-blue);
    --color-info-bg:     var(--steel-blue-faint);

    /* Surfaces */
    --surface-page:      var(--platinum);
    --surface-card:      var(--white);
    --surface-sidebar:   var(--alabaster);
    --surface-input:     var(--white);

    /* Text */
    --text-primary:      var(--space-indigo);
    --text-secondary:    #5A6B82;
    --text-muted:        var(--space-indigo);
    --text-on-primary:   var(--white);

    /* Typography — Poppins (Milkify brand) */
    --font-display:      'Poppins', sans-serif;
    --font-heading:      'Poppins', sans-serif;
    --font-body:         'Poppins', sans-serif;
    --font-accent:       'Poppins', sans-serif;

    /* Spacing scale */
    --space-xs:  0.25rem;
    --space-sm:  0.5rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Radii */
    --radius-sm:  4px;
    --radius-md:  8px;
    --radius-lg:  12px;
    --radius-xl:  20px;
    --radius-full: 9999px;

    /* Shadows (cool-tinted) */
    --shadow-sm:  0 1px 3px rgba(24,43,85,0.06), 0 1px 2px rgba(24,43,85,0.04);
    --shadow-md:  0 4px 12px rgba(24,43,85,0.08), 0 2px 4px rgba(24,43,85,0.04);
    --shadow-lg:  0 8px 30px rgba(24,43,85,0.10), 0 4px 8px rgba(24,43,85,0.06);
    --shadow-glow: 0 0 0 3px rgba(132,165,188,0.25);

    /* Transitions */
    --ease-out:  cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 64px;
    --bottom-nav-height: 72px;
    --content-max-width: 1400px;
}

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

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--surface-page);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle grain texture overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.012;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-out);
}
a:hover {
    color: var(--color-primary-hover);
}

img { max-width: 100%; height: auto; }

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.625rem; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.125rem; }

.display-title {
    font-family: var(--font-display);
    font-size: 2.25rem;
    letter-spacing: -0.01em;
}

.accent-text {
    font-family: var(--font-accent);
    font-style: italic;
    font-weight: 400;
    color: var(--text-secondary);
}

.greeting-text {
    font-family: var(--font-accent);
    font-size: 1.35rem;
    font-style: italic;
    color: var(--warm-gray);
}

small, .text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-muted { color: var(--text-secondary); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ---- Animations ---- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes gentlePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes underlineSlide {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

.animate-in {
    animation: fadeUp var(--duration-slow) var(--ease-out) both;
}

.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.3s; }
.stagger-7 { animation-delay: 0.35s; }
.stagger-8 { animation-delay: 0.4s; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---- App Shell — Mobile First ---- */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 var(--space-lg);
    background: var(--surface-card);
    border-bottom: 1px solid var(--parchment);
    box-shadow: var(--shadow-sm);
}

.app-header__brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--text-primary);
    text-decoration: none;
}

.app-header__brand svg {
    width: 28px;
    height: 28px;
    color: var(--terracotta);
}

.app-header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.header-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    position: relative;
}
.header-icon-btn:hover {
    background: var(--parchment);
    color: var(--text-primary);
}
.header-icon-btn .badge-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--terracotta);
    border: 2px solid var(--surface-card);
}

/* Sidebar — hidden on mobile */
.app-sidebar {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--surface-sidebar);
    border-right: 1px solid rgba(24,43,85,0.06);
    overflow-y: auto;
    padding: var(--space-lg) 0;
    z-index: 90;
}

.sidebar-section {
    padding: 0 var(--space-lg);
    margin-bottom: var(--space-xl);
}

.sidebar-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0 var(--space-md);
    margin-bottom: var(--space-sm);
}

.sidebar-nav {
    list-style: none;
}

.sidebar-nav__item a {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 0.6rem var(--space-md);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--duration-fast) var(--ease-out);
    text-decoration: none;
    position: relative;
}
.sidebar-nav__item a svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}
.sidebar-nav__item a:hover {
    background: rgba(24,43,85,0.07);
    color: var(--text-primary);
}
.sidebar-nav__item a:hover svg { opacity: 1; }

.sidebar-nav__item.active a {
    background: var(--terracotta-faint);
    color: var(--terracotta-dark);
    font-weight: 600;
}
.sidebar-nav__item.active a svg {
    opacity: 1;
    color: var(--terracotta);
}

/* Sidebar user card */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    margin: 0 var(--space-sm);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.5);
}
.sidebar-user__avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--terracotta-light);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.9rem;
}
.sidebar-user__name {
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.3;
}
.sidebar-user__role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Main content */
.app-main {
    flex: 1;
    padding: var(--space-lg);
    padding-bottom: calc(var(--bottom-nav-height) + var(--space-xl));
    max-width: var(--content-max-width);
    width: 100%;
    margin: 0 auto;
}

/* Bottom navigation — mobile only */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--bottom-nav-height);
    background: var(--surface-card);
    border-top: 1px solid var(--parchment);
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    padding: 0 var(--space-xs);
    box-shadow: 0 -2px 12px rgba(24,43,85,0.06);
}

.bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: var(--space-xs) var(--space-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 500;
    transition: color var(--duration-fast) var(--ease-out);
    min-width: 56px;
    position: relative;
}
.bottom-nav__item svg {
    width: 22px;
    height: 22px;
    transition: transform var(--duration-fast) var(--ease-spring);
}
.bottom-nav__item.active {
    color: var(--terracotta);
}
.bottom-nav__item.active svg {
    transform: scale(1.1);
}
.bottom-nav__item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--terracotta);
    border-radius: 0 0 3px 3px;
}

/* ---- Desktop overrides (768px+) ---- */
@media (min-width: 768px) {
    .app-sidebar {
        display: block;
    }
    .app-main {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
        max-width: none;
        padding: var(--space-xl) var(--space-2xl);
        padding-bottom: var(--space-2xl);
    }
    .bottom-nav {
        display: none;
    }
    .mobile-only {
        display: none !important;
    }
}

@media (min-width: 1200px) {
    .app-main {
        max-width: var(--content-max-width);
        padding: var(--space-2xl) var(--space-3xl);
    }
}

.desktop-only {
    display: none;
}
@media (min-width: 768px) {
    .desktop-only {
        display: block;
    }
}

/* ---- Page Header ---- */
.page-header {
    margin-bottom: var(--space-xl);
}
.page-header h1 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    margin-bottom: var(--space-xs);
}
.page-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ---- Cards ---- */
.card {
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(24,43,85,0.04);
    transition: box-shadow var(--duration-normal) var(--ease-out), transform var(--duration-normal) var(--ease-out);
}
.card:hover {
    box-shadow: var(--shadow-md);
}
.card-interactive:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card__header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--parchment);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}
.card__header h2,
.card__header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.card__body {
    padding: var(--space-lg);
}

.card__footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--parchment);
    background: rgba(211,224,226,0.3);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Warm accent card variant */
.card--warm {
    background: linear-gradient(135deg, var(--white) 0%, var(--space-indigo-faint) 100%);
    border-color: var(--steel-blue);
}

.card--sage {
    background: linear-gradient(135deg, #f4f8f3 0%, #C5D8C2 100%);
    border-color: #5B8C5A;
}

/* ---- Stat Cards ---- */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

@media (min-width: 768px) {
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

.stat-card {
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(24,43,85,0.04);
    animation: fadeUp var(--duration-slow) var(--ease-out) both;
}
.stat-card__label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}
.stat-card__value {
    font-family: var(--font-display);
    font-size: 1.75rem;
    color: var(--text-primary);
    line-height: 1.2;
}
.stat-card__sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.stat-card__meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* Stat card — active count highlights */
.stat-card--warning {
    border-left: 4px solid #E09945;
    background: linear-gradient(135deg, #FFF7ED 0%, var(--white) 100%);
}
.stat-card--warning .stat-card__value { color: #B47A2E; }

.stat-card--danger {
    border-left: 4px solid var(--rose);
    background: linear-gradient(135deg, #FFF0EF 0%, var(--white) 100%);
}
.stat-card--danger .stat-card__value { color: var(--rose); }

.stat-card--info {
    border-left: 4px solid var(--steel-blue);
    background: linear-gradient(135deg, var(--steel-blue-faint) 0%, var(--white) 100%);
}
.stat-card--info .stat-card__value { color: var(--space-indigo); }

.stat-card--success {
    border-left: 4px solid var(--steel-blue);
    background: linear-gradient(135deg, var(--space-indigo-faint) 0%, var(--white) 100%);
}
.stat-card--success .stat-card__value { color: var(--space-indigo); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.65rem 1.25rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}
.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--terracotta);
    color: var(--white);
    border-color: var(--terracotta);
}
.btn-primary:hover {
    background: var(--terracotta-dark);
    border-color: var(--terracotta-dark);
    color: var(--white);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: transparent;
    color: var(--terracotta);
    border-color: var(--terracotta-light);
}
.btn-secondary:hover {
    background: var(--terracotta-faint);
    border-color: var(--terracotta);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--parchment);
    color: var(--text-primary);
}

.btn-success {
    background: var(--sage-deep);
    color: var(--white);
    border-color: var(--sage-deep);
}
.btn-success:hover {
    background: #4a6d47;
    transform: translateY(-1px);
    color: var(--white);
}

.btn-danger {
    background: var(--rose);
    color: var(--white);
    border-color: var(--rose);
}
.btn-danger:hover {
    background: #a84d49;
    transform: translateY(-1px);
    color: var(--white);
}

.btn-warning {
    background: var(--honey);
    color: var(--charcoal);
    border-color: var(--honey);
}

.btn-info {
    background: var(--sky);
    color: var(--white);
    border-color: var(--sky);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}
.btn-sm svg { width: 15px; height: 15px; }

.btn-lg {
    padding: 0.85rem 1.75rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

.btn-block {
    width: 100%;
}

.btn:disabled, .btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.form-label .required {
    color: var(--rose);
    margin-left: 2px;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.7rem 0.9rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text-primary);
    background: var(--surface-input);
    border: 1.5px solid var(--parchment);
    border-radius: var(--radius-md);
    transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
    appearance: none;
    -webkit-appearance: none;
}
.form-control::placeholder {
    color: var(--text-muted);
}
.form-control:focus {
    outline: none;
    border-color: var(--terracotta-light);
    box-shadow: var(--shadow-glow);
}

.form-control.is-invalid {
    border-color: var(--rose);
    box-shadow: 0 0 0 3px rgba(194,91,86,0.15);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235A6B82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
    cursor: pointer;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-top: 1px;
    accent-color: var(--terracotta);
    cursor: pointer;
    flex-shrink: 0;
}
.form-check label {
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Radio group (inline) */
.radio-group {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}
.radio-option {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.5rem 1rem;
    border: 1.5px solid var(--parchment);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    font-size: 0.9rem;
}
.radio-option:hover {
    border-color: var(--terracotta-light);
}
.radio-option.selected,
.radio-option:has(input:checked) {
    border-color: var(--terracotta);
    background: var(--terracotta-faint);
}
.radio-option input {
    accent-color: var(--terracotta);
}

/* Form row (side-by-side fields) */
.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
}
@media (min-width: 480px) {
    .form-row--2 { grid-template-columns: 1fr 1fr; }
    .form-row--3 { grid-template-columns: 1fr 1fr 1fr; }
    .form-row--4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

/* Invalid feedback */
.invalid-feedback {
    font-size: 0.8rem;
    color: var(--rose);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.invalid-feedback::before {
    content: '';
    width: 14px;
    height: 14px;
    background: 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='%23C25B56' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='8' x2='12' y2='12'/%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'/%3E%3C/svg%3E") no-repeat center;  /* rose/danger — intentionally kept */
    flex-shrink: 0;
}

/* ---- Tables ---- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.table thead {
    background: var(--parchment);
}
.table th {
    padding: 0.75rem var(--space-md);
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    white-space: nowrap;
}
.table td {
    padding: 0.75rem var(--space-md);
    border-bottom: 1px solid var(--parchment);
    vertical-align: middle;
}
.table tbody tr {
    transition: background var(--duration-fast) var(--ease-out);
}
.table tbody tr:hover {
    background: rgba(211,224,226,0.35);
}
.table tbody tr:last-child td {
    border-bottom: none;
}

/* Mobile card-style table */
@media (max-width: 767px) {
    .table-mobile-cards thead {
        display: none;
    }
    .table-mobile-cards tbody tr {
        display: block;
        padding: var(--space-md);
        margin-bottom: var(--space-sm);
        background: var(--surface-card);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        border: 1px solid rgba(24,43,85,0.04);
    }
    .table-mobile-cards td {
        display: flex;
        justify-content: space-between;
        padding: 0.35rem 0;
        border-bottom: none;
        font-size: 0.85rem;
    }
    .table-mobile-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.8rem;
        margin-right: var(--space-md);
    }
}

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.2rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.badge-primary {
    background: var(--terracotta-faint);
    color: var(--terracotta-dark);
}
.badge-success {
    background: var(--color-success-bg);
    color: var(--sage-deep);
}
.badge-warning {
    background: var(--color-warning-bg);
    color: #8B6E1A;
}
.badge-danger {
    background: var(--color-danger-bg);
    color: var(--rose);
}
.badge-info {
    background: var(--color-info-bg);
    color: #3D6F97;
}
.badge-muted {
    background: var(--parchment);
    color: var(--warm-gray);
}

.badge-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-pulse {
    animation: gentlePulse 2s ease-in-out infinite;
}

/* ---- Alerts ---- */
.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    border: 1px solid transparent;
    animation: fadeUp var(--duration-slow) var(--ease-out) both;
}
.alert svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--sage-deep);
    border-color: var(--sage);
}
.alert-danger, .alert-error {
    background: var(--color-danger-bg);
    color: var(--rose);
    border-color: var(--rose);
}
.alert-warning {
    background: var(--color-warning-bg);
    color: #6B5415;
    border-color: var(--honey);
}
.alert-info {
    background: var(--color-info-bg);
    color: #2D5F8A;
    border-color: var(--sky);
}

.alert-dismissible {
    position: relative;
    padding-right: var(--space-2xl);
}
.alert-dismiss-btn {
    position: absolute;
    top: var(--space-sm);
    right: var(--space-sm);
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    line-height: 1;
    padding: 4px;
}
.alert-dismiss-btn:hover { opacity: 1; }

/* ---- Progress ---- */
.progress-bar {
    height: 8px;
    background: var(--parchment);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--steel-blue), var(--space-indigo));
    border-radius: var(--radius-full);
    transition: width 0.8s var(--ease-out);
}

.progress-bar--sage .progress-bar__fill {
    background: linear-gradient(90deg, #C5D8C2, #3D6B3C);
}

/* ---- Accordion ---- */
.accordion {
    border: 1px solid var(--parchment);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.accordion-item {
    border-bottom: 1px solid var(--parchment);
}
.accordion-item:last-child {
    border-bottom: none;
}
.accordion-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    background: var(--surface-card);
    border: none;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    transition: background var(--duration-fast) var(--ease-out);
}
.accordion-trigger:hover {
    background: rgba(211,224,226,0.4);
}
.accordion-trigger svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    transition: transform var(--duration-normal) var(--ease-out);
    flex-shrink: 0;
}
.accordion-item.open .accordion-trigger svg {
    transform: rotate(180deg);
}
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--duration-slow) var(--ease-out);
}
.accordion-item.open .accordion-content {
    max-height: 2000px;
}
.accordion-content__inner {
    padding: var(--space-md) var(--space-lg) var(--space-lg);
}

/* ---- Checklist ---- */
.checklist {
    list-style: none;
}
.checklist-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
    font-size: 0.9rem;
}
.checklist-icon {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.checklist-icon--done {
    background: var(--sage-light);
    color: var(--sage-deep);
}
.checklist-icon--pending {
    background: var(--parchment);
    color: var(--warm-gray-light);
}
.checklist-icon--active {
    background: var(--terracotta-faint);
    color: var(--terracotta);
    animation: gentlePulse 2s ease-in-out infinite;
}
.checklist-icon svg {
    width: 14px;
    height: 14px;
}

/* ---- Tabs ---- */
.tabs {
    display: flex;
    gap: var(--space-xs);
    border-bottom: 2px solid var(--parchment);
    margin-bottom: var(--space-xl);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tab {
    padding: 0.6rem var(--space-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all var(--duration-fast) var(--ease-out);
}
.tab:hover {
    color: var(--text-primary);
}
.tab.active {
    color: var(--terracotta);
    border-bottom-color: var(--terracotta);
    font-weight: 600;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-xl);
    color: var(--text-secondary);
}
.empty-state svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}
.empty-state h3 {
    font-family: var(--font-heading);
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}
.empty-state p {
    max-width: 360px;
    margin: 0 auto var(--space-lg);
    font-size: 0.9rem;
}

/* ---- Auth Layout ---- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    background:
        radial-gradient(ellipse at 20% 50%, rgba(24,43,85,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(132,165,188,0.08) 0%, transparent 40%),
        radial-gradient(ellipse at 60% 80%, rgba(211,224,226,0.12) 0%, transparent 40%),
        var(--platinum);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2xl);
    animation: fadeUp 0.5s var(--ease-out) both;
    border: 1px solid rgba(24,43,85,0.04);
}

.auth-card__logo {
    text-align: center;
    margin-bottom: var(--space-xl);
}
.auth-card__logo svg {
    width: 48px;
    height: 48px;
    color: var(--terracotta);
    margin-bottom: var(--space-sm);
}
.auth-card__logo h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
}
.auth-card__logo p {
    font-family: var(--font-accent);
    font-style: italic;
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 4px;
}

.auth-links {
    text-align: center;
    margin-top: var(--space-lg);
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.auth-links a {
    font-weight: 600;
}

/* ---- Donor Banner ---- */
.donor-banner {
    background: linear-gradient(135deg, var(--space-indigo) 0%, var(--space-indigo-dark) 100%);
    color: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
    position: relative;
    overflow: hidden;
    animation: fadeUp var(--duration-slow) var(--ease-out) both;
}
.donor-banner::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -10%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
}
.donor-banner h2 {
    color: var(--white);
    font-family: var(--font-accent);
    font-weight: 400;
    font-style: italic;
    font-size: 1.15rem;
    opacity: 0.9;
    margin-bottom: var(--space-xs);
}
.donor-banner .donor-id {
    font-family: var(--font-display);
    font-size: 1.5rem;
    letter-spacing: 0.02em;
}
.donor-banner .donor-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: var(--space-sm);
    padding: 0.3rem 0.8rem;
    background: rgba(255,255,255,0.2);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

/* ---- Section Divider ---- */
.section-divider {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin: var(--space-xl) 0 var(--space-lg);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--parchment);
}

/* ---- Quick Actions Grid ---- */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

@media (min-width: 768px) {
    .quick-actions { grid-template-columns: repeat(4, 1fr); }
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-lg) var(--space-md);
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: var(--text-primary);
    transition: all var(--duration-normal) var(--ease-out);
    text-align: center;
    border: 1px solid rgba(24,43,85,0.04);
}
.quick-action:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    color: var(--terracotta);
}
.quick-action__icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--terracotta-faint);
    color: var(--terracotta);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--duration-fast) var(--ease-out);
}
.quick-action:hover .quick-action__icon {
    background: var(--terracotta);
    color: var(--white);
}
.quick-action__icon svg {
    width: 22px;
    height: 22px;
}
.quick-action span {
    font-size: 0.8rem;
    font-weight: 600;
}

/* ---- Signature Pad ---- */
.signature-pad-wrapper {
    border: 2px dashed var(--parchment);
    border-radius: var(--radius-md);
    background: var(--white);
    padding: var(--space-sm);
    text-align: center;
}
.signature-pad-wrapper canvas {
    width: 100%;
    max-width: 500px;
    height: 150px;
    cursor: crosshair;
    touch-action: none;
}

/* ---- Initials Input ---- */
.initials-input {
    width: 60px;
    text-align: center;
    text-transform: uppercase;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.05em;
}

/* ---- File Upload ---- */
.file-upload {
    border: 2px dashed var(--parchment);
    border-radius: var(--radius-md);
    padding: var(--space-xl);
    text-align: center;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}
.file-upload:hover {
    border-color: var(--terracotta-light);
    background: rgba(24,43,85,0.03);
}
.file-upload svg {
    width: 32px;
    height: 32px;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}
.file-upload p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ---- Utility classes ---- */
.d-flex { display: flex; }
.d-grid { display: grid; }
.d-none { display: none; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mr-sm { margin-right: var(--space-sm); }
.ml-auto { margin-left: auto; }

.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

.w-full { width: 100%; }
.rounded { border-radius: var(--radius-md); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ---- Mention styling ---- */
.mention-user {
    color: var(--terracotta);
    background: var(--terracotta-faint);
    padding: 1px 4px;
    border-radius: 4px;
    font-weight: 600;
}

/* ---- Search input ---- */
.search-input-wrapper {
    position: relative;
}
.search-input-wrapper svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}
.search-input-wrapper .form-control {
    padding-left: 38px;
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    margin-top: var(--space-xl);
}
.pagination a, .pagination span {
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--duration-fast) var(--ease-out);
}
.pagination a:hover {
    background: var(--parchment);
    color: var(--text-primary);
}
.pagination .active {
    background: var(--terracotta);
    color: var(--white);
}

/* ---- Tooltip-like info boxes ---- */
.info-box {
    background: var(--color-info-bg);
    border: 1px solid rgba(132,165,188,0.3);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    font-size: 0.875rem;
    color: #2D5F8A;
    margin-bottom: var(--space-lg);
}
.info-box strong {
    display: block;
    margin-bottom: 4px;
}

/* ---- Mobile menu overlay ---- */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(24,43,85,0.5);
    z-index: 89;
    opacity: 0;
    transition: opacity var(--duration-normal) var(--ease-out);
}
.mobile-menu-overlay.active {
    display: block;
    opacity: 1;
}

.app-sidebar.mobile-open {
    display: block;
    animation: slideInRight var(--duration-normal) var(--ease-out);
}

@media (min-width: 768px) {
    .mobile-menu-overlay { display: none !important; }
}

/* ---- Print styles ---- */
@media print {
    .app-sidebar, .bottom-nav, .app-header, .btn { display: none !important; }
    .app-main { margin: 0; padding: 0; max-width: 100%; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ---- Tag/Chip inputs for recipient selection ---- */
.tag-input-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    border: 1.5px solid var(--parchment);
    border-radius: var(--radius-md);
    background: var(--surface-input);
    min-height: 42px;
    cursor: text;
    transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.tag-input-container:focus-within {
    border-color: var(--terracotta-light);
    box-shadow: var(--shadow-glow);
}
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--terracotta-faint);
    color: var(--terracotta-dark);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
}
.tag-chip button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--terracotta);
    padding: 0 2px;
}
.tag-input-container input {
    flex: 1;
    min-width: 120px;
    border: none;
    outline: none;
    font-family: var(--font-body);
    font-size: 0.9rem;
    background: transparent;
    padding: 4px;
}

/* ---- Autocomplete dropdown ---- */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface-card);
    border: 1px solid var(--parchment);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: 200;
    display: none;
}
.autocomplete-dropdown.show { display: block; }
.autocomplete-item {
    padding: 0.6rem var(--space-md);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background var(--duration-fast);
}
.autocomplete-item:hover {
    background: var(--terracotta-faint);
}

/* ---- Conditional field visibility ---- */
.conditional-section {
    transition: opacity var(--duration-normal) var(--ease-out);
}
.conditional-section.hidden {
    display: none;
}

/* ---- Grid layouts ---- */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
}
@media (min-width: 768px) {
    .grid-2 { grid-template-columns: 1fr 1fr; }
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
}
@media (min-width: 768px) {
    .grid-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ---- Donor consent form specifics ---- */
.consent-section {
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid var(--parchment);
}
.consent-section:last-of-type {
    border-bottom: none;
}
.consent-section h3 {
    font-family: var(--font-heading);
    margin-bottom: var(--space-md);
    color: var(--terracotta-dark);
}
.consent-initials-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    background: rgba(211,224,226,0.3);
    border-radius: var(--radius-md);
}
.consent-initials-row .initials-input {
    flex-shrink: 0;
}
.consent-initials-row p {
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ---- Messages unread indicator ---- */
.msg-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--terracotta);
    flex-shrink: 0;
}
.msg-row--unread {
    font-weight: 600;
}
.msg-row--unread td { font-weight: 600; }

/* ---- Exclusion periods display ---- */
.exclusion-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--color-warning-bg);
    color: #6B5415;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 500;
}

/* ---- Admin/Staff specific ---- */
.admin-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    align-items: center;
    margin-bottom: var(--space-lg);
}
.filter-bar .form-control {
    width: auto;
    min-width: 160px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-xs);
}
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid rgba(211,224,226,0.5);
    font-size: 0.9rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-row dt {
    color: var(--text-secondary);
    font-weight: 500;
}
.detail-row dd {
    font-weight: 600;
    text-align: right;
}

/* ---- Warm divider ---- */
hr.warm {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--parchment), transparent);
    margin: var(--space-xl) 0;
}

/* ---- Loading skeleton ---- */
.skeleton {
    background: linear-gradient(90deg, var(--alabaster) 25%, #E5EEF3 50%, var(--alabaster) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
    height: 1em;
}

/* ---- Notes section ---- */
.note-item {
    padding: var(--space-md);
    border-left: 3px solid var(--terracotta-light);
    background: rgba(211,224,226,0.25);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: var(--space-md);
}
.note-item__meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* ---- Timeline ---- */
.timeline {
    position: relative;
    padding-left: 24px;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--parchment);
}
.timeline-item {
    position: relative;
    padding-bottom: var(--space-lg);
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -21px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--terracotta-light);
    border: 2px solid var(--surface-page);
}
.timeline-item--active::before {
    background: var(--terracotta);
}
.timeline-item--complete::before {
    background: var(--sage);
    border-color: var(--sage);
    width: 18px;
    height: 18px;
    left: -24px;
    top: 1px;
}
.timeline-item--complete::after {
    content: '';
    position: absolute;
    left: -19px;
    top: 4px;
    width: 8px;
    height: 5px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg);
}
.timeline-item--failed::before {
    background: var(--color-danger, #dc3545);
    border-color: var(--color-danger, #dc3545);
}
.timeline-item--needs_review::before {
    background: var(--color-warning, #f59e0b);
    border-color: var(--color-warning, #f59e0b);
}
.timeline-item--pending::before {
    background: var(--parchment);
    border-color: var(--text-muted);
    border-width: 2px;
    border-style: solid;
}

/* ---- Modals ---- */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 0; height: 0;
    z-index: 1000;
    pointer-events: none;
}
.modal.active { display: block; }
.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    width: calc(100% - 2rem);
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    pointer-events: auto;
    z-index: 1001;
}
.modal-content.is-dragging,
.modal-content.was-dragged {
    transform: none;
}
.modal-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--parchment);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
}
.modal-header:active { cursor: grabbing; }
.modal-title { margin: 0; font-size: 1.125rem; font-weight: 600; }
.modal-close {
    background: none; border: none;
    font-size: 1.5rem; cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: var(--space-lg); }
.modal-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--parchment);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}

/* ============================================================
   Journal — Conversational Chat UI
   ============================================================ */

/* Remove app-main padding so journal fills full content area */
.app-main:has(.journal-container) {
    padding: 0 !important;
    overflow: hidden;
}

.journal-container {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - var(--header-height) - var(--bottom-nav-height));
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    padding: 0;
}
@media (min-width: 768px) {
    .journal-container { height: calc(100vh - var(--header-height)); }
}
.journal-chat {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    scroll-behavior: smooth;
}
.journal-bubble {
    max-width: 85%;
    padding: var(--space-sm) var(--space-md);
    border-radius: 18px;
    line-height: 1.5;
    animation: journalFadeUp 0.3s ease-out both;
}
.journal-bubble--system {
    align-self: flex-start;
    background: var(--white);
    border: 1px solid var(--alabaster);
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
}
.journal-bubble--user {
    align-self: flex-end;
    background: var(--steel-blue-faint);
    border-bottom-right-radius: 4px;
    color: var(--charcoal);
}
.journal-bubble--info {
    align-self: center;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    padding: var(--space-xs);
}
@keyframes journalFadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Category selection cards */
.journal-categories {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
    width: 100%;
    max-width: 320px;
}
.journal-cat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: var(--space-md) var(--space-sm);
    background: var(--white);
    border: 2px solid var(--parchment);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
}
.journal-cat-card:hover {
    border-color: var(--terracotta);
    background: var(--terracotta-faint);
}
.journal-cat-card svg {
    width: 28px;
    height: 28px;
    stroke: var(--terracotta);
}

/* Pill buttons for yes/no and quick options */
.journal-pills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
}
.journal-pill {
    padding: 8px 20px;
    border-radius: 20px;
    border: 2px solid var(--parchment);
    background: var(--white);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.15s ease;
    font-family: var(--font-body);
}
.journal-pill:hover {
    border-color: var(--terracotta);
    background: var(--terracotta-faint);
}
.journal-pill--selected {
    border-color: var(--terracotta);
    background: var(--terracotta);
    color: var(--white);
}

/* Inline input area */
.journal-input-row {
    display: flex;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
    width: 100%;
    max-width: 320px;
}
.journal-input-row input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--parchment);
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    background: var(--white);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
}
.journal-input-row input:focus {
    border-color: var(--terracotta);
}
.journal-input-row button {
    padding: 10px 16px;
    border-radius: 12px;
    border: none;
    background: var(--terracotta);
    color: var(--white);
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    transition: background 0.15s;
}
.journal-input-row button:hover {
    background: var(--terracotta-dark);
}

/* Autocomplete input */
.journal-autocomplete {
    width: 100%;
    max-width: 320px;
    position: relative;
}
.journal-ac-dropdown {
    background: var(--white);
    border: 1.5px solid var(--parchment);
    border-radius: 12px;
    margin-top: 4px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(24,43,85,0.10);
}
.journal-ac-item {
    padding: 10px 14px;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid var(--linen);
}
.journal-ac-item:last-child {
    border-bottom: none;
}
.journal-ac-item:hover,
.journal-ac-item.active {
    background: var(--terracotta-faint);
}
.journal-ac-item strong {
    color: var(--terracotta);
    font-weight: 600;
}

/* Review card */
.journal-review-card {
    background: var(--white);
    border: 1.5px solid var(--parchment);
    border-radius: 14px;
    padding: var(--space-sm) var(--space-md);
    max-width: 85%;
    align-self: flex-start;
}
.journal-review-row {
    display: flex;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: 6px 0;
    border-bottom: 1px solid var(--linen);
    font-size: 0.9rem;
    line-height: 1.4;
}
.journal-review-row:last-child {
    border-bottom: none;
}
.journal-review-label {
    color: var(--text-secondary);
    flex-shrink: 0;
}
.journal-review-value {
    font-weight: 500;
    color: var(--text-primary);
    text-align: right;
}

/* Done state */
.journal-done {
    text-align: center;
    padding: var(--space-lg);
}
.journal-done svg {
    width: 48px;
    height: 48px;
    stroke: var(--sage-deep);
    margin-bottom: var(--space-sm);
}
.journal-done p {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

/* History list */
.journal-history-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md);
    border-bottom: 1px solid var(--parchment);
}
.journal-history-item:last-child { border-bottom: none; }
.journal-history-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.journal-history-icon svg { width: 18px; height: 18px; }
.journal-history-icon--medication { background: var(--sky-light); }
.journal-history-icon--medication svg { stroke: var(--sky); }
.journal-history-icon--illness { background: var(--honey-light); }
.journal-history-icon--illness svg { stroke: var(--honey); }
.journal-history-icon--diet_alcohol { background: var(--rose-light); }
.journal-history-icon--diet_alcohol svg { stroke: var(--rose); }
.journal-history-icon--ounces { background: var(--sage-light); }
.journal-history-icon--ounces svg { stroke: var(--sage-deep); }
.journal-history-body { flex: 1; }
.journal-history-body strong { display: block; margin-bottom: 2px; }
.journal-history-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Journal source badge for admin views */
.badge-journal {
    background: #f3e8ff;
    color: #6b21a8;
    font-weight: 600;
}

/* Journal entries timeline in admin detail view */
.journal-timeline {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}
.journal-timeline-entry {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--platinum);
    border-radius: 12px;
    border-left: 3px solid var(--steel-blue);
}
.journal-timeline-entry__icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--space-indigo-faint);
}
.journal-timeline-entry__icon svg { width: 16px; height: 16px; stroke: var(--space-indigo); }
.journal-timeline-entry__body { flex: 1; }
.journal-timeline-entry__type {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 2px;
}
