:root {
    --bg: #f5efe4;
    --surface: rgba(255, 251, 244, 0.86);
    --surface-strong: #fffaf1;
    --line: rgba(104, 81, 54, 0.18);
    --text: #2f2418;
    --muted: #6f5a45;
    --accent: #156b63;
    --accent-strong: #0f4f4a;
    --warn: #b4543e;
    --warn-soft: rgba(180, 84, 62, 0.14);
    --ok-soft: rgba(21, 107, 99, 0.12);
    --shadow: 0 18px 55px rgba(79, 56, 27, 0.12);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --font-ui: "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
    --font-display: "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-ui);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.85), transparent 32%),
        linear-gradient(180deg, #f8f2e9 0%, #f0e5d3 42%, #e7dbc5 100%);
    position: relative;
}

button,
input,
select,
textarea {
    font: inherit;
}

.background-glow {
    position: fixed;
    z-index: -1;
    border-radius: 999px;
    filter: blur(18px);
    opacity: 0.8;
    pointer-events: none;
}

.glow-one {
    top: -5rem;
    right: -5rem;
    width: 18rem;
    height: 18rem;
    background: rgba(21, 107, 99, 0.16);
}

.glow-two {
    bottom: 15%;
    left: -5rem;
    width: 16rem;
    height: 16rem;
    background: rgba(180, 84, 62, 0.14);
}

.page-header,
.layout,
.auth-shell {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
}

.page-header {
    padding: 3rem 0 2rem;
}

.layout {
    padding-bottom: 3rem;
    display: grid;
    gap: 1.25rem;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 0;
}

.auth-card {
    width: min(720px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    display: grid;
    gap: 1rem;
}

.auth-panel {
    background: rgba(255, 251, 244, 0.78);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.auth-form {
    margin-top: 0.5rem;
}

.header-topline {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    align-items: flex-start;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.7rem 0.95rem;
    background: rgba(255, 251, 244, 0.78);
    border: 1px solid var(--line);
    color: var(--accent-strong);
    font-weight: 600;
}

.eyebrow,
.section-kicker,
.module-chip-label,
.summary-label,
.stat-label {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    color: var(--muted);
}

h1,
h2,
h3 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0;
}

h1 {
    font-size: clamp(2.8rem, 5vw, 4.4rem);
    line-height: 0.96;
    margin-top: 0.45rem;
}

.lead,
.section-copy,
.medication-meta,
.plan-copy,
.summary-note,
.empty-state,
.field-hint,
.table-muted,
.toolbox-meta-card p,
.medication-stat p {
    color: var(--muted);
    line-height: 1.55;
}

.lead {
    max-width: 60ch;
    font-size: 1.08rem;
}

.module-strip,
.summary-grid,
.grid-two,
.grid-two-fields {
    display: grid;
    gap: 1rem;
}

.module-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 2rem;
}

.module-chip,
.card,
.summary-card {
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.module-chip,
.card,
.summary-card,
.banner,
.medication-item,
.plan-item,
.medication-stat,
.toolbox-meta-card {
    border-radius: var(--radius-lg);
}

.module-chip {
    background: rgba(255, 249, 239, 0.72);
    padding: 1rem 1.1rem;
    display: grid;
    gap: 0.25rem;
}

.module-chip.is-active {
    background: linear-gradient(135deg, rgba(21, 107, 99, 0.14), rgba(255, 250, 241, 0.9));
    border-color: rgba(21, 107, 99, 0.28);
}

.card {
    background: var(--surface);
    padding: 1.4rem;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    align-items: flex-start;
    margin-bottom: 1.15rem;
}

.summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary-card {
    background: var(--surface-strong);
    padding: 1rem;
    display: grid;
    gap: 0.35rem;
}

.summary-value,
.plan-time {
    font-family: var(--font-display);
}

.summary-value {
    font-size: clamp(1.8rem, 3vw, 2.5rem);
}

.grid-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-two.wide-left {
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
}

.stack-form,
.medication-list,
.today-plan,
.week-chart,
.medication-stats,
.toolbox-panel {
    display: grid;
    gap: 0.9rem;
}

fieldset {
    margin: 0;
    padding: 0;
    border: 0;
    display: grid;
    gap: 1rem;
}

label {
    display: grid;
    gap: 0.4rem;
}

label span {
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid rgba(104, 81, 54, 0.22);
    background: rgba(255, 253, 248, 0.94);
    color: var(--text);
    padding: 0.85rem 0.95rem;
}

textarea {
    resize: vertical;
    min-height: 110px;
}

.schedule-panel {
    display: grid;
    gap: 0.65rem;
    padding: 1rem;
    background: rgba(21, 107, 99, 0.06);
    border-radius: var(--radius-lg);
    border: 1px dashed rgba(21, 107, 99, 0.2);
}

.form-actions,
.action-row,
.toolbox-meta-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.inline-form {
    margin: 0;
}

.primary-button,
.secondary-button,
.ghost-button,
.inline-button,
.ghost-link,
.inline-link,
.danger-button {
    border: 0;
    cursor: pointer;
    text-decoration: none;
}

.primary-button {
    border-radius: 999px;
    padding: 0.85rem 1.1rem;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #fff;
}

.secondary-button,
.ghost-button {
    border-radius: 999px;
    padding: 0.85rem 1.1rem;
}

.secondary-button {
    background: rgba(47, 36, 24, 0.08);
    color: var(--text);
}

.ghost-button {
    background: transparent;
    color: var(--muted);
}

.inline-button,
.ghost-link,
.inline-link,
.danger-button {
    background: transparent;
    color: var(--accent-strong);
    padding: 0;
    font-weight: 600;
}

.ghost-link {
    color: var(--muted);
}

.danger-button {
    color: var(--warn);
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.banner {
    padding: 1rem 1.15rem;
    border: 1px solid var(--line);
    background: rgba(255, 251, 244, 0.86);
}

.banner-success {
    border-color: rgba(21, 107, 99, 0.24);
    background: rgba(21, 107, 99, 0.08);
}

.banner-error,
.banner-warning {
    border-color: rgba(180, 84, 62, 0.28);
    background: rgba(180, 84, 62, 0.08);
}

.medication-item,
.plan-item,
.medication-stat,
.toolbox-meta-card {
    background: rgba(255, 251, 244, 0.78);
    border: 1px solid var(--line);
    padding: 1rem;
}

.medication-topline,
.plan-item,
.stat-header,
.toolbox-meta-card {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}

.mini-pill,
.status-pill {
    border-radius: 999px;
    padding: 0.45rem 0.75rem;
    font-weight: 600;
}

.schedule-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.mini-pill {
    background: rgba(21, 107, 99, 0.12);
    color: var(--accent-strong);
}

.mini-pill.warn,
.status-overdue {
    background: var(--warn-soft);
    color: var(--warn);
}

.status-done {
    background: rgba(21, 107, 99, 0.12);
    color: var(--accent-strong);
}

.status-upcoming {
    background: rgba(47, 36, 24, 0.08);
    color: var(--text);
}

.plan-time {
    font-size: 1.45rem;
}

.week-row {
    display: grid;
    grid-template-columns: 6rem minmax(0, 1fr) auto;
    gap: 0.85rem;
    align-items: center;
}

.bar-track {
    height: 16px;
    background: rgba(47, 36, 24, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, #3ea296 100%);
    border-radius: inherit;
}

.bar-fill.is-over {
    background: linear-gradient(90deg, #c16b4b 0%, #d48c72 100%);
}

.stat-meter .bar-track {
    height: 12px;
}

.log-table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 0.8rem 0.55rem;
    border-bottom: 1px solid rgba(104, 81, 54, 0.12);
    vertical-align: top;
}

th {
    font-size: 0.88rem;
    color: var(--muted);
}

code {
    font-family: "Cascadia Mono", "Consolas", monospace;
}

@media (max-width: 980px) {
    .module-strip,
    .summary-grid,
    .grid-two,
    .grid-two.wide-left {
        grid-template-columns: 1fr;
    }

    .section-heading,
    .header-topline {
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    .page-header,
    .layout,
    .auth-shell {
        width: min(100% - 1rem, 1180px);
    }

    .page-header {
        padding-top: 1.2rem;
    }

    .card {
        padding: 1rem;
    }

    .grid-two-fields,
    .medication-topline,
    .plan-item,
    .stat-header,
    .toolbox-meta-card,
    .week-row {
        display: grid;
        grid-template-columns: 1fr;
    }
}
