/* Identidade visual Salva Beauty
   Paleta oficial: Red Help #C7080D · Red Margot #680A08 · Creamy #FFF3E3 · Ocean Grey #869197 · Grafite #222B32 */
:root {
  --red: #C7080D;          /* Red Help: ações principais */
  --red-dark: #680A08;     /* Red Margot: títulos, menu ativo, hover */
  --cream: #FFF3E3;        /* Creamy: fundo */
  --grey: #869197;         /* Ocean Grey: detalhes e bordas */
  --ink: #222B32;          /* Grafite: texto */

  --bg: var(--cream);
  --card: #fff;
  --line: #E8DCCB;         /* Creamy mais escuro */
  --muted: #566168;        /* Ocean Grey escurecido (contraste para texto) */
  --ok: #17663a; --ok-bg: #dff4e6;
  --warn: #7a4a00; --warn-bg: #ffe9b8;
  --danger: var(--red-dark); --danger-bg: #fbdcda;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(34,43,50,.06), 0 4px 14px rgba(34,43,50,.05);
}
* { box-sizing: border-box; }
html { font-size: 17px; }
body { margin: 0; font: 1rem/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.2; color: var(--red-dark); letter-spacing: .01em; }
h2 { font-size: 1.7rem; font-weight: 700; }
h3 { font-size: 1.2rem; font-weight: 650; }
a { color: var(--red); text-underline-offset: 3px; }
a:hover { color: var(--red-dark); }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.right { margin-left: auto; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }

