:root {
  color-scheme: light;
  font-family: Arial, "Noto Sans Hebrew", sans-serif;
  background: #f4f6f4;
  color: #1d2522;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(71, 121, 111, 0.12), transparent 360px),
    #f4f6f4;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1,
.empty-state h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

.topbar p,
.empty-state p {
  margin: 6px 0 0;
  color: #66736e;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(360px, 36vw);
  min-width: 230px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #d7ded9;
  border-radius: 8px;
  background: #fff;
}

.searchbox input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.icon-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
}

.icon-button {
  width: 42px;
  height: 42px;
  background: #fff;
  color: #31433d;
  border: 1px solid #d7ded9;
}

.primary-button {
  min-height: 44px;
  padding: 0 16px;
  background: #256c5b;
  color: #fff;
  font-weight: 700;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #b8c9c2;
  border-radius: 8px;
  background: #fff;
  color: #256c5b;
  font-weight: 800;
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card,
.panel,
.person-drawer,
.settings-modal,
.empty-state,
.template-card,
.community-card,
.empty-directory {
  border: 1px solid #dbe2de;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 34px rgba(41, 54, 49, 0.08);
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 90px;
  padding: 16px;
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #e8efec;
  color: #256c5b;
}

.stat-value {
  font-size: 30px;
  font-weight: 800;
}

.stat-label {
  color: #66736e;
  font-size: 14px;
}

.stat-card.events .stat-icon {
  background: #f1eadb;
  color: #926b1c;
}

.stat-card.issues .stat-icon {
  background: #f9e3df;
  color: #af4436;
}

.stat-card.mail .stat-icon {
  background: #e4edf7;
  color: #2d669b;
}

.stat-card.admin .stat-icon {
  background: #e8e5f5;
  color: #5d4ca0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.main-column {
  display: grid;
  gap: 18px;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel h2,
.settings-modal h2,
.person-drawer h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

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

.panel-title-row span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 28px;
  border-radius: 14px;
  background: #eef3f0;
  color: #52615c;
  font-weight: 700;
}

.bar-list {
  display: grid;
  gap: 11px;
}

.bar-row {
  display: grid;
  grid-template-columns: 78px minmax(80px, 1fr) 34px;
  gap: 10px;
  align-items: center;
  font-size: 14px;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 5px;
  background: #e8eeeb;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: #4a8879;
}

.directory-shell {
  display: grid;
  gap: 18px;
}

.directory-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
}

.directory-head h1 {
  margin: 0;
  font-size: 28px;
}

.directory-head p {
  margin: 6px 0 0;
  color: #66736e;
}

.template-grid,
.community-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.template-card {
  display: grid;
  gap: 10px;
  min-height: 190px;
  padding: 18px;
  border-color: #d7ded9;
  color: #1d2522;
  text-align: right;
}

.template-card:hover,
.community-card:hover {
  border-color: #8db6aa;
  box-shadow: 0 16px 38px rgba(37, 108, 91, 0.14);
}

.template-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: #e8efec;
  color: #256c5b;
  font-size: 22px;
}

.template-card strong {
  font-size: 21px;
}

.template-card > span:not(.template-icon) {
  color: #66736e;
}

.template-metrics,
.community-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: auto;
}

.template-metrics span,
.community-metrics span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef3f0;
  color: #52615c;
  font-size: 13px;
  font-weight: 700;
}

.community-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.community-card h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.community-card p {
  margin: 0;
  color: #66736e;
  direction: ltr;
  text-align: right;
}

.community-card .primary-button {
  justify-self: start;
  min-width: 108px;
}

.community-metrics strong {
  margin-inline-start: 4px;
}

.empty-directory {
  padding: 26px;
  text-align: center;
}

.empty-directory h2 {
  margin: 0 0 8px;
}

.empty-directory p {
  margin: 0;
  color: #66736e;
}

.back-button {
  white-space: nowrap;
}

.table-panel {
  padding-bottom: 10px;
}

.table-scroll {
  overflow: auto;
  max-height: 540px;
  border: 1px solid #e4e9e6;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf1ef;
  text-align: right;
  vertical-align: middle;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7faf8;
  color: #52615c;
  font-size: 13px;
}

td strong {
  display: block;
  margin-bottom: 2px;
}

td small {
  color: #7b8782;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #eef6f2;
}

.timeline {
  display: grid;
  gap: 10px;
  max-height: 560px;
  overflow: auto;
  padding-inline-start: 2px;
}

.event-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 14px;
}

.event-filter button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid #d7ded9;
  border-radius: 999px;
  background: #fff;
  color: #52615c;
  font-weight: 700;
}

.event-filter button.active {
  border-color: #8db6aa;
  background: #e8efec;
  color: #256c5b;
}

