* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --pico-bg: #13171f;
  --pico-card: #181c25;
  --pico-card-section: #1c212c;
  --pico-text: #c2c7d0;
  --pico-muted: #7b8495;
  --pico-border: #202632;
  --pico-primary: #01aaff;
  --pico-primary-bg: #0172ad;
  --pico-primary-hover: #017fc0;
  --pico-success: #2a7b6f;
  --pico-warning: #d4a017;
  --pico-danger: #c94c4c;
  --pico-radius: 0.5rem;
  --pico-shadow: 0.0145rem 0.029rem 0.174rem rgba(7, 8.5, 12, 0.017),
                 0.0335rem 0.067rem 0.402rem rgba(7, 8.5, 12, 0.024),
                 0.0625rem 0.125rem 0.75rem rgba(7, 8.5, 12, 0.03),
                 0 0 0 0.0625rem rgba(7, 8.5, 12, 0.015);
}
html { scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--tg-theme-bg-color, var(--pico-bg));
  color: var(--tg-theme-text-color, var(--pico-text));
  line-height: 1.5;
  font-size: 15px;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 80px;
}

.top-bar, #btn-menu, .drawer, .overlay { display: none; }

/* Stats */
.tabs-row {
  display: flex; padding: 12px 16px;
}
.stat-tab {
  flex: 1; text-align: center;
  background: var(--pico-card); border: 1px solid var(--pico-border);
  border-right: none;
  padding: 10px 12px;
  font-size: 14px; color: var(--pico-muted);
  cursor: pointer; user-select: none;
}
.stat-tab:first-child { border-radius: var(--pico-radius) 0 0 var(--pico-radius); }
.stat-tab:last-child { border-radius: 0 var(--pico-radius) var(--pico-radius) 0; border-right: 1px solid var(--pico-border); }
.stat-tab span { color: var(--pico-text); font-weight: 700; }
.stat-tab.active {
  background: rgba(1, 114, 173, 0.18);
  color: var(--pico-primary);
}
.stat-tab.active span { color: var(--pico-primary); }

.filters-row {
  display: flex; padding: 0 0 8px 0;
}
.filter-tab {
  flex: 1; text-align: center;
  padding: 8px 4px;
  border: 1px solid var(--pico-border);
  border-right: none;
  background: var(--pico-card); color: var(--pico-muted);
  font-size: 13px; cursor: pointer; user-select: none;
}
.filter-tab:first-child { border-radius: var(--pico-radius) 0 0 var(--pico-radius); }
.filter-tab:last-child { border-radius: 0 var(--pico-radius) var(--pico-radius) 0; border-right: 1px solid var(--pico-border); }
.filter-tab.active {
  background: rgba(1, 114, 173, 0.18); color: var(--pico-primary);
  font-weight: 600;
}

.progress-card {
  background: var(--pico-card); border: 1px solid var(--pico-border);
  margin: 0 16px 0; padding: 14px 24px 24px 014px; border-radius: var(--pico-radius);
  box-shadow: var(--pico-shadow);
}
.progress-label { font-size: 13px; color: var(--pico-muted); margin-bottom: 8px; }
.progress-track { height: 8px; background: var(--pico-bg); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--pico-primary); width: 0%; transition: width .3s ease; }

/* Bottom tabs */
.bottom-tabs {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: var(--tg-theme-secondary-bg-color, var(--pico-card));
  border-top: 1px solid var(--pico-border); z-index: 20;
  max-width: 720px; margin: 0 auto;
}
.tab {
  flex: 1; padding: 14px 8px; border: none; background: transparent;
  color: var(--tg-theme-hint-color, var(--pico-muted)); font-size: 13px; cursor: pointer;
  border-top: 2px solid transparent;
}
.tab.active { color: var(--pico-primary); border-top-color: var(--pico-primary); font-weight: 600; }

/* Views */
.view { display: none; padding: 0 16px 16px; }
.view.active { display: block; }

/* Cards */
.input-card, .card, .task, .note {
  background: var(--pico-card); border: 1px solid var(--pico-border);
  border-radius: var(--pico-radius); box-shadow: var(--pico-shadow);
}
.input-card { margin: 14px 0; padding: 14px; }
.card { margin-top: 14px; padding: 16px; }
.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 14px; color: var(--pico-text); }

/* Inputs */
input, textarea, select {
  width: 100%; padding: 10px 12px; border-radius: var(--pico-radius);
  border: 1px solid var(--pico-border); background: var(--pico-card-section);
  color: var(--pico-text); font-size: 15px; outline: none;
}
input::placeholder, textarea::placeholder { color: var(--pico-muted); }
input:focus, textarea:focus, select:focus { border-color: var(--pico-primary); }

#add-form { margin-top: -8px !important; }
.hidden { display: none !important; }
.top-actions { padding: 9px 0 9px 0; }
.add-toggle { width: 100%; margin: 0; }
.input-card.hidden { display: none; }
.input-card { margin: 0px 0 8px 0; }
.add-row { display: flex; flex-direction: column; gap: 10px; }
.add-row input { min-height: 48px; font-size: 16px; }
.add-row .btn-primary { width: 100%; }

