:root {
  --bar: #1f2937;
  --bg: #f3f4f6;
  --panel: #fff;
  --border: #d1d5db;
  --muted: #6b7280;
  --text: #111827;
  --accent: #ec4899;
  --accent-dark: #db2777;
  --danger: #dc2626;
  --ok: #059669;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; background: var(--bar); color: #fff; }
.topbar .brand { font-weight: 700; font-size: 17px; text-decoration: none; }
.menu { position: relative; }
.menu > button { background: transparent; color: #fff; border: 1px solid #4b5563; border-radius: 6px; padding: 6px 10px; font: inherit; cursor: pointer; }
.menu ul { display: none; position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; margin: 0; padding: 6px 0; list-style: none; background: var(--panel); color: var(--text); border-radius: 8px; box-shadow: 0 8px 24px #0003; z-index: 10; }
.menu.open ul { display: block; }
.menu li a, .menu li button { display: block; width: 100%; padding: 8px 14px; text-align: left; text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; }
.menu li a:hover, .menu li button:hover { background: var(--bg); }

main { max-width: 960px; margin: 24px auto; padding: 0 16px; }
.card { background: var(--panel); border-radius: 10px; box-shadow: 0 1px 3px #0001; padding: 20px; margin-bottom: 20px; }
.card h2 { margin: 0 0 14px; font-size: 18px; }
.narrow { max-width: 380px; margin: 60px auto; }

label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; margin: 12px 0 4px; }
input, select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #f9fafb; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: #fff; }

.btn { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; font: inherit; cursor: pointer; }
.btn:hover { background: var(--accent-dark); }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--bg); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.full { width: 100%; margin-top: 18px; }

.msg { margin-top: 12px; font-size: 14px; min-height: 1em; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; font-weight: 600; }
tr.inactive td { color: #9ca3af; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions input { width: 140px; padding: 4px 8px; }
.badge { display: inline-block; border-radius: 10px; padding: 1px 8px; font-size: 12px; background: #e5e7eb; }
.badge.admin { background: #fce7f3; color: var(--accent-dark); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; }

.placeholder { text-align: center; color: var(--muted); padding: 60px 20px; }

/* Board */
.board-page main { max-width: none; margin: 0; padding: 0; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px 0; }
.toolbar .msg { margin: 0; }
.board { display: flex; gap: 12px; overflow-x: auto; padding: 12px 16px 24px; align-items: flex-start; min-height: calc(100vh - 120px); }
.column { flex: 0 0 260px; background: #e5e7eb; border-radius: 10px; padding: 10px; display: flex; flex-direction: column; max-height: calc(100vh - 140px); }
.column.hold { background: #fde68a55; border: 2px dashed #f59e0b; }
.column h3 { display: flex; justify-content: space-between; align-items: center; margin: 2px 2px 10px; font-size: 14px; color: #374151; }
.column .count { background: #d1d5db; border-radius: 10px; padding: 0 8px; font-weight: normal; font-size: 12px; }
.cards { min-height: 60px; overflow-y: auto; flex: 1; padding-bottom: 4px; }
.tile { background: var(--panel); border-radius: 8px; padding: 10px; margin-bottom: 8px; box-shadow: 0 1px 2px #0002; font-size: 14px; font-weight: 600; cursor: grab; overflow-wrap: anywhere; user-select: none; touch-action: manipulation; }
.tile:hover { box-shadow: 0 2px 6px #0003; }
.tile.ghost { opacity: 0.4; }
.tile.chosen { box-shadow: 0 6px 16px #0004; }
.new-tile { margin-bottom: 8px; }
.new-tile input { background: #fff; }
.new-tile small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
@media (max-width: 600px) { .column { flex-basis: 82vw; } }

/* Rich tiles */
.tile-title { margin-bottom: 6px; }
.tile-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; min-height: 2px; }
.tag { border-radius: 4px; padding: 1px 7px; font-size: 11px; font-weight: 600; color: #fff; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: #3b82f6; color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar.inactive { background: #9ca3af; }
.tile-footer { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 6px; font-size: 11px; font-weight: normal; color: var(--muted); }
.tile-footer a { color: var(--accent-dark); text-decoration: none; }
.due.late { color: var(--danger); font-weight: 600; }
.new-tile-row { display: flex; gap: 6px; }
.new-tile .cancel { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; cursor: pointer; font: inherit; }

/* Details modal */
.modal-backdrop { position: fixed; inset: 0; background: #0006; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { position: relative; background: var(--panel); border-radius: 12px; box-shadow: 0 12px 40px #0004; padding: 22px; width: 100%; max-width: 620px; }
.modal .close { position: absolute; top: 10px; right: 12px; background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal .meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; padding-right: 24px; }
.modal .title-input { font-size: 18px; font-weight: 700; background: #fff; }
.modal .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.modal textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: #f9fafb; resize: vertical; }
.modal textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: #fff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.history { border-top: 1px solid #e5e7eb; margin-top: 18px; padding-top: 10px; }
.history h4 { margin: 0 0 6px; font-size: 13px; }
.history ul { list-style: none; margin: 0; padding: 0; font-size: 12px; color: #374151; max-height: 220px; overflow-y: auto; }
.history li { padding: 3px 0; }
@media (max-width: 600px) {
  .modal-backdrop { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  .modal .grid { grid-template-columns: 1fr; }
}

/* Admin: categories */
.category-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.category-form label { margin-top: 0; }
.category-form input[type=color], td input[type=color] { width: 48px; height: 34px; padding: 2px; }
td input[type=text] { width: 160px; padding: 4px 8px; }
tr.inactive .tag { opacity: 0.5; }

/* Filters */
.toolbar .search { width: 240px; max-width: 100%; }
.toolbar .filter { width: auto; }
.tile.hidden { display: none; }
.column select.days { width: auto; padding: 2px 6px; font-size: 12px; margin: -4px 2px 8px; background: #fff; }
.tile-footer .published { color: var(--ok); }
.modal-actions .archive { margin-right: auto; }
