:root {
  --red: #C8102E;
  --red-dark: #8B0A1E;
  --black: #0a0a0a;
  --charcoal: #2a2a2a;
  --muted: #6b6b6b;
  --line: #e4e4e4;
  --bg: #f4f4f5;
  --card: #fff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
  --font: 'Heebo', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--black);
  direction: rtl;
  min-height: 100%;
}
button, input, textarea, select { font: inherit; }
a { color: inherit; }

.hidden { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--black);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  /* inherit page RTL: mark first (far right), title to its left */
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  direction: ltr; /* rocking → ISRAEL left-to-right */
}
.brand-rocking {
  font-weight: 900; font-size: 22px; letter-spacing: -0.03em;
  text-transform: lowercase;
}
.brand-badge {
  font-size: 9px; font-weight: 800; letter-spacing: .08em;
  background: var(--red); color: #fff;
  padding: 3px 6px; border-radius: 10px;
}
.brand-sub {
  opacity: .7;
  font-size: 13px;
  font-weight: 400;
  margin-right: 6px; /* space toward the logo mark on the right */
}

.btn {
  border: none; cursor: pointer;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
  transition: transform .08s ease, background .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost {
  background: transparent; color: #fff;
  border: 1px solid rgba(255,255,255,.25);
}
.btn-ghost:hover { background: rgba(255,255,255,.08); }
.btn-pdf {
  background: var(--red);
  color: #fff !important;
  font-weight: 800;
  padding: 9px 16px;
  box-shadow: 0 0 0 2px rgba(200,16,46,.25);
}
.btn-pdf:hover { background: #e01235; }
.btn-sm {
  padding: 5px 10px; font-size: 12px;
  background: #eee; color: var(--black); border-radius: 6px;
}
.btn-sm.danger {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  font-weight: 500;
}
.btn-sm.danger:hover {
  background: #fde8ec;
  color: var(--red);
  border-color: #f0c8cb;
}
.btn-sm.primary-action {
  background: var(--charcoal);
  color: #fff;
  border: 1px solid var(--charcoal);
  font-weight: 700;
}
.btn-sm.primary-action:hover { background: var(--black); filter: none; }
.btn-sm.secondary-action {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--charcoal);
  font-weight: 600;
}
.btn-sm:hover { filter: brightness(.96); }
.btn-icon {
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); font-size: 16px; padding: 2px 6px;
}
.btn-icon:hover { color: var(--red); }

.list-toolbar { padding: 16px 20px 0; max-width: 1100px; margin: 0 auto; }
#search {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
}
#search:focus { border-color: #bbb; box-shadow: 0 0 0 3px rgba(0,0,0,.04); }

.card-list {
  max-width: 1100px; margin: 0 auto;
  padding: 16px 20px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid transparent;
  transition: border-color .15s;
}
.card:hover { border-color: #ddd; }
.card h3 {
  margin: 0; font-size: 16px; font-weight: 800; line-height: 1.35;
}
.card .meta {
  color: var(--muted); font-size: 13px;
  display: flex; flex-wrap: wrap; gap: 6px 12px;
}
.card-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px; padding-top: 10px;
  border-top: 1px solid var(--line);
}
.empty {
  text-align: center; color: var(--muted);
  padding: 48px 20px; font-size: 15px;
}

.editor-topbar .topbar-right,
.editor-topbar .topbar-actions {
  display: flex; align-items: center; gap: 10px;
}
.save-status {
  font-size: 12px;
  font-weight: 700;
  opacity: .75;
  letter-spacing: 0.01em;
}
.save-status.saving {
  color: #ffe08a; opacity: 1;
  background: rgba(255,208,122,.2);
  padding: 2px 8px; border-radius: 6px;
}
.save-status.saved { color: #9dffb8; opacity: 1; }
.save-status.err {
  color: #ffb0b0; opacity: 1;
  background: rgba(255,80,80,.18);
  padding: 2px 8px; border-radius: 6px;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.05fr) minmax(360px, 0.95fr);
  gap: 0;
  height: calc(100vh - 58px);
  overflow: hidden;
}

.preview-pane {
  background: #d8d8da;
  border-left: 1px solid #ccc;
  overflow: hidden;
  display: flex;
  min-width: 0;
}
.preview-frame-wrap {
  flex: 1;
  margin: 12px;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-width: 0;
  background: transparent;
}
/* Slot = scaled footprint; host = real A4, transform-scaled to fit */
.preview-scale-slot {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  background: #fff;
}
.preview-scale-host {
  position: absolute;
  top: 0;
  left: 0;
  width: 794px; /* 210mm @ 96dpi — real A4 content width */
  transform-origin: top left;
  background: #fff;
}
#preview {
  width: 794px;
  height: 1123px; /* initial A4; JS sets to content height */
  border: 0;
  display: block;
  background: #fff;
}

.form-pane {
  overflow: auto;
  padding: 12px 16px 40px;
  background: var(--bg);
}

