/* ═══════════════════════════════════════════════════════
   HUB PESSOAL — Design System
   Importar em todos os módulos: ../css/design-system.css
   ═══════════════════════════════════════════════════════ */

/* ─── TOKENS ─────────────────────────────────────────── */
:root {
  /* Superfícies */
  --bg:        #faf9f6;
  --bg-raised: #f4f2ee;
  --bg-input:  #ffffff;
  --bg-hover:  #eeece8;

  /* Bordas */
  --border:    #e2ddd7;
  --border-2:  #ccc8c1;

  /* Texto */
  --text:      #1c1917;
  --text-2:    #6b6560;
  --text-3:    #a8a29e;

  /* Ações */
  --accent:    #1d4ed8;
  --accent-h:  #1e40af;
  --accent-bg: rgba(29, 78, 216, .08);

  /* Semântica */
  --success:   #15803d;
  --success-bg:#f0fdf4;
  --danger:    #b91c1c;
  --danger-bg: #fef2f2;
  --warn:      #b45309;
  --warn-bg:   #fffbeb;

  /* Forma */
  --radius:    4px;
  --radius-m:  7px;
  --radius-l:  12px;
  --shadow:    0 1px 2px rgba(0,0,0,.05);
  --shadow-m:  0 2px 8px rgba(0,0,0,.07), 0 0 0 1px rgba(0,0,0,.04);

  /* Tipografia */
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Mono', 'Cascadia Code', ui-monospace, monospace;
}

[data-theme="dark"] {
  --bg:        #111110;
  --bg-raised: #1a1917;
  --bg-input:  #201f1d;
  --bg-hover:  #242220;

  --border:    #2c2a27;
  --border-2:  #3d3b37;

  --text:      #e8e4de;
  --text-2:    #87817a;
  --text-3:    #524e49;

  --accent:    #5b9cf6;
  --accent-h:  #84b4f8;
  --accent-bg: rgba(91, 156, 246, .1);

  --success:   #4ade80;
  --success-bg:rgba(74,222,128,.08);
  --danger:    #f87171;
  --danger-bg: rgba(248,113,113,.08);
  --warn:      #fbbf24;
  --warn-bg:   rgba(251,191,36,.08);

  --shadow:    0 1px 3px rgba(0,0,0,.4);
  --shadow-m:  0 2px 10px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.04);
}

/* ─── RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── NAV ─────────────────────────────────────────────── */
.nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-weight: 700;
  font-size: .92rem;
  color: var(--text);
  margin-right: 8px;
  padding: 14px 0;
  text-decoration: none;
  letter-spacing: -.2px;
  white-space: nowrap;
}
.nav-brand:hover { text-decoration: none; }
.nav-sep {
  color: var(--border-2);
  margin: 0 8px;
  font-size: .85rem;
  padding: 14px 0;
}
.nav-module {
  font-size: .85rem;
  color: var(--text-2);
  padding: 14px 0;
  margin-right: 16px;
}
.nav-links { display: flex; gap: 0; margin-left: 4px; }
.nav-link {
  padding: 14px 13px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  display: block;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--accent); border-bottom-color: var(--accent); }
.nav-spacer { flex: 1; }
.nav-theme-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 5px 9px;
  font-size: .8rem;
  color: var(--text-2);
  transition: all .15s;
}
.nav-theme-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ─── LAYOUT ──────────────────────────────────────────── */
.main { max-width: 1060px; margin: 0 auto; padding: 28px 24px; }
.page-title { font-size: 1.2rem; font-weight: 700; letter-spacing: -.3px; color: var(--text); }

/* ─── CARDS ───────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 18px 20px;
}
.card-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); font-weight: 600; }
.card-value { font-size: 1.5rem; font-weight: 700; margin-top: 5px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.card-sub { font-size: .75rem; color: var(--text-3); margin-top: 3px; }
.card.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.card.accent .card-label { color: rgba(255,255,255,.65); }
.card.accent .card-sub   { color: rgba(255,255,255,.55); }
.card.good   { border-left: 3px solid var(--success); }
.card.warn   { border-left: 3px solid var(--warn); }
.card.danger { border-left: 3px solid var(--danger); }

/* ─── SECTION ─────────────────────────────────────────── */
.section {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.section-title { font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); margin-bottom: 14px; }

