*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #0891B2;
  --primary-dk: #0E7490;
  --primary-lt: #E0F2FE;
  --cta:        #059669;
  --cta-dk:     #047857;
  --cta-lt:     #ECFDF5;
  --violet:     #7C3AED;
  --violet-lt:  #EDE9FE;
  --bg:         #F0F9FF;
  --card:       #FFFFFF;
  --border:     #E2E8F0;
  --text:       #0F172A;
  --muted:      #64748B;
  --red:        #DC2626;
  --red-lt:     #FEF2F2;
  --amber:      #D97706;
  --amber-lt:   #FFFBEB;
  --focus:      rgba(8,145,178,0.25);
}

body {
  font-family: 'Figtree', -apple-system, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
}

/* ── Header ── */
.app-header { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.header-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px; height: 60px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { color: var(--primary); flex-shrink: 0; }
.brand-name { font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.brand-sub  { font-size: 0.72rem; color: var(--muted); }
.user-chip  { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; }
.user-name  { font-weight: 600; }
.logout-btn {
  display: inline-flex; align-items: center;
  padding: 5px 13px; border: 1.5px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--muted); font-size: 0.8rem; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: border-color .15s, color .15s, background .15s;
}
.logout-btn:hover { border-color: var(--red); color: var(--red); background: var(--red-lt); }

.nav-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 13px; border: 1.5px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--muted); font-size: 0.8rem; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: border-color .15s, color .15s, background .15s;
}
.nav-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-lt); }

/* ── Login layout ── */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px; padding: 24px 16px;
}
.login-brand { text-align: center; }
.login-brand svg { color: var(--primary); }
.login-brand h1 { font-size: 1.55rem; font-weight: 700; margin-top: 10px; }
.login-brand p  { font-size: 0.88rem; color: var(--muted); margin-top: 3px; }
.login-card { width: 100%; max-width: 400px; }

/* ── Main layout ── */
.main-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 16px 48px;
}