.block {
  background: #fff;
  border-radius: var(--radius);
  margin-bottom: 10px;
  border: 1px solid var(--line);
  overflow: hidden;
}
.block > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 800;
  font-size: 14px;
  padding: 12px 14px;
  background: #fafafa;
  border-bottom: 1px solid transparent;
  user-select: none;
}
.block[open] > summary { border-bottom-color: var(--line); }
.block > summary::-webkit-details-marker { display: none; }
.block-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }

label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; font-weight: 600; color: #333;
}
label input, label textarea {
  font-weight: 400;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  outline: none;
}
label input:focus, label textarea:focus {
  border-color: #bbb;
  box-shadow: 0 0 0 3px rgba(200,16,46,.08);
}
label.check {
  flex-direction: row; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500;
}
label.check input { width: auto; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.subhead {
  font-weight: 800; font-size: 12.5px;
  margin-top: 4px; color: var(--charcoal);
}
.hint {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.array-list { display: flex; flex-direction: column; gap: 6px; touch-action: pan-y; }
.array-row {
  display: grid;
  gap: 6px;
  align-items: center;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  transition: background .12s, box-shadow .12s, opacity .12s, border-color .12s;
}
/* handle | fields… | ↑↓ | × */
.array-row.strings { grid-template-columns: auto auto 1fr auto; }
.array-row.schedule { grid-template-columns: auto auto 110px 1fr auto; }
.array-row.contacts { grid-template-columns: auto auto 1fr 1fr 1fr auto; }
.array-row.band { grid-template-columns: auto auto 110px 1fr 1fr auto; }
.array-row input {
  padding: 7px 8px;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  width: 100%;
  background: #fff;
}
.array-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 36px;
  padding: 0 4px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: -2px;
  border-radius: 6px;
}
.array-handle:hover, .array-handle:focus-visible {
  color: var(--red, #D7141A);
  background: #fff0f0;
  outline: none;
}
.array-row.dragging {
  opacity: 0.55;
  background: #fff5f5;
  box-shadow: 0 2px 8px rgba(215, 20, 26, 0.18);
  cursor: grabbing;
}
.array-row.dragging .array-handle { cursor: grabbing; }
.array-row.drag-over {
  border-color: var(--red, #D7141A);
  background: #fff0f0;
}
.array-list.is-reordering { user-select: none; }
.array-move, .section-order-move {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}
.array-move .btn-icon,
.section-order-move .btn-icon {
  min-width: 28px;
  min-height: 18px;
  padding: 0;
  font-size: 10px;
  line-height: 1;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.array-move .btn-icon:hover:not(:disabled),
.section-order-move .btn-icon:hover:not(:disabled) {
  color: var(--red, #D7141A);
  border-color: #f0b0b0;
}
.array-move .btn-icon:disabled,
.section-order-move .btn-icon:disabled {
  opacity: 0.35;
  cursor: default;
}
.array-add {
  align-self: flex-start;
  margin-top: 2px;
}

.presets {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding-top: 4px;
}
.presets-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { border-color: var(--red); color: var(--red); }

@media (max-width: 960px) {
  .editor-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .preview-pane {
    height: 55vh;
    border-left: none;
    border-bottom: 1px solid #ccc;
    order: -1;
  }
  .form-pane { height: auto; }
  .grid-2 { grid-template-columns: 1fr; }
  .array-row.strings { grid-template-columns: auto auto 1fr auto; }
  .array-row.contacts,
  .array-row.band,
  .array-row.schedule { grid-template-columns: auto auto 1fr auto; }
  .array-row.schedule input,
  .array-row.contacts input,
  .array-row.band input { grid-column: 3; }
  .editor-topbar { flex-wrap: wrap; }
}

/* Add to Home Screen tip */
.a2hs-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 16px 0;
  padding: 12px 14px;
  background: #fff8f8;
  border: 1px solid #f0c8cb;
  border-radius: var(--radius);
  color: var(--charcoal);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: var(--shadow);
}
.a2hs-tip.hidden { display: none !important; }
.a2hs-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.a2hs-text strong { color: var(--red); }
.a2hs-note { color: var(--muted); font-size: 12px; margin-top: 4px; }
.a2hs-tip .btn-sm {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  font-size: 16px;
  cursor: pointer;
  color: var(--muted);
  padding: 2px 6px;
}

@media (min-width: 900px) {
  .a2hs-tip { max-width: 720px; margin-inline: auto; }
}

/* Classification + templates admin */
.btn-ghost-light {
  background: #fff;
  color: var(--black);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.btn-ghost-light:hover { border-color: var(--red); color: var(--red); }

.list-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
}
.list-toolbar #search { flex: 1; }

.classify-block select {
  font-weight: 400;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  width: 100%;
}

/* Classify hierarchy + date display */
.classify-block .grid-2 { gap: 12px 14px; margin-bottom: 10px; }
.classify-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.classify-actions .btn-sm { min-height: 34px; }
.classify-hint-sep {
  width: 100%;
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.date-field-wrap { display: flex; flex-direction: column; gap: 4px; }
.date-field-wrap input[type="date"] {
  direction: ltr;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.date-display {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}
input[name="dayName"][readonly] {
  background: #f3f3f4;
  color: var(--charcoal);
  cursor: default;
}
.presets {
  margin-top: 8px;
  padding: 8px 10px;
  background: #f7f7f8;
  border-radius: 8px;
  border: 1px dashed var(--line);
}
.presets-note { font-size: 11px; color: var(--muted); width: 100%; margin-top: 4px; }
.admin-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.admin-item-actions .btn-sm.danger { opacity: .7; }
.admin-status-line { font-size: 12px; color: var(--muted); margin: 0 0 8px; }



.attach-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.attach-upload { cursor: pointer; display: inline-flex; align-items: center; }
.attach-list { display: flex; flex-direction: column; gap: 6px; }
.attach-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}
.attach-row .att-name { flex: 1; font-weight: 600; word-break: break-all; }
.attach-row .att-meta { color: var(--muted); font-size: 11px; white-space: nowrap; }

.card .meta .tag {
  background: #f3f3f4;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--charcoal);
}
.card .meta .tag.artist { background: #fff0f1; color: var(--red); }

/* Templates admin */
.templates-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px 40px;
  display: grid;
  grid-template-columns: minmax(200px, 280px) 1fr;
  gap: 16px;
}
.panel-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
}
.templates-artists, .templates-types {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  min-height: 320px;
}
.templates-types-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.admin-list { display: flex; flex-direction: column; gap: 6px; }
.admin-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
  cursor: pointer;
  text-align: right;
  width: 100%;
  font: inherit;
}
.admin-item:hover { border-color: #ccc; }
.admin-item.active {
  border-color: var(--charcoal);
  background: #f0f1f3;
  box-shadow: 0 0 0 2px rgba(42,42,42,.14);
}
.admin-item .name { flex: 1; font-weight: 700; font-size: 14px; }
.admin-item .sub { color: var(--muted); font-size: 11px; }
.admin-type-detail {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.admin-type-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.template-preview {
  margin-top: 10px;
  padding: 10px;
  background: #f6f6f7;
  border-radius: 8px;
  font-size: 11px;
  max-height: 220px;
  overflow: auto;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Dialogs */
.teum-dlg {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 420px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.teum-dlg::backdrop { background: rgba(0,0,0,.45); }
.teum-dlg.dlg-wide { max-width: 560px; }
.teum-dlg form, .dlg-past-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px 16px;
}
.teum-dlg h3 { margin: 0 0 4px; font-size: 17px; }
.dlg-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  margin-top: 6px;
}
.past-filters { display: flex; gap: 14px; flex-wrap: wrap; }
.past-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow: auto; }
.past-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  text-align: right;
  font: inherit;
}
.past-item:hover { border-color: var(--red); }
.past-item strong { font-size: 14px; }
.past-item span { font-size: 12px; color: var(--muted); }

@media (max-width: 960px) {
  .templates-layout { grid-template-columns: 1fr; }
  .list-toolbar { flex-direction: column; align-items: stretch; }
}

.band-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.array-row.band {
  grid-template-columns: auto auto 110px 1fr 1fr auto;
}
@media (max-width: 960px) {
  .array-row.band { grid-template-columns: auto auto 1fr auto; }
}

.admin-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 1100px;
  margin: 12px auto 0;
  padding: 0 20px;
}
.admin-tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.admin-tab.active {
  background: var(--black);
  color: #fff;
  border-color: var(--black);
}
.admin-panel.hidden { display: none !important; }
.admin-single {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px 40px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 12px;
  margin-inline: 20px;
}
#people-search, #person-pick-search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
}
.admin-item-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
  min-width: 0;
}
.admin-item-main .name { font-weight: 800; font-size: 14px; }
.admin-item-main .sub { color: var(--muted); font-size: 12px; }
.sync-status { font-size: 12.5px; }

