/* ═══════════════════════════════════════════════
   PeraSmart — Design System
   Tema: "pomar" — verde-pera vivo sobre papel claro,
   sidebar verde-noite. Bricolage Grotesque + Figtree.
   ═══════════════════════════════════════════════ */

:root {
  --pera-300: #a8d94e;
  --pera-400: #8fc72c;
  --pera-500: #7cb518;
  --pera-600: #659711;
  --pera-700: #4e750c;
  --pera-tint: #eef6da;
  --pera-tint-2: #e2efc4;

  --night-900: #0d160e;
  --night-800: #122015;
  --night-700: #1a2e1e;
  --night-line: #24402a;

  --paper: #f2f4ec;
  --surface: #ffffff;
  --ink: #1a2519;
  --ink-2: #44523f;
  --muted: #74836c;
  --line: #e3e8d9;

  --red: #e5484d;
  --red-tint: #fdebec;
  --amber: #eb9c07;
  --amber-tint: #fdf3dd;
  --blue: #3e63dd;
  --blue-tint: #e9edfc;

  --font-display: "Bricolage Grotesque", sans-serif;
  --font-body: "Figtree", sans-serif;

  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow-1: 0 1px 2px rgba(20, 32, 16, .05), 0 4px 16px rgba(20, 32, 16, .06);
  --shadow-2: 0 4px 10px rgba(20, 32, 16, .08), 0 16px 40px rgba(20, 32, 16, .12);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
  max-width: 100vw;
}

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -.01em; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

.hidden { display: none !important; }

/* ───────────── Botões ───────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: var(--r-sm);
  padding: 11px 20px;
  font-weight: 700;
  font-size: 14.5px;
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), background .18s;
}
.btn:active { transform: scale(.97); }

.btn-brand {
  background: linear-gradient(135deg, var(--pera-400), var(--pera-600));
  color: #fff;
  box-shadow: 0 2px 8px rgba(124, 181, 24, .35);
}
.btn-brand:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(124, 181, 24, .45);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1.5px solid var(--line);
}
.btn-ghost:hover { border-color: var(--pera-500); color: var(--pera-700); }

.btn-block { width: 100%; justify-content: center; }

/* ═══════════════ LOGIN ═══════════════ */

.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--night-900);
}

.login-deco { position: absolute; inset: 0; }

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .5;
  animation: drift 14s ease-in-out infinite alternate;
}
.blob-a { width: 520px; height: 520px; background: #2f5a15; top: -160px; left: -120px; }
.blob-b { width: 420px; height: 420px; background: #7cb51833; bottom: -120px; right: -80px; animation-delay: -5s; }
.blob-c { width: 300px; height: 300px; background: #1a3a20; top: 40%; left: 55%; animation-delay: -9s; }

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(60px, -40px) scale(1.15); }
}

.grain {
  position: absolute; inset: 0;
  opacity: .4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.06 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.login-panel {
  position: relative;
  z-index: 2;
  width: min(400px, calc(100vw - 40px));
  background: rgba(255, 255, 255, .97);
  border-radius: 26px;
  padding: 44px 40px 36px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  animation: loginIn .7s var(--ease-out) both;
}

@keyframes loginIn {
  from { opacity: 0; transform: translateY(26px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.login-brand { text-align: center; margin-bottom: 30px; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 62px; height: 62px;
  border-radius: 20px;
  background: linear-gradient(140deg, var(--pera-tint), var(--pera-tint-2));
  color: var(--pera-600);
  margin-bottom: 14px;
  box-shadow: inset 0 0 0 1.5px var(--pera-tint-2);
}
.brand-mark.small {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--pera-500), var(--pera-700));
  color: #eaf6cf;
  margin: 0;
  box-shadow: none;
}

.login-brand h1 {
  font-size: 34px;
  font-weight: 800;
  color: var(--ink);
}
.login-brand h1 em, .side-brand-name em {
  font-style: normal;
  color: var(--pera-600);
}
.tagline { color: var(--muted); font-size: 14px; margin-top: 2px; }

.field { display: block; margin-bottom: 16px; }
.field span {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: #fbfcf8;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--pera-500);
  box-shadow: 0 0 0 3.5px rgba(124, 181, 24, .18);
}

#login-form .btn { margin-top: 6px; }

.login-hint {
  margin-top: 14px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}

.login-foot {
  position: relative;
  z-index: 2;
  margin-top: 26px;
  color: #6f8468;
  font-size: 12.5px;
  letter-spacing: .04em;
}

/* ═══════════════ APP SHELL ═══════════════ */

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

/* ───── Sidebar ───── */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(178deg, var(--night-800), var(--night-900) 70%);
  border-right: 1px solid var(--night-line);
  padding: 22px 14px;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  padding: 4px 10px 22px;
}
.side-brand-name {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  color: #f2f7e8;
}
.side-brand-name em { color: var(--pera-400); }

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--night-line) transparent;
}
.side-nav::-webkit-scrollbar { width: 6px; }
.side-nav::-webkit-scrollbar-thumb { background: var(--night-line); border-radius: 3px; }
.side-nav::-webkit-scrollbar-track { background: transparent; }

