:root {
  --bg: #f7f7fb;
  --text: #222;
  --muted: #666;
  --primary: #2a6cf0;
  --primary-dark: #1e5ad9; /* Darker shade for hover */
  --border: #e5e7eb;
  --success: #16a34a;
  --success-dark: #128a3e;
  --warning: #f59e0b;
  --danger: #dc2626;
  --danger-dark: #b81c1c;
  --card: #fff;
  --open: #fce7f3;       /* pink */
  --accepted: #dcfce7;   /* green */
  --proposed: #ede9fe;   /* purple */
  --archived: #f3f4f6;   /* gray */
  --gold: #f7d674;
  --upcoming: #e0f2fe;   /* light blue for KPI "upcoming" */
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1100px; margin: 0 auto; padding: 16px; }

.navbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-bottom: 1px solid var(--border); padding: 10px 16px; position: sticky; top: 0; z-index: 5;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.nav-left, .nav-right { display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 700; letter-spacing: .3px; font-size: 1.1em; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 10px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--border); background: #fff;
  font-weight: 500;
}
.badge.locale { padding: 2px 8px; } /* Smaller for locale flags */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--primary); color: #fff; border: none;
  padding: 10px 16px; border-radius: 8px; cursor: pointer;
  font-size: 15px; font-weight: 600;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  text-decoration: none;
}
.btn.secondary {
  background: #e5e7eb; color: #111;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn.secondary:hover {
  background: #d1d5db;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.btn.success { background: var(--success); }
.btn.success:hover { background: var(--success-dark); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger-dark); }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn.link {
  background: transparent; color: var(--primary); padding: 0;
  box-shadow: none; font-weight: 500;
}
.btn.link:hover {
  background: transparent; color: var(--primary-dark);
  text-decoration: underline; box-shadow: none;
}

input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="time"], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 15px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}
textarea { min-height: 90px; resize: vertical; }
label { display: block; margin-bottom: 4px; font-weight: 500; color: var(--text); font-size: 0.95em; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 12px; }
.form-actions { display:flex; gap: 10px; align-items: center; margin-top: 16px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3,1fr); }
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

