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

:root {
  --primary: #1a7a5e;
  --primary-light: #22a37e;
  --primary-dark: #135c47;
  --bg: #f0f4f2;
  --card: #ffffff;
  --border: #d1e0da;
  --text: #1a2e27;
  --text-muted: #5a7a6e;
  --check-color: #1a7a5e;
  --danger: #c0392b;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --section-header-bg: linear-gradient(135deg, #f7faf8 0%, #eef5f1 100%);
  --item-hover-bg: #f7faf8;
  --checkbox-bg: #ffffff;
  --btn-new-bg: #e8f5ee;
}

[data-theme="dark"] {
  --primary: #2ecc9a;
  --primary-light: #3de0a8;
  --primary-dark: #1fa87a;
  --bg: #111a15;
  --card: #1b2820;
  --border: #2a3d32;
  --text: #dff0e8;
  --text-muted: #7aaa90;
  --check-color: #2ecc9a;
  --danger: #e05c4b;
  --shadow: 0 2px 8px rgba(0,0,0,0.35);
  --section-header-bg: linear-gradient(135deg, #1e2f26 0%, #172319 100%);
  --item-hover-bg: #1e2f26;
  --checkbox-bg: #253328;
  --btn-new-bg: #1e2f26;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* TOPBAR */
.topbar {
  background: var(--primary-dark);
  color: #fff;
  padding: 0 1.5rem;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
}
.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
}
.topbar-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.btn {
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1rem;
  min-height: 44px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-ghost {
  background: rgba(255,255,255,0.15);
  color: #fff;
}
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.25); }
.btn-primary {
  background: var(--primary-light);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary); }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover:not(:disabled) { background: var(--primary); color: #fff; }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #a93226; }
.topbar-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.2);
  margin: 0 0.1rem;
}

.lang-btn {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.7);
  border: 1.5px solid rgba(255,255,255,0.25);
  border-radius: 5px;
  padding: 0.45rem 0.75rem;
  min-height: 36px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.15s;
}
.lang-btn.active {
  background: rgba(255,255,255,0.28);
  color: #fff;
  border-color: rgba(255,255,255,0.6);
}
.lang-btn:hover { background: rgba(255,255,255,0.22); }

.btn-new {
  background: var(--btn-new-bg);
  color: var(--primary);
  border: 1.5px solid var(--border);
}
.btn-new:hover:not(:disabled) { background: var(--border); }

/* MAIN LAYOUT */
.main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

/* PROGRESS CARD */
.progress-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.2rem;
  border: 1px solid var(--border);
}
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.progress-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.progress-count {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}
.progress-bar-wrap {
  height: 10px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 99px;
  transition: width 0.3s ease;
}
.progress-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
}
.progress-pct {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.toggle-completed-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem 0;
  min-height: 44px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.toggle-completed-btn:hover { color: var(--primary-dark); }

/* FILE CONTROLS */
.file-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.4rem;
  margin-bottom: 1.2rem;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.file-name-input {
  flex: 1;
  min-width: 160px;
  min-height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}
.file-name-input:focus { border-color: var(--primary); }
.save-status {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  margin-left: auto;
}
.save-status.ok { color: var(--primary); }

/* SECTIONS */
.section-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  overflow: hidden;
}
.section-header {
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  background: var(--section-header-bg);
}
.section-number {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  margin-top: 0.1rem;
}
.section-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  line-height: 1.4;
}
.section-badge {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border-radius: 99px;
  padding: 0.15rem 0.6rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.section-badge.done { background: #27ae60; }

.items-list { list-style: none; }
.item-row {
  display: flex;
  align-items: center;
  padding: 1rem 1.4rem;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  min-height: 56px;
}
.item-row:last-child { border-bottom: none; }
.item-row:hover { background: var(--item-hover-bg); }
.item-row.completed { opacity: 0.6; }
.item-row.hidden { display: none; }

.item-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: var(--checkbox-bg);
  flex-shrink: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.item-checkbox:checked {
  background: var(--check-color);
  border-color: var(--check-color);
}
.item-checkbox:checked::after {
  content: '';
  display: block;
  width: 6px;
  height: 11px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}
.item-checkbox:focus { outline: 2px solid var(--primary-light); outline-offset: 2px; }

.item-content { flex: 1; }
.item-code {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.05em;
  margin-bottom: 0.15rem;
}
.item-label {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
}
.item-row.completed .item-label {
  text-decoration: line-through;
  color: var(--text-muted);
}

.info-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.info-btn:hover { background: var(--primary); color: #fff; }

/* MODAL */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 1.2rem 1.4rem 0.8rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.modal-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { color: var(--text); background: var(--item-hover-bg); }
.modal-body {
  padding: 1.2rem 1.4rem;
  overflow-y: auto;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
}
.modal-footer {
  padding: 0.8rem 1.4rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

#file-input { display: none; }

@media (max-width: 600px) {
  .topbar-title { font-size: 0.88rem; }
  .file-card { flex-direction: column; align-items: stretch; }
  .save-status { margin-left: 0; }
}
