:root {
  color-scheme: light;
  --ink: oklch(22% 0.025 145);
  --forest: oklch(24% 0.06 145);
  --forest-2: oklch(31% 0.065 145);
  --lime: oklch(86% 0.2 126);
  --paper: oklch(97% 0.009 115);
  --surface: oklch(99% 0.004 115);
  --muted: oklch(58% 0.025 145);
  --line: oklch(88% 0.015 130);
  --danger: oklch(52% 0.18 28);
  --warm: oklch(90% 0.1 85);
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--lime); color: var(--ink); padding: 12px 16px; }
.skip-link:focus { top: 12px; }
.eyebrow { margin: 0 0 var(--space-sm); color: var(--muted); font: 700 0.72rem/1.2 "Bahnschrift", "Trebuchet MS", sans-serif; letter-spacing: .14em; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, .brand-mark { font-family: "Bahnschrift", "Arial Narrow", sans-serif; letter-spacing: -.025em; }
h1 { font-size: clamp(1.75rem, 4vw, 2.7rem); line-height: 1.05; margin-bottom: var(--space-sm); }
h2 { font-size: 1.45rem; line-height: 1.1; margin-bottom: var(--space-sm); }
h3 { font-size: 1.05rem; margin-bottom: var(--space-xs); }

.login-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, .9fr) minmax(420px, 1.1fr); }
.login-brand { min-height: 100%; padding: clamp(32px, 7vw, 96px); color: var(--paper); background: var(--forest); display: flex; flex-direction: column; justify-content: space-between; }
.login-brand::after { content: ""; display: block; width: min(34vw, 440px); aspect-ratio: 1; border: 1px solid color-mix(in oklch, var(--lime) 55%, transparent); border-radius: 50%; transform: translate(-24%, 12%); }
.brand-mark { color: var(--lime); font-size: clamp(3rem, 8vw, 7rem); font-weight: 800; }
.login-brand p { max-width: 24ch; font-size: 1.25rem; line-height: 1.45; }
.login-panel { background: var(--surface); display: flex; flex-direction: column; justify-content: center; padding: clamp(32px, 9vw, 120px); }
.login-copy { max-width: 46ch; color: var(--muted); margin-bottom: var(--space-2xl); line-height: 1.55; }
.form-stack { display: grid; gap: var(--space-lg); max-width: 440px; }
label { display: grid; gap: var(--space-sm); font-weight: 700; font-size: .88rem; }
input, select, textarea { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); padding: 12px 14px; outline: none; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--forest-2); box-shadow: 0 0 0 3px color-mix(in oklch, var(--lime) 35%, transparent); }
.form-error { min-height: 1.25rem; margin: 0; color: var(--danger); font-weight: 700; font-size: .88rem; }
.helper-copy { color: var(--muted); line-height: 1.55; max-width: 58ch; margin-bottom: var(--space-xl); }
.field-hint { color: var(--muted); line-height: 1.45; }
.secure-note { color: var(--muted); font-size: .8rem; margin: var(--space-xl) 0 0; }

.button, .icon-button, .text-button { border: 0; min-height: 44px; font-weight: 800; }
.button { padding: 11px 18px; border-radius: var(--radius-sm); }
.button.primary { color: var(--paper); background: var(--forest); }
.button.accent { color: var(--ink); background: var(--lime); }
.button.secondary { color: var(--forest); background: color-mix(in oklch, var(--lime) 24%, var(--surface)); border: 1px solid color-mix(in oklch, var(--forest) 18%, var(--line)); }
.button.ghost { color: var(--forest); background: transparent; border: 1px solid var(--line); }
.button:disabled { opacity: .55; cursor: wait; }
.icon-button { width: 44px; padding: 0; border-radius: 50%; background: var(--forest); color: var(--paper); font-size: 1.25rem; }
.text-button { background: transparent; color: var(--forest-2); text-decoration: underline; text-underline-offset: 5px; padding: 0 var(--space-sm); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px 1fr; grid-template-rows: auto 1fr; }
.side-nav { grid-row: 1 / -1; position: sticky; top: 0; height: 100vh; padding: var(--space-xl); background: var(--forest); color: var(--paper); display: flex; flex-direction: column; }
.side-brand { display: flex; align-items: baseline; gap: var(--space-sm); margin-bottom: var(--space-3xl); }
.side-brand strong { color: var(--lime); font: 800 2rem/1 "Bahnschrift", sans-serif; }
.side-brand span { color: color-mix(in oklch, var(--paper) 70%, transparent); letter-spacing: .16em; font-size: .72rem; }
.side-nav nav { display: grid; gap: var(--space-sm); }
.nav-button { min-height: 48px; border: 0; background: transparent; color: color-mix(in oklch, var(--paper) 70%, transparent); text-align: left; padding: 0 14px; border-radius: var(--radius-sm); font-weight: 700; }
.nav-button[aria-current="page"] { color: var(--ink); background: var(--lime); }
.side-user { margin-top: auto; padding-top: var(--space-xl); border-top: 1px solid color-mix(in oklch, var(--paper) 16%, transparent); display: flex; align-items: center; gap: var(--space-md); }
.side-user > span { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: var(--ink); background: var(--paper); font-weight: 800; }
.side-user div { min-width: 0; display: grid; }
.side-user small { color: color-mix(in oklch, var(--paper) 62%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar { grid-column: 2; min-height: 112px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-xl); padding: var(--space-xl) clamp(24px, 5vw, 72px); background: color-mix(in oklch, var(--paper) 94%, transparent); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.35rem); }
.top-actions { display: flex; align-items: center; gap: var(--space-sm); }
main { grid-column: 2; width: 100%; max-width: 1440px; margin: 0 auto; padding: clamp(24px, 4vw, 56px) clamp(20px, 5vw, 72px) 96px; }
.view { animation: view-in .26s cubic-bezier(.2,.8,.2,1); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view { animation: none; } }

