:root {
  --bg: #0f1117;
  --bg-2: #161922;
  --panel: #1c2030;
  --panel-2: #232838;
  --border: #2a3042;
  --text: #e7eaf3;
  --muted: #8b93a7;
  --muted-2: #5b6377;
  --primary: #5b8cff;
  --primary-600: #4575ee;
  --green: #2fd07d;
  --green-bg: rgba(47, 208, 125, 0.14);
  --red: #ff5d6c;
  --red-bg: rgba(255, 93, 108, 0.14);
  --amber: #ffb547;
  --pampling: #ff5a36;
  --wituka: #2bb673;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1b2336 0%, var(--bg) 55%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app { display: grid; grid-template-columns: 320px 1fr; height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #8a5bff);
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  color: #fff; letter-spacing: 0.5px;
}
.brand h1 { font-size: 17px; font-weight: 700; }
.brand p { font-size: 12px; color: var(--muted); }

.filters { display: flex; flex-direction: column; gap: 8px; }
.filter-row { display: flex; gap: 6px; }
.chip {
  flex: 1; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel); color: var(--muted); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: 0.15s;
}
.chip:hover { color: var(--text); }
.chip-active { background: var(--primary); border-color: var(--primary); color: #fff; }

.list-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted-2);
  padding: 4px 2px;
}
.count { background: var(--panel); border-radius: 20px; padding: 1px 9px; color: var(--muted); }

.launch-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.launch-list::-webkit-scrollbar { width: 8px; }
.launch-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

