:root {
  --primary: #FF6B35;
  --primary-dark: #E55A28;
  --bg: #0F1117;
  --bg2: #1A1D26;
  --surface: #1E2132;
  --surface2: #272B40;
  --border: #2E3350;
  --text: #F0F2FF;
  --text2: #9BA3C8;
  --text3: #5A6180;
  --success: #4CAF87;
  --danger: #FF5757;
  --blue: #5B8AF0;
  --radius: 14px;
  --radius-sm: 9px;
}

html[data-theme="light"] {
  --bg: #F4F5FB;
  --bg2: #FFFFFF;
  --surface: #FFFFFF;
  --surface2: #EEF0F9;
  --border: #D8DBF0;
  --text: #1A1D2E;
  --text2: #4A5175;
  --text3: #8A91B8;
  --shadow: 0 4px 24px rgba(0,0,0,0.10);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.07);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ── */
.site-nav {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-inner {
  max-width: 1100px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 24px; height: 60px;
}
.nav-logo {
  font-family: 'Nunito', sans-serif; font-weight: 900; font-size: 22px;
  color: var(--primary); text-decoration: none; letter-spacing: -0.5px;
  flex-shrink: 0;
}
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a {
  padding: 7px 14px; border-radius: 8px; font-size: 14px; font-weight: 600;
  color: var(--text2); text-decoration: none; transition: all .15s;
}
.nav-links a:hover { color: var(--text); background: var(--surface); }
.nav-links a.active { color: var(--primary); background: rgba(255,107,53,.1); }
.nav-links a.btn-sm {
  background: var(--primary); color: white; padding: 7px 16px;
}
.nav-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.nav-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Nunito', sans-serif; font-weight: 900; font-size: 14px; color: white;
  flex-shrink: 0;
}
.nav-name { font-size: 14px; font-weight: 600; color: var(--text2); }
.nav-logout { font-size: 13px; color: var(--text3); }
.theme-toggle {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; transition: background .15s;
}
.theme-toggle:hover { background: var(--border); }
.theme-icon-dark  { display: none; }
.theme-icon-light { display: none; }
html[data-theme="dark"]  .theme-icon-dark  { display: block; }
html[data-theme="light"] .theme-icon-light { display: block; }
html[data-theme="light"] .cal-cell.other-month { background: rgba(244,245,251,.7); }
html[data-theme="light"] .table tbody tr:hover { background: rgba(0,0,0,.02); }

