* {
  box-sizing: border-box;
}

:root {
  --bg: #0b1220;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-700: #1d4ed8;
  --danger: #dc2626;
  --danger-700: #b91c1c;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at top left, #1e293b 0%, rgba(30, 41, 59, 0) 36%),
    radial-gradient(circle at top right, #1d4ed8 0%, rgba(29, 78, 216, 0) 34%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.container-wide {
  max-width: min(1700px, 98vw);
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.header {
  margin-bottom: 16px;
}

.header-inner {
  background: linear-gradient(132deg, rgba(37, 99, 235, 0.98), rgba(14, 116, 144, 0.98));
  border-radius: 16px;
  padding: 22px 20px;
  color: #fff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-size: 26px;
  font-weight: 700;
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 12px;
  background: #fff;
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.35);
}

.header-subtitle {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.92);
}

.card {
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.pill {
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
}

.pill.muted {
  background: #e2e8f0;
  color: #334155;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 10px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 14px;
  color: #334155;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="file"] {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 11px;
  background: #fff;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="file"]:focus {
  outline: 2px solid rgba(37, 99, 235, 0.23);
  border-color: #93c5fd;
}

button {
  padding: 9px 14px;
  border: 0;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: 0.15s ease;
}

button:hover {
  background: var(--primary-700);
  transform: translateY(-1px);
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: var(--danger-700);
}

.ghost-danger {
  box-shadow: inset 0 0 0 1px rgba(220, 38, 38, 0.1);
}

.campaign-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
  margin-bottom: 12px;
  background: var(--surface-soft);
}

.campaign-main {
  display: flex;
  gap: 14px;
  align-items: center;
}

.campaign-text h3 {
  margin: 0;
}

.campaign-text p {
  margin: 8px 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.campaign-name-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
  transition: color 0.15s, text-decoration-color 0.15s;
  text-underline-offset: 3px;
}

.campaign-name-link:hover {
  color: var(--primary-700);
  text-decoration: underline;
}

.amount {
  font-size: 23px;
  font-weight: 700;
  color: #0f172a;
}

.total-card {
  margin-top: 10px;
  background: linear-gradient(135deg, #eff6ff, #ecfeff);
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 14px;
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  min-width: 240px;
}

.total-label {
  color: #334155;
  font-size: 13px;
  font-weight: 600;
}

.total-value {
  font-size: 30px;
  line-height: 1.1;
  font-weight: 800;
  color: #1d4ed8;
}

.campaign-item-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
}

.btn-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.btn-edit:hover,
.btn-edit-active {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: var(--primary);
  transform: none;
}

.btn-edit svg {
  flex-shrink: 0;
}

.edit-panel {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.edit-panel-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.edit-panel-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  flex: 1 1 180px;
  min-width: 160px;
}

.edit-panel-label input[type="text"] {
  width: 100%;
}

.edit-panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-bottom: 1px;
}

.thumb {
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--muted);
}

.cover {
  margin-top: 8px;
  width: 260px;
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  background: #eef2ff;
  color: #1e40af;
  border: 1px solid #c7d2fe;
}

.link-button:hover {
  background: #e0e7ff;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

/* Truncate long-text columns with an ellipsis; full text shown via title tooltip */
.cell-truncate {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

thead th {
  background: #f1f5f9;
}

tbody tr:nth-child(even) {
  background: #fcfdff;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.flash-container {
  margin-bottom: 12px;
}

.flash {
  padding: 11px 12px;
  border-radius: 9px;
  margin-bottom: 8px;
  border: 1px solid transparent;
  font-weight: 500;
}

.flash.success {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.flash.error {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

/* Scrollable wrapper for wide donations table */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll table {
  min-width: 1600px;
}

/* Failed donation rows — muted appearance */
tr.donation-failed td {
  color: var(--muted);
  text-decoration: line-through;
  background: #fef2f2;
}

tr.donation-failed .badge {
  text-decoration: none;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-completed {
  background: #dcfce7;
  color: #166534;
}

.badge-failed {
  background: #fee2e2;
  color: #991b1b;
}

/* Negative amounts */
.amount-negative {
  color: var(--danger);
}

/* ── Donations toolbar: search + column picker ─────────────────────────── */
.donations-toolbar {
  margin-bottom: 14px;
}

.search-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.search-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  min-width: 130px;
  flex: 1 1 130px;
}

.search-label input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
  background: #fff;
  width: 100%;
}

.search-label input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.2);
  border-color: #93c5fd;
}

.search-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  padding-bottom: 1px;
}

.btn-ghost {
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}

.btn-ghost:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #1e40af;
  transform: none;
}

/* Column picker dropdown */
.col-picker-wrap {
  position: relative;
}

.col-picker-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 200;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
  padding: 10px 4px;
  min-width: 210px;
  max-height: 340px;
  overflow-y: auto;
}

.col-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #1e293b;
  cursor: pointer;
  border-radius: 6px;
  margin: 0 4px;
}

.col-picker-item:hover {
  background: #f1f5f9;
}

.col-picker-item input[type="checkbox"] {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Header nav ────────────────────────────────────────────────────────────── */
.header-nav {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover,
.nav-link-active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.nav-user {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  padding: 6px 10px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.88);
}

.nav-logout-form {
  margin: 0;
}

.nav-logout-btn {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.nav-logout-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: min(100%, 420px);
  padding: 28px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.login-brand h1 {
  margin: 0;
  font-size: 24px;
}

.login-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── KPI cards ──────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.1);
}

.kpi-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
}

/* ── Chart cards ───────────────────────────────────────────────────────────── */
.chart-card {
  margin-bottom: 16px;
}

.chart-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.chart-wrap {
  position: relative;
  height: 300px;
  margin-top: 16px;
}

.chart-wrap-tall {
  height: 360px;
}

.chart-wrap-doughnut {
  height: 320px;
}

.chart-empty {
  color: var(--muted);
  font-size: 14px;
  margin: 20px 0 4px;
}

/* ── Bottom two-column row ─────────────────────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.charts-row .chart-card {
  margin-bottom: 0;
}

/* ── Timeline controls ─────────────────────────────────────────────────────── */
.chart-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chart-select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  background: #fff;
  color: #1e293b;
  cursor: pointer;
  max-width: 260px;
}

.chart-select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.2);
  border-color: #93c5fd;
}

.toggle-group {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.toggle-btn {
  padding: 6px 12px;
  border: 0;
  border-radius: 0;
  background: #f8fafc;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.toggle-btn:hover {
  background: #eef2ff;
  color: #1e40af;
  transform: none;
}

.toggle-btn-active {
  background: var(--primary);
  color: #fff;
}

.toggle-btn-active:hover {
  background: var(--primary-700);
  color: #fff;
}

@media (max-width: 760px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .card-title-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .campaign-item-controls {
    margin-left: auto;
  }

  .edit-panel-form {
    flex-direction: column;
  }

  .edit-panel-label {
    flex: 1 1 100%;
  }

  .edit-panel-actions {
    width: 100%;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .charts-row {
    grid-template-columns: 1fr;
  }

  .chart-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .chart-select {
    max-width: 100%;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-value {
    font-size: 18px;
  }
}
