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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f0f2;
  color: #1d1d1f;
  min-height: 100vh;
}

header {
  background: #1c1c1e;
  color: white;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

header h1 { font-size: 1.2rem; font-weight: 600; letter-spacing: 0.01em; flex: 1; }

#campaign-select {
  background: #2c2c2e;
  color: white;
  border: 1px solid #48484a;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
}

#campaign-select:focus { border-color: #636366; }

#add-btn {
  background: none;
  color: #aaa;
  border: 1px solid #48484a;
  border-radius: 6px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

#add-btn:hover { color: white; border-color: #888; }

nav {
  background: white;
  border-bottom: 1px solid #ddd;
  padding: 0 2rem;
  display: flex;
}

.tab-btn {
  padding: 0.8rem 1.25rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: #888;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  font-weight: 500;
}

.tab-btn:hover:not(.active) { color: #444; }
.tab-btn.active { color: #1c1c1e; border-bottom-color: #1c1c1e; }

#search-bar {
  background: white;
  border-bottom: 1px solid #ddd;
  padding: 0.65rem 2rem;
}

#search-input {
  width: 100%;
  max-width: 400px;
  padding: 0.4rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

#search-input:focus { border-color: #999; }

main {
  max-width: 780px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.panel { display: none; }
.panel.active { display: block; }

#loading {
  text-align: center;
  color: #aaa;
  padding: 3rem;
  font-size: 0.95rem;
}

/* Accordion */
.item {
  background: white;
  border-radius: 10px;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  overflow: hidden;
}

.item-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem 1.25rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}

.item-header:hover { background: #fafafa; }

.item-name {
  font-weight: 500;
  font-size: 0.97rem;
}

.chevron {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.4;
  transition: transform 0.22s ease, opacity 0.15s;
}

.item.open .chevron { transform: rotate(180deg); opacity: 0.7; }

.item-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease;
}

.item.open .item-body { max-height: 1200px; }

.item-content {
  padding: 0.85rem 1.25rem 1.25rem;
  border-top: 1px solid #f0f0f0;
}

.item-content p {
  color: #555;
  line-height: 1.65;
  font-size: 0.92rem;
  white-space: pre-wrap;
  text-align: center;
}

.item-image-box {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
  border-radius: 8px;
  padding: 1rem;
}

.item-image {
  max-width: 100%;
  max-height: 380px;
  object-fit: contain;
  border-radius: 5px;
}

.file-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.85rem;
  color: #0051a8;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
}

.file-link:hover { text-decoration: underline; }
.file-link svg { flex-shrink: 0; }

/* Item action buttons */
.item-actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f0f0f0;
}

.edit-btn, .delete-btn {
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 0.3rem 0.85rem;
  font-size: 0.8rem;
  cursor: pointer;
  background: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.edit-btn  { color: #444; }
.edit-btn:hover  { background: #f5f5f5; border-color: #bbb; }
.delete-btn { color: #c0392b; border-color: #eecfcc; }
.delete-btn:hover { background: #fdf0ef; border-color: #c0392b; }

/* Delete confirm modal */
#delete-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

#delete-overlay.open { display: flex; }

#delete-modal {
  background: white;
  border-radius: 12px;
  padding: 1.75rem;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

#delete-modal h2 { font-size: 1.1rem; font-weight: 600; }
#delete-modal p  { font-size: 0.88rem; color: #888; }

#delete-modal label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: #666;
}

#delete-modal input {
  padding: 0.45rem 0.7rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

#delete-modal input:focus { border-color: #999; }

#delete-error {
  font-size: 0.85rem;
  color: #c0392b;
  min-height: 1.1em;
}

#delete-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

#delete-cancel {
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.45rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: #555;
}

#delete-cancel:hover { border-color: #aaa; }

#delete-confirm {
  background: #c0392b;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 1.1rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}

#delete-confirm:hover    { background: #a93226; }
#delete-confirm:disabled { background: #aaa; cursor: default; }

#modal-note {
  font-size: 0.8rem;
  color: #888;
  font-style: italic;
}

.modal-field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: #666;
  margin-bottom: 0.3rem;
}

#modal-campaigns-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.campaign-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #1d1d1f;
  font-weight: normal;
  cursor: pointer;
}

.delete-all-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: #1d1d1f;
  cursor: pointer;
}

/* Modal */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

#modal-overlay.open { display: flex; }

#modal {
  background: white;
  border-radius: 12px;
  padding: 1.75rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

#modal h2 { font-size: 1.1rem; font-weight: 600; }

#modal label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: #666;
}

#modal input[type="text"],
#modal input[type="password"],
#modal select,
#modal textarea {
  padding: 0.45rem 0.7rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  color: #1d1d1f;
}

#modal input:focus,
#modal select:focus,
#modal textarea:focus { border-color: #999; }

#modal textarea { resize: vertical; }

#modal-error {
  font-size: 0.85rem;
  color: #c0392b;
  min-height: 1.1em;
}

#modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

#modal-cancel {
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.45rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: #555;
  transition: border-color 0.15s;
}

#modal-cancel:hover { border-color: #aaa; }

#modal-submit {
  background: #1c1c1e;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 1.1rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}

#modal-submit:hover { background: #333; }
#modal-submit:disabled { background: #aaa; cursor: default; }