:root {
  --bg: #0f1419;
  --sidebar: #1a2332;
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(15, 20, 25, 0.08);
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #eef2f7;
  color: var(--text);
  min-height: 100vh;
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--sidebar);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand {
  display: flex;
  gap: 0.75rem;
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand__icon {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.brand strong {
  display: block;
  font-size: 1rem;
}

.brand small {
  color: #94a3b8;
  font-size: 0.75rem;
}

.sidebar__nav {
  padding: 1rem 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  text-align: left;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-item.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.nav-item--restricted {
  border: 1px dashed rgba(255, 255, 255, 0.15);
}

.nav-item--restricted.locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.nav-lock {
  font-size: 0.75rem;
  margin-left: 0.25rem;
}

.user-wrap {
  position: relative;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 8px;
}

.user-pill:hover {
  background: #f1f5f9;
}

.user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 280px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
  padding: 0.5rem 0;
}

.user-menu__label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  padding: 0.5rem 1rem;
  letter-spacing: 0.04em;
}

.user-menu ul {
  list-style: none;
}

.user-menu li button {
  width: 100%;
  text-align: left;
  padding: 0.65rem 1rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
}

.user-menu li button:hover {
  background: #f1f5f9;
}

.user-menu li button.active {
  background: #eff6ff;
  color: var(--accent);
  font-weight: 600;
}

.user-menu li small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

.access-panel {
  max-width: 480px;
  margin: 2rem auto;
  text-align: center;
  background: var(--card);
  padding: 2.5rem 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.access-panel__icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.access-panel h3 {
  margin-bottom: 0.75rem;
}

.access-panel p {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.access-panel__hint {
  font-size: 0.85rem;
  margin-top: 1rem;
}

.demo-hint code {
  background: #f1f5f9;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.gate-form {
  text-align: left;
  margin-top: 1.5rem;
}

.gate-form label {
  display: block;
  margin-bottom: 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.gate-form input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-weight: 400;
}

.form-error {
  color: #dc2626;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.bereavement-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.bereavement-banner .link-btn {
  color: #93c5fd;
  margin-left: auto;
}

.bereavement-panels .finance-panel {
  margin-top: 0;
}

.tenant-switcher-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.tenant-switcher__label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.tenant-switcher {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  min-width: 180px;
}

.nav-item--owner {
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.12);
  color: #93c5fd;
}

.nav-item--owner.active {
  background: var(--accent);
  color: #fff;
}

.account-banner {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.account-banner--past-due {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
}

.account-banner--blocked {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.account-banner strong {
  font-weight: 700;
}

.mt-lg {
  margin-top: 1.25rem;
}

.platform-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.platform-actions button {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.platform-actions button.danger {
  color: #b91c1c;
  border-color: #fecaca;
}

.platform-actions button.success {
  color: #047857;
  border-color: #a7f3d0;
}

.tenant-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: capitalize;
}

.tenant-badge.active {
  background: #d1fae5;
  color: #047857;
}

.tenant-badge.past_due {
  background: #fef3c7;
  color: #b45309;
}

.tenant-badge.blocked {
  background: #fee2e2;
  color: #b91c1c;
}

.empty-msg {
  color: var(--muted);
  padding: 2rem;
  text-align: center;
}

.platform-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.api-status {
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  background: #f1f5f9;
  color: var(--muted);
}

.api-status--ok {
  background: #d1fae5;
  color: #047857;
}

.api-status--off {
  background: #fef3c7;
  color: #b45309;
}

.sidebar__footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.badge-prototype {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  display: inline-block;
}

.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--card);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.topbar h1 {
  font-size: 1.35rem;
}

.topbar p {
  color: var(--muted);
  font-size: 0.85rem;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.search {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 220px;
  font-size: 0.9rem;
}

.notif-wrap {
  position: relative;
}

.notif-btn {
  background: #f1f5f9;
  border: none;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}

.notif-count {
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  margin-left: 0.25rem;
}

.notif-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 320px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  z-index: 50;
}

.notif-dropdown__header {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.8rem;
}

.notif-list {
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
}

.notif-list li {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.85rem;
}

.notif-list li.unread {
  background: #eff6ff;
}

.notif-list li time {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.user-pill__avatar {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.content {
  padding: 1.5rem;
  flex: 1;
  overflow-y: auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card);
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card span {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card strong {
  display: block;
  font-size: 1.75rem;
  margin-top: 0.35rem;
  color: var(--accent);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card--wide {
  grid-column: 1 / -1;
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.simple-list {
  list-style: none;
}

.simple-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.simple-list li:last-child {
  border-bottom: none;
}

.section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-toolbar p {
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 520px;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

.primary-btn:hover {
  background: var(--accent-hover);
}

.secondary-btn {
  background: #f1f5f9;
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  cursor: pointer;
}

.meetings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.meeting-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.meeting-card__head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.meeting-card h3 {
  font-size: 1.05rem;
}

.meeting-card .schedule {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.plan-list {
  list-style: none;
  margin: 1rem 0;
}

.plan-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  border-bottom: 1px dashed #e2e8f0;
}

.subscribers {
  font-size: 0.8rem;
  color: var(--success);
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.events-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.event-row {
  background: var(--card);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 1rem;
  align-items: center;
}

.event-row h4 {
  font-size: 1rem;
}

.event-row .meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.status-pill {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-weight: 600;
  text-transform: capitalize;
}

.status-pill.upcoming {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-pill.completed {
  background: #d1fae5;
  color: #047857;
}

.status-pill.draft {
  background: #f1f5f9;
  color: #64748b;
}

.status-pill.overdue {
  background: #fee2e2;
  color: #b91c1c;
}

.finance-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

@media (max-width: 900px) {
  .finance-summary {
    grid-template-columns: 1fr 1fr;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .calendar-layout {
    grid-template-columns: 1fr !important;
  }
}

.finance-stat {
  background: var(--card);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.finance-stat span {
  font-size: 0.8rem;
  color: var(--muted);
}

.finance-stat strong {
  display: block;
  font-size: 1.4rem;
  margin-top: 0.25rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.finance-panel {
  display: none;
  background: var(--card);
  padding: 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.finance-panel.active {
  display: block;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.campaign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.campaign-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.campaign-card h4 {
  margin-bottom: 0.5rem;
}

.progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  margin: 0.75rem 0;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: var(--success);
  border-radius: 4px;
}

.calendar-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
}

.calendar-card {
  min-height: 420px;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.icon-round-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
}

.cal-day:hover {
  background: #f1f5f9;
}

.cal-day.other-month {
  color: #cbd5e1;
}

.cal-day.today {
  background: #dbeafe;
  font-weight: 700;
}

.cal-day.selected {
  border-color: var(--accent);
  background: #eff6ff;
}

.cal-day.has-event::after {
  content: "";
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  position: absolute;
  bottom: 6px;
}

.cal-day-detail {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  min-height: 60px;
}

.prefs-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.field-row select {
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.mt-lg {
  margin-top: 1.5rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(440px, 92vw);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  z-index: 101;
}

.modal--sm {
  width: min(360px, 92vw);
}

.modal::backdrop {
  background: transparent;
}

.modal form,
.modal > header {
  padding: 0;
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.25rem 0;
}

.modal__header h2 {
  font-size: 1.15rem;
}

.modal__sub {
  padding: 0 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal label {
  display: block;
  padding: 0.5rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.modal input,
.modal select,
.modal textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-weight: 400;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #1e293b;
  color: #fff;
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 200;
  box-shadow: var(--shadow);
}

.toast[hidden] {
  display: none;
}

.filters select {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.event-actions {
  display: flex;
  gap: 0.5rem;
}

.event-actions button {
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.event-actions button.danger {
  color: #dc2626;
  border-color: #fecaca;
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .search {
    display: none;
  }
}