/* ─── TABLE ───────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: .855rem; }
th {
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text-3);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
}
td { padding: 9px 10px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
tr:last-child > td { border-bottom: none; }
tbody tr:hover > td { background: var(--bg-hover); }
.td-r { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; font-family: var(--font-mono); }
.td-m { color: var(--text-2); white-space: nowrap; font-size: .8rem; }

/* ─── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  font-family: var(--font);
  transition: all .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); border-color: var(--accent-h); }
.btn-ghost    { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.btn-danger   { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn-icon { background: none; border: none; cursor: pointer; padding: 4px 6px; color: var(--text-3); font-size: .95rem; line-height: 1; border-radius: var(--radius); }
.btn-icon:hover { background: var(--bg-hover); color: var(--text-2); }

/* ─── FORM ────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-2); margin-bottom: 5px; letter-spacing: .1px; }
.input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  font-family: var(--font);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  font-family: var(--font);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  cursor: pointer;
}
.select:focus { border-color: var(--accent); }

/* ─── BADGES ──────────────────────────────────────────── */
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: .7rem; font-weight: 600; white-space: nowrap; }
.badge-cartao { background: var(--accent-bg); color: var(--accent); }
.badge-pix    { background: var(--success-bg); color: var(--success); }
.badge-warn   { background: var(--warn-bg);    color: var(--warn); }

/* ─── PROGRESS ────────────────────────────────────────── */
.progress { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; min-width: 50px; }
.progress-fill { height: 100%; border-radius: 3px; transition: width .4s; }
.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.fill-ok    { background: var(--success); }
.fill-warn  { background: var(--warn); }
.fill-over  { background: var(--danger); }

/* ─── DROPZONE ────────────────────────────────────────── */
.dropzone {
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-m);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
}
.dropzone:hover, .dropzone.drag-over { border-color: var(--accent); background: var(--accent-bg); }
.dropzone-icon { font-size: 2rem; margin-bottom: 10px; opacity: .5; }
.dropzone-text { font-size: .9rem; color: var(--text-2); font-weight: 500; }
.dropzone-sub  { font-size: .78rem; color: var(--text-3); margin-top: 4px; }