.communication-panel {
  display: grid;
  gap: 14px;
}

.communication-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.communication-summary article {
  display: grid;
  gap: 2px;
  min-height: 70px;
  padding: 12px;
  border: 1px solid #e4e9e6;
  border-radius: 8px;
  background: #fbfcfb;
}

.communication-summary strong {
  font-size: 24px;
}

.communication-summary span {
  color: #66736e;
  font-size: 13px;
}

.communication-table {
  max-height: 430px;
}

.ready-pill,
.missing-pill,
.minor-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.ready-pill {
  background: #e5f3ed;
  color: #236149;
}

.missing-pill {
  background: #fff3dd;
  color: #805817;
}

.minor-pill {
  background: #eef3f0;
  color: #52615c;
}

.message-preview-panel {
  display: grid;
  gap: 14px;
}

.message-preview-panel .panel-title-row p {
  margin: 4px 0 0;
  color: #66736e;
}

.preview-controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-controls label,
.relationship-filter {
  margin-bottom: 0;
}

.preview-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.queue-result {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid #b9dccc;
  border-radius: 8px;
  background: #edf8f2;
  color: #236149;
}

.relationship-filter {
  max-width: 320px;
}

.preview-table {
  max-height: 520px;
}

.message-cell {
  min-width: 300px;
  max-width: 520px;
  line-height: 1.5;
  white-space: normal;
}

.timeline-item {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e6ebe8;
  border-radius: 8px;
  background: #fbfcfb;
}

.timeline-date {
  display: grid;
  gap: 3px;
  color: #51605a;
}

.timeline-date span,
.timeline-item p,
.branch-card small,
.issue span {
  color: #66736e;
  font-size: 13px;
}

.timeline-item h3,
.branch-card h3 {
  margin: 0;
  font-size: 15px;
}

.timeline-item p {
  margin: 3px 0 0;
}

.tag {
  min-width: 88px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef3f0;
  text-align: center;
  color: #4d5e58;
  font-size: 12px;
  font-weight: 700;
}

.tag.birthday {
  background: #e4edf7;
  color: #2d669b;
}

.tag.anniversary {
  background: #f1eadb;
  color: #926b1c;
}

.branch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.branch-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid #e6ebe8;
  border-radius: 8px;
  background: #fbfcfb;
}

.branch-card.selected {
  border-color: #8db6aa;
  background: #f0f7f4;
}

.branch-card p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: #4d5e58;
}

.branch-open {
  justify-self: start;
  min-height: 36px;
}

.branch-menu-button {
  white-space: nowrap;
}

.marriage-badge,
.marriage-years {
  color: #805817;
  font-weight: 800;
}

.marriage-badge {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff3dd;
  font-size: 13px;
}

.marriage-years {
  margin-top: 5px;
}

.branch-detail {
  display: grid;
  gap: 16px;
}

.branch-detail .panel-title-row h2 {
  margin-bottom: 2px;
}

.branch-detail .panel-title-row p,
.muted {
  margin: 0;
  color: #66736e;
}

.branch-family-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
}

.branch-family-grid h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.mini-person-list,
.child-family-list {
  display: grid;
  gap: 10px;
}

.mini-person-list button,
.child-family-card {
  padding: 12px;
  border: 1px solid #e6ebe8;
  border-radius: 8px;
  background: #fbfcfb;
  text-align: right;
}

.mini-person-list button {
  display: grid;
  gap: 3px;
}

.mini-person-list span,
.child-family-card span,
.child-family-card p {
  color: #66736e;
  font-size: 13px;
}

.child-family-card {
  display: grid;
  gap: 8px;
}

.child-family-card p {
  margin: 0;
}

.child-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.issue-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

.issue {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid #f0d8d3;
  border-radius: 8px;
  background: #fff7f5;
  color: #8a3429;
}

.issue div {
  display: grid;
  gap: 2px;
}

.person-drawer {
  position: sticky;
  top: 18px;
  min-height: 420px;
  padding: 18px;
}

.person-drawer.empty {
  display: grid;
  place-items: center;
  text-align: center;
  color: #66736e;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.drawer-head h2 {
  margin-bottom: 0;
}

.person-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.person-meta span,
.relationship-list span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef3f0;
  color: #52615c;
  font-size: 13px;
}

.drawer-section {
  padding: 14px 0;
  border-top: 1px solid #e6ebe8;
}

.drawer-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #50615a;
}

.drawer-section p {
  margin: 4px 0;
}

.relationship-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(26, 34, 31, 0.42);
}

.settings-modal {
  width: min(620px, 100%);
  padding: 22px;
}

