@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Work+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ---------------------------------------------------------------------------
   Tokens
--------------------------------------------------------------------------- */
:root{
  --ink: #213330;
  --ink-soft: #4B5D58;
  --paper: #EEF3EF;
  --surface: #FFFFFF;
  --surface-sunken: #E6EDE7;
  --line: #D9E2DC;
  --line-strong: #C2CFC7;

  --pine: #3D6B5C;
  --pine-dark: #2B4F44;
  --pine-tint: #E1ECE6;

  --clay: #D98C4A;
  --clay-dark: #B16E32;
  --clay-tint: #F6E6D4;

  --teal: #3E7C8C;
  --teal-dark: #2D5C69;
  --teal-tint: #DDEAEE;

  --brick: #C1473A;
  --brick-tint: #F6DEDA;

  --gold: #C99A2E;
  --gold-tint: #F5EAC8;

  --font-display: 'Fraunces', 'Iowan Old Style', serif;
  --font-body: 'Work Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --shadow-sm: 0 1px 2px rgba(33,51,48,0.06), 0 1px 1px rgba(33,51,48,0.04);
  --shadow-md: 0 8px 24px rgba(33,51,48,0.10);
  --shadow-lg: 0 24px 48px rgba(33,51,48,0.18);
}

*{ box-sizing: border-box; }
[hidden]{ display:none !important; }
html,body{ margin:0; padding:0; }
body{
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4{ font-family: var(--font-display); margin:0; color: var(--ink); }
p{ margin:0; }
a{ color: var(--pine-dark); }
button{ font-family: inherit; }
::selection{ background: var(--clay-tint); }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.skip-link{
  position:absolute; left:-999px; top:0; background:var(--ink); color:#fff; padding:8px 16px; z-index:999;
}
.skip-link:focus{ left:8px; top:8px; border-radius: var(--radius-sm); }

:focus-visible{ outline: 2px solid var(--clay); outline-offset: 2px; }

/* ---------------------------------------------------------------------------
   Login
--------------------------------------------------------------------------- */
.login-body{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  background: var(--ink);
  padding: 24px;
}

.login-shell{
  width:100%;
  max-width: 1040px;
  display:grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow:hidden;
  box-shadow: var(--shadow-lg);
}

.login-art{
  position:relative;
  background: radial-gradient(120% 120% at 15% 15%, #335B4F 0%, #233C34 55%, #1A2C26 100%);
  color: #F2F6F3;
  padding: 56px 48px;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  min-height: 560px;
  overflow:hidden;
}

.rhythm-mark{
  position:absolute;
  top: -60px;
  right: -60px;
  width: 320px;
  height: 320px;
  opacity: 0.9;
}
.rhythm-mark svg{ width:100%; height:100%; }
.ring{ fill:none; stroke: rgba(247,244,238,0.22); stroke-width: 1; }
.ring-2{ stroke: rgba(247,244,238,0.32); }
.ring-3{ stroke: rgba(217,140,74,0.55); stroke-width: 1.4; }
.ring-dot{ fill: #D98C4A; }
.orbit-dot{
  fill: #F7F4EE;
  transform-origin: 100px 100px;
  animation: orbit 14s linear infinite;
}
@keyframes orbit{ from{ transform: rotate(0deg); } to{ transform: rotate(360deg); } }

.login-eyebrow{
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #BFD6CC;
  margin-bottom: 18px;
}
.login-headline{
  font-size: 40px;
  line-height: 1.12;
  font-weight: 600;
  margin-bottom: 18px;
  max-width: 360px;
  color: #F2F6F3;
}
.login-sub{
  font-size: 15px;
  line-height: 1.6;
  color: #CFE0D8;
  max-width: 360px;
}

.login-panel{
  padding: 56px 48px;
  display:flex;
  flex-direction:column;
  gap: 32px;
  justify-content:center;
}

.login-form{ display:flex; flex-direction:column; gap: 16px; }
.login-form-eyebrow{
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.login-form-title{ font-size: 26px; margin-bottom: 4px; }

.field{ display:flex; flex-direction:column; gap:6px; }
.field-label{ font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea{
  font-family: var(--font-body);
  font-size: 15px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus{
  outline:none;
  border-color: var(--pine);
  box-shadow: 0 0 0 3px var(--pine-tint);
}

.login-error{
  font-size: 13.5px;
  color: var(--brick);
  background: var(--brick-tint);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.btn{
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14.5px;
  padding: 12px 20px;
  border-radius: 999px;
  border: none;
  cursor:pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
}
.btn:active{ transform: translateY(1px); }
.btn-primary{ background: var(--pine); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover{ background: var(--pine-dark); }
.btn-block{ width:100%; }

.btn-ghost{
  background: transparent;
  border: 1.5px solid var(--line-strong);
  color: var(--ink);
  font-weight: 600;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 999px;
  cursor:pointer;
}
.btn-ghost:hover{ background: var(--surface-sunken); }

.btn-sm{ padding: 7px 13px; font-size: 13px; }
.btn-danger{ background: var(--brick); color:#fff; }
.btn-danger:hover{ filter: brightness(0.92); }

.demo-users{ display:flex; flex-direction:column; gap:10px; }
.demo-title{ font-size: 12.5px; font-weight:600; color: var(--ink-soft); margin-bottom: 2px; }
.demo-chip{
  display:flex; align-items:center; gap: 4px; flex-wrap: wrap;
  width:100%; text-align:left; cursor:pointer;
  border: 1.5px solid var(--line);
  border-left: 4px solid var(--pine);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: var(--font-body);
}
.demo-chip--funcionario{ border-left-color: var(--teal); }
.demo-chip--responsavel{ border-left-color: var(--clay); }
.demo-chip:hover{ background: var(--surface-sunken); }
.demo-chip-role{ font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); width: 100%; }
.demo-chip-name{ font-size: 14.5px; font-weight: 600; }
.demo-chip-cred{ font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); margin-left:auto; }

@media (max-width: 860px){
  .login-shell{ grid-template-columns: 1fr; }
  .login-art{ min-height: 240px; padding: 32px; }
  .login-headline{ font-size: 28px; }
}

/* ---------------------------------------------------------------------------
   App shell
--------------------------------------------------------------------------- */
.app-body{ min-height:100vh; }
.shell{ display:flex; min-height:100vh; }

.sidebar{
  width: 252px;
  flex-shrink:0;
  background: linear-gradient(180deg, #233C34 0%, #1B2E27 100%);
  color: #ECF3EF;
  display:flex;
  flex-direction:column;
  padding: 22px 16px;
  position: sticky;
  top:0;
  height: 100vh;
}
.sidebar-brand{ display:flex; align-items:center; gap:10px; padding: 6px 8px 22px; }
.brand-mark svg{ width: 30px; height:30px; }
.brand-ring{ fill:none; stroke: rgba(247,244,238,0.5); stroke-width: 1.6; }
.brand-ring-2{ fill:none; stroke: #D98C4A; stroke-width: 1.6; }
.brand-dot{ fill:#F7F4EE; }
.brand-name{ font-family: var(--font-display); font-size: 20px; font-weight:600; color:#F7F4EE; }
.brand-name strong{ color: var(--clay); }

.sidebar-nav{ display:flex; flex-direction:column; gap:3px; flex:1; overflow-y:auto; }
.nav-section-label{
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: #93A89E; padding: 16px 12px 6px;
}
.nav-link{
  display:flex; align-items:center; gap:11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #D9E5DF;
  text-decoration:none;
  font-size: 14.5px;
  font-weight: 500;
  cursor:pointer;
  border:none;
  background:transparent;
  width:100%;
  text-align:left;
}
.nav-link svg{ width:18px; height:18px; flex-shrink:0; stroke: currentColor; fill:none; stroke-width:1.8; }
.nav-link:hover{ background: rgba(255,255,255,0.06); color:#fff; }
.nav-link.active{ background: rgba(217,140,74,0.18); color:#fff; box-shadow: inset 3px 0 0 var(--clay); }

.sidebar-footer{ padding-top: 14px; }
.sidebar-footer .btn-ghost{ color:#D9E5DF; border-color: rgba(255,255,255,0.22); }
.sidebar-footer .btn-ghost:hover{ background: rgba(255,255,255,0.08); }

.main-col{ flex:1; min-width:0; display:flex; flex-direction:column; }

.topbar{
  display:flex; align-items:center; gap: 16px;
  padding: 18px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top:0; z-index: 20;
}
.sidebar-toggle{ display:none; }
.topbar-title{ flex:1; min-width:0; }
.topbar-eyebrow{ font-family: var(--font-mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-soft); }
.topbar-heading{ font-size: 24px; }

.topbar-actions{ display:flex; align-items:center; gap: 14px; }

.icon-btn{
  width: 38px; height:38px; border-radius:999px; border:1.5px solid var(--line);
  background: var(--surface); display:flex; align-items:center; justify-content:center;
  cursor:pointer; position:relative;
}
.icon-btn svg{ width:19px; height:19px; fill:none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }
.icon-btn:hover{ background: var(--surface-sunken); }

.bell-badge{
  position:absolute; top:-4px; right:-4px;
  background: var(--brick); color:#fff;
  font-size: 10.5px; font-weight:700; font-family: var(--font-mono);
  min-width: 17px; height:17px; border-radius:999px;
  display:flex; align-items:center; justify-content:center;
  padding: 0 3px;
}

.user-chip{ display:flex; align-items:center; gap:10px; padding-left: 6px; border-left: 1px solid var(--line); }
.user-avatar{
  width:36px; height:36px; border-radius:999px; background: var(--pine-tint); color: var(--pine-dark);
  display:flex; align-items:center; justify-content:center; font-weight:700; font-size:13px;
}
.user-meta{ display:flex; flex-direction:column; line-height:1.25; }
.user-name{ font-size: 13.5px; font-weight:600; }
.user-role{ font-size: 11.5px; color: var(--ink-soft); }

.main-content{ padding: 28px 32px 60px; flex:1; }

/* role accent on user avatar */
.role-admin .user-avatar{ background: var(--pine-tint); color: var(--pine-dark); }
.role-funcionario .user-avatar{ background: var(--teal-tint); color: var(--teal-dark); }
.role-responsavel .user-avatar{ background: var(--clay-tint); color: var(--clay-dark); }

/* ---------------------------------------------------------------------------
   Page composition helpers
--------------------------------------------------------------------------- */
.page-head{ display:flex; align-items:flex-end; justify-content:space-between; gap: 16px; margin-bottom: 22px; flex-wrap:wrap; }
.page-lede{ color: var(--ink-soft); font-size: 14.5px; margin-top:4px; max-width: 560px; }

.kpi-row{ display:grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card{
  background: var(--surface); border:1px solid var(--line); border-radius: var(--radius-md);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
  min-width: 0; container-type: inline-size;
}
.kpi-label{ font-family: var(--font-mono); font-size: 11.5px; text-transform: uppercase; letter-spacing:0.05em; color: var(--ink-soft); }
.kpi-value{ font-family: var(--font-display); font-size: 30px; font-weight:600; margin-top:6px; overflow-wrap: anywhere; }
.kpi-sub{ font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }

/* Coluna estreita demais pro valor em font-size 30px (acontece tanto em telas
   pequenas quanto em telas largas com a sidebar expandida, ex.: tablets ~900px de
   largura) — encolhe a fonte pela largura real do card, não do viewport. */
@container (max-width: 220px){
  .kpi-value{ font-size: 22px; }
}

@media (max-width: 480px){
  .kpi-row{ grid-template-columns: 1fr; }
}

.card{
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 22px 24px; box-shadow: var(--shadow-sm); margin-bottom: 22px;
}
.card-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:16px; flex-wrap:wrap; }
.card-title{ font-size: 17px; }
.card-title-sub{ font-size: 12.5px; color: var(--ink-soft); margin-top:2px; }

.section-grid{ display:grid; gap:22px; }
.grid-2{ grid-template-columns: 1.4fr 1fr; }
@media (max-width: 980px){ .grid-2{ grid-template-columns: 1fr; } }

/* Rhythm strip — signature element: a 24h timeline of the day's care events */
.rhythm-strip{ position:relative; padding: 28px 6px 10px; }
.rhythm-line{ position:relative; height: 3px; background: var(--line-strong); border-radius:2px; }
.rhythm-now{
  position:absolute; top:-7px; width:2px; height:17px; background: var(--brick);
}
.rhythm-now::after{
  content:''; position:absolute; top:-5px; left:-4px; width:10px; height:10px; border-radius:999px;
  background: var(--brick); box-shadow: 0 0 0 4px rgba(193,71,58,0.18);
}
.rhythm-event{
  position:absolute; top:-6px; width: 14px; height:14px; border-radius:999px; transform: translateX(-50%);
  border: 2px solid var(--surface); cursor:default;
}
.rhythm-event[data-tipo="Tarefa"]{ background: var(--clay); }
.rhythm-event[data-tipo="Urgência"]{ background: var(--brick); }
.rhythm-event[data-tipo="Informativo"]{ background: var(--teal); }
.rhythm-labels{ display:flex; justify-content:space-between; margin-top:10px; font-family: var(--font-mono); font-size:11px; color: var(--ink-soft); }
.rhythm-legend{ display:flex; gap:16px; margin-top: 14px; flex-wrap:wrap; }
.rhythm-legend-item{ display:flex; align-items:center; gap:6px; font-size:12.5px; color: var(--ink-soft); }
.rhythm-legend-dot{ width:9px; height:9px; border-radius:999px; }

/* Tables */
.table-wrap{ overflow-x:auto; }
table.data-table{ width:100%; border-collapse: collapse; font-size: 14px; }
.data-table th{
  text-align:left; font-size: 11.5px; text-transform:uppercase; letter-spacing:0.04em;
  color: var(--ink-soft); padding: 10px 14px; border-bottom: 1.5px solid var(--line-strong); white-space:nowrap;
}
.data-table td{ padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:hover{ background: var(--surface-sunken); }
.data-table .num, .mono{ font-family: var(--font-mono); }
.row-actions{ display:flex; gap:8px; justify-content:flex-end; }

.empty-state{
  text-align:center; padding: 48px 24px; color: var(--ink-soft);
}
.empty-state h3{ color: var(--ink); margin-bottom:6px; font-size:16px; }

/* Badges */
.badge{
  display:inline-flex; align-items:center; gap:5px; font-size: 12px; font-weight:600;
  padding: 4px 10px; border-radius: 999px; white-space:nowrap;
}
.badge-green{ background: var(--pine-tint); color: var(--pine-dark); }
.badge-clay{ background: var(--clay-tint); color: var(--clay-dark); }
.badge-teal{ background: var(--teal-tint); color: var(--teal-dark); }
.badge-brick{ background: var(--brick-tint); color: var(--brick); }
.badge-gold{ background: var(--gold-tint); color: var(--gold); }
.badge-dim{ background: var(--surface-sunken); color: var(--ink-soft); }
.badge-dot{ width:6px; height:6px; border-radius:999px; background: currentColor; }

/* Forms inside modals */
.form-grid{ display:grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .field-full{ grid-column: 1 / -1; }
@media (max-width: 600px){ .form-grid{ grid-template-columns: 1fr; } }

.checkrow{ display:flex; align-items:center; gap:9px; padding: 9px 0; }
.checkrow input{ width:17px; height:17px; accent-color: var(--pine); }

.repeatable-list{ display:flex; flex-direction:column; gap:10px; }
.repeatable-item{
  display:grid; grid-template-columns: 1fr 1fr 1fr auto; gap:8px; align-items:center;
  background: var(--surface-sunken); padding: 10px; border-radius: var(--radius-sm);
}
@media (max-width: 700px){ .repeatable-item{ grid-template-columns: 1fr; } }

.modal-form-actions{ display:flex; justify-content:flex-end; gap:10px; margin-top: 20px; padding-top:16px; border-top:1px solid var(--line); }

/* Toolbar above tables */
.toolbar{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:16px; }
.toolbar input[type="search"], .toolbar select{
  font-family: var(--font-body); font-size:13.5px; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line-strong); background: var(--surface);
}
.toolbar input[type="search"]:focus, .toolbar select:focus{ outline:none; border-color: var(--pine); }
.toolbar-spacer{ flex:1; }

/* Tabs (used for dashboard scoping) */
.tabs{ display:flex; gap:6px; border-bottom: 1.5px solid var(--line); margin-bottom: 18px; }
.tab-btn{
  background:none; border:none; cursor:pointer; padding: 10px 4px; font-size: 14px; font-weight:600;
  color: var(--ink-soft); border-bottom: 2.5px solid transparent; margin-bottom:-1.5px;
}
.tab-btn.active{ color: var(--pine-dark); border-bottom-color: var(--pine); }

/* Schedule grid */
.escala-table th, .escala-table td{ text-align:center; }
.escala-cell{ font-size:12px; padding: 6px; border-radius: 6px; }

/* Modal */
.modal-overlay{
  position:fixed; inset:0; background: rgba(33,51,48,0.45); backdrop-filter: blur(2px);
  display:flex; align-items:center; justify-content:center; padding: 24px; z-index:100;
}
.modal{
  background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 640px;
  max-height: 88vh; overflow-y:auto; box-shadow: var(--shadow-lg);
}
.modal-head{
  display:flex; align-items:center; justify-content:space-between; padding: 20px 24px;
  border-bottom: 1px solid var(--line); position:sticky; top:0; background:var(--surface);
}
.modal-body{ padding: 24px; }

/* Notification drawer */
.notif-overlay{ position:fixed; inset:0; background: rgba(33,51,48,0.35); z-index: 90; }
.notif-drawer{
  position:fixed; top:0; right:-420px; width: 400px; max-width: 92vw; height:100vh;
  background: var(--surface); box-shadow: var(--shadow-lg); z-index: 95; transition: right .22s ease;
  display:flex; flex-direction:column;
}
.notif-drawer.open{ right:0; }
.notif-drawer-head{ display:flex; align-items:center; justify-content:space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.notif-drawer-list{ overflow-y:auto; padding: 8px 14px; flex:1; }

.notif-item{ padding: 14px 10px; border-bottom: 1px solid var(--line); display:flex; gap:12px; }
.notif-item.unread{ background: var(--pine-tint); border-radius: var(--radius-sm); }
.notif-item-dot{ width:9px; height:9px; border-radius:999px; flex-shrink:0; margin-top:6px; }
.notif-item-dot[data-tipo="Tarefa"]{ background: var(--clay); }
.notif-item-dot[data-tipo="Urgência"]{ background: var(--brick); }
.notif-item-dot[data-tipo="Informativo"]{ background: var(--teal); }
.notif-item-title{ font-weight:600; font-size: 13.5px; }
.notif-item-text{ font-size: 12.5px; color: var(--ink-soft); margin-top:3px; }
.notif-item-meta{ font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); margin-top:6px; }

/* Toasts */
.toast-stack{ position:fixed; bottom: 22px; right: 22px; display:flex; flex-direction:column; gap:10px; z-index: 200; }
.toast{
  background: var(--ink); color:#fff; padding: 13px 18px; border-radius: var(--radius-sm);
  font-size: 13.5px; box-shadow: var(--shadow-md); max-width: 320px; animation: toast-in .18s ease;
}
.toast.toast-success{ background: var(--pine-dark); }
.toast.toast-danger{ background: var(--brick); }
@keyframes toast-in{ from{ opacity:0; transform: translateY(8px); } to{ opacity:1; transform:none; } }

/* responsive sidebar */
@media (max-width: 880px){
  .sidebar{ position:fixed; left:-272px; z-index: 80; transition: left .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open{ left:0; }
  .sidebar-toggle{ display:flex; }
  .main-content{ padding: 22px 16px 60px; }
  .topbar{ padding: 14px 16px; }
  .user-meta{ display:none; }
}
