:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-strong: #eef6f1;
  --ink: #111827;
  --muted: #5f6b7a;
  --line: #d9e1ea;
  --primary: #0f5132;
  --primary-dark: #08351f;
  --primary-soft: #dff3e8;
  --navy: #0f172a;
  --warning: #9a5b00;
  --warning-bg: #fff3cd;
  --danger: #b42318;
  --danger-bg: #fee4e2;
  --focus: #2563eb;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.1);
  --radius: 8px;
  font-family: Arial, "Noto Sans Hebrew", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 81, 50, 0.08), transparent 34%),
    var(--bg);
  font-size: 17px;
  line-height: 1.55;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
main:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  transform: translateY(-140%);
  background: var(--navy);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 20px;
  background: var(--navy);
  color: white;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong {
  display: block;
  font-size: 22px;
}

.brand span:not(.brand-mark) {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: #34d399;
  color: #052e1b;
  font-size: 24px;
  font-weight: 900;
}

.brand-mark.large {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  font-size: 34px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item,
.tab-item {
  min-height: 52px;
  border: 0;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: right;
}

.nav-item {
  width: 100%;
  padding: 0 14px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
}

.nav-item span,
.tab-item span {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 900;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 96px;
  padding: 22px clamp(18px, 4vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
}

.top-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 15px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.15;
}

.top-actions,
.action-row,
.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: white;
  color: var(--muted);
  font-weight: 700;
}

.content {
  min-width: 0;
  width: min(1280px, 100%);
  margin-inline: auto;
  padding: clamp(18px, 4vw, 42px);
  padding-bottom: 110px;
}

.hero-board {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(24px, 5vw, 46px);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(15, 81, 50, 0.92), rgba(15, 23, 42, 0.96)),
    var(--navy);
  color: white;
  box-shadow: var(--shadow);
}

.hero-board h2 {
  margin: 0 0 10px;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1.08;
}

.hero-board p {
  max-width: 680px;
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(17px, 2.2vw, 22px);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.metric-card,
.panel,
.student-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 26px rgba(15, 23, 42, 0.05);
}

.metric-card {
  padding: 18px;
  display: grid;
  gap: 4px;
}

.metric-card span,
.metric-card small,
.section-heading p,
.student-card p,
.lead-row span,
.lead-row small {
  color: var(--muted);
}

.metric-card strong {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
}

.dashboard-grid,
.split-view {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.panel,
.student-card {
  padding: 20px;
}

.strong-panel {
  background: var(--surface-strong);
}

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

.section-heading h2,
.section-heading h3,
.section-heading h4,
.panel h2 {
  margin: 0;
}

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

.button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 18px;
  background: white;
  color: var(--ink);
  font-weight: 800;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.button.quiet {
  background: transparent;
}

.button.full {
  width: 100%;
}

.link-button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 900;
  text-decoration: underline;
}

.icon-button {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  font-size: 28px;
}

.next-lesson {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  align-items: center;
  margin: 20px 0;
}

.next-lesson > strong {
  min-height: 86px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--primary);
  color: white;
  font-size: 28px;
}

.next-lesson h4,
.next-lesson p {
  margin: 0;
}

.lead-list,
.receipt-list,
.agenda,
.expense-list,
.crm-list,
.pipeline {
  display: grid;
  gap: 10px;
}

.lead-row,
.agenda-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: white;
}

.lead-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
}

.lead-row strong,
.lead-row span,
.lead-row b,
.lead-row small {
  display: block;
}

.crm-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: white;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 14px;
}

.rank-badge {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--navy);
  color: white;
  font-weight: 900;
}

.crm-row h3,
.crm-row p {
  margin: 0;
}

.crm-row p {
  color: var(--muted);
}

.crm-row strong {
  display: block;
  margin-top: 4px;
}

.crm-value {
  text-align: left;
}

.crm-value span,
.crm-value b {
  display: block;
}

.crm-value span {
  color: var(--primary);
  font-size: 20px;
  font-weight: 900;
}

.business-note {
  margin-top: 18px;
}

.agenda-item {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  align-items: center;
  gap: 16px;
}

.agenda-item time {
  font-size: 26px;
  font-weight: 900;
  color: var(--primary);
}

.agenda-item h3,
.agenda-item p {
  margin: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 5px 12px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 900;
  font-size: 14px;
  white-space: nowrap;
}

.status-pill.warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  margin-bottom: 18px;
}

.search-box,
.form-stack label,
.sheet label,
.settings-form label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

input,
select,
textarea {
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 14px;
  background: white;
  color: var(--ink);
}

textarea {
  min-height: 220px;
  padding: 14px;
  line-height: 1.6;
  resize: vertical;
}

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

.student-card {
  position: relative;
  overflow: hidden;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  touch-action: pan-y;
}

.student-card::before,
.student-card::after {
  position: absolute;
  top: 14px;
  z-index: 0;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 900;
  opacity: 0;
  transition: opacity 160ms ease;
}

.student-card::before {
  content: "טופל";
  right: 14px;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.student-card::after {
  content: "לתזכורת";
  left: 14px;
  background: var(--warning-bg);
  color: var(--warning);
}

.student-card.swiped-right {
  transform: translateX(18px);
  border-color: var(--primary);
  box-shadow: 0 14px 35px rgba(15, 81, 50, 0.18);
}

.student-card.swiped-left {
  transform: translateX(-18px);
  border-color: var(--warning);
  box-shadow: 0 14px 35px rgba(154, 91, 0, 0.16);
}

.student-card.swiped-right::before,
.student-card.swiped-left::after {
  opacity: 1;
}

.progress-line {
  height: 12px;
  border-radius: 999px;
  background: #e6ecf3;
  overflow: hidden;
}

.progress-line span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #22c55e);
}

