/* Arcada — interface
   Porcelana quente, grafite, um verde-menta profundo como única cor de ação.
   Títulos em serifa (prontuário), interface em sans, números em mono. */

:root {
  --bg: #F3F1EB;
  --surface: #FFFFFF;
  --surface-2: #F9F7F2;
  --line: #E4E0D6;
  --line-strong: #CEC8BA;
  --ink: #16201C;
  --ink-2: #48524D;
  --ink-3: #78807B;
  --accent: #0E5A4F;
  --accent-hover: #0A4A41;
  --accent-soft: #E1EDE9;
  --accent-ink: #FFFFFF;
  --danger: #A2332A;
  --danger-soft: #F7E6E3;
  --warn-soft: #F6EEDD;
  --warn: #7A520F;
  --focus: #2D7FF9;

  --font-ui: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --r: 10px;
  --r-sm: 7px;
  --side-w: 248px;
  --shadow: 0 1px 2px rgba(22, 32, 28, .05), 0 6px 20px -12px rgba(22, 32, 28, .18);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01';
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.i { width: 20px; height: 20px; flex: none; }
.i-sm { width: 16px; height: 16px; }
.mono { font-family: var(--font-mono); font-size: .88em; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }

.skip { position: fixed; z-index: 200; left: 12px; top: -60px; padding: 10px 14px; border-radius: var(--r-sm); background: var(--ink); color: #fff; font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; }

/* ---------- carregamento ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-mark { width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(22, 32, 28, .05); border-color: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #8A2A22; border-color: #8A2A22; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: transparent; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-sm);
  border: 0; background: transparent; color: var(--ink-2); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: rgba(22, 32, 28, .06); color: var(--ink); }
.icon-btn-accent { background: var(--accent); color: #fff; }
.icon-btn-accent:hover { background: var(--accent-hover); color: #fff; }

/* ---------- estrutura ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }

.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 20px 14px 14px; border-right: 1px solid var(--line); background: var(--surface-2);
}
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand span { font-family: var(--font-display); font-size: 26px; line-height: 1; letter-spacing: -.01em; }
.mark { width: 28px; height: 28px; color: var(--accent); }

.room { margin: 22px 0 18px; padding: 12px 12px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.room-label { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.room-label::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #2F9E6E; box-shadow: 0 0 0 3px rgba(47, 158, 110, .16); }
.room-name { display: block; margin-top: 6px; font-weight: 600; line-height: 1.3; }
.room select {
  width: 100%; margin-top: 6px; padding: 6px 28px 6px 0; border: 0; background: transparent; font-weight: 600; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378807B' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right center; background-size: 18px;
}
.room-empty { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--accent); font-weight: 600; text-decoration: none; }
.room-admin { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink-2); }

.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 10px; border-radius: var(--r-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: rgba(22, 32, 28, .05); color: var(--ink); }
.nav a.is-active { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; }
.nav a.is-active .i { color: var(--accent); }

.side-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--line); }
.avatar {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: .02em;
}
.avatar-lg { width: 56px; height: 56px; font-size: 19px; }
.who { min-width: 0; flex: 1; display: grid; line-height: 1.25; }
.who strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { font-size: 12px; color: var(--ink-3); }

.main { min-width: 0; }
.mobile-bar { display: none; }
.content { width: 100%; max-width: 1080px; margin: 0 auto; padding: 36px 40px 80px; }
.scrim { display: none; }

/* ---------- cabeçalho de página ---------- */
.page-head { margin-bottom: 28px; }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; color: var(--ink-3); text-decoration: none; font-size: 14px; font-weight: 500; }
.back:hover { color: var(--ink); }
.page-head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.page-head h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(32px, 4vw, 44px); line-height: 1.05; letter-spacing: -.015em; }
.page-head h1 em { font-style: italic; color: var(--accent); }
.page-sub { margin-top: 8px; color: var(--ink-2); max-width: 60ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section { margin-top: 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.section-head a { font-size: 14px; font-weight: 600; color: var(--accent); text-decoration: none; }
.section-head a:hover { text-decoration: underline; }

/* ---------- superfícies ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.panel-pad { padding: 24px; }

/* métricas */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); }
.stat { padding: 18px 22px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat dt { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.stat dd { margin: 4px 0 0; font-family: var(--font-display); font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }

/* listas em linhas */
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.rows > li + li { border-top: 1px solid var(--line); }
.row {
  display: grid; grid-template-columns: var(--cols, 1fr auto); gap: 16px; align-items: center;
  padding: 14px 18px; text-decoration: none; color: inherit; min-height: 64px;
}
a.row:hover { background: var(--surface-2); }
a.row:hover .row-go { color: var(--ink); transform: translateX(2px); }
.row-go { color: var(--ink-3); transition: transform .15s var(--ease), color .15s; }
.row-main { min-width: 0; display: flex; align-items: center; gap: 12px; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-text { min-width: 0; display: grid; }
.row-meta { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.cols-head {
  display: grid; grid-template-columns: var(--cols); gap: 16px; padding: 0 18px 8px;
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3);
}

.time-chip {
  display: inline-grid; place-items: center; min-width: 52px; height: 30px; padding: 0 8px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--line); font-family: var(--font-mono); font-size: 13px; color: var(--ink-2);
}

.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--accent-soft); color: var(--accent); }
.badge-off { background: #ECE9E2; color: var(--ink-3); }
.badge-live { background: var(--accent-soft); color: var(--accent); }
.badge-live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #2F9E6E; }
.badge-new { background: var(--warn-soft); color: var(--warn); }

/* ---------- cartões de consultório ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 14px; padding: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  text-decoration: none; color: inherit; transition: border-color .15s, transform .15s var(--ease);
}
.card:hover { border-color: var(--line-strong); }
.card.is-live { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.card h3 { font-family: var(--font-display); font-weight: 400; font-size: 26px; line-height: 1.1; }
.card h3 a { text-decoration: none; }
.card h3 a::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-lines { display: grid; gap: 6px; font-size: 14px; color: var(--ink-2); }
.card-lines div { display: flex; gap: 8px; align-items: flex-start; }
.card-lines .i { margin-top: 2px; color: var(--ink-3); }
.card-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); }
.card-foot .btn { position: relative; z-index: 1; }

/* ---------- ficha (detalhe) ---------- */
.dossier { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; }
.facts { padding: 22px; }
.facts-id { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.facts dl { margin: 0; display: grid; gap: 14px; }
.facts dt { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.facts dd.pre { white-space: pre-line; }
.facts-actions { display: flex; gap: 8px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* linha do tempo do histórico */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item { display: grid; grid-template-columns: 92px 20px minmax(0, 1fr); gap: 0 14px; }
.tl-date { padding-top: 16px; text-align: right; }
.tl-date strong { display: block; font-family: var(--font-display); font-weight: 400; font-size: 22px; line-height: 1.1; }
.tl-date span { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.tl-rail { position: relative; }
.tl-rail::before { content: ''; position: absolute; left: 9px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.tl-item:first-child .tl-rail::before { top: 24px; }
.tl-item:last-child .tl-rail::before { bottom: calc(100% - 24px); }
.tl-rail::after { content: ''; position: absolute; left: 4px; top: 20px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.tl-item:first-child .tl-rail::after { background: var(--accent); }
.tl-body { padding: 12px 0; }
.tl-card { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.tl-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.tl-proc { font-weight: 600; font-size: 16px; }
.tl-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; font-size: 13px; color: var(--ink-3); }
.tl-meta span { display: inline-flex; align-items: center; gap: 5px; }
.tl-obs { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); color: var(--ink-2); white-space: pre-line; font-size: 14px; }

/* ---------- formulários ---------- */
.form { display: grid; gap: 28px; }
.fieldset { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; }
.fieldset + .fieldset { padding-top: 28px; border-top: 1px solid var(--line); }
.fieldset-legend h2 { font-size: 15px; font-weight: 600; }
.fieldset-legend p { margin-top: 4px; font-size: 13px; color: var(--ink-3); }
.grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.field { grid-column: span 6; display: grid; gap: 6px; align-content: start; }
.span-1 { grid-column: span 1; } .span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.field label, .label { font-size: 14px; font-weight: 600; }
.opt { font-weight: 400; color: var(--ink-3); font-size: 12px; margin-left: 4px; }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 88px; line-height: 1.5; }
.field select {
  appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378807B' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px;
}
.input:hover, .field input:hover, .field select:hover, .field textarea:hover { border-color: var(--ink-3); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 90, 79, .16); }
.field input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.field input::placeholder, .field textarea::placeholder { color: #A3A9A4; }
.field .help { font-size: 13px; color: var(--ink-3); }
.field .error { display: none; font-size: 13px; color: var(--danger); font-weight: 500; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field.has-error .error { display: block; }
.form-foot { display: flex; justify-content: flex-end; gap: 10px; padding-top: 20px; border-top: 1px solid var(--line); }
.form-alert { display: none; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm); background: var(--danger-soft); color: var(--danger); font-weight: 500; font-size: 14px; }
.form-alert.show { display: flex; }

/* valor automático (consultório e data na consulta) */
.auto { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.auto > div { background: var(--surface-2); padding: 14px 16px; }
.auto dt { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.auto dd { margin: 4px 0 0; font-weight: 600; }
.auto small { display: block; font-size: 12px; color: var(--ink-3); font-weight: 400; margin-top: 2px; }
.auto a { color: var(--accent); }

/* combobox de paciente */
.combo { position: relative; }
.combo-input { position: relative; }
.combo-input .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.combo-input input { padding-left: 40px !important; }
.combo-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); max-height: 320px; overflow: auto;
  margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r); box-shadow: 0 16px 40px -16px rgba(22, 32, 28, .35);
}
.combo-list[hidden] { display: none; }
.combo-opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 10px; border-radius: 6px; cursor: pointer; }
.combo-opt[aria-selected="true"] { background: var(--accent-soft); }
.combo-opt mark { background: transparent; color: var(--accent); font-weight: 700; }
.combo-opt .mono { color: var(--ink-3); }
.combo-new { color: var(--accent); font-weight: 600; justify-content: flex-start; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 11px; border-radius: 0 0 6px 6px; }
.combo-new .i { flex: none; }
.combo-empty { padding: 10px; color: var(--ink-3); font-size: 14px; }

.patient-pick {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: var(--ink);
}
.patient-pick.is-new { background: var(--warn-soft); }
.patient-pick .avatar { background: var(--surface); }
.patient-pick .grow { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.patient-pick .grow span { font-size: 13px; color: var(--ink-2); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  height: 30px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink-2);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* busca */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search input { width: 100%; height: 42px; padding: 0 12px 0 40px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 90, 79, .16); }
.count { font-size: 14px; color: var(--ink-3); }

/* vazio */
.empty { text-align: center; padding: 48px 24px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r); }
.empty-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); margin-bottom: 14px; }
.empty h2 { font-family: var(--font-display); font-weight: 400; font-size: 26px; }
.empty p { margin: 6px auto 0; max-width: 42ch; color: var(--ink-2); }
.empty-action { margin-top: 18px; }
.empty-sm { padding: 28px 20px; }
.empty-sm h2 { font-size: 21px; }