/* ─── MODAL ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 26px;
  max-width: 460px; width: 100%;
  box-shadow: var(--shadow-m);
}
.modal-title { font-size: 1rem; font-weight: 700; margin-bottom: 18px; letter-spacing: -.2px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; }

/* ─── TOAST ───────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  padding: 10px 18px;
  border-radius: var(--radius-m);
  font-size: .84rem; font-weight: 500;
  box-shadow: var(--shadow-m);
  z-index: 999;
  animation: toastIn .18s ease;
  border: 1px solid transparent;
}
.toast-success { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.toast-error   { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger); }
@keyframes toastIn { from { transform: translateY(6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── MONTH CHIPS ─────────────────────────────────────── */
.month-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.mchip {
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 20px;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-2);
  transition: all .15s;
  font-family: var(--font);
}
.mchip:hover { border-color: var(--accent); color: var(--accent); }
.mchip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ─── SPINNER ─────────────────────────────────────────── */
.spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── UTILITIES ───────────────────────────────────────── */
.text-muted    { color: var(--text-3); }
.text-2        { color: var(--text-2); }
.text-right    { text-align: right; }
.text-mono     { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warn     { color: var(--warn); }
.flex-between  { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.gap-8         { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mb-16         { margin-bottom: 16px; }
.mb-8          { margin-bottom: 8px; }
.mt-8          { margin-top: 8px; }
.empty-state   { text-align: center; padding: 48px; color: var(--text-3); font-size: .88rem; }
.dup-badge     { background: var(--warn-bg); color: var(--warn); font-size: .68rem; font-weight: 600; padding: 1px 6px; border-radius: 8px; margin-left: 6px; }

input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }

/* ─── TABS ────────────────────────────────────────────────── */
.tab-nav { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 16px;
  border: none; border-bottom: 2px solid transparent;
  background: none; cursor: pointer;
  font-size: .85rem; font-weight: 500;
  color: var(--text-2); font-family: var(--font);
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 768px) {
  .main { padding: 16px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .nav-link { padding: 13px 10px; font-size: .8rem; }

  /* Nav: brand/module fixed, links scroll horizontally */
  .nav { overflow: hidden; padding: 0 12px; }
  .nav-links {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1 1 0;
    min-width: 0;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-module { display: none; }
  .nav-spacer { flex: 0; }
  /* Category rows: hide bar and percentage on narrow screens */
  .cat-bar  { display: none; }
  .cat-pct  { display: none; }
  .cat-diff { display: none; }

  /* Filter chips: tighter spacing on mobile */
  .month-chips { gap: 5px; margin-bottom: 10px; }
  .mchip { padding: 3px 10px; font-size: .75rem; }

  /* Task list header: stack title and controls */
  .flex-between { gap: 8px; }
  .flex-between > .gap-8 { flex-wrap: wrap; }
  .flex-between > .gap-8 > .input { flex: 1 1 120px; min-width: 0; }
}

/* ─── SUPORTE — extensões ─────────────────────────────── */

/* Badges de prioridade */
.badge-alta   { background: var(--danger-bg);  color: var(--danger); }
.badge-media  { background: var(--warn-bg);    color: var(--warn); }
.badge-baixa  { background: var(--accent-bg);  color: var(--accent); }

/* Badges de status */
.badge-pendente           { background: var(--bg-hover);    color: var(--text-2); }
.badge-em_andamento       { background: var(--accent-bg);   color: var(--accent); }
.badge-aguardando_cliente { background: var(--warn-bg);     color: var(--warn); }
.badge-concluido          { background: var(--success-bg);  color: var(--success); }
.badge-arquivado          { background: var(--bg-hover);    color: var(--text-3); }

/* Chat */
.chat-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px 0 8px;
}
.msg {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}
.msg.agencia { align-self: flex-end; align-items: flex-end; }
.msg.cliente { align-self: flex-start; align-items: flex-start; }
.msg-bubble {
  padding: 9px 13px;
  border-radius: var(--radius-m);
  font-size: .855rem;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg.agencia .msg-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 3px; }
.msg.cliente .msg-bubble { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.msg-meta { font-size: .7rem; color: var(--text-3); margin-top: 3px; }
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.attach-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: .75rem;
  color: var(--accent);
  background: var(--bg-input);
  text-decoration: none;
  transition: all .15s;
}
.attach-link:hover { background: var(--accent-bg); text-decoration: none; }

/* Chat input area */
.chat-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
}
.chat-file-preview { display: flex; flex-wrap: wrap; gap: 6px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px 8px;
  font-size: .75rem;
  color: var(--text-2);
}
.file-chip button { background: none; border: none; cursor: pointer; color: var(--text-3); padding: 0; font-size: .8rem; line-height: 1; }

/* Notas */
.notas-preview {
  min-height: 80px;
  line-height: 1.65;
  font-size: .875rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-m);
}
.login-title { font-size: 1.1rem; font-weight: 700; letter-spacing: -.3px; margin-bottom: 4px; }
.login-sub   { font-size: .82rem; color: var(--text-2); margin-bottom: 22px; }

/* Client code badge in nav */
.nav-client { font-size: .78rem; color: var(--text-3); padding: 14px 0; margin-right: 6px; }
.nav-client strong { color: var(--text-2); }

/* Stat row for master dashboard */
.client-row-stats { font-size: .75rem; color: var(--text-3); margin-top: 3px; }

/* Task priority column */
.prio-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  flex-shrink: 0;
}
.prio-alta   .prio-dot { background: var(--danger); }
.prio-media  .prio-dot { background: var(--warn); }
.prio-baixa  .prio-dot { background: var(--accent); }

/* ─── TAG CHIP ────────────────────────────────────────────── */
.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1.5px solid;
  cursor: pointer;
  transition: all .15s;
  line-height: 1.6;
}