.side-cat {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #6f8768;
  padding: 11px 12px 4px;
}
.side-cat:first-child { padding-top: 2px; }

.side-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 11px;
  text-decoration: none;
  color: #9db396;
  font-weight: 600;
  font-size: 14.5px;
  transition: background .15s, color .15s, transform .15s var(--ease-out);
  position: relative;
}
.side-nav a:hover { color: #e9f2df; background: rgba(124, 181, 24, .1); transform: translateX(3px); }

.side-nav a.active {
  color: #f4fae8;
  background: linear-gradient(90deg, rgba(124, 181, 24, .28), rgba(124, 181, 24, .08));
}
.side-nav a.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 20%;
  bottom: 20%;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--pera-400);
}

.side-nav svg, .side-logout svg {
  width: 20px; height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.side-logout {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--night-line);
  border-radius: 11px;
  background: transparent;
  color: #8ba283;
  font-weight: 600;
  font-size: 14.5px;
  transition: color .15s, border-color .15s, background .15s;
}
.side-logout:hover { color: #ffb4b4; border-color: #5c2a2a; background: rgba(229, 72, 77, .08); }

/* ───── Topbar ───── */

.main { min-width: 0; max-width: 100%; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 32px 0;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px; height: 42px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.menu-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.menu-toggle:active { transform: scale(.94); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(20, 28, 16, .5);
  opacity: 0;
  transition: opacity .25s;
}
.sidebar-backdrop.show { opacity: 1; }

.topbar-title h2 { font-size: 24px; font-weight: 800; }
.crumb { font-size: 13px; color: var(--muted); }

.topbar-user { display: flex; align-items: center; gap: 13px; }
.greet { text-align: right; line-height: 1.25; }
.greet strong { display: block; font-size: 14px; }
.greet span { font-size: 12px; color: var(--muted); letter-spacing: .05em; }

.avatar {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--pera-400), var(--pera-700));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  box-shadow: 0 2px 8px rgba(124, 181, 24, .4);
}

/* ───── View ───── */

.view { padding: 24px 32px 44px; min-width: 0; max-width: 100%; }
.view > *, .stat-row, .widget-grid, .chart-panel { min-width: 0; max-width: 100%; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  animation: fadeSlideIn .55s var(--ease-out) both;
  animation-delay: var(--d, 0s);
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 0;
}
.panel-head h3 { font-size: 17px; font-weight: 700; }
.panel-body { padding: 20px 24px 24px; }

/* ═══════════════ DASHBOARD ═══════════════ */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }

.stat-icon {
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  border-radius: 16px;
  flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stat-icon.up { background: var(--pera-tint); color: var(--pera-700); }
.stat-icon.down { background: var(--red-tint); color: var(--red); }
.stat-icon.warn { background: var(--amber-tint); color: var(--amber); }
.stat-icon.info { background: var(--blue-tint); color: var(--blue); }

.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.1;
}
.stat-label { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ───── Gráfico financeiro ───── */

.chart-panel { margin-bottom: 18px; }

.chart-legend { display: flex; gap: 18px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.chart-legend i {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 3.5px;
  margin-right: 6px;
}

.chart-svg { width: 100%; height: auto; display: block; max-height: 320px; }

.bar {
  transform-origin: bottom;
  transform: scaleY(0);
  animation: barGrow .8s var(--ease-out) forwards;
  animation-delay: var(--bd, 0s);
}
@keyframes barGrow { to { transform: scaleY(1); } }

.chart-line {
  stroke-dasharray: 2000;
  stroke-dashoffset: 2000;
  animation: chartDraw 1.4s var(--ease-out) .3s forwards;
}
@keyframes chartDraw { to { stroke-dashoffset: 0; } }

.bar-group:hover .bar { filter: brightness(1.12); }

.chart-tip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--night-800);
  color: #eef5e4;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 12.5px;
  line-height: 1.6;
  box-shadow: var(--shadow-2);
  opacity: 0;
  transition: opacity .12s;
  white-space: nowrap;
}
.chart-tip.show { opacity: 1; }
.chart-tip strong { font-family: var(--font-display); font-size: 13px; }

/* ───── Grelha de widgets ───── */

