:root {
  color-scheme: light;
  --ink: #102929;
  --muted: #536b6b;
  --primary: #086c5b;
  --primary-dark: #065244;
  --mint: #e4f5ee;
  --line: #dce8e4;
  --surface: #fff;
  --background: #f3f8f6;
  --danger: #a12639;
  --radius: 22px;
  --shadow: 0 14px 42px #183e3010;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--ink);
  font: 1rem/1.55 "Aptos", "Segoe UI", system-ui, sans-serif;
}
h1, h2, p, dl, dd { margin: 0; }
h1, h2 { line-height: 1.12; letter-spacing: -.035em; }
h1 { font-size: clamp(2rem, 4vw, 3.1rem); }
h2 { font-size: 1.35rem; }
a { color: inherit; }
nav { position: sticky; top: 0; z-index: 2; background: #fffffff5; border-bottom: 1px solid var(--line); }
nav .container, .app-container { width: min(100% - 3rem, 1170px); margin-inline: auto; }
nav .container {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .95rem;
}
.logo { display: inline-flex; align-items: center; gap: .7rem; white-space: nowrap; text-decoration: none; font-size: 1.15rem; font-weight: 750; letter-spacing: -.025em; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: white;
  background: var(--primary);
  border-radius: 11px;
  font: 600 1.6rem/1 system-ui, sans-serif;
}
.nav-links { display: flex; align-items: center; flex-wrap: wrap; gap: .2rem; }
.nav-links a { padding: .5rem .78rem; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 650; }
.nav-links a:hover, .nav-links a.active { background: var(--mint); color: var(--primary-dark); }
.nav-links a[data-page="sair"] { margin-left: .35rem; color: var(--danger); }
main { padding-block: clamp(1.5rem, 5vw, 4rem) 4rem; }
#feedback:not(:empty) { margin-bottom: 1rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: white; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1.2rem, 3vw, 2rem); box-shadow: var(--shadow); min-width: 0; }
.auth-layout { width: min(100%, 960px); margin-inline: auto; display: grid; grid-template-columns: 1.05fr 1fr; overflow: hidden; background: white; border: 1px solid var(--line); border-radius: 28px; box-shadow: 0 24px 84px #113e3220; }
.auth-intro { min-height: 430px; position: relative; isolation: isolate; overflow: hidden; padding: clamp(2rem, 5vw, 4rem); background: radial-gradient(ellipse at bottom right, #177d68, transparent 65%), #073e36; color: #f7fffb; }
.auth-intro h1, .auth-intro p { position: relative; z-index: 1; }
.auth-intro h1 { font-size: clamp(2rem, 4vw, 3.35rem); max-width: 12ch; margin-top: 1.25rem; }
.auth-intro p { color: #c4ece0; margin-top: 1.1rem; max-width: 30ch; }
.auth-mark { background: #c3f3df; color: #084c40; width: 42px; height: 42px; }
.auth-decoration { position: absolute; bottom: -90px; right: -72px; width: 290px; height: 290px; border: 1px solid #aaf2d96b; border-radius: 50%; box-shadow: 0 0 0 33px #aaf2d92b, 0 0 0 66px #aaf2d91e, 0 0 0 99px #aaf2d913; pointer-events: none; }
.auth-panel { border: 0; border-radius: 0; box-shadow: none; align-self: center; padding: clamp(1.55rem, 4vw, 3.6rem); }
.auth-panel h2 { margin-bottom: 1.5rem; font-size: 1.9rem; }
.auth-panel label { display: block; margin-bottom: 1rem; font-size: .9rem; font-weight: 650; }
.auth-panel input { margin-top: .35rem; }
.auth-actions { display: grid; gap: .65rem; margin-top: 1.35rem; }
.page-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1.5rem; }
.page-heading p { margin-top: .4rem; color: var(--muted); }
.dashboard-grid { display: grid; grid-template-columns: minmax(230px, .85fr) minmax(0, 1.65fr); gap: 1.25rem; align-items: start; }
.latest-card { color: #f3fff9; background: linear-gradient(145deg, #094e41, #086c5b); border-color: transparent; }
.latest-date { display: inline-block; margin-top: 1rem; color: #cdf4e5; font-size: .9rem; }
.latest-value { margin-top: .5rem; font-size: clamp(2.4rem, 4vw, 3.8rem); font-weight: 760; font-variant-numeric: tabular-nums; letter-spacing: -.06em; line-height: 1.05; }
.latest-value span { font-size: .95rem; letter-spacing: 0; color: #cdf4e5; }
.latest-label { margin-top: .45rem; color: #cdf4e5; }
.latest-details { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .85rem; margin-top: 1.35rem; border-top: 1px solid #d0fff752; padding-top: 1.05rem; }
.latest-details dt { color: #d6f7ec; font-size: .8rem; }
.latest-details dd { font-weight: 700; }
.stats-heading { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .5rem 1rem; margin-bottom: 1.15rem; }
.stats-heading span { color: var(--primary-dark); background: var(--mint); font-size: .82rem; font-weight: 650; padding: .25rem .65rem; border-radius: 100px; }
.metrics-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .7rem; }
.metric { background: #f4f9f7; border: 1px solid #e6efeb; border-radius: 14px; padding: .85rem; }
.metric dt { font-size: .82rem; color: var(--muted); }
.metric dd { margin-top: .25rem; font-size: 1.45rem; font-weight: 740; font-variant-numeric: tabular-nums; letter-spacing: -.035em; }
.metric dd span { color: var(--muted); font-size: .79rem; letter-spacing: 0; }
.metric p { color: var(--muted); font-size: .77rem; }
.empty-message { margin-top: .8rem; }
button, input, select, textarea { font: inherit; }
input:not([type="hidden"]), select, textarea {
  width: 100%;
  min-height: 44px;
  padding: .55rem .75rem;
  background: white;
  color: var(--ink);
  border: 1px solid #c7dad4;
  border-radius: 10px;
}
textarea { resize: vertical; }
:where(button, a, input, select, textarea):focus-visible { outline: 3px solid #168c77; outline-offset: 3px; }
.btn {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  padding: .6rem .9rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary { color: white; background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { color: var(--primary-dark); background: var(--mint); }
.btn-secondary:hover { background: #d4eee3; }
.btn-danger { color: var(--danger); background: #fff0f2; }
.btn-danger:hover { background: #f8dfe4; }
.btn-sm { min-height: 38px; padding: .3rem .55rem; font-size: .8rem; }
#measurement-card, #perfil .card { max-width: 730px; }
.measurement-form { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; align-items: start; }
.form-label { display: block; margin-bottom: .35rem; font-size: .9rem; font-weight: 650; }
#field-glucose { margin-top: .4rem; }
.full-width { grid-column: 1 / -1; }
.history-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.history-toolbar select { width: auto; max-width: 100%; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: .75rem; border-bottom: 1px solid var(--line); text-align: left; }
th { background: var(--mint); color: var(--primary-dark); font-size: .81rem; white-space: nowrap; }
td:last-child { white-space: nowrap; }
td:last-child .btn + .btn { margin-left: .25rem; }
tbody tr:hover td { background: #f7fbf9; }
.profile-details { display: grid; gap: 1rem; overflow-wrap: anywhere; }
.profile-details dt { color: var(--muted); font-size: .85rem; }
.profile-details dd { font-size: 1.05rem; font-weight: 650; }
@media (max-width: 720px) {
  nav .container, .app-container { width: calc(100% - 2rem); }
  nav .container { flex-direction: column; align-items: flex-start; justify-content: center; gap: .35rem; padding-block: .62rem; }
  .nav-links { gap: .15rem; }
  .nav-links a { padding: .45rem .5rem; }
  .nav-links a[data-page="sair"] { margin-left: 0; }
  .auth-layout, .dashboard-grid { grid-template-columns: 1fr; }
  .auth-intro { min-height: 0; padding: 1.5rem; }
  .auth-intro h1 { font-size: 2rem; }
  .auth-intro p { margin-top: .6rem; }
  .auth-mark { display: none; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: .7rem; }
}
@media (max-width: 420px) {
  .page-heading { align-items: flex-start; flex-direction: column; }
  .measurement-form { grid-template-columns: 1fr; }
  .history-card { padding: 1rem; }
}

.measurement-time { padding-bottom: .85rem; border-bottom: 1px solid var(--line); }
.measurement-time input { width: min(100%, 24rem); }
.measurement-alert { color: var(--danger); font-size: .84rem; font-weight: 700; margin-top: .35rem; }
.measurement-alert:empty { margin: 0; }
#measurement-form input.has-alert { border-color: var(--danger); color: var(--danger); background: #fff4f5; }
.measurement-references { border-top: 1px solid var(--line); padding-top: .8rem; font-size: .88rem; color: var(--muted); }
.measurement-references summary { color: var(--primary-dark); cursor: pointer; font-weight: 700; }
.measurement-references p { margin-top: .5rem; }
.measurement-references ul { padding-left: 1.2rem; }
.measurement-references li + li { margin-top: .35rem; }