.facts,
.receipt-lines {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.facts {
  grid-template-columns: repeat(3, 1fr);
}

.facts div,
.receipt-lines div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

dt {
  color: var(--muted);
  font-size: 14px;
}

dd {
  margin: 0;
  font-weight: 900;
}

.receipt-row {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: white;
  text-align: right;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
}

.receipt-row small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.receipt-row.selected {
  border-color: var(--primary);
  box-shadow: inset 4px 0 0 var(--primary);
}

.receipt-preview {
  min-height: 520px;
}

.receipt-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.receipt-head h2,
.receipt-head p {
  margin: 0;
}

.receipt-head span {
  color: var(--primary);
  font-size: 22px;
  font-weight: 900;
}

.receipt-lines .total {
  background: var(--primary-soft);
  border-color: var(--primary-soft);
}

.signature {
  margin-top: 28px;
  color: var(--muted);
}

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

.bar-row > div:first-child {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
}

.settings-form {
  display: grid;
  gap: 14px;
  max-width: 680px;
}

.import-form {
  display: grid;
  gap: 16px;
}

.import-form label {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

.import-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.import-steps div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: white;
  display: grid;
  gap: 8px;
}

.import-steps strong {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: white;
}

.import-schema {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.import-schema code {
  display: block;
  direction: ltr;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #f8fafc;
  overflow: auto;
}

.metric-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mobile-tabs {
  display: none;
}

.login-mode .side-nav,
.login-mode .mobile-tabs,
.login-mode .top-actions {
  display: none;
}

.login-mode .app-shell {
  grid-template-columns: 1fr;
}

.login-mode .workspace {
  min-height: 100vh;
}

.login-layout {
  min-height: calc(100vh - 190px);
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(100%, 460px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 30px;
  text-align: center;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 18px 0 6px;
  font-size: 34px;
}

.login-panel p {
  margin: 0 0 18px;
  color: var(--muted);
}

.form-stack {
  display: grid;
  gap: 14px;
  text-align: right;
}

.hint-box {
  margin-top: 16px;
  border-radius: var(--radius);
  background: var(--surface-strong);
  padding: 14px;
  color: var(--primary-dark);
  display: grid;
  gap: 3px;
  text-align: right;
}

.alert.error {
  border-radius: var(--radius);
  background: var(--danger-bg);
  color: var(--danger);
  padding: 12px;
  font-weight: 900;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.55);
}

.sheet {
  width: min(560px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 14px;
  background: white;
  padding: 22px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.toast {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 100;
  max-width: 360px;
  border-radius: var(--radius);
  background: var(--navy);
  color: white;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.onboarding-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.68);
}

.onboarding-card {
  width: min(520px, 100%);
  border-radius: 16px;
  background: white;
  padding: 24px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

.onboarding-card h2 {
  margin: 0;
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.12;
}

.onboarding-card p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.onboarding-progress {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

.onboarding-progress span {
  height: 8px;
  border-radius: 999px;
  background: #dbe3ee;
}

.onboarding-progress span.active {
  background: var(--primary);
}

.gesture-visual {
  min-height: 120px;
  border-radius: 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
  background:
    radial-gradient(circle at 50% 50%, rgba(52, 211, 153, 0.34), transparent 38%),
    #f8fafc;
  color: var(--navy);
}

.gesture-visual span {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: white;
  border: 1px solid var(--line);
  font-size: 28px;
  font-weight: 900;
}

.gesture-visual strong {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: white;
  font-size: 30px;
}

.gesture-note {
  border-radius: var(--radius);
  padding: 14px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 900;
}

.onboarding-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 30px;
  background: white;
  text-align: center;
  color: var(--muted);
}

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

  .side-nav {
    display: none;
  }

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

  .metric-grid,
  .dashboard-grid,
  .split-view,
  .student-grid,
  .import-steps,
  .metric-grid.compact {
    grid-template-columns: 1fr;
  }

  .mobile-tabs {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(78px, 1fr);
    gap: 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
  }

  .tab-item {
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    min-height: 60px;
    background: transparent;
    color: var(--muted);
  }

  .tab-item span {
    background: #edf2f7;
  }

  .tab-item.active {
    color: var(--primary);
    background: var(--primary-soft);
  }

  .hero-board {
    align-items: stretch;
    flex-direction: column;
  }

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

@media (max-width: 560px) {
  body {
    font-size: 16px;
  }

  .topbar,
  .content {
    padding-inline: 14px;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .hero-board {
    padding: 22px;
  }

  .agenda-item {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .next-lesson {
    grid-template-columns: 1fr;
  }

  .facts,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .lead-row,
  .crm-row,
  .receipt-row,
  .receipt-head {
    grid-template-columns: 1fr;
    display: grid;
  }
}

@media print {
  body {
    background: white;
  }

  .side-nav,
  .topbar,
  .mobile-tabs,
  .no-print,
  .panel:not(.receipt-preview) {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .content,
  .split-view {
    display: block;
    padding: 0;
    margin: 0;
  }

  .receipt-preview {
    border: 0;
    box-shadow: none;
  }
}