/* ── Section order drag panel (admin only; not sheet.css) ── */
.section-order-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.section-order-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: background .12s, box-shadow .12s, opacity .12s;
}
.section-order-item:active { cursor: grabbing; }
.section-order-item.dragging {
  opacity: 0.55;
  background: #fff5f5;
  box-shadow: 0 2px 8px rgba(215, 20, 26, 0.18);
}
.section-order-item.drag-over {
  border-color: var(--red, #D7141A);
  background: #fff0f0;
}
.section-order-handle {
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
  letter-spacing: -2px;
  padding: 4px 6px;
  min-width: 28px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  border-radius: 6px;
}
.section-order-handle:hover {
  color: var(--red, #D7141A);
  background: #fff0f0;
}
.section-order-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--charcoal);
}
.section-order-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Screen section helpers */
.screen-size-helper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 12px;
  color: var(--muted, #666);
  direction: ltr; /* keep width X height visually 4 X 3 */
}
.screen-dim {
  width: 72px;
  padding: 7px 8px;
  border: 1px solid var(--line, #e0e0e0);
  border-radius: 6px;
  direction: ltr;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.screen-dim-x {
  font-weight: 800;
  color: #333;
  direction: ltr;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip-row .chip {
  border: 1px solid var(--line, #ddd);
  background: #fff;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.chip-row .chip:hover {
  border-color: var(--red, #D7141A);
  color: var(--red, #D7141A);
}