.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
}
.badge.up { background: var(--pera-tint); color: var(--pera-700); }
.badge.warn { background: var(--amber-tint); color: #9a6a00; }
.badge.info { background: var(--blue-tint); color: var(--blue); }
.badge.down { background: var(--red-tint); color: var(--red); }

/* ───── Listas compactas dos widgets do dashboard ───── */
.mini-list { list-style: none; display: flex; flex-direction: column; }
.mini-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
}
.mini-list li:last-child { border-bottom: 0; }
.mini-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.mini-main strong { font-size: 14px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.mini-sub { font-size: 12.5px; color: var(--muted); }
.mini-badge { flex-shrink: 0; }
.mini-chev { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.mini-list li.row-link { cursor: pointer; transition: background .15s; border-radius: 8px; padding-left: 8px; padding-right: 8px; margin: 0 -8px; }
.mini-list li.row-link:hover { background: var(--pera-tint); }
.mini-list li.row-link:hover .mini-chev { color: var(--pera-700); }

.empty {
  padding: 26px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.empty svg { width: 34px; height: 34px; stroke: var(--line); fill: none; stroke-width: 1.6; margin-bottom: 6px; }

/* ═══════════════ TABELAS ═══════════════ */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1.5px solid var(--line);
  white-space: nowrap;
}

tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
}
tbody tr { transition: background .13s; }
tbody tr:hover { background: #f7f9f1; }
tbody tr:last-child td { border-bottom: none; }

.td-strong { font-weight: 700; }
.td-dim { color: var(--muted); font-size: 13px; }

.row-actions { display: flex; gap: 6px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  transition: background .13s, color .13s, transform .13s var(--ease-out);
}
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { transform: translateY(-1.5px); }
.icon-btn.view:hover { background: var(--blue-tint); color: var(--blue); }
.icon-btn.edit:hover { background: var(--pera-tint); color: var(--pera-700); }
.icon-btn.del:hover { background: var(--red-tint); color: var(--red); }

/* ───── Barra de lista ───── */

.list-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 20px 24px 6px;
}

.search-box { position: relative; }
.search-box svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}
.search-box input {
  width: 260px;
  padding: 10px 14px 10px 38px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: #fbfcf8;
  transition: border-color .15s, box-shadow .15s;
}
.search-box input:focus {
  outline: none;
  border-color: var(--pera-500);
  box-shadow: 0 0 0 3.5px rgba(124, 181, 24, .18);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px 20px;
  flex-wrap: wrap;
}
.pager-info { font-size: 13px; color: var(--muted); }
.pager-btns { display: flex; gap: 6px; }
.page-btn {
  min-width: 34px; height: 34px;
  padding: 0 8px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 700;
  font-size: 13.5px;
  transition: all .13s;
}
.page-btn:hover:not(:disabled) { border-color: var(--pera-500); color: var(--pera-700); }
.page-btn.active { background: var(--pera-600); border-color: var(--pera-600); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ═══════════════ FORMULÁRIO / TABS ═══════════════ */

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  border-bottom: 1.5px solid var(--line);
}
.tab {
  border: none;
  background: transparent;
  padding: 13px 16px;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -1.5px;
  transition: color .14s, border-color .14s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--pera-700); border-bottom-color: var(--pera-500); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px 20px;
}
.form-grid .span-2 { grid-column: span 2; }

.field-inline { display: flex; gap: 10px; align-items: flex-end; }
.field-inline .field { flex: 1; margin-bottom: 0; }
.field-inline .btn { padding: 11px 16px; white-space: nowrap; }

.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}
.switch {
  position: relative;
  width: 46px; height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; cursor: pointer; z-index: 2; margin: 0; }
.switch i {
  position: absolute; inset: 0;
  border-radius: 99px;
  background: #d5dcc9;
  transition: background .18s;
}
.switch i::after {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  transition: transform .18s var(--ease-out);
}
.switch input:checked + i { background: var(--pera-500); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch-label { font-weight: 600; font-size: 14px; color: var(--ink-2); }

.form-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 6px 24px 24px;
}

/* ═══════════════ PLACEHOLDER (módulos fase 2) ═══════════════ */

.soon {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 70px 20px;
}
.soon .brand-mark { margin-bottom: 18px; }
.soon h3 { font-size: 21px; margin-bottom: 6px; }
.soon p { color: var(--muted); max-width: 420px; }

/* ═══════════════ TOAST ═══════════════ */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translate(-50%, 80px);
  background: var(--night-800);
  color: #eef5e4;
  padding: 13px 22px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow-2);
  opacity: 0;
  transition: transform .3s var(--ease-out), opacity .3s;
  z-index: 100;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.ok { border-left: 4px solid var(--pera-400); }
.toast.err { border-left: 4px solid var(--red); }

/* ═══════════════ EXTRAS PARTILHADOS ═══════════════ */

.badge.brand { background: var(--pera-tint); color: var(--pera-700); }
.badge.dim { background: #eef0e8; color: var(--muted); }
.stat-icon.brand { background: var(--pera-tint); color: var(--pera-600); }

.stat-link { text-decoration: none; color: inherit; cursor: pointer; }
.stat-row-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.row-link { cursor: pointer; }

.form-hint {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--pera-700);
  min-height: 1.4em;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2.5px solid var(--pera-500);
  outline-offset: 2px;
}