/* Search pane: full-width centered block shown while searching */
.search-pane-card {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

/* Three-column config grid */
.three-col {
  display: grid;
  grid-template-columns: 280px 1fr 260px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1100px) {
  .three-col { grid-template-columns: 1fr 1fr; }
  .three-col > *:last-child { grid-column: 1 / -1; }
}
@media (max-width: 680px) {
  .three-col { grid-template-columns: 1fr; }
}

/* ── Cards ── */
.card {
  background: var(--card); border-radius: 14px; padding: 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  border: 1px solid var(--border); margin-bottom: 20px;
}
.card:last-child { margin-bottom: 0; }
.card-pos { position: relative; }
.card-title {
  font-size: 0.95rem; font-weight: 700; margin-bottom: 18px;
  display: flex; align-items: center; gap: 8px;
}
.num-badge {
  width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; flex-shrink: 0;
}
.num-badge.green  { background: var(--cta); }
.num-badge.indigo { background: #6366F1; }
.num-badge.violet { background: var(--violet); }

/* ── Forms ── */
.field { margin-bottom: 13px; }
label { display: flex; align-items: center; gap: 5px; font-size: 0.79rem; font-weight: 600; color: #475569; margin-bottom: 5px; }
.opt-tag { font-size: 0.67rem; font-weight: 500; background: #F1F5F9; color: var(--muted); border-radius: 4px; padding: 1px 6px; }
.load-tag { font-size: 0.68rem; font-weight: 400; color: var(--muted); display: none; align-items: center; gap: 3px; margin-left: auto; }
.load-tag.on { display: flex; }

input[type=text], input[type=email], input[type=date], input[type=password] {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 0.91rem; color: var(--text); background: #fff;
  font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
input:focus          { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
input::placeholder   { color: #CBD5E1; }
input:disabled       { background: #F8FAFC; color: #94A3B8; cursor: not-allowed; border-style: dashed; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint  { font-size: 0.74rem; color: var(--muted); margin-top: 4px; }

/* ── Combo ── */
.combo { position: relative; }
.combo-wrap { position: relative; }
.combo-wrap input { padding-right: 30px; cursor: text; }
.combo-wrap input:disabled { cursor: not-allowed; }
.combo-arr {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%) rotate(0);
  color: var(--muted); pointer-events: none; transition: transform .2s;
}
.combo.open .combo-arr { transform: translateY(-50%) rotate(180deg); }
.combo-drop {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1.5px solid var(--primary); border-radius: 8px;
  max-height: 230px; overflow-y: auto; z-index: 50; display: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}
.combo-drop.open { display: block; }
.combo-drop ul   { list-style: none; padding: 4px 0; }
.combo-drop li   { padding: 9px 13px; cursor: pointer; font-size: 0.89rem; color: var(--text); transition: background .1s; }
.combo-drop li:hover, .combo-drop li.hi { background: var(--primary-lt); color: var(--primary-dk); }
.combo-drop li.combo-sub { padding-left: 26px; }
.combo-drop li.combo-sub::before { content: '↳'; margin-right: 6px; color: var(--muted); }
.combo-drop .no-result { padding: 11px 13px; font-size: 0.83rem; color: var(--muted); text-align: center; }

/* ── Filter chips ── */
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; cursor: pointer;
  padding: 5px 11px; border-radius: 20px;
  font-size: 0.77rem; font-weight: 600; font-family: inherit;
  border: 1.5px solid var(--border); background: #fff; color: var(--muted);
  transition: background .12s, border-color .12s, color .12s;
  user-select: none;
}
.chip input { display: none; }
.chip:hover { border-color: #94A3B8; color: #475569; }
.chip.active { background: var(--primary-lt); border-color: var(--primary); color: var(--primary-dk); }

/* ── Buttons ── */
.btn {
  width: 100%; padding: 11px 16px; border: none; border-radius: 9px;
  font-size: 0.91rem; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: background .15s, transform .1s; min-height: 44px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dk); }
.btn-cta { background: var(--cta); color: #fff; }
.btn-cta:hover:not(:disabled) { background: var(--cta-dk); }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary-lt); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #B91C1C; }
.btn:disabled { background: #CBD5E1; color: #94A3B8; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.btn-ext {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; padding: 11px 20px; background: var(--cta); color: #fff;
  border-radius: 9px; font-size: 0.91rem; font-weight: 700;
  min-height: 44px; transition: background .15s; white-space: nowrap;
}
.btn-ext:hover { background: var(--cta-dk); }

/* ── Alerts ── */
.alert { padding: 10px 13px; border-radius: 8px; font-size: 0.84rem; margin-bottom: 14px; line-height: 1.5; display: flex; align-items: flex-start; gap: 8px; }
.alert svg  { flex-shrink: 0; margin-top: 1px; }
.alert-err  { background: var(--red-lt);     color: #B91C1C;          border: 1px solid #FECACA; }
.alert-ok   { background: var(--cta-lt);     color: #047857;          border: 1px solid #A7F3D0; }
.alert-info { background: var(--primary-lt); color: var(--primary-dk); border: 1px solid #BAE6FD; }

/* ── Token card ── */
.connected-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--cta-lt); color: #047857; border: 1px solid #A7F3D0;
  border-radius: 20px; padding: 3px 9px; font-size: 0.76rem; font-weight: 600;
  margin-left: auto;
}
.bm-wrap { text-align: center; margin: 12px 0 8px; }
.bm-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 20px;
  background: var(--primary); color: #fff; border-radius: 9px;
  font-size: 0.87rem; font-weight: 700; text-decoration: none;
  border: 2px dashed rgba(255,255,255,0.4); cursor: grab;
  user-select: none; transition: background .15s; font-family: inherit;
}
.bm-btn:hover { background: var(--primary-dk); }
.bm-hint { font-size: 0.72rem; color: var(--muted); margin-top: 6px; }

.steps { margin: 10px 0; }
.step  { display: flex; gap: 8px; margin-bottom: 9px; font-size: 0.82rem; color: #475569; line-height: 1.5; }
.step-n {
  background: var(--primary-lt); color: var(--primary);
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 700; flex-shrink: 0; margin-top: 2px;
}
.step a { color: var(--primary); }
.divider { display: flex; align-items: center; gap: 10px; margin: 12px 0; color: var(--muted); font-size: 0.74rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Config overlay ── */
.overlay {
  position: absolute; inset: 0; background: rgba(240,249,255,0.88);
  backdrop-filter: blur(3px); border-radius: 14px;
  display: flex; align-items: center; justify-content: center; z-index: 20;
}
.overlay-box {
  background: #fff; border: 1.5px solid var(--border); border-radius: 12px;
  padding: 20px 28px; text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.overlay-box p { font-size: 0.84rem; color: var(--muted); margin-top: 8px; }

/* ── Search pane status ── */
.status-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 20px; font-size: 0.82rem; font-weight: 700; margin-bottom: 14px; }
.chip-running { background: var(--amber-lt); color: var(--amber); }
.chip-found   { background: var(--cta-lt);   color: #047857; }
.chip-stopped { background: var(--red-lt);   color: var(--red); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.dot-pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.25} }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.stat     { background: #F8FAFC; border-radius: 10px; padding: 13px 12px; text-align: center; }
.stat-num { font-size: 1.55rem; font-weight: 800; color: var(--primary); }
.stat-lbl { font-size: 0.69rem; color: var(--muted); margin-top: 2px; }

.log-lbl { font-size: 0.74rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.log-box {
  background: #0F172A; color: #4ADE80; border-radius: 8px; padding: 11px 13px;
  font-family: 'Menlo','Courier New',monospace; font-size: 0.73rem;
  max-height: 200px; overflow-y: auto; line-height: 1.7;
}
.log-box div { white-space: pre-wrap; word-break: break-all; }

/* ── Results view ── */
.results-banner {
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(135deg, #065F46 0%, #047857 100%);
  border-radius: 16px;
  padding: 24px 28px;
  margin-bottom: 24px;
  color: #fff;
  flex-wrap: wrap;
}
.results-banner-icon {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.results-banner-text { flex: 1; min-width: 160px; }
.results-banner-title { font-size: 1.4rem; font-weight: 800; line-height: 1.2; }
.results-banner-sub   { font-size: 0.9rem; opacity: 0.85; margin-top: 3px; }
.results-banner-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.results-banner-actions .btn-ext {
  background: #fff; color: #047857;
}
.results-banner-actions .btn-ext:hover { background: #F0FDF4; }
.results-banner-actions .btn {
  width: auto; padding: 11px 18px;
  background: rgba(255,255,255,0.15); color: #fff;
  border: 1.5px solid rgba(255,255,255,0.4);
}
.results-banner-actions .btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.25);
}

/* Appointment grid */
.appt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.appt-card-lg {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  border: 1.5px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  border-top: 4px solid var(--cta);
  transition: box-shadow .15s;
}
.appt-card-lg:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.appt-time {
  font-size: 1.4rem; font-weight: 800; color: var(--cta);
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px;
}
.appt-gun {
  font-size: 0.8rem; font-weight: 600; color: #047857;
  background: var(--cta-lt); border-radius: 6px; padding: 2px 8px;
}
.appt-kurum { font-size: 0.9rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.appt-hekim { font-size: 0.83rem; color: var(--muted); margin-bottom: 2px; }
.appt-klinik {
  font-size: 0.76rem; color: var(--primary-dk);
  background: var(--primary-lt); border-radius: 5px;
  padding: 2px 8px; display: inline-block; margin-top: 6px;
}

/* ── Spinner ── */
.spin {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0;
}
.spin-muted { border-color: rgba(0,0,0,0.1); border-top-color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #0F172A; color: #fff; padding: 10px 22px; border-radius: 10px;
  font-size: 0.87rem; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  transition: transform .3s ease; z-index: 100; white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ── Screens ── */
.screen        { display: none; }
.screen.active { display: block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Jobs screen ── */
.jobs-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.jobs-title { font-size: 1.3rem; font-weight: 800; }
.jobs-sub   { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }

.job-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}
@media (max-width: 680px) {
  .job-grid { grid-template-columns: 1fr; }
}

.job-card {
  background: var(--card); border-radius: 14px; padding: 18px 20px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  transition: box-shadow .15s;
}
.job-card:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.08), 0 6px 20px rgba(0,0,0,0.06); }

.job-patient {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 14px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.job-patient svg { color: var(--primary); flex-shrink: 0; }
.job-patient-info { flex: 1; min-width: 0; }
.job-patient-name {
  font-size: 1.05rem; font-weight: 800; color: var(--text);
  line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.job-patient-birth {
  font-size: 0.78rem; color: var(--muted); margin-top: 2px;
}

.job-search-text {
  display: flex; align-items: flex-start; gap: 8px;
  background: #F8FAFC; border-radius: 8px; padding: 10px 12px;
  font-size: 0.83rem; color: #475569; line-height: 1.5;
  margin-bottom: 14px;
}
.job-search-text svg { color: var(--muted); flex-shrink: 0; margin-top: 2px; }
.job-search-text span { word-break: break-word; }

.job-card-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.job-card-summary {
  font-size: 0.92rem; font-weight: 700; color: var(--text);
  line-height: 1.4; flex: 1;
}

.job-card-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px;
  margin-bottom: 12px;
}
.job-stat { display: flex; flex-direction: column; gap: 1px; }
.job-stat-lbl { font-size: 0.68rem; color: var(--muted); font-weight: 600; }
.job-stat-val { font-size: 0.85rem; font-weight: 700; color: var(--text); }

.job-card-err {
  background: var(--red-lt); color: var(--red);
  border-radius: 8px; padding: 8px 12px;
  font-size: 0.78rem; margin-bottom: 12px;
}

.job-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; border-top: 1px solid var(--border); padding-top: 12px;
}
.job-id {
  font-family: 'Menlo','Courier New',monospace;
  font-size: 0.74rem; color: var(--muted);
}
.job-email {
  font-size: 0.74rem; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.job-card-actions { display: flex; gap: 8px; }

.btn-sm {
  padding: 6px 14px; font-size: 0.78rem; width: auto;
}

.job-empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
  grid-column: 1 / -1;
}
.job-empty svg { color: var(--border); margin-bottom: 12px; }
.job-empty p { font-size: 0.9rem; }
