* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0b0b0f;
  --surface: #16161e;
  --surface2: #1e1e2a;
  --surface-hover: #252535;
  --accent: #6c63ff;
  --accent-hover: #5a52d5;
  --text: #e8e8ec;
  --text-muted: #6b6b80;
  --green: #22c55e;
  --red: #ef4444;
  --radius: 10px;
  --tile-size: 82px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  padding: 10px 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#app {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  flex-shrink: 0;
}

header h1 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-muted);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}

.icon-btn:hover { color: var(--text); background: var(--surface); }

.icon-btn svg { width: 18px; height: 18px; }

/* Main grid — une seule ligne, espace réparti */
main {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
  justify-content: space-around;
}

/* Categories */
.category {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.category-title {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding-left: 2px;
}

.tiles {
  display: grid;
  gap: 6px;
  /* colonnes fixées par JS via style inline */
}

/* Square tile */
.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all .15s;
  position: relative;
  text-decoration: none;
  color: var(--text);
}

.tile:hover {
  background: var(--surface-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}

.tile-icon {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.tile-name {
  font-size: .62rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.2;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Status dot */
.status-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.up { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.down { background: var(--red); box-shadow: 0 0 6px var(--red); }

/* URL tooltip on hover */
.tile-urls {
  display: none;
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border-radius: 6px;
  padding: 4px 8px;
  white-space: nowrap;
  z-index: 10;
  gap: 8px;
  font-size: .65rem;
}

.tile:hover .tile-urls { display: flex; }

.tile-urls a {
  color: var(--accent);
  text-decoration: none;
}
.tile-urls a:hover { text-decoration: underline; }

/* ============ Modal ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  width: 92%;
  max-width: 620px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--surface2);
}
.modal-header h2 { font-size: 1rem; font-weight: 600; }

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--surface2);
  text-align: right;
}

.settings-section { margin-bottom: 20px; }

.settings-section h3 {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.setting-item {
  background: var(--surface2);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
}

.setting-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.setting-item-header span { font-weight: 500; font-size: .85rem; }

.setting-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 6px;
}

input, select {
  background: var(--bg);
  border: 1px solid #2a2a3a;
  color: var(--text);
  padding: 7px 10px;
  border-radius: 6px;
  font-size: .8rem;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

label { font-size: .7rem; color: var(--text-muted); display: block; margin-bottom: 3px; }

.btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid #2a2a3a;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-size: .8rem;
  transition: all .2s;
}
.btn:hover { background: var(--surface-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { padding: 5px 10px; font-size: .75rem; }

.btn-danger {
  background: transparent;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: .75rem;
  padding: 3px 6px;
}
.btn-danger:hover { background: rgba(239,68,68,.1); border-radius: 4px; }

/* Login */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.login-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.login-box h2 { font-size: 1.2rem; font-weight: 600; }

.remember {
  font-size: .75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  cursor: pointer;
}

.remember input { width: auto; }

.login-error {
  color: var(--red);
  font-size: .8rem;
}

.hidden { display: none !important; }

/* Template grid */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.template-card {
  background: var(--surface2);
  border-radius: 10px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.template-card:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.template-card svg { width: 36px; height: 36px; color: var(--accent); }
.template-card span { font-size: .85rem; font-weight: 500; }

/* Child popup */
.has-children .tile-name::after {
  content: ' ▾';
  font-size: .7rem;
  opacity: .6;
}

.child-popup {
  position: fixed;
  background: var(--surface2);
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  padding: 4px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  min-width: 150px;
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
}

.child-item {
  padding: 8px 14px;
  font-size: .82rem;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  transition: background .15s;
  white-space: nowrap;
}
.child-item:hover { background: var(--surface-hover); }

/* Trello */
.trello-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-top: 6px;
  min-height: 0;
  align-items: center;
  position: relative;
  z-index: 0;
}

.trello-section.hidden { display: none; }

.trello-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.trello-tabs > div {
  display: flex;
  gap: 4px;
}

.trello-tab {
  padding: 5px 12px;
  border-radius: 6px;
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: .75rem;
  font-weight: 500;
  transition: all .15s;
}
.trello-tab:hover { color: var(--text); background: var(--surface2); }
.trello-tab.active { background: var(--accent); color: #fff; }

.kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  flex: 1;
  padding-bottom: 8px;
  min-height: 0;
  width: 100%;
  justify-content: center;
}

.kanban-list {
  min-width: 250px;
  max-width: 280px;
  flex-shrink: 0;
  background: var(--surface2);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
}

.kanban-list-header {
  padding: 10px 12px;
  font-weight: 600;
  font-size: .8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--bg);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kanban-list-header span { font-size: .65rem; opacity: .6; }

.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kanban-card {
  background: var(--surface);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: .8rem;
  cursor: default;
  position: relative;
  transition: all .15s;
}
.kanban-card:hover { background: var(--surface-hover); }

.kanban-card-name {
  margin-bottom: 4px;
  word-break: break-word;
}

.kanban-card-labels {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.kanban-label {
  font-size: .6rem;
  padding: 1px 6px;
  border-radius: 3px;
  color: #fff;
  font-weight: 500;
}

.kanban-card-due {
  font-size: .65rem;
  color: var(--text-muted);
}

.kanban-card-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  font-size: .75rem;
  padding: 2px 4px;
  border-radius: 4px;
}
.kanban-card:hover .kanban-card-delete { opacity: 1; }
.kanban-card-delete:hover { color: var(--red); background: rgba(239,68,68,.1); }

.kanban-add {
  padding: 8px;
  flex-shrink: 0;
  border-top: 1px solid var(--bg);
}

.kanban-add-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .75rem;
  padding: 6px 8px;
  width: 100%;
  text-align: left;
  border-radius: 6px;
  transition: all .15s;
}
.kanban-add-btn:hover { background: var(--surface); color: var(--text); }

.kanban-add-input {
  display: flex;
  gap: 6px;
}

.kanban-add-input input {
  flex: 1;
  font-size: .8rem;
  padding: 6px 8px;
}

.kanban-add-input button {
  padding: 6px 10px;
  font-size: .75rem;
}

/* Responsive */
@media (min-width: 1400px) {
  :root { --tile-size: 90px; }
}

@media (max-width: 600px) {
  :root { --tile-size: 72px; }
  body { padding: 12px; }
  .tile-icon { width: 26px; height: 26px; }
  .tile-name { font-size: .58rem; }
}
