:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --ink: #111111;
  --ink-2: #555550;
  --ink-3: #8a8a84;
  --line: #e4e2dc;
  --line-2: #d3d0c8;
  --pending: #a8620a;
  --pending-bg: #fdf1df;
  --ok: #1d7a46;
  --ok-bg: #e3f4ea;
  --changes: #b4331f;
  --changes-bg: #fbe7e3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(17, 17, 17, .04), 0 4px 16px rgba(17, 17, 17, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }

/* ---------- topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
}
.topbar .logo { height: 30px; width: auto; }
.topbar .who { margin-left: auto; text-align: right; font-size: 13px; line-height: 1.3; }
.topbar .who strong { display: block; font-size: 14px; }
.menu-btn {
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px;
  padding: 7px 12px; font-size: 13px; cursor: pointer;
}

.page { max-width: 1080px; margin: 0 auto; padding: 20px 16px 64px; }

/* ---------- abas ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 20px; }
.tab {
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 8px 16px; cursor: pointer; white-space: nowrap; font-weight: 500;
}
.tab[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.tab .count {
  display: inline-block; min-width: 20px; margin-left: 6px; padding: 0 6px; border-radius: 999px;
  background: var(--pending-bg); color: var(--pending); font-size: 12px; font-weight: 600; text-align: center;
}
.tab[aria-selected="true"] .count { background: rgba(255, 255, 255, .18); color: #fff; }

/* ---------- botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
  border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer; text-decoration: none;
  min-height: 44px;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.danger { background: var(--surface); color: var(--changes); border-color: var(--line-2); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.link-btn { border: 0; background: none; padding: 0; color: var(--ink-2); text-decoration: underline; cursor: pointer; font-size: 13px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.input, textarea.input, select.input {
  width: 100%; border: 1px solid var(--line-2); background: var(--surface); border-radius: 10px;
  padding: 11px 12px; outline: none; min-height: 44px;
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(17, 17, 17, .08); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }
.error { color: var(--changes); font-size: 13px; margin: 6px 0 0; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px 24px; box-shadow: var(--shadow);
}
.login-card .logo { width: 190px; margin: 0 auto 8px; }
.login-card p.lead { text-align: center; color: var(--ink-2); margin: 0 0 24px; font-size: 14px; }

/* ---------- resumo ---------- */
.hello { margin-bottom: 16px; }
.hello h1 { font-size: 24px; }
.hello p { margin: 4px 0 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 24px; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--ink-2); }

/* ---------- artes ---------- */
.month { margin: 28px 0 12px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.month:first-child { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.carousel { position: relative; background: #ecebe7; }
.slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slides a { flex: 0 0 100%; scroll-snap-align: start; aspect-ratio: 4 / 5; }
.slides img { width: 100%; height: 100%; object-fit: contain; }
.counter {
  position: absolute; top: 10px; right: 10px; background: rgba(17, 17, 17, .72); color: #fff;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
}
.nav-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, .9); box-shadow: var(--shadow); cursor: pointer; font-size: 18px; line-height: 1;
}
.nav-arrow.prev { left: 8px; }
.nav-arrow.next { right: 8px; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-head h3 { font-size: 16px; }
.date { font-size: 13px; color: var(--ink-2); }
.badge {
  display: inline-block; white-space: nowrap; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
}
.badge.pending { background: var(--pending-bg); color: var(--pending); }
.badge.approved { background: var(--ok-bg); color: var(--ok); }
.badge.changes { background: var(--changes-bg); color: var(--changes); }
.caption { white-space: pre-wrap; font-size: 14px; color: #2a2a28; max-height: 7.5em; overflow: hidden; position: relative; }
.caption.open { max-height: none; }
.actions { display: flex; gap: 8px; margin-top: auto; }
.actions .btn { flex: 1; }
.history { border-top: 1px solid var(--line); padding-top: 10px; font-size: 13px; }
.history summary { cursor: pointer; color: var(--ink-2); }
.event { margin-top: 8px; padding-left: 10px; border-left: 2px solid var(--line-2); }
.event.changes { border-color: var(--changes); }
.event.approved { border-color: var(--ok); }
.event .meta { color: var(--ink-3); font-size: 12px; }
.event .body { white-space: pre-wrap; }

.empty {
  text-align: center; padding: 48px 16px; color: var(--ink-2);
  background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius);
}

/* ---------- documentos ---------- */
.doc-list { display: flex; flex-direction: column; gap: 10px; }
.doc {
  display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; text-decoration: none;
}
.doc-icon {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 10px; background: var(--bg);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--ink-2);
}
.doc-info { flex: 1; min-width: 0; }
.doc-info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-info span { font-size: 13px; color: var(--ink-2); }

/* ---------- painel ---------- */
.client-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.client-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  text-decoration: none; display: block; box-shadow: var(--shadow);
}
.client-card:hover { border-color: var(--ink); }
.client-card h3 { font-size: 17px; margin-bottom: 4px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel h2 { font-size: 17px; margin-bottom: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.section-head h1 { font-size: 24px; }
.back { display: inline-block; margin-bottom: 10px; font-size: 13px; color: var(--ink-2); text-decoration: none; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumbs img { width: 64px; height: 80px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.user-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.user-row:last-child { border-bottom: 0; }
.user-row .grow { flex: 1; min-width: 160px; }
.secret {
  background: #111; color: #fff; border-radius: 10px; padding: 12px 14px; font-family: ui-monospace, Menlo, monospace;
  font-size: 14px; white-space: pre-wrap; word-break: break-all;
}

/* ---------- modal e aviso ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(17, 17, 17, .45); display: grid; place-items: end center; z-index: 50; padding: 0;
}
.modal {
  width: 100%; max-width: 520px; background: var(--surface); border-radius: 18px 18px 0 0; padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow: auto;
}
.modal h2 { font-size: 18px; margin-bottom: 14px; }
@media (min-width: 640px) {
  .modal-back { place-items: center; padding: 16px; }
  .modal { border-radius: 18px; }
}
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 500;
  transition: .2s; pointer-events: none; z-index: 60; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 520px) {
  .stats { gap: 8px; }
  .stat { padding: 10px; }
  .stat b { font-size: 20px; }
  .grid { grid-template-columns: 1fr; }
  .topbar .who span { display: none; }
  .tab { padding: 7px 13px; font-size: 14px; }
}