.options-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.options-row input[type=datetime-local] { flex: 1; min-width: 160px; font-size: 13px; }
.check { font-size: 13px; color: var(--pico-muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.check input { width: 18px; height: 18px; accent-color: var(--pico-primary); }

/* Buttons */
.btn-primary {
  padding: 10px 16px; border-radius: var(--pico-radius); border: none;
  background: var(--pico-primary-bg); color: #fff; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background .15s;
}
.btn-primary:active { background: var(--pico-primary-hover); }
.btn-primary.full { width: 100%; margin-top: 8px; }
.btn-secondary {
  padding: 6px 12px; border-radius: var(--pico-radius);
  border: 1px solid var(--pico-border); background: transparent;
  color: var(--pico-muted); font-size: 12px; cursor: pointer;
}
.btn-secondary:active { border-color: var(--pico-primary); color: var(--pico-primary); }



/* Search */
.search { padding: 10px 12px; font-size: 14px; }

/* Tasks */
.task-list, .note-list { display: flex; flex-direction: column; gap: 8px; }
.task { padding: 14px; }
.task.done { opacity: 0.65; }
.task-top { display: flex; align-items: flex-start; gap: 12px; }
.task-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--pico-border); display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex: 0 0 auto; font-size: 12px; color: transparent; margin-top: 2px;
}
.task.done .task-check { background: var(--pico-success); border-color: var(--pico-success); color: #fff; }
.task-body { flex: 1; }
.task-title { font-size: 15px; line-height: 1.4; word-break: break-word; color: var(--pico-text); }
.task.done .task-title { text-decoration: line-through; color: var(--pico-muted); }
.task-meta { font-size: 12px; color: var(--pico-muted); margin-top: 4px; }
.task-priority {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: rgba(212, 160, 23, 0.15); color: var(--pico-warning); font-size: 11px; margin-bottom: 6px;
}
.task-actions { display: flex; margin-top: 12px; }
.task-actions .btn-secondary {
  flex: 1; justify-content: center;
  padding: 6px 2px; font-size: 11px; border-radius: 0;
  border-right: none; white-space: nowrap;
}
.task-actions .btn-secondary:first-child { border-radius: var(--pico-radius) 0 0 var(--pico-radius); }
.task-actions .btn-secondary:last-child { border-radius: 0 var(--pico-radius) var(--pico-radius) 0; border-right: 1px solid var(--pico-border); }
.task-files { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.file-btn { display: inline-flex; align-items: center; gap: 6px; }
.file-btn i { font-size: 13px; }
.file-btn span { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Notes */
.note { padding: 14px; }
.note-content { white-space: pre-wrap; font-size: 14px; word-break: break-word; color: var(--pico-text); }
.note-actions { display: flex; gap: 6px; margin-top: 10px; }

/* Export */
.form-row { margin-bottom: 10px; }
.form-row.dates { display: flex; gap: 8px; align-items: center; }
.form-row.dates input { flex: 1; }
.export-result { margin-top: 12px; color: var(--pico-text); }
.export-result a { color: var(--pico-primary); }
.export-result pre {
  background: var(--pico-bg); padding: 10px; border-radius: var(--pico-radius);
  white-space: pre-wrap; font-size: 12px; margin-top: 8px;
  border: 1px solid var(--pico-border); color: var(--pico-muted);
}

.task-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  color: #fff; font-size: 11px;
}
.subtask-count, .assignee { margin-right: 8px; }

.modal {
  position: fixed; inset: 0; background: rgba(7, 8.5, 12, 0.85); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-content {
  background: var(--pico-card); border: 1px solid var(--pico-border);
  border-radius: var(--pico-radius); width: 100%; max-width: 420px; max-height: 80vh;
  overflow-y: auto; padding: 16px; box-shadow: var(--pico-shadow);
}
.modal-content h3 { margin-bottom: 12px; font-size: 16px; color: var(--pico-text); }
.modal-content h4 { margin: 14px 0 8px; font-size: 13px; color: var(--pico-muted); }
.modal-section { margin-bottom: 12px; }
.subtask { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.subtask input { width: 18px; height: 18px; accent-color: var(--pico-primary); }
.subtask span { flex: 1; font-size: 14px; }
.add-subtask { display: flex; gap: 8px; margin-top: 8px; }
.add-subtask input { flex: 1; }
.tags-select { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.tag-check { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; color: #fff; font-size: 12px; }
.tag-check input { width: 14px; height: 14px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn-secondary { flex: 1; justify-content: center; }

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-size: 14px;
}
.toggle-row input[type=checkbox] {
  width: 44px;
  height: 24px;
  accent-color: var(--pico-primary);
}

.time-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 10px;
}
.time-table th,
.time-table td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--pico-border);
  text-align: left;
}
.time-table th {
  font-weight: 600;
  opacity: 0.8;
}

/* Drawer */
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 260px;
  background: var(--pico-card); z-index: 30;
  transform: translateX(-100%); transition: transform .25s ease;
  border-right: 1px solid var(--pico-border);
}
.drawer.open { transform: translateX(0); }
.drawer-header { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--pico-border); color: var(--pico-text); }
.drawer-body { padding: 12px; }
.drawer-item { display: block; padding: 12px; text-decoration: none; color: var(--pico-text); border-radius: var(--pico-radius); }
.drawer-item:active { background: var(--pico-card-section); }
.overlay {
  position: fixed; inset: 0; background: rgba(7, 8.5, 12, 0.75); z-index: 25;
  display: none;
}
.overlay.show { display: block; }

/* Misc */
.empty { text-align: center; color: var(--pico-muted); padding: 30px 20px; }
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--pico-card); color: var(--pico-text); padding: 10px 16px;
  border-radius: 999px; font-size: 13px; z-index: 40; border: 1px solid var(--pico-border);
  box-shadow: var(--pico-shadow); display: none;
}
.toast.show { display: block; }