/* ───────── Estoque (célula com barra) ───────── */

.stock-cell { display: flex; align-items: center; gap: 9px; min-width: 150px; }
.stock-num { font-family: var(--font-display); font-weight: 800; font-size: 15px; min-width: 28px; }
.stock-num.baixo { color: var(--red); }
.stock-num.medio { color: var(--amber); }
.stock-num.ok { color: var(--pera-700); }
.stock-bar {
  flex: 1;
  height: 6px;
  max-width: 70px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}
.stock-bar i { display: block; height: 100%; border-radius: 99px; transition: width .4s var(--ease-out); }
.stock-bar i.baixo { background: var(--red); }
.stock-bar i.medio { background: var(--amber); }
.stock-bar i.ok { background: var(--pera-500); }
.stock-min { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* ───────── Catálogo de Serviços ───────── */

.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 16px;
}

.service-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 18px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(124, 181, 24, .07), transparent 55%),
    var(--surface);
  cursor: pointer;
  animation: fadeSlideIn .5s var(--ease-out) both;
  animation-delay: var(--d, 0s);
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out), border-color .2s;
}
.service-card:hover {
  transform: translateY(-4px);
  border-color: var(--pera-400);
  box-shadow: 0 10px 26px rgba(78, 117, 12, .16);
}
.service-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
}
.service-cod {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .07em;
  color: var(--muted);
}
.service-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .18s; }
.service-card:hover .service-actions,
.service-card:focus-within .service-actions { opacity: 1; }

.service-card h4 {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.3;
}
.service-card p {
  font-size: 13px;
  color: var(--muted);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.service-card footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.service-price {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  color: var(--pera-700);
  letter-spacing: -.02em;
}
.service-tag {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

/* ───────── OS: filtros (chips) ───────── */

.os-filter { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: 99px;
  padding: 7px 14px;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink-2);
  transition: all .15s;
}
.chip b { font-weight: 800; color: var(--muted); margin-left: 3px; }
.chip:hover { border-color: var(--pera-400); color: var(--pera-700); }
.chip.active {
  background: var(--night-800);
  border-color: var(--night-800);
  color: #eef5e4;
}
.chip.active b { color: var(--pera-300); }

/* ───────── OS: cards ───────── */

.os-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
  gap: 16px;
}

.os-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 17px 18px 15px;
  border: 1.5px solid var(--line);
  border-left-width: 4.5px;
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  animation: fadeSlideIn .5s var(--ease-out) both;
  animation-delay: var(--d, 0s);
  transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.os-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); }

.os-card.status-aberta    { border-left-color: var(--blue); }
.os-card.status-pecas     { border-left-color: var(--amber); }
.os-card.status-andamento { border-left-color: var(--pera-500); }
.os-card.status-concluida { border-left-color: var(--pera-700); }
.os-card.status-entregue  { border-left-color: #b9c2ae; }

.os-card header { display: flex; align-items: center; justify-content: space-between; }
.os-num { font-family: var(--font-display); font-weight: 800; font-size: 14px; color: var(--ink-2); letter-spacing: .02em; }
.os-card h4 { font-size: 15.5px; font-weight: 700; line-height: 1.3; }
.os-cliente { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.os-defeito {
  font-size: 13px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.os-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 11px;
  border-top: 1px dashed var(--line);
}
.os-data { font-size: 12px; color: var(--muted); font-weight: 600; }
.os-valor { font-family: var(--font-display); font-weight: 800; color: var(--pera-700); }

.os-fotos-strip { display: flex; gap: 6px; margin-top: 4px; }
.os-fotos-strip img {
  width: 42px; height: 42px;
  object-fit: cover;
  border-radius: 8px;
  border: 1.5px solid var(--line);
}
.os-fotos-strip .mais {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 8px;
  background: var(--pera-tint);
  color: var(--pera-700);
  font-weight: 800;
  font-size: 12px;
}

/* ───────── Fotos: dropzone + galeria ───────── */

.foto-sec { margin-top: 26px; }
.foto-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.foto-sec-head h4 { font-size: 15px; font-weight: 700; }

.foto-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 26px 20px;
  border: 2px dashed var(--line);
  border-radius: var(--r-md);
  background: #fafbf6;
  color: var(--muted);
  text-align: center;
  transition: border-color .18s, background .18s;
}
.foto-drop.drag { border-color: var(--pera-500); background: var(--pera-tint); }
.foto-drop p { font-size: 13.5px; }
.foto-drop p strong { color: var(--ink-2); }
.foto-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.foto-galeria {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.foto-thumb {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid var(--line);
  aspect-ratio: 1;
  animation: fadeSlideIn .4s var(--ease-out) both;
  animation-delay: var(--d, 0s);
}
.foto-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  cursor: zoom-in;
  transition: transform .25s var(--ease-out);
}
.foto-thumb:hover img { transform: scale(1.06); }
.foto-remover {
  position: absolute;
  top: 6px; right: 6px;
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(13, 22, 14, .72);
  color: #fff;
  backdrop-filter: blur(4px);
  transition: background .15s, transform .15s;
}
.foto-remover:hover { background: var(--red); transform: scale(1.08); }

/* ───────── Modal ───────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(13, 22, 14, .45);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .18s;
}
.modal-overlay.open { opacity: 1; }

.modal-panel {
  width: min(460px, 100%);
  max-height: min(86vh, 720px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: 0 24px 70px rgba(13, 22, 14, .35);
  transform: translateY(14px) scale(.97);
  transition: transform .22s var(--ease-out);
}
.modal-overlay.open .modal-panel { transform: none; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.modal-head h3 { font-size: 18px; font-weight: 800; }

.lightbox-img {
  max-width: min(88vw, 900px);
  max-height: 82vh;
  display: block;
  border-radius: 12px;
}
.modal-overlay:has(.lightbox-img) { padding: 0; }
.modal-overlay:has(.lightbox-img) .modal-panel {
  background: transparent;
  box-shadow: none;
  padding: 0;
  width: auto;
  max-height: none;
  overflow: visible;
}

/* ───────── Ficha do cliente (modal) ───────── */

.detail-title { display: flex; align-items: center; gap: 13px; }
.detail-title h3 { line-height: 1.15; }

.detail-grid { display: flex; flex-direction: column; }
.detail-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
}
.detail-row:last-child { border-bottom: none; }
.detail-row dt {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  padding-top: 2px;
}
.detail-row dd { font-size: 14.5px; font-weight: 600; word-break: break-word; }
.detail-row dd a { color: var(--pera-700); }