.edit-modal {
  width: min(820px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-head p {
  margin: 4px 0 0;
  color: #66736e;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
  color: #40514a;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label {
  margin-bottom: 0;
}

.form-section-title {
  margin: 18px 0 12px;
  font-size: 16px;
}

.preferred-channel-field {
  max-width: 360px;
}

.preferred-channel-field small {
  color: #66736e;
  font-weight: 500;
  line-height: 1.5;
}

.channel-link {
  color: #287363;
  font-weight: 800;
  text-decoration: none;
}

.primary-channel-pill {
  display: inline-flex;
  align-items: center;
  margin-inline-start: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eaf6f2;
  color: #287363;
  font-size: 12px;
  font-weight: 800;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-top: 18px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d7ded9;
  border-radius: 8px;
  padding: 11px 12px;
  outline: 0;
  background: #fff;
  direction: ltr;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #4a8879;
  box-shadow: 0 0 0 3px rgba(74, 136, 121, 0.18);
}

.error-banner {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #efc6bd;
  border-radius: 8px;
  background: #fff3f0;
  color: #933c30;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: calc(100vh - 56px);
  margin: 28px;
  padding: 28px;
  text-align: center;
}

.auth-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 28px;
}

.auth-card {
  width: min(460px, 100%);
  padding: 26px;
  border: 1px solid #dbe2de;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 44px rgba(41, 54, 49, 0.12);
}

.auth-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 18px;
  border-radius: 8px;
  background: #256c5b;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
}

.auth-card h1 {
  margin: 0;
  font-size: 24px;
}

.auth-card p {
  margin: 8px 0 18px;
  color: #66736e;
}

.auth-warning,
.success-banner {
  margin-bottom: 14px;
  padding: 11px 12px;
  border-radius: 8px;
}

.auth-warning {
  border: 1px solid #ead7a5;
  background: #fff8e2;
  color: #7a5a12;
}

.success-banner {
  border: 1px solid #b9dccc;
  background: #edf8f2;
  color: #236149;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: 8px;
  background: #eef3f0;
}

.segmented button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #52615c;
  font-weight: 700;
}

.segmented button.active {
  background: #fff;
  color: #256c5b;
  box-shadow: 0 2px 8px rgba(41, 54, 49, 0.08);
}

.wide {
  width: 100%;
}

.link-button,
.text-button {
  border: 0;
  background: transparent;
  color: #256c5b;
  font-weight: 700;
}

.link-button {
  display: block;
  margin: 14px auto 0;
}

.text-button {
  min-height: 42px;
  padding: 0 6px;
}

.whatsapp-link {
  color: #0b7d4d;
  font-weight: 800;
  text-decoration: none;
}

.whatsapp-link:hover {
  text-decoration: underline;
}

.session-pill {
  display: inline-flex;
  align-items: center;
  max-width: 220px;
  min-height: 34px;
  padding: 4px 10px;
  overflow: hidden;
  border: 1px solid #d7ded9;
  border-radius: 999px;
  background: #fff;
  color: #52615c;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 4px 10px;
  border: 1px solid #d7ded9;
  border-radius: 999px;
  background: #f7faf8;
  color: #52615c;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.role-pill.super {
  border-color: #d6d0ef;
  background: #f1eefb;
  color: #5d4ca0;
}

.compact {
  margin: 0 0 12px;
}

.empty-state p {
  max-width: 560px;
  margin-bottom: 20px;
}

.spin {
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .branch-family-grid {
    grid-template-columns: 1fr;
  }

  .person-drawer {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .toolbar,
  .directory-head {
    align-items: stretch;
    flex-direction: column;
  }

  .searchbox {
    width: 100%;
  }

  .stats-grid,
  .split-grid,
  .form-grid,
  .communication-summary,
  .preview-controls,
  .preview-summary {
    grid-template-columns: 1fr;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }
}


.telegram-invite-box {
  display: grid;
  gap: 10px;
  border: 1px solid #cfe0da;
  border-radius: 8px;
  padding: 14px;
  background: #f7fbf9;
}

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

.invite-title-row h3 {
  margin: 0;
}

.invite-title-row span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8efec;
  color: #256c5b;
  font-size: 12px;
  font-weight: 800;
}

.telegram-invite-box p {
  margin: 0;
  color: #66736e;
  line-height: 1.45;
}

.primary-button.wide {
  width: 100%;
}

.invite-result {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #d7ded9;
  border-radius: 8px;
  background: #fff;
}

.invite-result code {
  display: block;
  direction: ltr;
  text-align: left;
  padding: 10px;
  border-radius: 8px;
  background: #1d2522;
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.invite-result small {
  color: #66736e;
}


.invite-link {
  display: block;
  direction: ltr;
  text-align: left;
  padding: 10px;
  border-radius: 8px;
  background: #1d2522;
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.invite-link:hover {
  background: #26312d;
}