/* ---------- avisos ---------- */
.toasts { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 380px; padding: 12px 16px; border-radius: var(--r-sm);
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 500; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .4);
  animation: toast-in .25s var(--ease);
}
.toast .i { color: #7FD3B0; }
.toast-error .i { color: #FFA59B; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.dialog { border: 0; padding: 0; border-radius: 14px; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45); }
.dialog::backdrop { background: rgba(22, 32, 28, .42); }
.dialog form { padding: 24px; }
.dialog h2 { font-family: var(--font-display); font-weight: 400; font-size: 28px; line-height: 1.1; }
.dialog p { margin-top: 10px; color: var(--ink-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* ---------- acesso (login / configuração) ---------- */
.gate { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr); }
.gate-art {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
  padding: 40px 48px; background: var(--accent); color: #F1F7F4;
}
.gate-art .brand { color: #fff; }
.gate-art .mark { color: #9FD9C2; }
.gate-art h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(44px, 5.4vw, 76px); line-height: .98; letter-spacing: -.02em; max-width: 11ch; }
.gate-art h1 em { color: #9FD9C2; }
.gate-art p { margin-top: 18px; max-width: 40ch; color: rgba(241, 247, 244, .78); font-size: 16px; }
.gate-arch { position: absolute; right: -40px; bottom: -60px; width: 460px; height: 460px; color: rgba(255, 255, 255, .07); pointer-events: none; }
.gate-foot { font-size: 13px; color: rgba(241, 247, 244, .6); }
.gate-form { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.gate-box { width: 100%; max-width: 380px; }
.gate-box h2 { font-family: var(--font-display); font-weight: 400; font-size: 36px; line-height: 1.05; }
.gate-box > p { margin-top: 8px; color: var(--ink-2); }
.gate-box .form { gap: 16px; margin-top: 28px; }
.gate-box .grid { gap: 14px; }
.pw { position: relative; }
.pw button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); height: 34px; padding: 0 10px; border: 0; background: transparent; color: var(--ink-3); font-size: 13px; font-weight: 600; cursor: pointer; border-radius: 6px; }
.pw button:hover { color: var(--ink); background: var(--surface-2); }
.pw input { padding-right: 76px !important; }

/* filtros de atendimentos */
.filters { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.15fr) repeat(2, minmax(0, 1fr)) repeat(2, minmax(0, 1.2fr)); gap: 12px 14px; padding: 16px 18px; margin-bottom: 16px; }
.filter { display: grid; gap: 5px; align-content: start; min-width: 0; }
.filter label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.filter input, .filter select {
  width: 100%; height: 40px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); font-size: 14px; min-width: 0;
}
.filter select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; text-overflow: ellipsis;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378807B' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 8px center / 16px;
}
.filter input:focus, .filter select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 90, 79, .16); }
.filter-input { position: relative; }
.filter-input .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.filter-input input { padding-left: 32px; }
.filter-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }
.filter-foot .chips { margin-top: 0; }
.filter-status { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.filter-fields { display: contents; }
.filter-toggle { display: none; }
.filter-n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; }
.more { display: flex; justify-content: center; margin-top: 14px; }
.row-meta { overflow: hidden; text-overflow: ellipsis; }
.show-sm { display: none !important; }
[hidden] { display: none !important; }