/* ───────── Venda: itens ───────── */

.venda-itens { margin-top: 22px; }
.venda-itens h4 { font-size: 15px; font-weight: 700; margin-bottom: 12px; }

.item-add {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 16px;
  background: #fafbf6;
  border: 1.5px dashed var(--line);
  border-radius: var(--r-md);
  margin-bottom: 14px;
}
.item-add .field { margin-bottom: 0; min-width: 130px; }

.venda-total {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 16px;
  padding: 14px 4px 2px;
  border-top: 1.5px solid var(--line);
  margin-top: 10px;
}
.venda-total span { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.venda-total strong {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: var(--pera-700);
  letter-spacing: -.02em;
}

/* ───────── Configurações ───────── */

.config-grid { display: flex; gap: 28px; flex-wrap: wrap; }
.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.logo-box { display: flex; flex-direction: column; gap: 10px; min-width: 220px; }
.logo-preview {
  display: grid;
  place-items: center;
  width: 220px;
  height: 120px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  overflow: hidden;
}
.logo-preview img { max-width: 92%; max-height: 92%; object-fit: contain; }

/* ───────── OS: header do card ───────── */

.os-head-right { display: flex; align-items: center; gap: 6px; }
.os-card .btn-print-os { opacity: 0; transition: opacity .18s; }
.os-card:hover .btn-print-os, .os-card:focus-within .btn-print-os { opacity: 1; }

/* ═══════════════ DOCUMENTOS (venda / OS) ═══════════════ */

.doc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 18px;
}

.doc-sheet {
  max-width: 860px;
  margin: 0 auto;
  padding: 46px 52px;
}

.doc { color: #17201a; font-size: 13.5px; line-height: 1.55; }

.doc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 2.5px solid #17201a;
  margin-bottom: 20px;
}
.doc-emp { display: flex; align-items: center; gap: 18px; }
.doc-logo { width: 130px; max-height: 76px; object-fit: contain; }
.doc-emp-dados { display: flex; flex-direction: column; gap: 1px; }
.doc-emp-dados strong { font-family: var(--font-display); font-size: 19px; letter-spacing: -.01em; }
.doc-emp-dados span { font-size: 12px; color: #4a544c; }

.doc-meta { text-align: right; flex-shrink: 0; }
.doc-meta h2 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .02em;
  margin-bottom: 4px;
}
.doc-meta span { display: block; font-size: 12px; color: #4a544c; }

.doc-partes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 20px;
}
.doc h3 {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #5a645c;
  margin-bottom: 5px;
}
.doc-partes p, .doc-bloco p { font-size: 13px; margin: 1px 0; }

.doc-bloco { margin-bottom: 16px; }

.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 18px;
}
.doc-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #5a645c;
  border-bottom: 1.5px solid #17201a;
  padding: 8px 10px;
}
.doc-table td { padding: 9px 10px; border-bottom: 1px solid #d9ded6; font-size: 13px; }
.doc-table .num { text-align: right; white-space: nowrap; }
.doc-table tfoot td {
  border-bottom: none;
  border-top: 2px solid #17201a;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  padding-top: 12px;
}

.doc-obs { margin-bottom: 18px; }

.doc-fotos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.doc-fotos img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border: 1px solid #d9ded6;
  border-radius: 6px;
}

