:root {
  --bg: #1c1f26;
  --panel: #232730;
  --panel-2: #2a2f3a;
  --border: #3a3f4b;
  --text: #e7eaf0;
  --text-dim: #9aa1ad;
  --accent: #4a8cff;
  --green: #2ecc71;
  --green-bg: rgba(46, 204, 113, 0.18);
  --red: #ff5c5c;
  --red-bg: rgba(255, 92, 92, 0.18);
  --tab-h: 44px;
  --search-h: 38px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input, textarea {
  font: inherit;
  color: inherit;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  outline: none;
}
input:focus, textarea:focus {
  border-color: var(--accent);
}
input:disabled, textarea:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: #1a1d23;
  color: var(--text-dim);
}

/* Phone-mask input: monospace + tabular nums so underscores align uniformly */
.phone-mask {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

/* === Tabs === */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  height: var(--tab-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: relative;     /* anchor user-chip */
}
.user-chip {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  text-decoration: none;
}
.user-chip:hover { color: var(--text); background: var(--border); }
.user-chip .user-name { font-weight: 500; }
.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  background: var(--panel);
  position: relative;
}
.tab.active {
  color: var(--text);
  background: var(--panel-2);
}
.tab.active::after {
  content: "";
  position: absolute;
  left: 25%;
  right: 25%;
  bottom: 0;
  height: 2px;
  background: var(--accent);
}
.tab-divider {
  background: var(--border);
}

/* === Search bar === */
.search-bar {
  height: var(--search-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 12px;
}
.search-bar input {
  width: min(420px, 60vw);
  background: var(--bg);
  font-size: 12px;
}
.search-bar #search-clear {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: calc(50vw - min(210px, 30vw) - 4px);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
}
.search-bar #search-clear:hover { background: var(--border); color: var(--text); }

/* === Board === */
.board {
  /* `100vh` includes the area behind the iOS Safari toolbar, so the bottom
     row gets clipped on tablets. `100dvh` is the *currently visible* height
     and reflows when the toolbar shows/hides. Keep `100vh` first as fallback
     for very old browsers. */
  height: calc(100vh - var(--tab-h) - var(--search-h));
  height: calc(100dvh - var(--tab-h) - var(--search-h));
  width: 100vw;
}
.tab-pane {
  display: grid;
  grid-template-columns: minmax(140px, 18%) minmax(0, 1fr);
  height: 100%;
  width: 100%;
}
.tab-pane[hidden] {
  display: none;
}

.left-col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--panel);
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}

.right-grid {
  display: grid;
  height: 100%;
  min-height: 0;
  min-width: 0;
}
/* minmax(0, 1fr) instead of 1fr → tracks ignore intrinsic content size, so a
   list with 100 cards never expands its grid cell. The list-body below has
   overflow-y:auto so it scrolls inside the locked-size cell. */
.right-grid-tab1 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
}
.right-grid-tab2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
}
.cell {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}
.cell:first-child { border-left: none; }
/* For tab1 (4 cols × 2 rows): items 5-8 already get border-bottom; remove on last row */
.right-grid-tab1 .cell:nth-child(n+5) { border-bottom: none; }
.right-grid-tab2 .cell:nth-child(n+3) { border-bottom: none; }
.right-grid-tab1 .cell:nth-child(4n+1) { border-left: none; }
.right-grid-tab2 .cell:nth-child(2n+1) { border-left: none; }

/* === List header & body === */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  height: 36px;
  flex: 0 0 36px;
}
.list-title {
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-meta {
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 3px;
}
.add-lead-btn {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  line-height: 1;
  flex: 0 0 auto;
}

.list-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  counter-reset: cardnum;
  /* Touch: only vertical pan starts a scroll. SortableJS gets the long-press
     to begin a drag (250 ms delay configured in board.js). */
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

/* === Card === */
.card {
  display: flex;
  align-items: center;
  padding: 0;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;       /* tap/click → modal */
  font-variant-numeric: tabular-nums;
  user-select: none;
  transition: background 0.15s;
  counter-increment: cardnum;
}
/* Number strip: a thin column hugging the left wall of the list, separated
   from the card content by a vertical line. Belongs visually to the LIST,
   not to the card. */
.card::before {
  content: counter(cardnum);
  flex: 0 0 18px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.card:hover {
  background: var(--panel-2);
}
.card.dragging {
  opacity: 0.5;
}
.card.green {
  background: var(--green-bg);
}
.card.red {
  background: var(--red-bg);
}
.card .phone {
  font-size: 13px;
  font-weight: 500;
  flex: 1 1 auto;
  padding: 10px 12px;
}

/* Drag-handle: the only place a drag starts (mouse + touch). Cards
   themselves stay clickable/scrollable for tap-to-edit and finger swipe.
   Width is set to match the card's natural height so the area is square. */
.card-handle {
  flex: 0 0 36px;          /* desktop: card ≈ 36 px tall → square handle */
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--border);
  color: var(--text-dim);
  cursor: grab;
  touch-action: none;
  -webkit-user-drag: element;
}
.card-handle:hover { color: var(--text); background: var(--panel-2); }
.card-handle:active { cursor: grabbing; }
.card-handle svg { width: 18px; height: 18px; display: block; }
@media (pointer: coarse) {
  .card-handle { flex-basis: 44px; }   /* touch card ≈ 44 px tall */
  .card-handle svg { width: 22px; height: 22px; }
}

/* "Aradım" / reset-timer button — only shown when card is green */
.card-action {
  display: none;
  width: 26px;
  height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--green);
  background: transparent;
  border: 1px solid var(--green);
  flex: 0 0 auto;
  margin: 0 8px;
  transition: background 0.15s, color 0.15s;
}
.card-action svg { width: 14px; height: 14px; display: block; }
/* Only the "Olumlu (Ödeme Bilgisi Gönderildi)" list shows the reset-timer
   button on green cards — other lists drag forward in the workflow instead. */
