* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #172b4d;
  background: #f4f5f7;
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: #5e6c84; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 6px; }
input, textarea {
  font: inherit; width: 100%; padding: 8px 10px;
  border: 2px solid #dfe1e6; border-radius: 6px; background: #fff; color: inherit;
}
input:focus, textarea:focus { outline: none; border-color: #0079bf; }

.btn-primary { background: #0079bf; color: #fff; padding: 8px 14px; }
.btn-primary:hover { background: #026aa7; }
.btn-danger { background: #eb5a46; color: #fff; padding: 8px 14px; }
.btn-light { background: rgba(255,255,255,.25); color: #fff; padding: 6px 12px; }
.btn-light:hover { background: rgba(255,255,255,.35); }
.btn-ghost { background: rgba(0,0,0,.15); color: #fff; padding: 6px 12px; }
.btn-ghost:hover { background: rgba(0,0,0,.25); }

/* Bilah atas */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: rgba(0,0,0,.25); color: #fff;
}
body.home-bg .topbar { background: #026aa7; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 18px; }

/* Beranda */
.home { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
.new-board {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: #fff; padding: 14px; border-radius: 10px; margin: 16px 0 24px;
  box-shadow: 0 1px 2px rgba(9,30,66,.2);
}
.new-board input { flex: 1 1 260px; }
.colors { display: flex; gap: 6px; }
.color-dot { width: 28px; height: 28px; border-radius: 50%; border: 3px solid transparent; }
.color-dot.active { border-color: #172b4d; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.board-tile {
  position: relative; display: block; height: 100px; padding: 12px; border-radius: 8px;
  color: #fff; text-decoration: none; font-weight: 700;
}
.board-tile:hover { filter: brightness(.92); }
.board-tile small { position: absolute; left: 12px; bottom: 10px; font-weight: 400; opacity: .9; }

/* Halaman board */
.board-page { padding: 12px 16px; }
.board-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.board-header h1 {
  margin: 0; color: #fff; font-size: 20px; padding: 4px 8px; border-radius: 6px; cursor: text;
}
.board-header h1:hover { background: rgba(255,255,255,.2); }
.board-header input { max-width: 320px; }

.lists {
  display: flex; align-items: flex-start; gap: 12px;
  overflow-x: auto; padding-bottom: 16px; min-height: calc(100vh - 130px);
}
.list {
  flex: 0 0 272px; background: #ebecf0; border-radius: 10px; padding: 8px;
  max-height: calc(100vh - 150px); display: flex; flex-direction: column;
}
.list-header { display: flex; align-items: center; gap: 4px; padding: 4px; cursor: grab; }
.list-title { flex: 1; font-weight: 600; padding: 4px 6px; border-radius: 4px; cursor: text; }
.list-title:hover { background: rgba(9,30,66,.08); }
.list-count { font-size: 12px; color: #5e6c84; }
.icon-btn { background: transparent; color: #5e6c84; padding: 4px 8px; font-size: 16px; }
.icon-btn:hover { background: rgba(9,30,66,.1); color: #172b4d; }

.cards { min-height: 8px; overflow-y: auto; padding: 2px; }
.card {
  background: #fff; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px;
  box-shadow: 0 1px 1px rgba(9,30,66,.25); cursor: pointer; word-wrap: break-word;
}
.card:hover { background: #f8f9fa; }
.card-label { height: 8px; width: 40px; border-radius: 4px; margin-bottom: 6px; }
.card-meta { display: flex; gap: 8px; margin-top: 6px; font-size: 12px; color: #5e6c84; }
.card-meta .late { color: #fff; background: #eb5a46; padding: 0 4px; border-radius: 3px; }
.sortable-ghost { opacity: .4; }
.sortable-drag { transform: rotate(3deg); }

.add-card, .add-list-btn {
  width: 100%; text-align: left; background: transparent; color: #5e6c84; padding: 8px;
}
.add-card:hover { background: rgba(9,30,66,.08); color: #172b4d; }
.inline-form textarea, .inline-form input { margin-bottom: 6px; }
.inline-form .row { display: flex; gap: 6px; align-items: center; }

.add-list { flex: 0 0 272px; }
.add-list-btn { background: rgba(255,255,255,.25); color: #fff; border-radius: 10px; padding: 12px; }
.add-list-btn:hover { background: rgba(255,255,255,.35); }
.add-list .inline-form { background: #ebecf0; padding: 8px; border-radius: 10px; }

.topbar-actions { display: flex; gap: 8px; }
.link-btn { background: none; color: #0079bf; padding: 0; text-decoration: underline; }

/* Riwayat */
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 8px 0; border-bottom: 1px solid #dfe1e6; font-size: 14px; }
.history li:last-child { border-bottom: 0; }
.history .when { display: block; font-size: 12px; color: #5e6c84; margin-top: 2px; }
.history .failed { color: #c9372c; }
.history-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 360px; max-width: 100%;
  background: #fff; z-index: 15; padding: 12px 16px; overflow-y: auto;
  box-shadow: -4px 0 16px rgba(9,30,66,.25);
}
.history-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; }
.history-head .modal-close { position: static; }
#card-history { max-height: 220px; overflow-y: auto; }

/* Modal kartu */
.modal-box.small { max-width: 380px; }
.error { color: #c9372c; font-weight: 600; margin: 8px 0 0; }
.btn-ghost-dark { background: #dfe1e6; color: #172b4d; padding: 8px 14px; }
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 10;
  overflow-y: auto;
}
.modal-box {
  position: relative; background: #f4f5f7; width: 100%; max-width: 520px;
  border-radius: 10px; padding: 20px;
}
.modal-box label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; color: #5e6c84; }
.modal-close { position: absolute; top: 8px; right: 10px; background: transparent; font-size: 24px; color: #5e6c84; }
.labels { display: flex; flex-wrap: wrap; gap: 6px; }
.label-opt { width: 44px; height: 28px; border: 3px solid transparent; }
.label-opt.active { border-color: #172b4d; }
.label-opt.none { background: #fff; color: #5e6c84; font-size: 12px; width: auto; padding: 0 8px; }
.modal-actions { display: flex; justify-content: space-between; margin-top: 20px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #172b4d; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 20;
}

@media (max-width: 600px) {
  .list, .add-list { flex-basis: 85vw; }
}
