:root {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --text: #1c1d1f;
  --muted: #6b6f76;
  --line: #e2e2dc;
  --us: #2f5fd0;
  --br: #1f8a4c;
  --outros: #77706a;
  --late: #c0392b;
  --late-bg: #fbeceb;
  --soon: #b7791f;
  --soon-bg: #fbf3e2;
  --you: #6d4bc4;
  --you-bg: #f0ecfa;
  --ok: #4a6b57;
  --ok-bg: #eaf2ec;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131416;
    --surface: #1c1e21;
    --text: #ecece9;
    --muted: #9a9ea6;
    --line: #2d3035;
    --us: #7c9df0;
    --br: #5cc189;
    --outros: #a59d96;
    --late: #f0877c;
    --late-bg: #3a201e;
    --soon: #e6b560;
    --soon-bg: #3a2f18;
    --you: #b29cf0;
    --you-bg: #2b2540;
    --ok: #9cc3aa;
    --ok-bg: #1f2c24;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding-bottom: 40px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 18px; font-weight: 650; }
h2 { font-size: 22px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
h4 { font-size: 15px; font-weight: 650; }
.muted { color: var(--muted); font-size: 13px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.top-right { display: flex; align-items: center; gap: 10px; }

.btn {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 12px; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }

.banner { margin: 12px 24px 0; padding: 10px 14px; border-radius: 8px; background: var(--late-bg); color: var(--late); }

/* ---- faixas: geral, EUA, Brasil, outros (uma abaixo da outra, largura total) */

.band { padding: 0 24px; margin-top: 24px; }
@media (max-width: 700px) { .band { padding: 0 12px; } }

.country { --accent: var(--outros); }
.country.us { --accent: var(--us); }
.country.br { --accent: var(--br); }
.country { margin-top: 36px; }

.country-head {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 10px; margin-bottom: 14px; border-bottom: 3px solid var(--accent);
}
.country-head h2 { color: var(--accent); }
.country.outros h2 { font-size: 17px; }
.flag { font-size: 36px; line-height: 1; }

/* Tarefas IA ocupa a largura toda; Estoque e Contas a pagar dividem a linha de baixo. */
.widgets { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.widgets > [data-widget="tarefas"] { grid-column: 1 / -1; }
@media (max-width: 900px) { .widgets { grid-template-columns: minmax(0, 1fr); } }

/* ---- caixa de widget */

.box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; min-width: 0;
}
.country .box { border-top: 3px solid var(--accent); }
.box-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; min-height: 26px; }
.fresh { font-size: 12px; color: var(--muted); white-space: nowrap; }
.fresh.stale { color: var(--late); font-weight: 600; }
.empty { color: var(--muted); padding: 8px 0 4px; }

/* ---- tarefas */

.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 4px 28px; }
@media (max-width: 500px) { .projects { grid-template-columns: minmax(0, 1fr); } }
.project { margin-top: 10px; min-width: 0; }
.project-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }

.items { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  padding: 10px 0 10px 12px; border-left: 3px solid var(--line); border-top: 1px solid var(--line);
}
.item:first-child { border-top: 0; }
.item.atrasado { border-left-color: var(--late); }
.item.vencendo { border-left-color: var(--soon); }
.item.acao { border-left-color: var(--you); }
.item.ok { border-left-color: var(--ok); }
.item-main { min-width: 0; flex: 1 1 auto; }
.item-title { font-weight: 550; overflow-wrap: anywhere; }
.item-detail { color: var(--muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); }
.item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }

