:root {
  --bg: #0b1220;
  --bg-soft: #121c2e;
  --card: #16223a;
  --card-2: #1b2a45;
  --line: #24344f;
  --text: #e8eefc;
  --muted: #93a4c4;
  --accent: #4f8cff;
  --high: #ff5c6c;
  --medium: #ffb020;
  --normal: #4f8cff;
  --low: #6b7a99;
  --ok: #2fd08a;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  overscroll-behavior-y: contain;
}

body {
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
}

header.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, rgba(11, 18, 32, .98), rgba(11, 18, 32, .92));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

header.top h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 650;
  flex: 1;
  letter-spacing: .2px;
}

header.top .sub {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
}

.icon-btn {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 17px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}

.icon-btn:active { transform: scale(.94); background: var(--card-2); }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 14px 14px 8px; }

.chips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
}

.chip b { display: block; font-size: 20px; line-height: 1.1; }
.chip span { font-size: 11px; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
}

.card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--normal);
}
.card.p-high::before { background: var(--high); }
.card.p-medium::before { background: var(--medium); }
.card.p-low::before { background: var(--low); }

.card-head { padding: 13px 14px 10px 17px; cursor: pointer; }

.card-title {
  font-size: 15px;
  font-weight: 620;
  margin: 0 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 11.5px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .2px;
  border: 1px solid transparent;
}
.badge.high { background: rgba(255, 92, 108, .14); color: #ff8b96; border-color: rgba(255, 92, 108, .3); }
.badge.medium { background: rgba(255, 176, 32, .13); color: #ffc45c; border-color: rgba(255, 176, 32, .3); }
.badge.normal { background: rgba(79, 140, 255, .13); color: #8db4ff; border-color: rgba(79, 140, 255, .3); }
.badge.low { background: rgba(107, 122, 153, .16); color: #a3b1cb; border-color: rgba(107, 122, 153, .3); }
.badge.due { background: rgba(255, 92, 108, .1); color: #ff9aa3; border-color: rgba(255, 92, 108, .25); }

.summary {
  margin: 10px 0 0;
  color: #c9d6ee;
  font-size: 13.5px;
}

.actions { padding: 0 14px 12px 17px; }

.actions h4 {
  margin: 10px 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  font-weight: 700;
}

.action {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 10px;
  background: var(--card-2);
  border-radius: 11px;
  margin-bottom: 6px;
  font-size: 13.5px;
  line-height: 1.35;
}

.action input[type=checkbox] {
  appearance: none;
  width: 20px; height: 20px;
  min-width: 20px;
  border: 2px solid #3d5378;
  border-radius: 6px;
  margin: 1px 0 0;
  cursor: pointer;
  position: relative;
  transition: background .15s, border-color .15s;
}
.action input[type=checkbox]:checked {
  background: var(--ok);
  border-color: var(--ok);
}
.action input[type=checkbox]:checked::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #05240f;
  font-size: 13px;
  font-weight: 900;
}
.action.done span { text-decoration: line-through; color: var(--muted); }

.risks {
  margin: 0 14px 12px 17px;
  padding: 9px 11px;
  border-radius: 11px;
  background: rgba(255, 92, 108, .08);
  border: 1px solid rgba(255, 92, 108, .2);
  color: #ffb3ba;
  font-size: 12.5px;
}

.body-full {
  display: none;
  padding: 0 14px 14px 17px;
  border-top: 1px dashed var(--line);
  margin-top: 4px;
  white-space: pre-wrap;
  font-size: 13px;
  color: #b9c8e3;
  max-height: 420px;
  overflow: auto;
}
.card.open .body-full { display: block; }

.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--muted);
  font-size: 14px;
}
.empty .big { font-size: 40px; display: block; margin-bottom: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 13px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: linear-gradient(180deg, #5b95ff, #3f7ae8); border-color: #5b95ff; color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; }

.field { margin-bottom: 13px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: .3px;
}
.field input, .field select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.field input:focus { border-color: var(--accent); }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.35; }

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .9px;
  color: var(--muted);
  font-weight: 700;
  margin: 20px 2px 10px;
}

.task-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px;
  margin-bottom: 8px;
}
.task-row .txt { flex: 1; font-size: 13.5px; }
.task-row .src { font-size: 11px; color: var(--muted); margin-top: 4px; }

nav.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(11, 18, 32, .96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}

nav.tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 7px 4px;
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  gap: 3px;
  place-items: center;
}
nav.tabs button .ico { font-size: 19px; line-height: 1; }
nav.tabs button.active { color: var(--text); background: var(--bg-soft); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: #22314d;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 90vw;
  z-index: 50;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #3a1a22; border-color: #6b2a37; }

.offline {
  display: none;
  background: #3a2a12;
  border-bottom: 1px solid #6b5122;
  color: #ffd08a;
  font-size: 12px;
  text-align: center;
  padding: 6px;
}
body.is-offline .offline { display: block; }

.source-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}


.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 8, 16, .78);
  padding: 22px;
  align-items: center;
  justify-content: center;
}
.modal.show { display: flex; }
.modal-box {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.modal-box h3 { margin: 0 0 8px; font-size: 17px; }
.modal-box input {
  width: 100%;
  padding: 13px 14px;
  margin: 10px 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 15px;
}
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { width: auto; flex: 1; }