/* ---------- Topo: logo + nome do sistema + menu ---------- */
.topbar { background: #fff; border-bottom: 4px solid var(--red); position: sticky; top: 0; z-index: 10; box-shadow: var(--shadow); }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; gap: 20px; align-items: center; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-decoration: none; flex: 0 0 auto; }
.brand img { height: 36px; width: auto; display: block; }
.brand .sys { font-size: .74rem; font-weight: 700; line-height: 1; color: var(--red-dark); text-transform: uppercase; letter-spacing: .3em; padding-left: 2px; white-space: nowrap; }
.nav { display: flex; gap: 6px; margin-left: 10px; }
.nav a { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 1.05rem; }
.ic { display: inline-flex; flex: 0 0 auto; }
.nav a svg, .btn svg { width: 1.25em; height: 1.25em; flex: 0 0 auto; }
.nav a:hover { background: var(--cream); color: var(--red-dark); }
.nav a.active { background: var(--red-dark); color: #fff; }
.top-actions { display: flex; gap: 8px; margin-left: auto; }

main { max-width: 1180px; margin: 0 auto; padding: 26px 20px 80px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 1rem; }

/* ---------- Cartões e grades ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--grey); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .n { font-size: 1.85rem; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.stat.danger { border-left-color: var(--red); }
.stat.danger .n { color: var(--red); }
.stat.warn { border-left-color: #E8A317; }
.stat.warn .n { color: var(--warn); }
.stat.good { border-left-color: var(--ok); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 20px; }
.grid2 > .card { margin-bottom: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 22px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.quick { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 13px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
td.actions > * + * { margin-left: 8px; }
tr.row-link { cursor: pointer; }
tr.row-link:hover { background: #fffaf3; }
tr.faded td, .faded { opacity: .6; }

/* ---------- Botões e campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; font: inherit; font-weight: 600; border: 1.5px solid #cfc3b3; background: #fff; color: var(--ink); min-height: 44px; padding: 8px 18px; border-radius: 10px; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--cream); border-color: var(--red-dark); color: var(--red-dark); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); border-color: var(--red-dark); color: #fff; }
.btn.danger { color: var(--red-dark); border-color: #e3aaa6; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.whats { color: #0b6b3a; border-color: #9fd3b4; }
.btn.whats:hover { background: var(--ok-bg); border-color: #0b6b3a; color: #0b6b3a; }
.btn.sm { min-height: 38px; padding: 5px 13px; font-size: .95rem; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; width: 100%; min-height: 46px; padding: 9px 12px; border: 1.5px solid #cfc3b3; border-radius: 10px; background: #fff; color: var(--ink); }
textarea { min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(199,8,13,.35); outline-offset: 0; border-color: var(--red); }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--red); }
.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; margin-bottom: 5px; }
.field .hint { font-size: .88rem; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 12px; align-items: center; }
.row > * { flex: 1; min-width: 0; }
.row > .fixed { flex: 0 0 auto; }
.field > label.check, .check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.search { max-width: 420px; }
.error { color: var(--red-dark); background: var(--danger-bg); border: 1px solid #efb3af; padding: 10px 14px; border-radius: 10px; margin: 10px 0; font-weight: 500; }

/* ---------- Selos ---------- */
.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: .88rem; font-weight: 700; 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(--red-dark); }
.badge.muted { background: #ece6dd; color: var(--muted); }

/* ---------- Serviços do ciclo ---------- */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 14px; }
.svc { border: 1.5px solid var(--line); border-radius: 12px; padding: 14px; background: #fffdf9; }
.svc .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 1.05rem; }
.svc .top span { font-weight: 700; color: var(--red-dark); font-size: 1.2rem; }
.svc progress { width: 100%; height: 12px; margin: 8px 0 12px; accent-color: var(--red); }
.svc.full { background: #f6efe6; }
.svc.over { border-color: var(--red); }
.svc.over progress { accent-color: var(--red-dark); }
details summary { cursor: pointer; font-weight: 600; color: var(--red-dark); padding: 10px 0; }

/* ---------- Anotações ---------- */
.note { border-left: 4px solid var(--red); padding: 10px 14px; margin-bottom: 12px; background: #fffaf3; border-radius: 0 10px 10px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.note .meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: .88rem; color: var(--muted); margin-top: 6px; white-space: normal; }

/* ---------- Janela (modal) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(34,43,50,.55); display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; z-index: 30; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; padding: 24px; border-top: 6px solid var(--red); }
.modal.wide { max-width: 700px; }
.modal-head { display: flex; align-items: center; margin-bottom: 18px; }
.modal-head .x { margin-left: auto; border: 0; background: none; font-size: 1.8rem; line-height: 1; cursor: pointer; color: var(--muted); width: 44px; height: 44px; border-radius: 10px; }
.modal-head .x:hover { background: var(--cream); color: var(--red-dark); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- Entrada (login) ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at 20% 10%, #fff 0, var(--cream) 55%, #f3e3cc 100%); }
.login { width: 100%; max-width: 440px; text-align: center; padding: 34px 30px 30px; border-top: 6px solid var(--red); margin: 0; }
.login .logo { width: 210px; max-width: 70%; height: auto; display: block; margin: 0 auto 18px; }
.login h2 { font-size: 1.45rem; margin-bottom: 4px; }
.login .field { text-align: left; }
.login .btn { width: 100%; margin-top: 6px; min-height: 50px; font-size: 1.1rem; }
.empty { color: var(--muted); padding: 18px 0; font-size: 1.05rem; }

/* ---------- Mensagens ---------- */
.msg-modal textarea { line-height: 1.5; margin: 6px 0 4px; }
.msg-modal .intro { background: var(--cream); border-left: 4px solid var(--red); padding: 10px 14px; border-radius: 8px; margin: 0 0 8px; }
.tpl summary { cursor: pointer; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 1.08rem; }
.tpl textarea { line-height: 1.5; margin: 10px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.chip { font: inherit; font-size: .88rem; padding: 4px 10px; border-radius: 999px; border: 1.5px solid #cfc3b3; background: #fff; cursor: pointer; color: var(--ink); }
.chip:hover { border-color: var(--red); color: var(--red-dark); }
.preview { white-space: pre-wrap; font: inherit; background: #e7f6e3; border-radius: 12px; padding: 14px 16px; margin: 6px 0 0; max-width: 520px; line-height: 1.5; }

/* ---------- Telas médias ---------- */
@media (max-width: 1000px) {
  .nav a { padding: 10px 12px; gap: 7px; font-size: 1rem; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Celular: menu fixo embaixo, tabelas viram cartões ---------- */
@media (max-width: 760px) {
  html { font-size: 16.5px; }
  .topbar-in { padding: 8px 14px; gap: 10px; }
  .brand img { height: 30px; }
  .brand .sys { font-size: .62rem; letter-spacing: .24em; }
  .top-actions .btn .lbl { display: none; }
  .top-actions .btn { padding: 8px 11px; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; gap: 0; background: #fff; border-top: 3px solid var(--red); z-index: 20; padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(34,43,50,.12); }
  .nav a { flex: 1; flex-direction: column; gap: 3px; border-radius: 0; padding: 9px 4px 8px; font-size: .8rem; text-align: center; }
  .nav a svg { width: 26px; height: 26px; }
  main { padding: 18px 14px 110px; }
  h2 { font-size: 1.45rem; }
  .card { padding: 16px; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { margin-top: 10px; font-size: .88rem; }
  .row { flex-wrap: wrap; }
  .modal { padding: 18px; }
  .stat .n { font-size: 1.5rem; }

  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { display: none; }
  table.stack tr { border: 1.5px solid var(--line); border-radius: 12px; padding: 6px 12px; margin-bottom: 12px; background: #fffdf9; }
  table.stack td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; font-weight: 600; text-align: left; flex: 0 0 auto; }
  table.stack td[data-label=""]::before { display: none; }
  table.stack td:empty { display: none; }
  table.stack td.actions { justify-content: flex-end; flex-wrap: wrap; padding-top: 10px; border-top: 1px dashed var(--line); margin-top: 6px; }
  table.stack td.actions::before { display: none; }
}

/* ---------- Relatórios, ajustes, usuários ---------- */
.error.ok { color: var(--ok); background: var(--ok-bg); border-color: #b9dcc3; }
.neg { color: var(--red-dark); font-weight: 700; }
.top-actions .who { align-self: center; margin-right: 4px; white-space: nowrap; }
td.barcell { width: 26%; }
td.barcell progress { width: 100%; height: 10px; accent-color: var(--red); }
@media (max-width: 760px) {
  .top-actions .who { display: none; }
  .nav a { font-size: .66rem; padding-left: 1px; padding-right: 1px; }
  .nav a span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav a svg { width: 22px; height: 22px; }
  table.stack td.barcell { display: none; }
}

/* ---------- Abas de Configurações ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin: 4px 0 18px; }
.tabs a { padding: 10px 18px; font-weight: 700; color: var(--muted); text-decoration: none; border-radius: 10px 10px 0 0; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a:hover { color: var(--red-dark); background: #fff3e3; }
.tabs a.active { color: var(--red-dark); border-bottom-color: var(--red); }