.pill { padding: 2px 8px; border-radius: 999px; font-weight: 600; background: var(--line); color: var(--text); }
.pill.atrasado { background: var(--late-bg); color: var(--late); }
.pill.vencendo { background: var(--soon-bg); color: var(--soon); }
.pill.acao { background: var(--you-bg); color: var(--you); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.ref { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.postpone {
  font: inherit; font-size: 12px; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 7px; padding: 3px 4px;
}

/* ---- contas a pagar */

.totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.total { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.total strong { display: block; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.total span { font-size: 12px; color: var(--muted); }
.total.late { background: var(--late-bg); border-color: transparent; }
.total.late strong { color: var(--late); }
.total.soon { background: var(--soon-bg); border-color: transparent; }
.total.soon strong { color: var(--soon); }

/* ---- estoque */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.zero { color: var(--late); font-weight: 650; }
td.low { color: var(--soon); font-weight: 650; }
.prod { display: block; font-weight: 550; }
.sku { display: block; font-size: 11px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---- e-mails */

.mails { list-style: none; margin: 0; padding: 0; }
.mail {
  display: grid; grid-template-columns: 210px minmax(0, 1fr) auto auto; gap: 14px; align-items: center;
  padding: 8px 4px; border-top: 1px solid var(--line);
}
.mail:first-child { border-top: 0; }
.mail-from, .mail-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-from, .mail-subject { font-weight: 650; }
.mail-summary, .mail-date { color: var(--muted); }
.mail-date { font-size: 12px; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {
  .mail { grid-template-columns: minmax(0, 1fr) auto auto; }
  .mail-text { grid-column: 1 / -1; grid-row: 2; white-space: normal; }
}

.reply { padding: 4px 4px 12px; }
.reply textarea, .notes-form input {
  display: block; width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px;
}
.reply textarea { resize: vertical; }
.reply-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.reply-actions .muted { margin-right: auto; }
.btn:disabled { opacity: .6; cursor: default; }

/* ---- Slack */

.chat { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.chat-msg { padding: 8px 4px; border-top: 1px solid var(--line); }
.chat-msg:first-child { border-top: 0; }
.chat-reply { margin-left: 22px; padding-left: 12px; border-top: 0; border-left: 2px solid var(--line); }
.chat-head { display: flex; align-items: baseline; gap: 10px; }
.chat-user { font-weight: 650; }
.chat-answer { margin-left: auto; }
.chat-text { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-file { margin: 2px 0 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.chat-compose { border-top: 1px solid var(--line); margin-top: 6px; padding: 10px 4px 2px; }
.chat-compose textarea {
  display: block; width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; resize: vertical;
}
.chat-target { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.chat-target span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chat-attach, .chat-attached { margin-right: auto; }
.chat-attach { cursor: pointer; }
.chat-picker { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.chat-attached { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; overflow-wrap: anywhere; }

/* ---- bloco de notas */

.geral { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

/* Lista no formato do ClickUp: círculo, nome, data de vencimento, prioridade, ações. */
.note-row {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) 150px 120px 92px; gap: 12px; align-items: center;
  padding: 7px 4px; border-bottom: 1px solid var(--line);
}
.note-cols { font-size: 12px; color: var(--muted); padding-top: 0; }
.note-new { border-bottom: 0; padding-top: 9px; }
.note-text { overflow-wrap: anywhere; }

.circle {
  width: 16px; height: 16px; padding: 0; border-radius: 50%; border: 2px solid var(--muted);
  background: transparent; cursor: pointer; display: block;
}
.circle.dashed { border-style: dashed; border-color: var(--us); cursor: default; }
button.circle:hover { border-color: var(--br); background: var(--ok-bg); }

.note-row input, .note-row select.prio {
  font: inherit; font-size: 13px; color: var(--text); background: transparent;
  border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; min-width: 0; width: 100%;
}
.note-row input:hover, .note-row select.prio:hover, .note-new input, .note-new select.prio { border-color: var(--line); }
.note-new .note-name { background: var(--bg); font-size: 15px; padding: 6px 10px; }
.note-row input[type="date"].late { color: var(--late); font-weight: 650; }
.note-row input[type="date"].today { color: var(--soon); font-weight: 650; }
.prio.urgente { color: var(--late); font-weight: 650; }
.prio.alta { color: var(--soon); font-weight: 650; }
.prio.normal { color: var(--us); }
.prio.baixa { color: var(--muted); }
.btn.save { background: #12b886; border-color: #12b886; color: #fff; font-weight: 600; white-space: nowrap; }

@media (max-width: 700px) {
  .note-row { grid-template-columns: 20px minmax(0, 1fr) auto; }
  .note-cols { display: none; }
  .note-row > input[type="date"], .note-row > select.prio { grid-row: 2; }
  .note-row > input[type="date"] { grid-column: 2; }
}

/* ---- diálogo e login */

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
  width: min(460px, calc(100vw - 32px)); padding: 20px;
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h3 { margin-bottom: 14px; }
dialog label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
dialog input, dialog select, dialog textarea {
  display: block; width: 100%; margin-top: 4px; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.form-error, .login-error { color: var(--late); font-size: 13px; }

body.login { display: grid; place-items: center; min-height: 100vh; padding: 0; }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; text-align: center; display: grid; gap: 14px; width: min(360px, calc(100vw - 32px));
}

/* ---- Agenda */
.agenda { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 28px; }
.agenda-date { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: capitalize; }
.agenda-date.today { color: var(--text); }
.agenda-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.agenda-ev { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 2px 10px; padding-left: 10px; border-left: 3px solid var(--line); }
.agenda-ev.now { border-left-color: var(--soon); }
.agenda-time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.agenda-title { overflow-wrap: anywhere; }
.agenda-where { grid-column: 2; overflow-wrap: anywhere; }