.action-banner { position: relative; overflow: hidden; min-height: 220px; background: var(--forest); color: var(--paper); padding: clamp(24px, 5vw, 56px); display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-2xl); border-radius: var(--radius-lg); }
.action-banner::after { content: ""; position: absolute; width: 260px; height: 260px; right: 16%; top: -58%; border-radius: 50%; border: 52px solid color-mix(in oklch, var(--lime) 25%, transparent); }
.action-banner > * { position: relative; z-index: 1; }
.action-banner .eyebrow { color: var(--lime); }
.action-banner h2 { font-size: clamp(1.8rem, 4vw, 3.4rem); max-width: 14ch; }
.action-banner p:not(.eyebrow) { color: color-mix(in oklch, var(--paper) 72%, transparent); max-width: 48ch; margin-bottom: 0; }
.metric-line { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); margin: var(--space-2xl) 0 var(--space-3xl); }
.metric { padding: var(--space-xl) 0; }
.metric + .metric { padding-left: var(--space-xl); border-left: 1px solid var(--line); }
.metric strong { display: block; font: 800 2rem/1 "Bahnschrift", sans-serif; }
.metric span { display: block; color: var(--muted); font-size: .82rem; margin-top: var(--space-sm); }
.split-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .7fr); gap: clamp(24px, 5vw, 64px); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: var(--space-lg); margin-bottom: var(--space-xl); }
.section-heading.wide { padding-bottom: var(--space-xl); border-bottom: 1px solid var(--line); }
.section-heading h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.15rem); }
.work-list, .data-list { display: grid; gap: var(--space-sm); }
.work-item, .data-item { display: grid; gap: var(--space-md); padding: 18px 0; border-bottom: 1px solid var(--line); }
.work-item { grid-template-columns: 100px minmax(0, 1fr) auto; align-items: center; }
.status-chip { justify-self: start; display: inline-flex; align-items: center; min-height: 28px; padding: 4px 9px; border-radius: 999px; color: var(--forest); background: color-mix(in oklch, var(--lime) 28%, var(--paper)); font-size: .74rem; font-weight: 800; }
.status-chip[data-status="Frio"], .status-chip[data-status="Sem status"] { background: color-mix(in oklch, var(--line) 65%, var(--paper)); }
.status-chip[data-status="Morno"] { background: var(--warm); }
.status-chip[data-status="V. Perdida"] { color: var(--danger); background: color-mix(in oklch, var(--danger) 10%, var(--paper)); }
.item-main { min-width: 0; }
.item-main h3 { overflow: hidden; text-overflow: ellipsis; }
.item-main p { color: var(--muted); margin: 0; line-height: 1.4; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: .8rem; }
.date-badge { min-width: 76px; font-weight: 800; color: var(--forest-2); text-align: right; }
.week-panel { align-self: start; color: var(--paper); background: var(--forest-2); padding: var(--space-2xl); border-radius: var(--radius-md); }
.week-panel .eyebrow { color: var(--lime); }
.week-panel-stat { display: flex; justify-content: space-between; gap: var(--space-lg); padding: 16px 0; border-bottom: 1px solid color-mix(in oklch, var(--paper) 15%, transparent); }
.week-panel-stat strong { font: 800 1.5rem/1 "Bahnschrift", sans-serif; }
.empty-state { padding: var(--space-3xl) 0; color: var(--muted); max-width: 52ch; }