.table { width: 100%; border-collapse: collapse; margin-top: 16px; }
.table th, .table td { padding: 12px; border-bottom: 1px solid var(--border); text-align: left; }
.table th { font-weight: 600; background: #fafafa; }
.table tbody tr:last-child td { border-bottom: none; }

.flash { padding: 12px 16px; border-radius: 8px; margin: 12px 0; font-weight: 500; }
.flash.success { background: #dcfce7; color: #065f46; border: 1px solid #bbf7d0; }
.flash.error { background: #fee2e2; color: #7f1d1d; border: 1px solid #fecaca; }

/* Modern KPI box */
.kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.kpi .item {
  background: #fff;
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  text-align: center;
  transition: transform .1s ease, box-shadow .2s ease, border-color .2s ease, background-color .2s ease;
  user-select: none;
}
.kpi .item:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.08);
  border-color: #dfe3ea;
}
.kpi .item:active {
  transform: translateY(0);
  box-shadow: 0 3px 8px rgba(0,0,0,0.07);
}
.kpi .item .icon {
  width: 40px; height: 40px; margin: 0 auto 10px auto;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700;
  background: #f3f4f6; color: #111;
}
.kpi .item .value {
  font-size: 30px; font-weight: 800; color: #0f172a; line-height: 1;
}
.kpi .item .label {
  font-size: 13px; color: var(--muted); margin-top: 6px; letter-spacing: .2px; font-weight: 600;
}

/* Themed variants */
.kpi .item.proposed { background: linear-gradient(180deg, #ffffff, #faf7ff); }
.kpi .item.proposed .icon { background: var(--proposed); color: #6b21a8; }
.kpi .item.proposed .value { color: #6b21a8; }

.kpi .item.open { background: linear-gradient(180deg, #ffffff, #fff7fb); }
.kpi .item.open .icon { background: var(--open); color: #be185d; }
.kpi .item.open .value { color: #be185d; }

.kpi .item.accepted { background: linear-gradient(180deg, #ffffff, #f3fff6); }
.kpi .item.accepted .icon { background: var(--accepted); color: #166534; }
.kpi .item.accepted .value { color: #166534; }

.kpi .item.upcoming { background: linear-gradient(180deg, #ffffff, #f0f9ff); }
.kpi .item.upcoming .icon { background: var(--upcoming); color: #075985; }
.kpi .item.upcoming .value { color: #075985; }

/* Modern Actions box */
.action-group {
  display: flex;
  flex-direction: column;
  gap: 12px; /* Spacing between action items */
  margin-top: 10px; /* Add some top margin to separate from heading */
}
.action-group .btn {
  width: fit-content; /* Default for larger screens */
  align-self: flex-start; /* Align to start when width is fit-content */
}

.action-item-form {
  display: flex;
  flex-direction: column; /* Stack selects and button by default */
  gap: 8px;
}

.action-item-form .form-group { /* For admin scope + button */
  display: flex;
  flex-wrap: wrap; /* Allow wrapping on small screens */
  gap: 8px;
  align-items: center;
}

.action-item-form select {
  flex-grow: 1; /* Allow select to grow */
  min-width: 120px; /* Minimum width for select */
}

/* Modern Event Cards for Dashboard */
.event-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Responsive columns */
  gap: 16px;
  margin-bottom: 16px; /* Add margin below event list */
}

.event-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform .1s ease, box-shadow .2s ease, border-color .2s ease;
  user-select: none; /* Added for consistency with KPI items */
}
.event-card:hover {
  transform: translateY(-1px); /* Adjusted to match KPI items */
  box-shadow: 0 6px 14px rgba(0,0,0,0.08); /* Adjusted to match KPI items */
  border-color: #dfe3ea; /* Added for consistency with KPI items */
}

.event-card .event-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 1.1em;
  color: var(--text);
}
.event-card .event-header .icon,
.event-card .event-details .icon,
.event-card .event-children .icon,
.event-card .event-note .icon {
  margin-right: 4px; /* Added margin to icons */
}

.event-card .event-details {
  font-size: 0.95em;
  color: var(--muted);
}
.event-card .event-details strong {
  color: var(--text);
}

.event-card .event-children {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.9em;
  color: var(--muted);
}
.event-card .event-children .child-item {
  background: #f3f4f6;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 500;
}

.event-card .event-note {
  font-size: 0.9em;
  color: var(--muted);
  margin-top: 4px;
  flex-grow: 1; /* Allow note to take up available space */
}

.event-card .event-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end; /* Align button to the right */
}

/* Themed event card variants */
.event-card.event-open {
  border-left: 5px solid #f472b6; /* Pink border */
  background: linear-gradient(180deg, #ffffff, var(--open));
}
.event-card.event-open .event-header { color: #be185d; } /* Darker pink text */

.event-card.event-accepted {
  border-left: 5px solid #22c55e; /* Green border */
  background: linear-gradient(180deg, #ffffff, var(--accepted));
}
.event-card.event-accepted .event-header { color: #166534; } /* Darker green text */

.event-card.event-proposed {
  border-left: 5px solid #8b5cf6; /* Purple border */
  background: linear-gradient(180deg, #ffffff, var(--proposed));
}
.event-card.event-proposed .event-header { color: #6b21a8; } /* Darker purple text */

.event-card.event-archived {
  border-left: 5px solid #9ca3af; /* Gray border */
  background: linear-gradient(180deg, #ffffff, var(--archived));
}
.event-card.event-archived .event-header { color: #4b5563; } /* Darker gray text */


.legend { display:flex; gap:15px; flex-wrap: wrap; font-size:14px; }
.legend .item { display:flex; align-items:center; gap:6px; }
.legend .color { width:16px; height:16px; border-radius: 4px; display:inline-block; border:1px solid var(--border); }

.calendar { background: var(--card); border:1px solid var(--border); border-radius:12px; overflow:hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.calendar .header { display:flex; align-items:center; justify-content: space-between; padding: 12px; border-bottom:1px solid var(--border); background: #fafafa; }
.calendar .header strong { font-size: 1.1em; }
.calendar .grid { display:grid; grid-template-columns: repeat(7, 1fr); }
.calendar .dow { background:#f0f0f0; font-weight:600; font-size:12px; text-transform: uppercase; letter-spacing: .5px; padding: 8px; border-bottom:1px solid var(--border); text-align: center; }
.calendar .cell { min-height: 120px; padding: 8px; border-right:1px solid var(--border); border-bottom: 1px solid var(--border); position: relative; }
.calendar .cell:nth-child(7n) { border-right: none; } /* No right border on last day of week */
.calendar .cell .date { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.calendar .cell .events { margin-top: 6px; display:flex; flex-direction:column; gap:4px; }
.calendar .bar {
  padding: 3px 8px; border-radius: 6px; font-size: 12px; display:inline-block;
  white-space: nowrap; overflow:hidden; text-overflow: ellipsis; cursor: pointer;
  max-width: 100%;
}
.calendar .cell.gold { background: linear-gradient(180deg, rgba(247,214,116,0.25), transparent); }
.calendar .cell .add {
  position: absolute; right: 6px; bottom: 6px; font-size: 12px;
  width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.calendar .cell .add:hover { background: var(--primary-dark); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); display:none; align-items: center; justify-content: center; z-index: 10; }
.modal { background:#fff; border-radius: 12px; border:1px solid var(--border); width: min(560px, 92%); padding: 20px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.modal.show + .modal-backdrop, .modal-backdrop.show { display:flex; }

.footer { color: var(--muted); font-size: 12px; padding: 20px 0; text-align: center; margin-top: 30px; }

/* Responsive adjustments for smaller screens */
@media (max-width: 600px) {
  .navbar { flex-wrap: wrap; justify-content: center; gap: 10px; }
  .nav-left, .nav-right { flex-wrap: wrap; justify-content: center; gap: 8px; }
  .brand { width: 100%; text-align: center; margin-bottom: 8px; }
  .btn { padding: 8px 12px; font-size: 14px; }
  .badge { padding: 3px 8px; font-size: 12px; }
  .calendar .cell { min-height: 80px; padding: 6px; }
  .calendar .bar { font-size: 11px; padding: 2px 5px; }
  .calendar .cell .add { width: 20px; height: 20px; font-size: 10px; right: 4px; bottom: 4px; }
  .legend { justify-content: center; gap: 10px; }
  .table th, .table td { padding: 8px; font-size: 14px; }
  .kpi { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .kpi .item .icon { width: 36px; height: 36px; font-size: 18px; }
  .kpi .item .value { font-size: 26px; }

  .action-group .btn {
    width: 100%; /* Full width on small screens */
    align-self: stretch; /* Stretch to fill container */
  }
  .action-item-form .form-group {
    flex-direction: column; /* Stack select and button on very small screens */
    align-items: stretch; /* Make them full width */
  }
  .action-item-form select {
    width: 100%; /* Ensure full width on small screens */
  }

  .event-list {
    grid-template-columns: 1fr; /* Single column on very small screens */
  }
}