@media (max-width: 1100px) {
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-wide { grid-column: span 2; }
}
@media (max-width: 820px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 14px; }
  .filter-wide { grid-column: 1 / -1; }
  .filter-fields > .filter:last-child { grid-column: 1 / -1; }
  .filter-toggle { display: inline-flex; grid-column: 1 / -1; justify-self: start; }
  .filter-fields { display: none; }
  .filters.is-open .filter-fields { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .filter-foot { padding-top: 10px; }
  .filters:not(.is-open) .filter-foot { border-top: 0; padding-top: 0; }
  .filter-status { margin-left: 0; width: 100%; justify-content: space-between; }
  .show-sm { display: block !important; }
}

/* ---------- responsivo ---------- */
.only-mobile { display: none; }

@media (max-width: 960px) {
  .dossier { grid-template-columns: 1fr; }
  .fieldset { grid-template-columns: 1fr; gap: 14px; }
  .gate { grid-template-columns: 1fr; }
  .gate-art { padding: 28px 24px 36px; min-height: 0; }
  .gate-art h1 { font-size: 44px; margin-top: 40px; }
  .gate-arch { width: 320px; height: 320px; right: -60px; bottom: -120px; }
  .gate-foot { display: none; }
}

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); height: auto;
    transform: translateX(-100%); transition: transform .25s var(--ease), visibility 0s linear .25s; visibility: hidden;
  }
  .menu-open .side { transform: none; visibility: visible; transition: transform .25s var(--ease); box-shadow: 20px 0 60px -20px rgba(0, 0, 0, .3); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(22, 32, 28, .4); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .menu-open .scrim { opacity: 1; pointer-events: auto; }
  .only-mobile { display: inline-grid; }
  .mobile-bar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between;
    height: 60px; padding: 0 12px; background: rgba(243, 241, 235, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  }
  .mobile-bar .brand span { font-size: 23px; }
  .content { padding: 24px 16px 64px; }
  .stats { grid-template-columns: 1fr 1fr 1fr; }
  .stat { padding: 14px; }
  .stat dd { font-size: 30px; }
  .row { --cols: 1fr auto !important; padding: 12px 14px; }
  .row .hide-sm, .cols-head { display: none !important; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field, .span-3, .span-4, .span-5, .span-6 { grid-column: span 2; }
  .span-1, .span-2 { grid-column: span 1; }
  .auto { grid-template-columns: 1fr; }
  .tl-item { grid-template-columns: 62px 18px minmax(0, 1fr); gap: 0 10px; }
  .tl-date strong { font-size: 18px; }
  .form-foot { position: sticky; bottom: 0; margin: 0 -16px; padding: 12px 16px; background: rgba(243, 241, 235, .96); backdrop-filter: blur(8px); }
  .form-foot .btn { flex: 1; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
  .actions .btn-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