.filter-row { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(160px, 240px); gap: var(--space-lg); margin-bottom: var(--space-xl); }
.search-field input { background: var(--surface); }
.data-item { grid-template-columns: minmax(0, 1fr) auto; padding: 20px 4px; }
.data-item-actions { display: flex; align-items: center; gap: var(--space-sm); }
.data-item details { grid-column: 1 / -1; }
.data-item summary { cursor: pointer; color: var(--forest-2); font-weight: 800; min-height: 44px; display: flex; align-items: center; }
.detail-body { display: grid; gap: var(--space-lg); padding: var(--space-lg) 0; }
.detail-body p { margin: 0; line-height: 1.55; max-width: 80ch; }
.quick-edit { display: grid; grid-template-columns: minmax(140px, 220px) minmax(160px, 220px) auto; gap: var(--space-md); align-items: end; }

.entry-view { max-width: 880px; }
.entry-form { display: grid; gap: var(--space-xl); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); }
.attachment-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); }
.attachment-control { min-height: 142px; padding: var(--space-xl); border: 1px dashed color-mix(in oklch, var(--forest) 30%, var(--line)); border-radius: var(--radius-md); background: color-mix(in oklch, var(--lime) 7%, var(--surface)); align-content: center; }
.attachment-control small { color: var(--muted); font-weight: 400; }
.attachment-control input { border: 0; padding: 8px 0 0; min-height: auto; background: transparent; }
.audio-control { display: grid; gap: var(--space-sm); }
.audio-control .button { justify-self: start; }
.form-actions { display: flex; justify-content: flex-end; padding-top: var(--space-lg); border-top: 1px solid var(--line); }
.form-actions .button { min-width: 180px; }
.bottom-nav { display: none; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; color: var(--paper); background: var(--forest); border-radius: var(--radius-sm); padding: 14px 18px; transform: translateY(140%); transition: transform .25s cubic-bezier(.2,.8,.2,1); }
.toast.visible { transform: none; }

@media (min-width: 681px) and (max-width: 1020px) {
  .app-shell { grid-template-columns: 188px 1fr; }
  .side-nav { padding: 28px 16px 24px; }
  .side-brand { margin-bottom: var(--space-2xl); }
  .side-user { gap: var(--space-sm); }
  .topbar { padding: 20px 28px; }
  main { padding-left: 28px; padding-right: 28px; }
}

@media (max-width: 680px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-brand { min-height: 250px; padding: 32px; }
  .login-brand::after { position: absolute; width: 190px; right: 4%; top: -36px; transform: none; }
  .login-brand p { margin: 0; }
  .login-panel { padding: 40px 28px 56px; }
  .app-shell { display: block; }
  .side-nav { display: none; }
  .topbar { position: sticky; top: 0; z-index: 20; min-height: 86px; padding: 16px 20px; }
  .topbar .eyebrow { margin-bottom: 4px; }
  .topbar h1 { font-size: 1.45rem; }
  .top-actions #install-button { display: none; }
  .password-button { min-width: 44px; width: 44px; overflow: hidden; color: transparent !important; position: relative; padding: 0; }
  .password-button::after { content: "Senha"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--forest); font-size: .68rem; }
  main { padding: 24px 18px calc(100px + env(safe-area-inset-bottom)); }
  .action-banner { min-height: 260px; align-items: stretch; flex-direction: column; justify-content: space-between; padding: 28px 24px; }
  .action-banner::after { width: 200px; height: 200px; right: -50px; top: -70px; border-width: 38px; }
  .action-banner h2 { font-size: 2.25rem; }
  .action-banner .button { align-self: stretch; }
  .metric-line { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(3) { border-left: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
  .split-layout { grid-template-columns: 1fr; }
  .work-item { grid-template-columns: 80px minmax(0, 1fr); }
  .work-item .date-badge { grid-column: 2; justify-self: start; text-align: left; }
  .bottom-nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
  .bottom-nav .nav-button { display: grid; place-items: center; min-height: 52px; padding: 4px; text-align: center; color: var(--muted); font-size: .7rem; }
  .bottom-nav .nav-button[aria-current="page"] { color: var(--forest); background: color-mix(in oklch, var(--lime) 30%, var(--surface)); }
  .filter-row, .form-grid, .attachment-grid { grid-template-columns: 1fr; }
  .data-item { grid-template-columns: 1fr; }
  .data-item-actions { justify-content: space-between; }
  .quick-edit { grid-template-columns: 1fr 1fr; }
  .quick-edit .button { grid-column: 1 / -1; }
  .toast { left: 18px; right: 18px; bottom: calc(82px + env(safe-area-inset-bottom)); text-align: center; }
}

@media (max-width: 420px) {
  .metric strong { font-size: 1.7rem; }
  .metric + .metric { padding-left: 14px; }
  .section-heading { align-items: start; }
  .section-heading.wide { flex-direction: column; }
  .section-heading.wide .button { width: 100%; }
  .quick-edit { grid-template-columns: 1fr; }
  .quick-edit .button { grid-column: auto; }
}
