:root {
  --bg: #0d0e11; --bg2: #121419; --card: #1a1d23; --card2: #20242c; --border: #2a2f38; --text: #eef1f6; --muted: #98a0ad;
  --a: #ff6d00; --b: #c2410c; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171; --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 20px; --glass: rgba(13,14,17,.72);
}
[data-theme="light"] {
  --bg: #f3f4f7; --bg2: #eceef3; --card: #fff; --card2: #f7f8fb; --border: #e3e6ec; --text: #171a21; --muted: #667085;
  --a: #ff7a1a; --b: #e64a00; --shadow: 0 10px 30px rgba(20,24,40,.08); --glass: rgba(243,244,247,.8);
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626;
}
[data-theme="colorful"] {
  --bg: #f1e9ff; --bg2: #e8dcff; --card: #fff; --card2: #faf6ff; --border: #dccbff; --text: #231a3a; --muted: #6b5b8a;
  --a: #7c3aed; --b: #ec4899; --shadow: 0 12px 34px rgba(124,58,237,.16); --glass: rgba(241,233,255,.82);
  --ok: #059669; --warn: #d97706; --bad: #e11d48;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; color: inherit; }
h1, h2, h3, h4 { margin: 0; }
svg { width: 1.1em; height: 1.1em; vertical-align: -0.17em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* topbar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--glass); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
.topbar .wrap { display: flex; align-items: center; gap: 12px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; letter-spacing: .4px; font-size: 18px; }
.logo { width: 36px; height: 36px; border-radius: 12px; background: linear-gradient(135deg, var(--a), var(--b)); display: grid; place-items: center; color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--a) 45%, transparent); }
.spacer { flex: 1; }
.seg { display: flex; background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg button { background: transparent; border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.seg button.on { background: linear-gradient(135deg, var(--a), var(--b)); color: #fff; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--a); object-fit: cover; background: var(--card); display: grid; place-items: center; font-weight: 800; cursor: pointer; padding: 0; overflow: hidden; }
.menu { position: absolute; right: 18px; top: 60px; width: 270px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 14px; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }

/* hero */
.hero { background: radial-gradient(1200px 400px at 90% -10%, rgba(255,255,255,.22), transparent 60%), linear-gradient(135deg, var(--a), var(--b)); color: #fff; padding: 30px 0 36px; border-radius: 0 0 34px 34px; }
.hero h1 { font-size: clamp(24px, 4vw, 34px); font-weight: 800; }
.hero p { margin: 6px 0 0; opacity: .92; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.2); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 700; margin-top: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 22px; }
.stat { background: rgba(255,255,255,.17); border: 1px solid rgba(255,255,255,.22); border-radius: 18px; padding: 14px 16px; }
.stat b { display: block; font-size: 28px; line-height: 1.1; margin-top: 6px; }
.stat span { font-size: 13px; opacity: .92; }

/* controls */
.tools { display: flex; gap: 10px; flex-wrap: wrap; margin: 22px 0 6px; align-items: center; }
.search { flex: 1 1 280px; position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; padding: 14px 16px 14px 42px; border-radius: 16px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 16px; outline: none; }
.search input:focus { border-color: var(--a); box-shadow: 0 0 0 3px color-mix(in srgb, var(--a) 25%, transparent); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.fchip { border: 1px solid var(--border); background: var(--card); border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 600; color: var(--muted); }
.fchip.on { background: var(--a); border-color: var(--a); color: #fff; }
.fchip small { opacity: .8; margin-left: 4px; }
select.sort { border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 14px; padding: 11px 12px; font: inherit; }

/* cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.section { font-weight: 800; margin: 24px 4px 12px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; padding-bottom: 80px; }
.vcard { padding: 16px; display: flex; gap: 14px; text-align: left; width: 100%; cursor: pointer; position: relative; overflow: hidden; transition: transform .15s, border-color .15s; }
.vcard:hover { transform: translateY(-3px); border-color: var(--a); }
.vcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--lvl, var(--muted)); }
.vimg { width: 78px; height: 78px; border-radius: 18px; background: linear-gradient(135deg, var(--a), var(--b)); display: grid; place-items: center; color: #fff; overflow: hidden; flex: none; font-size: 32px; }
.vimg img { width: 100%; height: 100%; object-fit: cover; }
.vname { font-weight: 800; font-size: 17px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.plate { display: inline-block; background: #fff; color: #111; border: 1.5px solid #222; border-radius: 6px; font-family: ui-monospace, SFMono-Regular, monospace; font-weight: 800; letter-spacing: 1.3px; font-size: 13px; padding: 0 9px; border-top: 6px solid #1e4db7; line-height: 1.5; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 11px; font-size: 12px; font-weight: 700; border: 1px solid; }
.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 13%, transparent); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.none { color: var(--muted); border-color: var(--border); }
.btn { display: inline-flex; align-items: center; gap: 8px; background: linear-gradient(135deg, var(--a), var(--b)); color: #fff; border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 700; box-shadow: 0 8px 20px color-mix(in srgb, var(--a) 35%, transparent); }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn:hover { filter: brightness(1.07); }
.alert { border-left: 5px solid var(--warn); padding: 14px 16px; margin-top: 18px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.alert.bad { border-left-color: var(--bad); }

/* login */
.login { min-height: calc(100vh - 62px); display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 860px; display: grid; grid-template-columns: 1.1fr 1fr; overflow: hidden; }
.login-art { background: radial-gradient(600px 300px at 80% 0%, rgba(255,255,255,.25), transparent 60%), linear-gradient(145deg, var(--a), var(--b)); color: #fff; padding: 36px; display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.login-art li { margin: 6px 0; list-style: none; display: flex; gap: 10px; align-items: center; }
.login-art ul { padding: 0; margin: 8px 0 0; }
.login-form { padding: 36px; display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.gbtn { display: flex; align-items: center; justify-content: center; gap: 12px; background: #fff; color: #222; border: 1px solid #dadce0; border-radius: 14px; padding: 13px 18px; font-weight: 700; font-size: 16px; }
.gbtn:hover { box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.gbtn svg { width: 20px; height: 20px; stroke: none; }
.notice { background: color-mix(in srgb, var(--warn) 14%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); border-radius: 12px; padding: 10px 12px; font-size: 14px; }

/* detail */
.crumb { background: none; border: 0; padding: 18px 0 10px; font-weight: 700; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.vhead { padding: 20px; display: flex; gap: 20px; flex-wrap: wrap; align-items: center; }
.vhead .vimg { width: 110px; height: 110px; border-radius: 24px; font-size: 44px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; flex: 1; min-width: 240px; }
.fact { background: var(--card2); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
.fact span { display: block; font-size: 12px; color: var(--muted); }
.fact b { font-size: 16px; }
.bar { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--lvl, var(--ok)); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.timeline { position: relative; padding-left: 8px; }
.timeline::before { content: ""; position: absolute; left: 27px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.month { margin: 18px 0 10px 56px; font-weight: 800; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .6px; }
.rec { display: flex; gap: 14px; margin-bottom: 12px; position: relative; }
.dot { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--card); border: 2px solid currentColor; z-index: 1; margin-left: 0; }
.rec .card { flex: 1; padding: 14px 16px; min-width: 0; }
.rec h4 { font-size: 16px; }
.rec p { margin: 8px 0 0; white-space: pre-wrap; line-height: 1.45; }
.next { font-weight: 700; font-size: 13px; margin-top: 8px; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.photo { width: 92px; height: 92px; border-radius: 14px; border: 1px solid var(--border); object-fit: cover; cursor: zoom-in; background: var(--card2); display: grid; place-items: center; color: var(--muted); font-size: 22px; }
.skeleton { animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .45; } }
.side .card { padding: 16px; margin-bottom: 14px; }
.side h3 { font-size: 15px; margin-bottom: 10px; }
.chart { display: flex; align-items: flex-end; gap: 8px; height: 110px; }
.chart div { flex: 1; text-align: center; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.chart i { display: block; background: linear-gradient(180deg, var(--a), var(--b)); border-radius: 6px 6px 0 0; min-height: 3px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 46px; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); display: grid; place-items: center; z-index: 60; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 10px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111827; color: #fff; padding: 12px 18px; border-radius: 14px; box-shadow: var(--shadow); z-index: 70; font-size: 14px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 0 40px; }

.print-head { display: none; }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .login-box { grid-template-columns: 1fr; }
  .seg button span { display: none; }
}
@media print {
  @page { margin: 14mm; }
  html, body { background: #fff !important; color: #000 !important; }
  .topbar, .hero, .actions, .tabs, .crumb, .tools, .side, .footer, .no-print, .menu { display: none !important; }
  .print-head { display: block; border-bottom: 3px solid #ff6d00; padding-bottom: 10px; margin-bottom: 16px; }
  .print-head h2 { font-size: 22px; }
  .layout { display: block; }
  .card { box-shadow: none !important; border: 1px solid #bbb !important; background: #fff !important; break-inside: avoid; }
  .muted, .fact span { color: #444 !important; }
  .timeline::before { display: none; }
  .dot { display: none; }
  .month { margin-left: 0; color: #000; }
  .photo { width: 70px; height: 70px; }
  .vhead { box-shadow: none; }
}

/* edição */
.iconbtn { background: var(--card2); border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px; color: var(--muted); line-height: 1; }
.iconbtn:hover { color: var(--text); border-color: var(--a); }
.rec .card { position: relative; }
.rec .card > .iconbtn { position: absolute; right: 12px; top: 12px; }
.rec .card h4 { padding-right: 44px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.panel { width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 20px; }
.ptitle { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panel > .form > .fld:nth-child(-n+2), .form > p, .form > .sub { grid-column: 1 / -1; }
.form .form { grid-column: 1 / -1; padding: 0; }
.fld { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.fld input, .fld select, .fld textarea { background: var(--card2); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; font: inherit; font-size: 15px; outline: none; width: 100%; }
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--a); box-shadow: 0 0 0 3px color-mix(in srgb, var(--a) 22%, transparent); }
.fld:has(textarea) { grid-column: 1 / -1; }
.sub { margin: 4px 0 0; font-size: 14px; }
.pactions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.btn.danger { color: var(--bad); }
@media (max-width: 560px) { .form { grid-template-columns: 1fr; } }

/* fotos e cliente */
.xwrap { position: relative; display: inline-block; }
.xbtn { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: #ef4444; color: #fff; border: 0; font-size: 11px; line-height: 1; z-index: 2; }
.fld.pp, .pp { grid-column: 1 / -1; }
.crow { display: flex; gap: 14px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; }
.crow:last-of-type { border-bottom: 0; }
.crow > svg { width: 1.3em; height: 1.3em; color: var(--a); }
.crow b { display: block; }
a.crow:hover { background: var(--card2); border-radius: 12px; }

/* suporte / chat */
.support { display: grid; gap: 12px; min-width: min(560px, 80vw); }
.support .row { display: flex; gap: 8px; align-items: center; }
.support .tktitle { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tickets { display: grid; gap: 8px; }
.tk { text-align: left; background: var(--card2, var(--card)); border: 1px solid var(--line, rgba(128,128,128,.25)); border-radius: 14px; padding: 12px; color: inherit; cursor: pointer; font: inherit; }
.tk:hover { border-color: var(--a); }
.unread { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #ef4444; margin-left: 8px; }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; min-height: 180px; overflow-y: auto; padding: 4px; }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.bubble small { display: block; opacity: .7; font-size: 11px; }
.bubble.me { align-self: flex-end; background: var(--a); color: #fff; }
.bubble.adm { align-self: flex-start; background: var(--card2, rgba(128,128,128,.18)); }
.compose { display: flex; gap: 8px; align-items: flex-end; }
.compose textarea { flex: 1; }

/* ===== ajustes de layout: nada pode estourar a tela ===== */
html, body { overflow-x: hidden; max-width: 100%; }
.panel { box-sizing: border-box; overflow-x: hidden; }
.form > *, .support > *, .pp, .fld { min-width: 0; }
.fld input, .fld select, .fld textarea { max-width: 100%; box-sizing: border-box; }
.support { min-width: 0; width: 100%; }
.support > .btn { justify-self: start; max-width: 100%; }
.tickets, .tk { width: 100%; box-sizing: border-box; }
.tk { overflow-wrap: anywhere; }
.compose { min-width: 0; }
.compose textarea { min-width: 0; width: 100%; box-sizing: border-box; background: var(--card2); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font: inherit; resize: vertical; }
.chat { box-sizing: border-box; width: 100%; }
.pactions { min-width: 0; }
.btn { max-width: 100%; }
@media (max-width: 640px) {
  .modal { padding: 8px; align-items: end; }
  .panel { max-height: 94vh; border-radius: 22px 22px 14px 14px; padding: 16px; }
  .pactions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ===== perfil: foto com botão de câmera ===== */
.avatar-edit { grid-column: 1 / -1; display: grid; justify-items: center; gap: 10px; padding: 4px 0 8px; }
.avatar-wrap { position: relative; width: 104px; height: 104px; }
.avatar.big { width: 104px; height: 104px; font-size: 40px; border-width: 3px; }
.avatar-wrap .cam { position: absolute; right: -2px; bottom: -2px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; padding: 0; border: 3px solid var(--card); background: linear-gradient(135deg, var(--a), var(--b)); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
.avatar-wrap .cam:hover { filter: brightness(1.08); }
.avatar-links { display: flex; gap: 8px; align-items: center; }
.link { background: none; border: 0; padding: 4px 6px; color: var(--a); font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--bad); }