/* ── Layout ── */
.page { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.page-header { margin-bottom: 28px; }
.page-header h1 {
  font-family: 'Nunito', sans-serif; font-weight: 900; font-size: 30px;
  letter-spacing: -0.5px; color: var(--text);
}
.page-header p { color: var(--text3); margin-top: 4px; font-size: 15px; }
.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.card-header {
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 {
  font-family: 'Nunito', sans-serif; font-size: 18px; font-weight: 800;
}
.card-body { padding: 20px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 20px; border-radius: var(--radius-sm); font-weight: 600;
  font-size: 14px; cursor: pointer; border: none; transition: all .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: rgba(255,87,87,.15); color: var(--danger); }
.btn-danger:hover { background: rgba(255,87,87,.25); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { background: var(--surface); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 13px 28px; font-size: 16px; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.form-label { font-size: 12px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; }
.form-control {
  background: var(--bg2); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 14px; color: var(--text); font-size: 15px; font-family: inherit;
  transition: border-color .15s; width: 100%;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-control::placeholder { color: var(--text3); }
select.form-control { appearance: none; cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Flash messages ── */
.flash {
  max-width: 1100px; margin: 0 auto; padding: 12px 24px;
  border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; margin-top: 16px;
}
.flash-success { background: rgba(76,175,135,.15); color: var(--success); border: 1px solid rgba(76,175,135,.3); }
.flash-error   { background: rgba(255,87,87,.12); color: var(--danger); border: 1px solid rgba(255,87,87,.25); }

/* ── Table ── */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.table th { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255,255,255,.02); }

/* ── Badge / Pill ── */
.badge {
  display: inline-flex; align-items: center; padding: 3px 9px;
  border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .03em;
}
.badge-owner  { background: rgba(255,107,53,.15); color: var(--primary); }
.badge-member { background: rgba(91,138,240,.15); color: var(--blue); }
.badge-viewer { background: var(--surface2); color: var(--text3); }

/* ── Calendar grid ── */
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.cal-header-cell {
  background: var(--surface2); padding: 10px 6px; text-align: center;
  font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase;
  letter-spacing: .05em; border-bottom: 1px solid var(--border);
}
.cal-cell {
  min-height: 100px; padding: 8px 6px; border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border); background: var(--surface); vertical-align: top;
  cursor: pointer; transition: background .1s; min-width: 0; overflow: hidden;
}
.cal-cell:hover { background: var(--surface2); }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.other-month { background: rgba(15,17,23,.5); }
.cal-cell.other-month .cal-day-num { color: var(--text3); }
.cal-cell.today .cal-day-num {
  background: var(--primary); color: white; width: 26px; height: 26px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.cal-day-num {
  font-size: 13px; font-weight: 700; color: var(--text2); margin-bottom: 5px;
  width: 26px; display: flex; align-items: center; justify-content: center;
}
.cal-event {
  font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px;
  margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; color: white;
}
.cal-more { font-size: 11px; color: var(--text3); padding-left: 4px; font-weight: 600; }

/* ── Month nav ── */
.cal-nav { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.cal-nav h2 { font-family: 'Nunito'; font-weight: 900; font-size: 22px; flex: 1; }

/* ── Filters ── */
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; font-size: 13px; font-weight: 600; color: var(--text2);
  cursor: pointer; text-decoration: none; transition: all .15s;
}
.filter-chip:hover { text-decoration: none; color: var(--text); }
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: white; }

/* ── Dashboard stats ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center;
}
.stat-value { font-family: 'Nunito'; font-weight: 900; font-size: 36px; color: var(--primary); line-height: 1; }
.stat-label { font-size: 12px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; margin-top: 6px; }

/* ── Two-col layout ── */
.two-col { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

/* ── Groups master-detail layout ── */
.groups-layout { display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: start; }
@media (max-width: 800px) { .groups-layout { grid-template-columns: 1fr; } }
.group-list-heading { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); padding: 14px 16px 6px; }
.group-list-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer; border-left: 3px solid transparent; }
.group-list-item:hover { background: var(--surface2); }
.group-list-item.active { background: var(--surface2); border-left-color: var(--primary); }

/* ── Event list item ── */
.event-row {
  display: flex; align-items: flex-start; gap: 14px; padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.event-row:last-child { border-bottom: none; }
.event-time { min-width: 68px; font-size: 13px; font-weight: 700; color: var(--text2); padding-top: 1px; }
.event-info { flex: 1; }
.event-title { font-size: 15px; font-weight: 600; color: var(--text); }
.event-meta { font-size: 12px; color: var(--text3); margin-top: 3px; }
.event-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Modal ── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  backdrop-filter: blur(6px); z-index: 200; display: none;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 20px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; padding: 28px;
  animation: modalIn .25s cubic-bezier(.34,1.56,.64,1);
}
.modal::-webkit-scrollbar { display: none; }
.modal h2 { font-family: 'Nunito'; font-weight: 900; font-size: 22px; margin-bottom: 22px; }
@keyframes modalIn { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Auth page ── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 32px 20px;
}
.auth-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 36px 32px; width: 100%; max-width: 400px;
}
.auth-logo { font-family: 'Nunito'; font-weight: 900; font-size: 36px; color: var(--primary); text-align: center; margin-bottom: 6px; }
.auth-tagline { text-align: center; color: var(--text3); font-size: 14px; margin-bottom: 28px; }
.auth-tabs { display: flex; background: var(--bg2); border-radius: 9px; padding: 3px; margin-bottom: 24px; }
.auth-tab { flex: 1; padding: 9px; text-align: center; border-radius: 7px; font-size: 14px; font-weight: 700; color: var(--text3); cursor: pointer; background: none; border: none; transition: all .15s; }
.auth-tab.active { background: var(--primary); color: white; }
.auth-link { text-align: center; font-size: 13px; color: var(--text3); margin-top: 18px; }

/* ── Group color dot ── */
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ── Empty state ── */
.empty { text-align: center; padding: 48px 20px; color: var(--text3); }
.empty h3 { font-family: 'Nunito'; font-weight: 800; font-size: 18px; color: var(--text2); margin-bottom: 8px; }
.empty p { font-size: 14px; max-width: 300px; margin: 0 auto; }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 18px 0; }

/* ── Announcement bar ── */
.announcement-bar {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 20px; background: rgba(255,179,71,.08);
  border-bottom: 1px solid rgba(255,179,71,.2);
}
.announcement-pin { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.announcement-body { flex: 1; font-size: 14px; color: var(--text); line-height: 1.5; }
.announcement-meta { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* ── Member avatar ── */
.member-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Nunito', sans-serif; font-weight: 900; font-size: 13px;
  flex-shrink: 0;
}

/* ── Color swatches (group member color picker) ── */
.color-swatch-row { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.color-swatch {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0; transition: transform .1s, border-color .1s;
}
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.selected { border-color: var(--text); transform: scale(1.15); }

/* ── Group settings card sections ── */
.settings-section-title { font-size: 13px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.toggle-row { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--text2); cursor: pointer; user-select: none; }
.toggle-row input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.settings-hint { font-size: 12px; color: var(--text3); margin: 6px 0 0; max-width: 560px; }

/* ── Event tags (recurring badge) ── */
.event-tag {
  display: inline-block; font-size: 11px; font-weight: 700;
  background: rgba(255,255,255,.15); border-radius: 4px;
  padding: 1px 4px; margin-left: 5px; vertical-align: middle;
}

/* ── Location link ── */
.location-link {
  color: var(--text3); font-size: 12px; text-decoration: none;
}
.location-link:hover { color: var(--primary); text-decoration: underline; }

/* ── Tier badge in nav ── */
.tier-badge {
  font-size: 10px; font-weight: 800; letter-spacing: .04em; padding: 2px 7px;
  border-radius: 20px; text-transform: uppercase;
}
.tier-badge-pro    { background: rgba(91,138,240,.2); color: var(--blue); }
.tier-badge-family { background: rgba(76,175,135,.2); color: var(--success); }

.nav-msg-badge {
  display: inline-block; min-width: 16px; padding: 1px 5px; font-size: 10px; font-weight: 800;
  line-height: 1.4; text-align: center; color: #fff; background: var(--primary); border-radius: 20px;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .page { padding: 20px 16px; }
  .page-header h1 { font-size: 24px; }
  .two-col { grid-template-columns: 1fr; }
  .cal-cell { min-height: 60px; }
}