.launch-item {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; cursor: pointer; transition: 0.15s; position: relative;
}
.launch-item:hover { border-color: #3a4258; transform: translateY(-1px); }
.launch-item.active { border-color: var(--primary); background: var(--panel-2); }
.launch-item .li-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.li-name { font-weight: 600; font-size: 14px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.li-date { display: flex; align-items: center; gap: 5px; }
.li-bar { height: 5px; background: var(--bg); border-radius: 6px; margin-top: 9px; overflow: hidden; }
.li-bar > i { display: block; height: 100%; background: var(--primary); border-radius: 6px; transition: width 0.3s; }
.li-bar.full > i { background: var(--green); }

.badge { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.4px; }
.badge-pampling { background: rgba(255, 90, 54, 0.16); color: var(--pampling); }
.badge-wituka { background: rgba(43, 182, 115, 0.16); color: var(--wituka); }

.tag-when { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.tag-today { background: var(--amber); color: #1a1300; }
.tag-tomorrow { background: var(--primary); color: #fff; }

.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.s-go { background: var(--green); }
.s-nogo { background: var(--red); }
.s-pending { background: var(--muted-2); }

.sync { font-size: 11px; color: var(--muted-2); display: flex; align-items: center; gap: 7px; }
.sync .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px 1px rgba(47,208,125,0.5); }

/* ---------- Buttons ---------- */
.btn { border: none; border-radius: 10px; padding: 10px 16px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; transition: 0.15s; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: var(--panel); color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }

/* ---------- Main ---------- */
.main { overflow-y: auto; padding: 32px 40px; }
.hidden { display: none !important; }

.empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); gap: 12px; }
.empty-icon { font-size: 54px; }
.empty h2 { color: var(--text); font-size: 22px; }
.empty p { max-width: 420px; font-size: 14px; line-height: 1.5; }

/* ---------- Detail ---------- */
.detail { max-width: 880px; margin: 0 auto; }
.detail-head { margin-bottom: 22px; }
.dh-top { display: flex; align-items: flex-start; gap: 14px; }
.dh-title { flex: 1; }
.dh-title input.title-input {
  font-size: 26px; font-weight: 800; background: transparent; border: none; color: var(--text);
  width: 100%; font-family: inherit; padding: 2px 4px; border-radius: 8px;
}
.dh-title input.title-input:focus { outline: none; background: var(--panel); }
.dh-sub { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.dh-sub .meta { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dh-sub input[type=date] {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 5px 9px; font-family: inherit; font-size: 13px;
}
.brand-select { display: flex; gap: 5px; }

.statusbar { display: flex; align-items: center; gap: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 22px; }
.prog-wrap { flex: 1; }
.prog-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 8px; }
.prog-top b { color: var(--text); }
.prog-bar { height: 9px; background: var(--bg); border-radius: 8px; overflow: hidden; }
.prog-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #8a5bff); border-radius: 8px; transition: width 0.35s; }
.prog-bar.full > i { background: var(--green); }

.gng { display: flex; gap: 7px; }
.gng button { padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); font-weight: 700; font-size: 13px; cursor: pointer; transition: 0.15s; }
.gng button.go.on { background: var(--green); border-color: var(--green); color: #042312; }
.gng button.nogo.on { background: var(--red); border-color: var(--red); color: #2c0307; }

/* ---------- Categories ---------- */
.cat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.cat-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; }
.cat-head h3 { font-size: 14px; font-weight: 700; flex: 1; }
.cat-progress { font-size: 12px; color: var(--muted); background: var(--bg); padding: 2px 9px; border-radius: 20px; }
.cat-del { background: none; border: none; color: var(--muted-2); cursor: pointer; font-size: 15px; opacity: 0; transition: 0.15s; }
.cat:hover .cat-del { opacity: 1; }
.cat-del:hover { color: var(--red); }

.items { padding: 0 8px 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: 10px; transition: 0.12s; }
.item:hover { background: var(--panel-2); }
.check { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--border); cursor: pointer; flex-shrink: 0; display: grid; place-items: center; transition: 0.15s; }
.check:hover { border-color: var(--primary); }
.check.on { background: var(--green); border-color: var(--green); }
.check.on::after { content: '✓'; color: #042312; font-size: 13px; font-weight: 800; }
.item-text { flex: 1; font-size: 14px; cursor: text; padding: 2px 4px; border-radius: 6px; }
.item-text:focus { outline: none; background: var(--bg); }
.item.done .item-text { color: var(--muted-2); text-decoration: line-through; }
.item-del { background: none; border: none; color: var(--muted-2); cursor: pointer; opacity: 0; transition: 0.15s; font-size: 14px; }
.item:hover .item-del { opacity: 1; }
.item-del:hover { color: var(--red); }

.add-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.add-item input { flex: 1; background: var(--bg); border: 1px dashed var(--border); color: var(--text); border-radius: 9px; padding: 9px 12px; font-family: inherit; font-size: 13px; }
.add-item input:focus { outline: none; border-color: var(--primary); border-style: solid; }

.add-cat { margin: 6px 0 30px; }
.notes { margin-top: 6px; }
.notes textarea { width: 100%; background: var(--panel); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 14px; font-family: inherit; font-size: 13px; resize: vertical; min-height: 70px; }
.notes textarea:focus { outline: none; border-color: var(--primary); }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted-2); margin: 24px 0 10px; font-weight: 700; }

.danger-zone { display: flex; justify-content: flex-end; margin: 30px 0 10px; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(8, 10, 16, 0.7); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 26px; width: 420px; max-width: 92vw; box-shadow: var(--shadow); animation: pop 0.18s ease; }
.modal-lg { width: 560px; max-height: 86vh; overflow-y: auto; }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h2 { font-size: 19px; margin-bottom: 6px; }
.modal-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.field input { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 11px 13px; font-family: inherit; font-size: 14px; }
.field input:focus { outline: none; border-color: var(--primary); }
.hint { display: block; margin-top: 6px; font-size: 12px; color: var(--primary); }
.seg { display: flex; gap: 6px; }
.seg-btn { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--muted); font-weight: 600; cursor: pointer; font-family: inherit; font-size: 13px; transition: 0.15s; }
.seg-btn.seg-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Template editor ---------- */
.tpl-editor { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.tpl-cat { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.tpl-cat-head { display: flex; gap: 8px; margin-bottom: 8px; }
.tpl-cat-head input { flex: 1; background: var(--panel); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px 10px; font-family: inherit; font-weight: 600; }
.tpl-items { display: flex; flex-direction: column; gap: 6px; }
.tpl-item { display: flex; gap: 8px; align-items: center; }
.tpl-item input { flex: 1; background: var(--panel); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 7px 10px; font-family: inherit; font-size: 13px; }
.icon-btn { background: none; border: none; color: var(--muted-2); cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { color: var(--red); background: var(--red-bg); }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 12px 20px; border-radius: 12px; font-size: 13px; box-shadow: var(--shadow); z-index: 60; animation: pop 0.18s; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; width: 300px; height: 100vh; transform: translateX(-100%); transition: 0.2s; }
  .sidebar.open { transform: none; }
  .main { padding: 20px; }
}