.list-body[data-list-code="olumlu_odeme"] .card.green .card-action { display: inline-flex; }
.card-action:hover {
  background: var(--green);
  color: white;
}

/* SortableJS ghost/chosen */
.sortable-ghost {
  opacity: 0.3;
  background: var(--accent) !important;
}

/* Search highlight mode: when body.searching, non-matches dim, matches outlined */
body.searching .card {
  opacity: 0.25;
  transition: opacity 0.12s, outline-color 0.12s;
}
body.searching .card.match {
  opacity: 1;
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* === Login screen (light/day mode, brand colors) === */
.login-shell {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
/* Day-mode palette — overrides the dark vars only on the login page so the
   board theme stays untouched. */
.login-shell.login-light {
  --lg-bg: #f4f6fb;
  --lg-card: #ffffff;
  --lg-border: #d8dde8;
  --lg-text: #1a2540;
  --lg-text-dim: #64708a;
  --lg-input-bg: #ffffff;
  --lg-brand: #16235c;          /* SpeakNow navy from the logo */
  --lg-brand-hover: #233487;
  background: var(--lg-bg);
  color: var(--lg-text);
}
.login-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  width: min(380px, 92vw);
}
.login-logo {
  width: 100%;
  max-width: 320px;
  height: auto;
  display: block;
}
.login-card {
  width: 100%;
  background: var(--lg-card);
  border: 1px solid var(--lg-border);
  border-radius: 10px;
  padding: 26px 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 8px 32px rgba(22, 35, 92, 0.08);
}
.login-card .field > span {
  color: var(--lg-text-dim);
}
.login-card input {
  background: var(--lg-input-bg);
  color: var(--lg-text);
  border: 1px solid var(--lg-border);
  padding: 10px 12px;
  font-size: 14px;
}
.login-card input:focus {
  border-color: var(--lg-brand);
  box-shadow: 0 0 0 3px rgba(22, 35, 92, 0.12);
}
.login-card .login-submit {
  margin-top: 6px;
  background: var(--lg-brand);
  color: #fff;
  border: none;
  padding: 12px 18px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.login-card .login-submit:hover {
  background: var(--lg-brand-hover);
}
.login-error {
  background: #fdeaea;
  border-left: 3px solid #d6453a;
  color: #6b1a14;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
}

/* ===== Touch / tablet tweaks =====
   On a coarse pointer (finger), enlarge tap targets a bit and give the
   reset-timer / add-lead buttons more breathing room without changing the
   desktop look. */
@media (pointer: coarse) {
  .card .phone { padding: 14px 12px; }
  .add-lead-btn { width: 28px; height: 28px; }
  .card-action { width: 32px; height: 32px; }
  .card-action svg { width: 16px; height: 16px; }
  .modal-close { width: 36px; height: 36px; font-size: 22px; }
  .btn { padding: 10px 18px; }
  .list-header { height: 42px; flex-basis: 42px; }
}

/* === Modal === */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
}
.modal-dialog {
  position: relative;
  width: min(640px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}
.modal-dialog.small {
  width: min(420px, 92vw);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 600; }
.modal-close {
  font-size: 20px;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  color: var(--text-dim);
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body {
  padding: 16px;
  overflow-y: auto;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
}
.btn {
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: 500;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #5d9bff; }
.btn-secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.field > span {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field-name { flex: 1.2; }
.timer-block:not([hidden]) {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.field-date input, .field-time input { width: 130px; }
.field-switch { flex: 0 0 auto; }
.field-switch input.switch {
  appearance: none;
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  border: none;
  padding: 0;
}
.field-switch input.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.field-switch input.switch:checked {
  background: var(--accent);
}
.field-switch input.switch:checked::after {
  transform: translateX(18px);
}
.field-notes textarea {
  width: 100%;
  resize: vertical;
  min-height: 100px;
}

/* === Flash messages === */
.flash-stack {
  position: fixed;
  top: 12px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 320px;
  pointer-events: none;
}
.flash-left { left: 12px; }
.flash-right { right: 12px; }

.flash {
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 36px 12px 14px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  pointer-events: auto;
  animation: flash-in 0.25s ease-out;
}
.flash.green { border-left: 4px solid var(--green); background: var(--green-bg); }
.flash.red { border-left: 4px solid var(--red); background: var(--red-bg); }
.flash.neutral { border-left: 4px solid var(--accent); }

.flash .close {
  position: absolute;
  top: 4px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
}
.flash .close:hover { background: var(--border); color: var(--text); }
/* Left-stack flash → close on right; right-stack → close on left (macOS-style mirror) */
.flash-left .flash .close { right: 4px; }
.flash-right .flash .close { left: 4px; }
.flash-right .flash { padding: 12px 14px 12px 36px; }

@keyframes flash-in {
  from { transform: translateX(-20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.flash-right .flash { animation-name: flash-in-right; }
@keyframes flash-in-right {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
