:root {
  --brand: #1155cc; --brand-ink: #fff; --bg: #f4f6fa; --card: #fff; --ink: #1c2430; --muted: #5d6b7e; --line: #dfe4ec;
  --ok: #17803d; --ok-bg: #e6f5ec; --warn: #a15c00; --warn-bg: #fff3dc; --danger: #b42318; --danger-bg: #fde8e6; --info-bg: #e8effc; --paused: #6b3fa0; --paused-bg: #f0e9fa;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.45; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
a { color: var(--brand); }
.boot { padding: 2rem; color: var(--muted); }
.muted { color: var(--muted); }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.stack > * + * { margin-top: .9rem; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 2rem; border-top: 5px solid var(--brand); }
.login-card h1 { color: var(--brand); }
.brand-mark { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.2rem; }
.brand-mark img { max-height: 40px; }
.profile-option { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin-top: .6rem; cursor: pointer; font: inherit; color: inherit; }
.profile-option:hover, .profile-option:focus-visible { border-color: var(--brand); outline: 2px solid var(--info-bg); }
.profile-option strong { display: block; } .profile-option span { color: var(--muted); font-size: .9rem; }

/* shell */
.topbar { background: var(--brand); color: var(--brand-ink); display: flex; align-items: center; gap: 1rem; padding: .6rem 1.2rem; flex-wrap: wrap; }
.topbar .title { font-weight: 700; font-size: 1.05rem; }
.topbar .client { opacity: .85; font-size: .9rem; }
.topbar .spacer { flex: 1; }
.topbar select, .topbar .btn { background: rgba(255,255,255,.14); color: var(--brand-ink); border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: .35rem .6rem; font: inherit; }
.topbar select option { color: #111; }
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100vh - 52px); }
.sidenav { background: var(--card); border-right: 1px solid var(--line); padding: .8rem; }
.sidenav h4 { margin: 1rem .4rem .3rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sidenav a { display: block; padding: .5rem .7rem; border-radius: 8px; color: var(--ink); text-decoration: none; }
.sidenav a:hover { background: var(--bg); }
.sidenav a.active { background: var(--info-bg); color: var(--brand); font-weight: 600; }
.content { padding: 1.2rem 1.5rem 3rem; min-width: 0; max-width: 1400px; }
.menu-toggle { display: none; }

/* cards e formulários */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; }
.card + .card { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field { display: block; } .field .label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
.field .hint { color: var(--muted); display: block; margin-top: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid #c4ccd8; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #9ec0ff; outline-offset: 1px; }
.check { display: flex; align-items: center; gap: .5rem; } .check input { width: 1.05rem; height: 1.05rem; }
.btn { border: 1px solid transparent; border-radius: 8px; padding: .55rem .95rem; font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: transparent; border-color: #b9c3d3; color: var(--ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: wait; }
.icon-btn { background: none; border: 0; font-size: 1.5rem; cursor: pointer; line-height: 1; color: var(--muted); }
.error-box { background: var(--danger-bg); color: var(--danger); border: 1px solid #f3b8b2; border-radius: 8px; padding: .6rem .8rem; margin: .6rem 0; }
.info-box { background: var(--info-bg); border-radius: 8px; padding: .6rem .8rem; margin: .6rem 0; }
.secret-box { background: #fffbe6; border: 1px dashed #d9b400; padding: .7rem .9rem; border-radius: 8px; font-family: ui-monospace, Menlo, monospace; word-break: break-all; }

/* tabela */
.tbl-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.tbl { border-collapse: collapse; width: 100%; font-size: .93rem; }
.tbl th { text-align: left; background: #f8f9fc; padding: .6rem .7rem; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.tbl td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr.clickable { cursor: pointer; } .tbl tr.clickable:hover { background: #f5f8ff; }
.tbl td.empty { text-align: center; color: var(--muted); padding: 2rem; }
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--info-bg); color: var(--brand); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); } .badge.muted { background: #eceff4; color: var(--muted); } .badge.paused { background: var(--paused-bg); color: var(--paused); }

/* painel */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.kpi .n { font-size: 1.9rem; font-weight: 700; } .kpi .l { color: var(--muted); font-size: .85rem; }
.bar-row { display: grid; grid-template-columns: 170px 1fr 40px; gap: .5rem; align-items: center; margin: .3rem 0; font-size: .9rem; }
.bar { background: #e9edf4; border-radius: 6px; height: 12px; overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--brand); }

/* chamado */
.ticket-head { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: baseline; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 3px solid var(--line); padding: .3rem 0 .8rem .9rem; position: relative; }
.timeline li.staff { border-color: var(--brand); } .timeline li.internal { border-color: #d9b400; background: #fffdf0; }
.timeline .meta { font-size: .8rem; color: var(--muted); }
.timeline .text { white-space: pre-wrap; word-break: break-word; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: .25rem .75rem; font-size: .93rem; } .kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: .55rem .9rem; font: inherit; cursor: pointer; border-bottom: 3px solid transparent; color: var(--muted); }
.tabs button.active { color: var(--brand); border-color: var(--brand); font-weight: 600; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; align-items: end; margin-bottom: 1rem; }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: .8rem; }

/* modal e toast */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; z-index: 50; padding: 1rem; overflow: auto; }
.modal { background: var(--card); border-radius: 12px; width: 100%; max-width: 640px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); } .modal-head h3 { margin: 0; }
.modal-body { padding: 1rem 1.1rem; max-height: 70vh; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; padding: .8rem 1.1rem; border-top: 1px solid var(--line); }
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translate(-50%, 20px); background: #1c2430; color: #fff; padding: .7rem 1.1rem; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 80; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); } .toast.error { background: var(--danger); } .toast.ok { background: #14532d; }
.cond-row { display: grid; grid-template-columns: 1.2fr .9fr 1.6fr auto; gap: .4rem; margin-bottom: .4rem; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .3rem .8rem; }
.week-row { display: grid; grid-template-columns: 90px 1fr; gap: .5rem; align-items: center; margin-bottom: .35rem; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidenav { display: none; } .sidenav.open { display: block; border-bottom: 1px solid var(--line); }
  .menu-toggle { display: inline-block; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
  .bar-row { grid-template-columns: 110px 1fr 36px; }
  .cond-row { grid-template-columns: 1fr; }
  .tbl.stackable thead { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* workflows de e-mail */
textarea.mono, .preview { font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace; font-size: 0.85rem; }
.preview { background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 12px; white-space: pre-wrap; word-break: break-word; margin: 0; max-height: 320px; overflow: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-family: ui-monospace, Consolas, monospace; font-size: 0.78rem; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.chip:hover, .chip:focus-visible { background: #eef3ff; border-color: #1155cc; outline: none; }
.notice { background: var(--warn-bg, #fff6e0); color: var(--warn, #8a5a00); border-radius: 8px; padding: 10px 14px; }
