:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #1d2330;
  --muted: #6b7280;
  --border: #dde1e7;
  --primary: #2563eb;
  --primary-text: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
  --radius: 10px;
  --note-yellow: #fff59d; --note-pink: #f8bbd0; --note-green: #c5e1a5;
  --note-blue: #b3e5fc;   --note-purple: #d1c4e9; --note-orange: #ffcc80;
  --note-text: #222;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c; --surface: #1a1f29; --surface-2: #232a36; --text: #e6e9ef;
    --muted: #9aa3b2; --border: #2e3644; --primary: #3b82f6;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }
.spacer { flex: 1; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.btn {
  font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: 8px 14px; border-radius: 8px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
.btn:hover { filter: brightness(.96); }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  background: var(--surface); padding: 32px; border-radius: 14px; box-shadow: var(--shadow);
  width: 100%; max-width: 340px; display: grid; gap: 12px; text-align: center;
}
.login-card h1 { margin: 0; }
.login-card p { margin: 0 0 8px; }

/* Header */
.top {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand h1 { margin: 0; font-size: 20px; }
.brand span { font-size: 13px; }
.countdown {
  background: var(--primary); color: var(--primary-text); padding: 6px 14px;
  border-radius: 999px; font-weight: 600; font-size: 14px;
}
.countdown.urgent { background: var(--danger); }
.countdown.past { background: var(--ok); }
.progress-wrap { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 180px; }
.progress { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; max-width: 320px; }
.progress div { height: 100%; width: 0; background: var(--ok); transition: width .3s; }

.tabs { display: flex; gap: 4px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button {
  font: inherit; background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 12px 16px; border-bottom: 3px solid transparent;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }

.tab { padding: 20px; max-width: 1400px; margin: 0 auto; }
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type=search] { flex: 1; min-width: 180px; }
.toolbar select { width: auto; }

/* Kanban */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.column { background: var(--surface-2); border-radius: var(--radius); padding: 12px; min-height: 200px; }
.column.drag-over { outline: 2px dashed var(--primary); }
.column h2 { font-size: 15px; margin: 0 0 12px; display: flex; justify-content: space-between; }
.column .count { color: var(--muted); font-weight: normal; }
.cards { display: grid; gap: 10px; min-height: 60px; }
.card {
  background: var(--surface); border-radius: 8px; padding: 12px; box-shadow: var(--shadow);
  cursor: pointer; border-left: 4px solid var(--border);
}
.card.p-alta { border-left-color: var(--danger); }
.card.p-media { border-left-color: var(--warn); }
.card.p-baixa { border-left-color: var(--ok); }
.card.dragging { opacity: .5; }
.card h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; word-break: break-word; }
.card[data-status=done] h3 { text-decoration: line-through; color: var(--muted); }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); }
.tag { background: var(--surface-2); padding: 2px 8px; border-radius: 999px; }
.tag.late { background: var(--danger); color: #fff; }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 16px 0; }

/* Dialog */
dialog {
  border: none; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { padding: 22px; display: grid; gap: 12px; max-height: 90vh; overflow-y: auto; }
dialog h2 { margin: 0; }
dialog label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.row { display: flex; gap: 8px; }
.checklist { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; }
.checklist li { display: flex; align-items: center; gap: 8px; }
.checklist li input[type=checkbox] { width: auto; }
.checklist li span { flex: 1; word-break: break-word; }
.checklist li.done span { text-decoration: line-through; color: var(--muted); }
.checklist li button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; }
.dialog-actions { display: flex; gap: 8px; margin-top: 6px; }

/* Arquivos */
.upload-box { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 20px; }
.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
}
.drop-zone.over { border-color: var(--primary); background: var(--surface-2); }
.upload-fields { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 12px; }
.upload-item { margin-top: 10px; font-size: 13px; }
.upload-item .progress { max-width: none; margin-top: 4px; }
.upload-item.err { color: var(--danger); }

.folder { margin-bottom: 22px; }
.folder h3 { font-size: 15px; margin: 0 0 8px; }
.file-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.file-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.file-table tr:last-child td { border-bottom: none; }
.file-name { font-weight: 600; word-break: break-all; }
.file-desc { font-size: 12px; color: var(--muted); }
.file-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.nowrap { white-space: nowrap; }

/* Notas adesivas */
.notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.note {
  color: var(--note-text); border-radius: 4px; padding: 10px; min-height: 200px;
  box-shadow: 0 4px 10px rgba(0,0,0,.15); display: flex; flex-direction: column; gap: 6px;
  transform: rotate(var(--rot, 0deg)); transition: transform .15s;
}
.note:hover, .note:focus-within { transform: rotate(0) scale(1.02); }
.note.yellow { background: var(--note-yellow); } .note.pink { background: var(--note-pink); }
.note.green { background: var(--note-green); }   .note.blue { background: var(--note-blue); }
.note.purple { background: var(--note-purple); } .note.orange { background: var(--note-orange); }
.note textarea {
  flex: 1; background: transparent; border: none; resize: none; color: var(--note-text);
  font-family: "Segoe Print", "Comic Sans MS", cursive, system-ui; font-size: 15px; min-height: 150px; padding: 4px;
}
.note textarea:focus { outline: none; }
.note-bar { display: flex; align-items: center; gap: 5px; }
.dot { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); cursor: pointer; padding: 0; }
.dot.sel { outline: 2px solid #333; outline-offset: 1px; }
.note-bar button.icon { background: none; border: none; cursor: pointer; font-size: 15px; opacity: .6; padding: 2px; }
.note-bar button.icon:hover { opacity: 1; }
.note-date { font-size: 11px; opacity: .6; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(100px);
  background: #222; color: #fff; padding: 10px 18px; border-radius: 8px; transition: transform .25s; z-index: 100;
}
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .board { grid-template-columns: 1fr; }
  .upload-fields, .grid2 { grid-template-columns: 1fr; }
  .tab { padding: 16px; }
  .file-table td.hide-sm { display: none; }
}
