:root {
    color-scheme: light;
    font-family: system-ui, sans-serif;
    color: #30271f;
    background: #f8f5ef;
    --muted: #62564a;
    --border: #e7ded2;
    --accent: #70502c;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: Georgia, serif; font-weight: 500; }
h1 { font-size: clamp(2.5rem, 6vw, 4rem); line-height: 1.02; letter-spacing: -.045em; }
h2 { font-size: 1.75rem; }
p { line-height: 1.55; }
img { object-fit: contain; }
.eyebrow { color: var(--accent); font-size: .76rem; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; margin-bottom: .8rem; }

.login {
    display: grid;
    grid-template-columns: 1fr 1fr;
    max-width: 930px;
    margin: max(5vh, calc((100svh - 510px) / 2)) auto;
    min-height: 510px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 22px 70px #59422913;
}

.identity { background: #efe2ce; padding: clamp(2rem, 6vw, 4.5rem); display: flex; flex-direction: column; justify-content: center; }
.identity img { mix-blend-mode: multiply; margin-bottom: 2rem; }
.sign-in { padding: clamp(2rem, 5vw, 4rem); display: grid; align-content: center; }
.sign-in form > p { color: var(--muted); margin: .5rem 0 1.75rem; }
label { display: block; font-size: .92rem; font-weight: 650; margin: 1rem 0 .45rem; }
input, button { font: inherit; border-radius: 8px; }
input { width: 100%; min-height: 46px; padding: .65rem .75rem; border: 1px solid #b7a99a; color: inherit; background: #fff; }
button { cursor: pointer; padding: .72rem 1rem; border: 1px solid var(--accent); background: var(--accent); color: white; font-weight: 650; }
button:hover { background: #52391e; }
.sign-in button { width: 100%; margin-top: 1.5rem; }
:focus-visible { outline: 3px solid #a9783e; outline-offset: 3px; }
.sign-in form > .error { color: #a02a23; font-size: .9rem; margin: .45rem 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem max(1.25rem, calc((100% - 1080px) / 2)); border-bottom: 1px solid var(--border); background: #fff; }
.brand { display: flex; align-items: center; gap: .75rem; }
.brand small { display: block; color: var(--muted); margin-top: .14rem; }
.secondary { background: #fff; color: var(--accent); }
.secondary:hover { background: #f4eada; }
.dashboard { width: min(1080px, calc(100% - 2.5rem)); margin: 2rem auto 4rem; }
.hero { padding: clamp(1.5rem, 6vw, 4rem); background: #efe2ce; border-radius: 18px; margin-bottom: 2rem; }
.section-note { color: var(--muted); margin: .4rem 0 1.2rem; }
.modules { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr)); gap: 1rem; }
.modules article { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 1.4rem; }
.modules h3 { font-size: 1.05rem; margin-bottom: .4rem; }
.modules p { color: var(--muted); }

@media (max-width: 960px) { .login { margin-inline: 1rem; } }
@media (max-width: 640px) {
    .login { grid-template-columns: 1fr; margin-block: 1rem; }
    .identity img { width: 72px; height: 72px; margin-bottom: .75rem; }
    .identity, .sign-in { padding: 1.5rem; }
}

a { color: var(--accent); }
.button { display: inline-block; padding: .72rem 1rem; border-radius: 8px; background: var(--accent); color: white; font-weight: 650; text-decoration: none; }
.button:hover { background: #52391e; }
.catalog-tile, .catalog-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; }
.catalog-tile { padding: 1.4rem; background: white; border: 1px solid var(--border); border-radius: 14px; margin-bottom: 2rem; }
.catalog-tile p { color: var(--muted); margin-top: .35rem; }
.back-link { display: inline-block; margin-bottom: 1rem; }
.catalog-heading { margin-bottom: 1.5rem; }
.catalog-search > div { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; }
.catalog-search input { width: min(100%, 320px); }
.catalog-search { margin-bottom: 1.2rem; }
.notice { padding: .75rem 1rem; margin-bottom: 1rem; border-radius: 8px; background: #e7f1e6; color: #254829; }
.table-wrap { overflow-x: auto; background: white; border: 1px solid var(--border); border-radius: 14px; }
.table-wrap table { width: 100%; min-width: 780px; border-collapse: collapse; text-align: left; }
.table-wrap th, .table-wrap td { padding: .75rem; border-bottom: 1px solid var(--border); }
.table-wrap thead th { background: #efe2ce; font-size: .9rem; }
.table-wrap tbody tr:last-child > * { border-bottom: 0; }
.table-wrap small { display: block; color: var(--muted); font-weight: 400; margin-top: .15rem; }
.catalog-pages { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; margin-top: 1rem; }
.medicine-editor { max-width: 730px; }
.medicine-form { background: white; border: 1px solid var(--border); border-radius: 14px; padding: 1.4rem; }
.medicine-form > label:first-of-type { margin-top: 0; }
.medicine-form > a { margin-left: .65rem; }
.medicine-form .error { color: #a02a23; margin-top: .35rem; }
.medicine-units { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 1rem; margin: 1.5rem 0; }
.medicine-units fieldset { min-width: 0; margin: 0; padding: .85rem; border: 1px solid var(--border); border-radius: 8px; }
.medicine-units legend { font-weight: 650; padding: 0 .35rem; }
.medicine-units label:first-of-type { margin-top: 0; }

.sale-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.sale-item { min-width: 0; margin: 1rem 0; padding: 1rem; border: 1px solid var(--border); border-radius: 8px; }
.sale-item legend { font-weight: 650; padding: 0 .35rem; }
.sale-item label:first-of-type { margin-top: 0; }
.medicine-form select { display: block; width: 100%; min-height: 46px; padding: .65rem .75rem; font: inherit; color: inherit; background: white; border: 1px solid #b7a99a; border-radius: 8px; }
.sale-item input { max-width: 10rem; }
.remove-sale-item { display: block; margin-top: .75rem; }
.remove-sale-item[hidden] { display: none; }
button:disabled { opacity: .55; cursor: default; }

.payment-methods { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.payment-methods a { padding: .5rem .8rem; border: 1px solid var(--border); border-radius: 8px; background: white; text-decoration: none; }
.payment-methods a[aria-current="page"] { border-color: var(--accent); background: #efe2ce; font-weight: 650; }
.payment-methods a:hover { border-color: var(--accent); }
.payment-actions { margin-top: 1.25rem; }

.income-filters { display: flex; flex-wrap: wrap; align-items: start; gap: 1rem; margin-bottom: 2rem; }
.income-filters > div { flex: 1 1 160px; }
.income-filters label { margin-top: 0; }
.income-filters .sale-actions { padding-top: 1.7rem; }
.income-summary .income-amount, .income-total .income-amount { color: var(--accent); font-size: 1.35rem; font-weight: 750; overflow-wrap: anywhere; }
.income-summary dl { margin: 1rem 0 0; border-top: 1px solid var(--border); padding-top: .65rem; color: var(--muted); }
.income-summary dl div { display: flex; justify-content: space-between; gap: .5rem; padding-block: .18rem; }
.income-summary dd { margin: 0; text-align: right; }
.income-total { margin-top: 1rem; background: #efe2ce; }
.income-total p { margin: 0; }
.expense-summary { margin-bottom: 1.5rem; }

.financial-recap { margin-bottom: 2rem; }
.financial-recap .income-filters { margin-bottom: 1rem; }
.financial-recap .income-summary article a { display: inline-block; margin-top: .4rem; }
.financial-recap .income-summary .negative-amount { color: #a02a23; }
.financial-recap .recap-heading { margin-bottom: .4rem; }

.sale-estimate { margin: 1rem 0; padding: .85rem 1rem; border-radius: 8px; background: #efe2ce; }
.sale-estimate output { display: inline-block; margin-left: .5rem; color: var(--accent); font-weight: 750; }
.sale-estimate .section-note { margin-bottom: 0; }

.login-home { margin-top: 1rem; justify-self: start; }
.topbar .brand { color: inherit; text-decoration: none; }
.topbar .brand:hover strong { text-decoration: underline; }
