:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, "Noto Sans Hebrew", sans-serif;
  --bg: #f4f7f8;
  --ink: #14202a;
  --text: #14202a;
  --muted: #667782;
  --panel: #ffffff;
  --panel-soft: #edf3f2;
  --surface: #f8faf9;
  --field: #ffffff;
  --border: #d9e2e1;
  --accent: #0f766e;
  --accent-2: #db6b4b;
  --accent-3: #315c9a;
  --shadow: rgba(20, 32, 42, .10);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111518;
  --ink: #f7faf9;
  --text: #f7faf9;
  --muted: #a0adb5;
  --panel: #1a2025;
  --panel-soft: #222b31;
  --surface: #151b20;
  --field: #11171c;
  --border: #31404a;
  --accent: #2dd4bf;
  --accent-2: #fb8b66;
  --accent-3: #93c5fd;
  --shadow: rgba(0, 0, 0, .30);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, .07) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 118, 110, .06) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px;
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 18px 0 20px;
}

.topbar p {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: .9rem;
  font-weight: 900;
}

.topbar h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2.4rem, 7vw, 5.6rem);
  line-height: .9;
}

.version-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-top: 10px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 850;
}

.back-link,
.primary,
.secondary,
.icon {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-weight: 850;
}

.back-link {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  background: var(--panel);
  text-decoration: none;
  box-shadow: 0 10px 28px var(--shadow);
}

.primary {
  border-color: transparent;
  padding: 0 16px;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 14px 24px rgba(15, 118, 110, .22);
}

.secondary,
.icon {
  padding: 0 14px;
  background: var(--panel);
}

.mini {
  min-height: 34px;
  padding: 0 10px;
}

.setup-panel {
  position: relative;
  overflow: hidden;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, .12), transparent 46%),
    var(--panel);
  box-shadow: 0 18px 48px var(--shadow);
}

.setup-panel::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 7px;
  height: 100%;
  background: linear-gradient(var(--accent), var(--accent-2));
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.summary-card span,
.summary-card small,
.calendar-head p,
.note-panel p {
  color: var(--muted);
}

.field span {
  font-size: .84rem;
  font-weight: 850;
}

.field input,
.field select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .16);
}

.summary-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.summary-card {
  min-height: 124px;
  display: grid;
  align-content: space-between;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 16px 40px var(--shadow);
}

.summary-card strong {
  color: var(--ink);
  font-size: 2.05rem;
  line-height: 1;
}

.today-card {
  background:
    linear-gradient(135deg, rgba(15, 118, 110, .18), rgba(219, 107, 75, .08)),
    var(--panel);
  border-color: rgba(15, 118, 110, .36);
}

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

.panel {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 16px 40px var(--shadow);
}

.panel-head,
.calendar-head,
.legend,
.day-head {
  display: flex;
  align-items: center;
}

.calendar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.view-switch {
  display: flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.view-switch .secondary {
  border-color: transparent;
  background: transparent;
}

.view-switch .secondary.active {
  background: var(--accent);
  color: #fff;
}

.panel-head,
.calendar-head,
.day-head {
  justify-content: space-between;
  gap: 10px;
}

.panel h2,
.calendar-head h2 {
  margin: 0;
  color: var(--ink);
}

.calendar-head {
  margin-bottom: 12px;
  text-align: center;
}

.icon {
  width: 46px;
  padding: 0;
  color: var(--accent);
  font-size: 1.5rem;
}

.legend {
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: .84rem;
  font-weight: 850;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
}

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

.dow {
  margin-bottom: 7px;
  color: var(--muted);
  text-align: center;
  font-size: .86rem;
  font-weight: 900;
}

.day {
  min-height: 128px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.day.out {
  opacity: .45;
}

.day.today {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.day.manual,
.month-table td.manual,
.month-row.manual {
  border-color: rgba(219, 107, 75, .55);
}

.day.manual .day-head::after,
.month-table td.manual .mobile-date::after,
.month-row.manual div::after {
  content: "עודכן";
  display: inline-flex;
  margin-inline-start: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(219, 107, 75, .16);
  color: var(--accent-2);
  font-size: .68rem;
  font-weight: 900;
}

.day-head {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 850;
}

.shift-pill {
  min-height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 1.4rem;
  font-weight: 950;
}

.shift-pill small {
  display: block;
  margin-top: 2px;
  font-size: .7rem;
  font-weight: 850;
  opacity: .78;
}

.M,
.shift-M { background: rgba(15, 118, 110, .14); color: var(--accent); }
.E,
.shift-E { background: rgba(219, 107, 75, .15); color: var(--accent-2); }
.N,
.shift-N { background: rgba(49, 92, 154, .16); color: var(--accent-3); }
.O,
.shift-O { background: rgba(102, 119, 130, .16); color: var(--muted); }
.W,
.shift-W { background: rgba(12, 129, 162, .16); color: #0c81a2; }

:root[data-theme="dark"] .W,
:root[data-theme="dark"] .shift-W { color: #67e8f9; }

.month-table,
.month-row-list {
  display: none;
}

body[data-view="table"] .dow,
body[data-view="table"] .calendar-grid,
body[data-view="table"] .month-row-list,
body[data-view="rows"] .dow,
body[data-view="rows"] .calendar-grid,
body[data-view="rows"] .month-table {
  display: none;
}

body[data-view="table"] .month-table {
  width: 100%;
  display: table;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 4px;
}

.month-table th {
  height: 30px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 900;
}

.month-table td {
  height: 68px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
  vertical-align: top;
}

.month-table td.out {
  opacity: .42;
}

.month-table td.today {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.mobile-date,
.mobile-shift {
  display: block;
}

.mobile-date {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 850;
}

.mobile-shift {
  min-height: 30px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  font-size: .95rem;
  font-weight: 950;
}

body[data-view="rows"] .month-row-list {
  display: grid;
  gap: 8px;
}

.month-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.month-row.today {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.month-row strong,
.month-row span {
  display: block;
}

.month-row div span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

.row-shift {
  min-width: 54px;
  min-height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-weight: 950;
}

.note-panel {
  margin-top: 14px;
}

.note-panel p {
  margin: 8px 0 0;
  line-height: 1.7;
}

.export-dialog {
  width: min(560px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 80px var(--shadow);
}

.export-dialog::backdrop {
  background: rgba(0, 0, 0, .46);
}

.export-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.export-card h2 {
  margin: 0;
}

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

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

@media (max-width: 880px) {
  .app {
    padding: 14px;
  }

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

  .setup-grid,
  .summary-grid,
  .layout,
  .export-grid {
    grid-template-columns: 1fr;
  }

  .back-link,
  .topbar .secondary {
    width: 100%;
    justify-content: center;
  }

  .calendar-actions,
  .view-switch {
    width: 100%;
  }

  .calendar-actions > *,
  .view-switch > * {
    flex: 1;
  }
}

@media (min-width: 1200px) {
  .day {
    min-height: 146px;
  }

  .calendar-grid,
  .dow {
    gap: 9px;
  }
}