.doc-assinaturas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  margin: 46px 20px 20px;
}
.doc-assinaturas span { display: block; border-bottom: 1.5px solid #17201a; height: 34px; }
.doc-assinaturas p { text-align: center; font-size: 11.5px; color: #4a544c; margin-top: 6px; }

.doc-foot {
  border-top: 1px solid #d9ded6;
  padding-top: 12px;
  text-align: center;
}
.doc-foot p { font-size: 11.5px; color: #5a645c; }

/* ───────── Financeiro ───────── */

.btn-danger {
  background: linear-gradient(135deg, #ef6b6f, #d33a3f);
  color: #fff;
  box-shadow: 0 2px 8px rgba(229, 72, 77, .3);
}
.btn-danger:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(229, 72, 77, .4); }

/* ───── Painel Master (admin) ───── */
#admin { min-height: 100vh; }
.admin-wrap { min-height: 100vh; background: var(--paper); display: flex; flex-direction: column; }
.admin-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: linear-gradient(178deg, var(--night-800), var(--night-900));
  color: #f2f7e8;
}
.admin-brand { display: flex; align-items: center; gap: 12px; }
.admin-brand .brand-mark { color: var(--pera-400); }
.admin-brand strong { font-family: var(--font-display); font-size: 18px; display: block; }
.admin-brand span { font-size: 12px; color: #9db396; }
.admin-top .btn-ghost { color: #cfe0c0; border-color: var(--night-line); }
.admin-tabs { display: flex; gap: 4px; padding: 0 24px; background: var(--night-900); border-bottom: 1px solid var(--night-line); }
.admin-tabs button {
  background: none; border: 0; color: #9db396; font-weight: 600; font-size: 14px;
  padding: 12px 16px; border-bottom: 2.5px solid transparent; cursor: pointer;
}
.admin-tabs button.active { color: #f2f7e8; border-bottom-color: var(--pera-400); }
.admin-main { max-width: 1080px; width: 100%; margin: 0 auto; padding: 28px 24px 60px; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.admin-stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.admin-stat-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.admin-stat strong { font-family: var(--font-display); font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-head h2 { font-size: 22px; }
.admin-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 20px; }
.admin-login { max-width: 420px; margin: 8vh auto 0; }
.admin-login h2 { font-size: 20px; margin-bottom: 4px; }
.admin-login form { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.admin-table-wrap { padding: 6px; overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
.admin-table td { padding: 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.btn-mini { padding: 6px 11px; font-size: 12.5px; }
@media (max-width: 640px) {
  .admin-main { padding: 18px 12px 40px; }
  .admin-table th:nth-child(3), .admin-table td:nth-child(3),
  .admin-table th:nth-child(5), .admin-table td:nth-child(5) { display: none; }
}

/* ───── Modal de confirmação ───── */
.confirm-box { text-align: center; padding: 6px 6px 2px; }
.confirm-ic {
  display: grid;
  place-items: center;
  width: 58px; height: 58px;
  margin: 0 auto 14px;
  border-radius: 50%;
}
.confirm-ic svg { width: 28px; height: 28px; }
.confirm-ic.perigo { background: var(--red-tint); color: var(--red); }
.confirm-ic.info { background: var(--blue-tint); color: var(--blue); }
.confirm-box h3 { font-size: 18px; margin-bottom: 6px; }
.confirm-box p { color: var(--ink-2); font-size: 14px; margin-bottom: 4px; }
.confirm-acoes {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.confirm-acoes .btn { flex: 1; justify-content: center; }

.val-pos { color: var(--pera-700); }
.val-neg { color: var(--red); }

.fin-filtros {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.fin-select {
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink-2);
}
.fin-select:focus { outline: none; border-color: var(--pera-500); }

.badge-btn {
  border: none;
  cursor: pointer;
  transition: transform .13s var(--ease-out), filter .13s;
}
.badge-btn:hover { transform: scale(1.06); filter: brightness(.95); }

.fin-totais td {
  border-bottom: none;
  border-top: 2px solid var(--line);
  font-size: 13.5px;
  padding-top: 14px;
  color: var(--ink-2);
}
.fin-totais strong { font-family: var(--font-display); font-size: 15px; }

/* termo de garantia no documento */
.doc-termo {
  background: #f7f8f4;
  border: 1px solid #e0e4da;
  border-radius: 8px;
  padding: 12px 14px;
}
.doc-termo p { font-size: 11px; line-height: 1.5; color: #3c463e; }

/* impressão */
#print-root { display: none; }

@media print {
  body { background: #fff; }
  .app, .login-wrap, .toast, .modal-overlay, .chart-tip { display: none !important; }
  #print-root { display: block; padding: 0; }
  #print-root .doc { font-size: 12.5px; }
  @page { margin: 16mm 14mm; }
}

/* ───────── Movimento reduzido ───────── */

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

/* ───────── Gráficos do financeiro ───────── */

.stat-value.sm { font-size: 18px; }

.fin-charts {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 900px) { .fin-charts { grid-template-columns: 1fr; } }

.fin-linha {
  stroke-dasharray: 1400;
  stroke-dashoffset: 1400;
  animation: linhaDesenha 1.4s .5s var(--ease-out) forwards;
}
@keyframes linhaDesenha { to { stroke-dashoffset: 0; } }

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.donut-svg { width: 165px; height: 165px; flex-shrink: 0; }
.donut-seg {
  opacity: 0;
  animation: fadeSlideIn .5s var(--ease-out) forwards;
  animation-delay: var(--dd, 0s);
}
.donut-legenda {
  list-style: none;
  flex: 1;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.donut-legenda li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
}
.donut-legenda i {
  width: 11px; height: 11px;
  border-radius: 3.5px;
  flex-shrink: 0;
}
.donut-legenda span { flex: 1; color: var(--ink-2); font-weight: 600; }
.donut-legenda strong { font-family: var(--font-display); font-size: 13.5px; }

/* ───────── Relatórios ───────── */

.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.export-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  animation: fadeSlideIn .5s var(--ease-out) both;
  animation-delay: var(--d, 0s);
  transition: border-color .18s, transform .18s var(--ease-out), box-shadow .18s;
}
.export-card:hover { border-color: var(--pera-400); transform: translateY(-2px); box-shadow: var(--shadow-1); }
.export-info { flex: 1; min-width: 0; }
.export-info h4 { font-size: 14.5px; margin-bottom: 2px; }
.export-info p { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.export-card .btn { white-space: nowrap; padding: 9px 14px; font-size: 13.5px; }

.backup-row {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.backup-info { flex: 1; min-width: 260px; }
.backup-info p { margin-bottom: 6px; font-size: 14px; }
.backup-acoes { display: flex; gap: 10px; flex-wrap: wrap; }

/* ───────── Portal do cliente ───────── */

.portal-wrap { justify-content: flex-start; padding: 40px 16px; overflow-y: auto; }

.portal-panel {
  position: relative;
  z-index: 2;
  width: 100%;
  background: rgba(255, 255, 255, .97);
  border-radius: 26px;
  padding: 36px 34px 30px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  animation: loginIn .7s var(--ease-out) both;
}

.portal-brand { text-align: center; margin-bottom: 24px; }
.portal-logo { max-width: 190px; max-height: 84px; object-fit: contain; }
.portal-brand h1 { font-size: 26px; }

.portal-intro { font-size: 13.5px; color: var(--ink-2); margin-bottom: 16px; line-height: 1.55; }

.portal-links {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  font-size: 13.5px;
}
.portal-links a { color: var(--pera-700); font-weight: 700; text-decoration: none; }
.portal-links a:hover { text-decoration: underline; }

.portal-equipa {
  display: block;
  text-align: center;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
  text-decoration: none;
}
.portal-equipa:hover { color: var(--ink-2); }

.portal-cta {
  display: block;
  text-align: center;
  margin-top: 16px;
  padding: 11px 12px;
  border-radius: var(--r-sm);
  background: var(--pera-tint);
  color: var(--pera-700);
  font-size: 13.5px;
  text-decoration: none;
  transition: background .15s;
}
.portal-cta:hover { background: var(--pera-tint-2); }

.portal-head-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1.5px solid var(--line);
}
.portal-head-user strong { display: block; font-family: var(--font-display); font-size: 17px; }

.portal-os-lista { display: flex; flex-direction: column; gap: 14px; }

.portal-os {
  border: 1.5px solid var(--line);
  border-left-width: 4.5px;
  border-radius: var(--r-md);
  padding: 16px 17px 14px;
  animation: fadeSlideIn .5s var(--ease-out) both;
  animation-delay: var(--d, 0s);
}
.portal-os.status-aberta    { border-left-color: var(--blue); }
.portal-os.status-pecas     { border-left-color: var(--amber); }
.portal-os.status-andamento { border-left-color: var(--pera-500); }
.portal-os.status-concluida { border-left-color: var(--pera-700); }
.portal-os.status-entregue  { border-left-color: #b9c2ae; }

.portal-os header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.portal-os h4 { font-size: 15.5px; margin-bottom: 8px; }
.portal-os footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.portal-diag { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.portal-os .os-fotos-strip { margin-top: 10px; }

.portal-sec {
  font-family: var(--font-display);
  font-size: 15px;
  margin: 22px 0 12px;
  padding-top: 16px;
  border-top: 1.5px solid var(--line);
}
.portal-os.portal-compra { border-left-color: var(--pera-500); }
.portal-compra-itens { list-style: none; margin: 6px 0 0; padding: 0; }
.portal-compra-itens li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  padding: 3px 0;
}
.portal-compra-itens li span:last-child { color: var(--ink-2); white-space: nowrap; }

.portal-passos {
  display: flex;
  align-items: center;
  margin: 4px 0 10px;
}
.portal-passos .passo {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--line);
  flex-shrink: 0;
  transition: background .3s;
}
.portal-passos .passo.feito { background: var(--pera-500); box-shadow: 0 0 0 3px var(--pera-tint); }
.portal-passos i {
  flex: 1;
  height: 2.5px;
  background: var(--line);
  margin: 0 3px;
}

/* ───────── Modal financeiro ───────── */

.fin-modal-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}
.modal-foot-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* ═══════════════ RESPONSIVO ═══════════════ */

/* Tablet e ecrãs médios */
@media (max-width: 900px) {
  /* Sidebar vira menu deslizante (off-canvas) */
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    width: 264px;
    max-width: 84vw;
    transform: translateX(-100%);
    transition: transform .28s var(--ease-out);
    box-shadow: 0 0 40px rgba(0, 0, 0, .3);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .sidebar-backdrop { display: block; }
  .menu-toggle { display: flex; }

  .view, .topbar { padding-left: 18px; padding-right: 18px; }
  .form-grid .span-2 { grid-column: span 1; }
  .widget-grid { grid-template-columns: 1fr; }
  .os-grid { grid-template-columns: repeat(auto-fill, minmax(265px, 1fr)); }
  .doc-sheet { padding: 30px 26px; }
}

/* Celular */
@media (max-width: 640px) {
  body { font-size: 14.5px; }

  .topbar { padding: 14px 12px 0; }
  .topbar-title h2 { font-size: 19px; }
  .crumb { display: none; }
  .greet { display: none; }
  .avatar { width: 36px; height: 36px; font-size: 15px; }

  .view { padding: 14px 12px 30px; }

  /* inputs a 16px evitam o zoom automático do iOS */
  .field input, .field select, .field textarea, .search-box input { font-size: 16px; }

  .stat-row, .stat-row-3 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 14px; gap: 10px; flex-direction: column; align-items: flex-start; }
  .stat-icon { width: 40px; height: 40px; border-radius: 12px; }
  .stat-value { font-size: 19px; }
  .stat-label { font-size: 12px; }

  .panel { border-radius: 16px; }
  .panel-head, .panel-body { padding-left: 14px; padding-right: 14px; }
  .list-tools { flex-direction: column; align-items: stretch; padding: 14px 14px 6px; }
  .list-tools .btn { justify-content: center; }
  .search-box input { width: 100%; }
  .os-filter { justify-content: flex-start; }
  .fin-filtros { width: 100%; }
  .fin-filtros .search-box { flex: 1; }
  .fin-filtros .search-box input { width: 100%; }

  thead th, tbody td { padding: 9px 8px; font-size: 13px; }

  .service-grid, .os-grid { grid-template-columns: 1fr; }

  .item-add { flex-direction: column; align-items: stretch; }
  .item-add .field, .item-add .btn { width: 100%; min-width: 0; }
  .item-add .btn { justify-content: center; }
  .venda-total strong { font-size: 22px; }

  .form-foot { flex-direction: column-reverse; align-items: stretch; }
  .form-foot .btn { justify-content: center; }
  .field-inline { flex-direction: column; align-items: stretch; }

  .detail-row { grid-template-columns: 1fr; gap: 2px; padding: 8px 2px; }

  /* modal em folha inferior */
  .modal-overlay { align-items: flex-end; padding: 0; display: flex; }
  .modal-panel {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    border-radius: 22px 22px 0 0;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateY(40px);
  }
  .modal-overlay.open .modal-panel { transform: none; }
  .modal-foot-info { flex-direction: column; align-items: stretch; }
  .modal-foot-info .form-foot { flex-direction: column-reverse; }

  .doc-toolbar { flex-direction: column; align-items: stretch; }
  .doc-toolbar > div { display: flex; flex-direction: column; gap: 8px; }
  .doc-toolbar .btn { justify-content: center; }
  .doc-sheet { padding: 22px 16px; }
  .doc-head { flex-direction: column; }
  .doc-meta { text-align: left; }
  .doc-partes { grid-template-columns: 1fr; gap: 14px; }
  .doc-assinaturas { gap: 24px; margin: 34px 4px 14px; }

  .config-grid { flex-direction: column; }
  .logo-preview { width: 100%; }

  .foto-btns { width: 100%; }
  .foto-btns .btn { flex: 1; justify-content: center; }
  .foto-galeria { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }

  .pager { justify-content: center; }
  .pager-info { width: 100%; text-align: center; }

  .toast { width: calc(100vw - 32px); text-align: center; }
}
