:root {
  color-scheme: only light;

  --bg: #fbf8f3;
  --bg-soft: #f3efe6;
  --bg-card: #ffffff;
  --line: #e8e1d3;
  --line-soft: #f0ebe0;
  --text: #211d16;
  --text-muted: #857c6b;
  --ink: #2b2620;

  --amber: #e08a2c;
  --amber-deep: #b3691a;
  --amber-soft: #fbe9d2;

  --teal: #12805f;
  --teal-soft: #dcf2ea;

  --red: #c94a3f;
  --red-soft: #fbe4e1;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-card: 0 1px 2px rgba(60, 45, 20, 0.05), 0 6px 20px -6px rgba(60, 45, 20, 0.10);
  --shadow-pop: 0 20px 60px -12px rgba(40, 30, 10, 0.28);

  --font-display: 'Rubik', system-ui, sans-serif;
  --font-body: 'Heebo', system-ui, sans-serif;
  --font-mono: 'Space Mono', monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(circle at 12% -6%, rgba(224, 138, 44, 0.10), transparent 42%),
    radial-gradient(circle at 100% 18%, rgba(18, 128, 95, 0.06), transparent 38%);
  background-attachment: fixed;
  padding-bottom: env(safe-area-inset-bottom);
}

::selection { background: var(--amber-soft); color: var(--amber-deep); }

.board { max-width: 1080px; margin: 0 auto; padding: 18px 16px 100px; }

/* ---------- header ---------- */
.board-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 4px;
  margin-inline: -4px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}

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

.route-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  background: linear-gradient(160deg, var(--amber), var(--amber-deep));
  color: #fff;
  border-radius: 13px;
  font-family: var(--font-display);
  line-height: 1;
  flex: none;
  box-shadow: 0 6px 14px -4px rgba(179, 105, 26, 0.55);
}
.route-badge-line { font-size: 9px; font-weight: 600; letter-spacing: 0.5px; opacity: 0.9; }
.route-badge-num { font-size: 20px; font-weight: 800; font-family: var(--font-mono); }

.brand-text { min-width: 0; }
.brand-text h1 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.2px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

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

/* ---------- tabs ---------- */
.tabbar {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 18px;
}
.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  min-width: 0;
}
.tab-btn span { overflow: hidden; text-overflow: ellipsis; }
.tab-icon { width: 17px; height: 17px; flex: none; }
.tab-btn.active {
  background: var(--bg-card);
  color: var(--amber-deep);
  box-shadow: var(--shadow-card);
}
.tab-panel[hidden] { display: none; }

.trips-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}
.btn-icon { width: 16px; height: 16px; flex: none; }
.btn:active { transform: scale(0.96); }
.btn.primary { background: var(--amber); color: #fff; box-shadow: 0 4px 12px -3px rgba(224, 138, 44, 0.55); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: var(--bg-card); border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--bg-soft); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.danger:hover { filter: brightness(0.97); }
.btn.small { padding: 7px 12px; font-size: 12.5px; min-height: 34px; }

/* floating action button - mobile only */
.fab {
  display: none;
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  inset-inline-end: 18px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(160deg, var(--amber), var(--amber-deep));
  color: #fff;
  box-shadow: 0 10px 24px -6px rgba(179, 105, 26, 0.6);
  align-items: center;
  justify-content: center;
  z-index: 20;
  cursor: pointer;
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(0.93); }

/* ---------- stats strip ---------- */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.stat-chip {
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  box-shadow: var(--shadow-card);
}
.stat-chip .num {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--amber-deep);
  display: block;
}
.stat-chip .label { font-size: 11px; color: var(--text-muted); line-height: 1.3; display: block; margin-top: 2px; }

/* ---------- trip cards ---------- */
.trips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.trip-card {
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.trip-card.closed { opacity: 0.75; }
.trip-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 4px; height: 100%;
  background: var(--teal);
}
.trip-card.closed::before { background: var(--red); }

.trip-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.trip-name { font-family: var(--font-display); font-weight: 700; font-size: 16.5px; margin: 0; color: var(--ink); }
.trip-meta { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); margin-top: 3px; }

.pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.pill.open { background: var(--teal-soft); color: var(--teal); }
.pill.closed { background: var(--red-soft); color: var(--red); }

.seats-bar-wrap { display: flex; flex-direction: column; gap: 5px; }
.seats-bar-track {
  height: 8px;
  border-radius: 99px;
  background: var(--bg-soft);
  overflow: hidden;
  border: 1px solid var(--line-soft);
}
.seats-bar-fill { height: 100%; background: linear-gradient(90deg, var(--amber), var(--amber-deep)); border-radius: 99px; transition: width 0.3s ease; }
.seats-bar-fill.full { background: var(--red); }
.seats-label { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); display: flex; justify-content: space-between; }

.trip-card-actions { display: flex; gap: 8px; margin-top: 2px; flex-wrap: wrap; }
.trip-card-actions .btn { flex: 1; min-width: 84px; }

/* ---------- dialogs ---------- */
dialog.sheet {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--bg-card);
  color: var(--text);
  width: min(460px, 92vw);
  box-shadow: var(--shadow-pop);
}
dialog.sheet.wide { width: min(680px, 94vw); }
dialog.sheet::backdrop { background: rgba(40, 30, 15, 0.35); backdrop-filter: blur(3px); }

.sheet-form { padding: 22px; display: flex; flex-direction: column; gap: 14px; max-height: 86vh; overflow-y: auto; }
.sheet-form h2 { font-family: var(--font-display); margin: 0 0 4px; font-size: 18px; color: var(--ink); }
.sheet-head-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-muted); font-weight: 500; }
.hint { font-weight: 400; opacity: 0.85; }
input[type=text], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=file] {
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  width: 100%;
}
input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.sheet-actions .btn { flex: 1; }
.muted { color: var(--text-muted); font-size: 13px; }

.table-wrap { max-height: 320px; overflow: auto; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line-soft); }
th { color: var(--text-muted); font-weight: 600; position: sticky; top: 0; background: var(--bg-card); font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; }
td.phone { font-family: var(--font-mono); direction: ltr; text-align: right; }

.add-contact-row { display: flex; gap: 8px; }
.add-contact-row input { flex: 1; }
.search-input { width: 100%; }
.form-error { color: var(--red); font-size: 12.5px; margin: -6px 0 0; }
.editable-name { cursor: pointer; border-bottom: 1px dashed var(--line); }
.editable-name input { width: 100%; background: var(--bg); border: 1.5px solid var(--amber); border-radius: 8px; padding: 5px 8px; color: var(--text); font-size: 13.5px; font-family: var(--font-body); }
.row-actions { display: flex; gap: 6px; }

.board-foot {
  margin-top: 26px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.board-foot code { background: var(--bg-soft); padding: 2px 6px; border-radius: 4px; }
.dot-sep { opacity: 0.5; }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
}

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .board { padding: 14px 12px 96px; }

  .board-head { align-items: center; }
  .brand-text h1 { font-size: 16px; max-width: 60vw; }

  .fab { display: flex; }
  .fab.hidden { display: none; }

  .trips-toolbar .btn span { display: none; }
  .trips-toolbar .btn.primary { display: none; } /* מוחלף ב-FAB בטלפון */
  .trips-toolbar #statusLine { font-size: 11.5px; }

  .stats-strip { grid-template-columns: repeat(2, 1fr); }

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

  dialog.sheet, dialog.sheet.wide {
    width: 100%;
    max-width: 100%;
    margin: 0;
    position: fixed;
    inset-block-end: 0;
    inset-block-start: auto;
    border-radius: 20px 20px 0 0;
  }
  .sheet-form { max-height: 84vh; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }

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

  .panel-card { padding: 14px; }
  .add-contact-row { flex-wrap: wrap; }
  .add-contact-row input { min-width: 120px; }

  .tab-btn span { display: none; }
  .tab-btn { padding: 12px 8px; }
  .tab-icon { width: 20px; height: 20px; }
}

@media (max-width: 380px) {
  .row2 { grid-template-columns: 1fr; }
}
