:root {
  --gq-sidebar: #1c1f26;
  --gq-sidebar-fg: #c7ccd6;
  --gq-accent: #b9935a;
  --pico-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --pico-border-radius: 10px;
}

[x-cloak] { display: none !important; }

body { margin: 0; }

.centered {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem;
}
.muted { color: var(--pico-muted-color); }

/* ------------------------------------------------------------------- login */
.login-card { width: 100%; max-width: 22rem; }
.login-card hgroup { text-align: center; margin-bottom: 1.5rem; }
.error { color: var(--pico-del-color, #c0392b); font-size: .875rem; }

/* ------------------------------------------------------------------ layout */
.layout {
  display: grid;
  grid-template-columns: 244px 1fr;
  min-height: 100dvh;
}
.sidebar {
  background: var(--gq-sidebar);
  color: var(--gq-sidebar-fg);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar nav { flex: 1; overflow-y: auto; padding-top: .75rem; }
.sidebar nav ul { list-style: none; margin: 0; padding: 0; }
.sidebar nav a {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  padding: .6rem 1.25rem;
  color: var(--gq-sidebar-fg);
  text-decoration: none;
  font-size: .925rem;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.04); color: #fff; }
.sidebar nav a.active {
  background: rgba(255,255,255,.06);
  color: #fff;
  border-left-color: var(--gq-accent);
}
.sidebar nav a.disabled { opacity: .4; pointer-events: none; }
.sidebar nav small { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; opacity: .6; }
.sidebar-foot {
  padding: 1rem 1.25rem 0;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .8rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.sidebar-foot a { color: var(--gq-accent); }

.content { padding: 2.5rem 3rem; max-width: 1100px; }

/* -------------------------------------------------------------- form pages */
.page-head { margin-bottom: 2rem; }
.page-head h2 { margin-bottom: .25rem; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 1.5rem;
}
.field-grid .col-span-2 { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .content { padding: 1.5rem; }
  .field-grid { grid-template-columns: 1fr; }
}

fieldset.group {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
fieldset.group > legend {
  font-weight: 600;
  padding: 0 .5rem;
  color: var(--pico-muted-color);
  text-transform: uppercase;
  font-size: .75rem;
  letter-spacing: .06em;
}

.signature-preview {
  border: 1px dashed var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  padding: 1rem;
  display: grid;
  place-items: center;
  min-height: 120px;
  background: #fff;
}
.signature-preview img { max-height: 120px; }

.form-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  position: sticky;
  bottom: 0;
  background: var(--pico-background-color);
  padding: 1rem 0;
  border-top: 1px solid var(--pico-muted-border-color);
}
/* ------------------------------------------------------------------ lists */
.list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.list-head button { width: auto; }
.search-bar {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.search-bar input,
.search-bar select { margin: 0; }
.search-bar select { width: auto; flex-shrink: 0; }
.search-bar button { width: auto; white-space: nowrap; }

table.striped { font-size: .925rem; }
.row-click { cursor: pointer; }
.row-click:hover td { background: var(--pico-primary-focus, rgba(120,120,255,.08)); }
.ta-right { text-align: right; }
.ta-center { text-align: center; }

.tag {
  display: inline-block;
  margin-left: .4rem;
  padding: 0 .4rem;
  font-size: .68rem;
  border-radius: 4px;
  background: var(--gq-accent);
  color: #fff;
  vertical-align: middle;
}
.tag-off { background: #9aa0ab; }
.tag-late { background: #c0392b; }

/* ---------------------------------------------------------- combobox cliente */
.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: 100%;
  margin: 0; padding: 0; list-style: none;
  background: var(--pico-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  max-height: 240px; overflow-y: auto;
}
.combo-list li { padding: .55rem .8rem; cursor: pointer; }
.combo-list li:hover { background: var(--pico-primary-focus, rgba(120,120,255,.1)); }
.picked {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .8rem; border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius); margin-bottom: 1rem;
}
.link-btn {
  background: none; border: none; color: var(--gq-accent);
  width: auto; padding: 0; margin: 0; font-size: .85rem; cursor: pointer;
}
.link-btn.danger { color: #c0392b; font-size: 1.1rem; line-height: 1; }
.sm { font-size: .82rem; }
button.sm { width: auto; padding: .3rem .8rem; margin-top: .5rem; }

/* ------------------------------------------------------------- itens/parcelas */
.items-table { font-size: .85rem; }
.items-table th { font-weight: 600; }
.items-table td { padding: .3rem .4rem; vertical-align: top; }
.items-table input, .items-table select { margin: 0; font-size: .85rem; padding: .35rem .5rem; }
.items-table td:first-child { min-width: 220px; }
.items-table input[type="number"] { max-width: 90px; }

.totals {
  display: grid; grid-template-columns: 1fr auto; gap: .3rem 1.5rem;
  max-width: 340px; margin: 1rem 0; font-size: .9rem;
}
.totals strong { text-align: right; }
.totals .diff { color: #c0392b; }

/* ------------------------------------------------------------------- stepper */
.stepper {
  display: flex; flex-wrap: nowrap; gap: .25rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius); padding: 1rem .5rem;
  overflow-x: auto;
}
.step {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  background: none; border: none; cursor: pointer;
  width: auto; flex: 0 0 104px; padding: .5rem .3rem; margin: 0;
  border-radius: 8px; color: var(--pico-muted-color);
  position: relative;
}
.step:not(:last-child)::after {
  content: ""; position: absolute; top: 21px; left: calc(50% + 18px); right: calc(-50% + 18px);
  height: 2px; background: var(--pico-muted-border-color);
}
.step.done:not(:last-child)::after { background: #7fae7f; }
.step:hover:not(:disabled) { background: var(--pico-primary-focus, rgba(120,120,255,.08)); }
.step-dot {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: .8rem; font-weight: 700;
  background: var(--pico-muted-border-color); color: #fff;
}
.step-name { font-size: .72rem; text-align: center; line-height: 1.2; }
.step-days { font-size: .62rem; opacity: .7; }
.step.done .step-dot { background: #7fae7f; }
.step.active .step-dot { background: var(--gq-accent); }
.step.active .step-name { color: var(--pico-color); font-weight: 700; }

.row-late td { background: rgba(192,57,43,.08) !important; }
.txt-late { color: #c0392b; font-weight: 600; }

/* ----------------------------------------------------------------- contratos */
.head-actions { display: flex; gap: .6rem; align-items: center; }
.head-actions [role="button"], .head-actions button { width: auto; white-space: nowrap; }

.tpl-editor { display: grid; grid-template-columns: 240px 1fr; gap: 1.5rem; align-items: start; }
.tpl-fields {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius); padding: .75rem; font-size: .85rem;
  max-height: 560px; overflow-y: auto;
}
.tpl-fields details { margin-bottom: .5rem; }
.tpl-fields summary { font-weight: 600; cursor: pointer; padding: .2rem 0; }
.field-chip {
  display: block; width: 100%; text-align: left; margin: .15rem 0;
  background: var(--pico-secondary-background, #eee); border: none;
  border-radius: 6px; padding: .3rem .5rem; font-size: .8rem; cursor: pointer; color: #2a2d34;
}
.field-chip:hover { background: var(--gq-accent); color: #fff; }
.tpl-body textarea { font-family: ui-monospace, Menlo, monospace; font-size: .82rem; line-height: 1.5; }
@media (max-width: 820px) { .tpl-editor { grid-template-columns: 1fr; } }

.contract-paper {
  background: #fff; color: #1a1a1a;
  border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius);
  padding: 3rem 3.2rem; margin: 1rem 0 2rem;
  white-space: pre-wrap; font-family: Georgia, "Times New Roman", serif;
  font-size: .92rem; line-height: 1.6; max-width: 820px;
}
.contract-paper .sig-img { max-height: 90px; display: block; margin: .5rem 0; }
.contract-paper .accept-stamp {
  display: inline-block; background: #eef6ee; border: 1px solid #bcd9bc;
  border-radius: 6px; padding: .4rem .7rem; font-family: system-ui, sans-serif; font-size: .82rem;
}
.contract-paper .sig-caption { font-family: system-ui, sans-serif; font-size: .8rem; color: #555; }

@media print {
  .sidebar, .no-print, .page-head .head-actions { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; max-width: none; }
  .contract-paper { border: none; padding: 0; max-width: none; }
}

/* --------------------------------------------------------------- financeiro */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--pico-muted-border-color); margin-bottom: 1.5rem; }
.tabs button {
  width: auto; background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px; padding: .6rem 1rem; color: var(--pico-muted-color); cursor: pointer;
}
.tabs button.active { color: var(--pico-color); border-bottom-color: var(--gq-accent); font-weight: 600; }

.kpis { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.kpi {
  border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius);
  padding: .8rem 1.1rem; min-width: 160px;
}
.kpi span { display: block; font-size: .78rem; color: var(--pico-muted-color); }
.kpi strong { font-size: 1.3rem; }
.kpi.late strong { color: #c0392b; }
.row-total td { border-top: 2px solid var(--pico-muted-border-color); }

.sign-box { border: 1px solid var(--gq-accent); border-radius: 10px; padding: 1.25rem; margin-top: 1.5rem; background: #fffdf8; }
.sign-box .switch { margin-bottom: 1rem; }
.sign-box button { width: auto; }

.grant-result { margin-top: 1rem; padding: 1rem; border: 1px dashed var(--gq-accent); border-radius: 8px; background: #fffdf8; }
.grant-result code { font-size: .95rem; user-select: all; }

/* ------------------------------------------------------------------- agenda */
.head-actions button.active { background: var(--gq-accent); color: #fff; border-color: var(--gq-accent); }
.month-nav { display: flex; align-items: center; gap: .6rem; }
.month-nav button { width: auto; padding: .3rem .7rem; }
.month-nav strong { min-width: 9rem; text-align: center; }

.cal { border: 1px solid var(--pico-muted-border-color); border-radius: var(--pico-border-radius); overflow: hidden; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--gq-sidebar); color: #c7ccd6; }
.cal-head div { padding: .5rem; text-align: center; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--pico-muted-border-color); }
.cal-day { min-height: 104px; border-right: 1px solid var(--pico-muted-border-color); padding: .3rem; display: flex; flex-direction: column; gap: .2rem; }
.cal-day:last-child { border-right: none; }
.cal-day.out { background: #fafafa; }
.cal-day.out .cal-daynum { opacity: .35; }
.cal-day.today .cal-daynum { background: var(--gq-accent); color: #fff; border-radius: 50%; }
.cal-daynum { font-size: .8rem; width: 1.4rem; height: 1.4rem; display: grid; place-items: center; }
.cal-ev {
  width: 100%; text-align: left; border: none; cursor: pointer; margin: 0;
  background: color-mix(in srgb, var(--c) 16%, white); border-left: 3px solid var(--c);
  border-radius: 4px; padding: .15rem .35rem; font-size: .72rem; line-height: 1.25;
  display: flex; gap: .3rem; color: #333; overflow: hidden;
}
.cal-ev span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev span:first-child { font-variant-numeric: tabular-nums; opacity: .7; }

.agenda-list h4 { margin: 1.5rem 0 .5rem; color: var(--pico-muted-color); }
.agenda-row {
  display: grid; grid-template-columns: 4rem 3.5rem auto 1fr; align-items: center; gap: .75rem;
  width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid var(--pico-muted-border-color);
  padding: .6rem .2rem; cursor: pointer; margin: 0;
  color: #2a2d34; font-size: .9rem; font-family: inherit;
}
.ar-title strong { font-size: .9rem; color: #1c1f26; }
.agenda-row:hover { background: var(--pico-primary-focus, rgba(120,120,255,.06)); }
.ar-date { font-size: .8rem; color: var(--pico-muted-color); text-transform: capitalize; }
.ar-time { font-variant-numeric: tabular-nums; font-size: .85rem; }
.ar-dot { width: 10px; height: 10px; border-radius: 50%; }
.ar-title { display: flex; flex-direction: column; }
.ar-title small { font-size: .78rem; }
@media (max-width: 720px) {
  .cal-day { min-height: 72px; }
  .agenda-row { grid-template-columns: 3.5rem auto 1fr; }
  .ar-time { display: none; }
}

.pager {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
  font-size: .875rem;
}
.pager button { width: auto; }

.back-link {
  display: inline-block;
  font-size: .85rem;
  margin-bottom: .35rem;
  color: var(--pico-muted-color);
}
.switch { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.req { color: var(--pico-del-color, #c0392b); margin-left: .15rem; }
.danger { --pico-color: #c0392b; --pico-border-color: #c0392b; }

.toast {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  background: #16351f;
  color: #d7f5df;
  padding: .75rem 1.25rem;
  border-radius: var(--pico-border-radius);
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
  font-size: .9rem;
}
.toast.err { background: #3a1a1a; color: #f7d7d7; }
