:root {
    --bg: #e8eef2;
    --surface: #ffffff;
    --ink: #1a2332;
    --muted: #5a6a7a;
    --line: #c5d0db;
    --accent: #0d6e6e;
    --accent-dark: #0a5555;
    --danger: #9b2c2c;
    --radius: 10px;
    --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(ellipse at top left, #d4e4ea 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, #cfe0d8 0%, transparent 45%),
        var(--bg);
    min-height: 100vh;
}

.page {
    max-width: 820px;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
}

.page-header {
    margin-bottom: 1.75rem;
}

.page-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.page-header h1 {
    margin: 0 0 0.35rem;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-header p {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

a.btn {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.btn-ghost-muted {
    border-color: var(--line);
    color: var(--muted);
}

.btn-ghost-muted:hover {
    background: #f4f7f8;
    color: var(--ink);
}

.form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    box-shadow: 0 1px 2px rgba(26, 35, 50, 0.04);
}

.card h2 {
    margin: 0 0 1rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-head h2 {
    margin: 0;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem 1rem;
}

.grid-crm {
    display: grid;
    grid-template-columns: 1fr 70px;
    gap: 0.85rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

label.full {
    grid-column: 1 / -1;
}

label span {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="date"],
select {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
    font-size: 0.95rem;
    color: var(--ink);
    background: #fafbfc;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.15);
    background: #fff;
}

#medicamentos-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.med-row {
    display: grid;
    grid-template-columns: 28px 1fr 32px;
    gap: 0.6rem;
    align-items: start;
    padding: 0.85rem;
    background: #f4f7f8;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.med-num {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 50%;
    margin-top: 1.45rem;
}

.med-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem 0.85rem;
}

.btn-remove {
    margin-top: 1.45rem;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--danger);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
}

.btn-remove:hover {
    background: #fde8e8;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 0.5rem;
}

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.65rem 1.15rem;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-dark);
}

.btn-secondary {
    background: #fff;
    border-color: var(--line);
    color: var(--ink);
}

.btn-secondary:hover {
    background: #f4f7f8;
}

.btn-ghost {
    background: transparent;
    border-color: var(--accent);
    color: var(--accent);
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
}

.btn-ghost:hover {
    background: rgba(13, 110, 110, 0.08);
}

.carimbo-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: #f4f7f8;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.carimbo-preview.full {
    grid-column: 1 / -1;
}

.carimbo-preview img {
    max-height: 70px;
    max-width: 160px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 4px;
}

.check-remover {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.check-remover input {
    width: auto;
}

.page-login {
    max-width: 420px;
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding-top: 0;
    padding-bottom: 0;
}

.login-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.login-card h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-sub {
    margin: -0.35rem 0 0.25rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.login-erro {
    margin: 0;
    padding: 0.65rem 0.75rem;
    border-radius: 6px;
    background: #fde8e8;
    color: var(--danger);
    font-size: 0.9rem;
}

.btn-login {
    width: 100%;
    margin-top: 0.35rem;
    justify-content: center;
}

@media (max-width: 640px) {
    .grid-2,
    .med-fields,
    .grid-crm {
        grid-template-columns: 1fr;
    }

    .actions {
        flex-direction: column-reverse;
    }

    .btn {
        width: 100%;
        text-align: center;
    }
}
