:root {
  --bg: hsl(220 18% 7%);
  --card: hsl(230 22% 14%);
  --muted: hsl(230 20% 20%);
  --text: hsl(0 0% 96%);
  --text-dim: hsl(0 0% 78%);
  --primary: hsl(25 95% 53%); /* turuncu */
  --primary-600: hsl(25 95% 48%);
  --primary-700: hsl(22 95% 43%);
  --success: hsl(142 70% 45%);
  --error: hsl(0 72% 55%);
  --ring: hsl(25 95% 60% / 0.45);
  --shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  /* tablo kolon genişlikleri (responsive olacak) */
  --col-action: 100px;
  --col-min: 140px;
  --col-date: 180px;
  --col-date-max: 180px;
  --col-sira: 120px;
  --sheet-min: 1180px;
  /* app max canvas */
  --app-max-w: 1200px;
  --app-max-h: 720px;
  /* dropzone max width */
  --dropzone-max-w: 560px;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial,
    sans-serif;
  color: var(--text);
  background: radial-gradient(
      1000px 600px at 10% -10%,
      hsl(25 95% 40% / 0.18),
      transparent
    ),
    radial-gradient(800px 400px at 90% 0%, hsl(278 72% 45% / 0.15), transparent),
    linear-gradient(0deg, var(--bg), var(--bg));
}

.container {
  width: 100%;
  max-width: var(--app-max-w);
  margin: 32px auto 64px;
  padding: 0 24px;
}

/* Header */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid hsl(0 0% 100% / 0.12);
  border-radius: 10px;
  background: hsl(0 0% 100% / 0.02);
  backdrop-filter: blur(6px);
}
.brand__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 6px hsl(25 95% 53% / 0.15);
}
.brand__title {
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: 18px;
}

.profile {
  border: 1px solid hsl(0 0% 100% / 0.12);
  background: hsl(0 0% 100% / 0.02);
  backdrop-filter: blur(6px);
  padding: 4px 6px;
  border-radius: 16px;
  display: grid;
  gap: 4px;
  min-width: 100px;
  text-align: right;
}
.profile__name {
  font-weight: 700;
}
.profile__meta {
  color: var(--text-dim);
  font-size: 6px;
}
/* Card */
.card {
  background: hsl(0 0% 100% / 0.04);
  border: 1px solid hsl(0 0% 100% / 0.1);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  overflow: hidden;
}
.section {
  padding: 22px;
}
.section--hero {
  margin-top: 28px;
  display: grid;
  gap: 26px; /* normal (az satır) durumda otomatik yükseklik */
  grid-template-rows: auto auto auto auto; /* dropzone + toolbar + status + sheet */
  overflow: visible;
}
.section--hero.fixed {
  /* çok satır olduğunda kart yüksekliği sabitlenir ve içi scroll olur */
  height: min(
    var(--app-max-h),
    calc(100vh - 96px)
  ); /* 32px üst + 64px alt marjin */
  overflow: hidden;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

/* Dropzone */
.dropzone {
  border: 2px dashed hsl(0 0% 100% / 0.2);
  background: hsl(0 0% 100% / 0.03);
  border-radius: 18px;
  min-height: 160px;
  display: grid;
  place-items: center;
  transition: 0.25s ease;
  position: relative;
  width: 100%;
  max-width: var(--dropzone-max-w);
  margin: 0 auto;
}
.dropzone.is-dragover {
  border-color: var(--primary);
  background: hsl(25 95% 53% / 0.06);
  box-shadow: 0 0 0 8px hsl(25 95% 53% / 0.06) inset;
}
.dropzone__inner {
  text-align: center;
  padding: 30px 20px;
}
.dropzone h2 {
  margin: 6px 0 4px;
  font-size: 22px;
}
.dropzone p {
  margin: 0;
  color: var(--text-dim);
}
.dropzone .chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: hsl(0 0% 100% / 0.06);
  border: 1px solid hsl(0 0% 100% / 0.1);
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 10px;
}

/* Toolbar */
.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: center;
}
.toolbar > * {
  min-width: 0;
}
.toolbar > * {
  min-width: 0;
}
select,
.btn,
input[type="file"]::file-selector-button {
  font: inherit;
}
select,
.btn {
  height: 44px;
  border-radius: 12px;
  border: 1px solid hsl(0 0% 100% / 0.12);
  background: hsl(0 0% 100% / 0.03);
  color: var(--text);
  padding: 0 14px;
}
select:focus {
  outline: none;
  box-shadow: 0 0 0 6px var(--ring);
  border-color: var(--primary);
}
/* Bot seçimi metnini ortala */
#botSelect {
  text-align: center;
  text-align-last: center;
}
#botSelect option {
  text-align: center;
}
/* native select gizle, custom dropdown kullanılacak */
#botSelect {
  display: block !important;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: 0.2s ease;
}
.btn:hover {
  background: hsl(0 0% 100% / 0.06);
}
.btn--danger {
  border-color: hsl(0 0% 100% / 0.1);
  background: hsl(0 0% 100% / 0.04);
  color: hsl(0 0% 100% / 0.85);
}
.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-700));
  border-color: hsl(0 0% 100% / 0.08);
}
.btn--primary:hover {
  filter: saturate(1.05) brightness(1.02);
  transform: translateY(-1px);
}
.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Link */
.soft-link {
  text-align: center;
  color: hsl(250 100% 74%);
  text-decoration: none;
  font-weight: 600;
}
.soft-link:hover {
  text-decoration: underline;
}
.statusline {
  text-align: center;
  color: hsl(250 100% 74%);
  font-weight: 600;
  min-height: 22px;
}
/* Icon base size (keep small like first version) */
.icon {
  width: 20px;
  height: 20px;
  display: inline-block;
}
/* Sheet (elle tablo girme alanı) */
.sheet {
  margin-top: 12px;
  border-radius: 18px;
  border: 1px solid hsl(0 0% 100% / 0.12);
  background: hsl(0 0% 100% / 0.03);
  box-shadow: inset 0 0 0 2px hsl(0 0% 100% / 0.02);
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}
/* === restore header/row/footer grid (eski düzen) === */
.sheet__header {
  display: grid;
  grid-template-columns:
    var(--col-action) var(--col-sira) var(--col-sira) minmax(
      var(--col-date),
      var(--col-date-max)
    )
    repeat(6, var(--col-sira));
}
.sheet__row {
  display: grid;
  grid-template-columns:
    var(--col-action) var(--col-sira) var(--col-sira) minmax(
      var(--col-date),
      var(--col-date-max)
    )
    repeat(6, var(--col-sira));
  align-items: center;
}
.sheet__footer {
  display: grid;
  grid-template-columns:
    var(--col-action) var(--col-sira) var(--col-sira) minmax(
      var(--col-date),
      var(--col-date-max)
    )
    repeat(6, var(--col-sira));
  align-items: center;
}

.sheet__headcell {
  padding: 16px 18px;
  font-weight: 800;
  color: var(--text);
  border-right: 1px solid hsl(0 0% 100% / 0.08);
  background: linear-gradient(
    180deg,
    hsl(0 0% 100% / 0.06),
    hsl(0 0% 100% / 0.02)
  );
  letter-spacing: 0.2px;
}
/* sol kenar çizgisini sabitle (üst çerçeve ile boşluk kalmasın) */
/* ilk hücrede ekstra sol sınır yok (çerçeveyle hizalı) */
.sheet__header .sheet__headcell:first-child {
  border-left: 0;
}
/* header hücresi iç köşe yuvarlamalarını kaldır (dış çerçeve ile hizalama) */
/* header sağ üst köşe yuvarlamasını dış çerçeve yönetecek */
.sheet__body {
  /* vertical scroll now on viewport */
  overflow-y: auto;
  overflow-x: hidden;
}

.cell {
  padding: 6px 8px;
  border-right: 1px solid hsl(0 0% 100% / 0.06);
  display: flex;
  align-items: center;
}
/* kolon ayırıcı çizgiler son hücrede tekrarlanmasın */
.sheet__header .sheet__headcell:last-child,
.sheet__row .cell:last-child {
  border-right: 0;
}
/* İşlem sütunu: birincil (X veya +) ve altına ekle butonu */
.actioncell {
  padding: 6px 8px;
  border-right: 1px solid hsl(0 0% 100% / 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border-left: 0;
}

.input {
  width: 100%;
  height: 38px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid hsl(0 0% 100% / 0.12);
  background: hsl(0 0% 100% / 0.02);
  color: var(--text);
}
.input:focus {
  outline: none;
  box-shadow: 0 0 0 6px var(--ring);
  border-color: var(--primary);
}
/* Tarih seçici ikonu: BEYAZ custom SVG + tarayıcı ikonunu gizle */
.input[type="date"] {
  color: var(--text);
  color-scheme: dark;
  padding-right: 40px;
}
.input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0;
}
.input[type="date"]::-moz-calendar-picker-indicator {
  opacity: 0;
}
.input[type="date"]::-webkit-inner-spin-button,
.input[type="date"]::-webkit-clear-button {
  display: none;
}
/* Firefox için takvim göstergesi gizle (arka plan svg'si kullanılacak) */
.input[type="date"]::-moz-calendar-picker-indicator {
  opacity: 0;
}
/* Sıra No sadece okunur görünsün */
.input[readonly] {
  background: hsl(0 0% 100% / 0.06);
  color: var(--text-dim);
}
/* Sıra No metnini ortala */
.input[data-key="siraNo"] {
  text-align: center;
}
/* Tarih butonu için sarmalayıcı ve buton */
.datewrap {
  position: relative;
  width: 100%;
}
.datebtn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.datebtn:hover {
  background: hsl(0 0% 100% / 0.08);
}
.datebtn svg {
  width: 18px;
  height: 18px;
  stroke: #ffffff;
}
/* ikonun üzerinde tıklanabilir ama görünmez date input */
.dateoverlay {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  opacity: 0;
  z-index: 3;
  cursor: pointer;
  border: 0;
  background: transparent;
  pointer-events: auto;
}
.datebtn {
  z-index: 2;
}
/* Native OS datepicker kullanılacak (ikon üstüne date overlay) */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid hsl(0 0% 100% / 0.12);
  background: hsl(0 0% 100% / 0.04);
  cursor: pointer;
  transition: 0.2s ease;
}
.icon-btn:hover {
  background: hsl(0 0% 100% / 0.07);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}
.icon-btn--del {
  color: var(--error);
  border-color: hsl(0 72% 55% / 0.4);
}
.icon-btn--add {
  color: var(--success);
  border-color: hsl(142 70% 45% / 0.4);
}
/* Footer + hizalama */
/* footer add button wraps inside a cell to match first column padding */
.footer-actioncell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 8px;
  border-left: 0;
}
.sheet__footer .hint {
  grid-column: 2 / -1;
  padding-left: 8px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* Toast */
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 10px;
  z-index: 50;
}
.toast__item {
  background: hsl(0 0% 100% / 0.06);
  border: 1px solid hsl(0 0% 100% / 0.14);
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

/* Progress overlay */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(15, 18, 32, 0.45);
  backdrop-filter: blur(3px);
  z-index: 40;
}
.overlay.active {
  display: grid;
}
.loader {
  width: 60px;
  height: 60px;
  border-radius: 999px;
  border: 6px solid hsl(0 0% 100% / 0.2);
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

/* Responsive tweaks */
@media (max-width: 1200px) {
}
@media (max-width: 980px) {
  .toolbar {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 760px) {
  .toolbar {
    grid-template-columns: 1fr;
  }
}
/* Print */
@media print {
  body {
    background: white;
  }
  .topbar,
  .section--hero .toolbar,
  .soft-link,
  .toast,
  .overlay {
    display: none !important;
  }
  .card,
  .logs,
  .logs__lane {
    border-color: #000 !important;
    background: white !important;
  }
  .log {
    border-color: #000 !important;
    background: white !important;
    color: #000;
  }
}
.sheet__viewport {
  overflow-y: auto;
  overflow-x: hidden;
  height: auto;
  max-height: none;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.section--hero.fixed .sheet__viewport {
  overflow-y: scroll;
  height: 100%;
  scrollbar-gutter: stable;
}
.sheet__viewport > .sheet__header,
.sheet__viewport > .sheet__body,
.sheet__viewport > .sheet__footer {
  width: max-content;
  min-width: 100%;
}
/* Always-visible bottom horizontal scroller */
.sheet__hscroll {
  height: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  background: hsl(0 0% 100% / 0.08);
  border-top: 1px solid hsl(0 0% 100% / 0.12);
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
}
.sheet__hscroll::-webkit-scrollbar {
  height: 12px;
}
.sheet__hscroll::-webkit-scrollbar-thumb {
  background: hsl(0 0% 100% / 0.35);
  border-radius: 999px;
}
.sheet__hscroll::-webkit-scrollbar-track {
  background: transparent;
}
.sheet__viewport::-webkit-scrollbar {
  height: 12px;
  width: 12px;
}
.sheet__viewport::-webkit-scrollbar-thumb {
  background: hsl(0 0% 100% / 0.35);
  border-radius: 999px;
}
.sheet__viewport::-webkit-scrollbar-track {
  background: hsl(0 0% 100% / 0.08);
}

/* PetraBot chip: hug content; do not stretch across the 1fr grid track */
.topbar .brand {
  justify-self: start !important; /* stay at the start of its grid cell */
  width: max-content !important; /* size to content width */
  max-width: max-content !important; /* prevent stretching */
  inline-size: max-content !important; /* logical width for extra safety */
}

/* ==== Petra: profile + logout button tweaks ==== */
.topbar {
  grid-auto-rows: auto;
} /* allow second row for logout button */
.profile-stack {
  display: grid;
  gap: 8px;
  justify-items: end;
}
.btn--ghost {
  background: hsl(0 0% 100% / 0.02);
  border-color: hsl(0 0% 100% / 0.12);
}
.btn--ghost:hover {
  background: hsl(0 0% 100% / 0.06);
}
.btn--xs {
  height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 13px;
}

/* Overlay: disabled primary button looks muted */
.btn--primary[disabled] {
  background: hsl(0 0% 100% / 0.08) !important;
  border-color: hsl(0 0% 100% / 0.12) !important;
  opacity: 0.6 !important;
  cursor: not-allowed !important;
  filter: none !important;
  transform: none !important;
}

/* Petra: dropdown list theming (non-invasive) */
/* Only the opened list panel of native selects */
select.input option,
select.input optgroup {
  background: var(--card);
  color: var(--text);
}
/* Açılan dropdown LİSTESİ (native panel) için arka plan */
#botSelect option,
#botSelect optgroup {
  background: var(--card);
  color: var(--text);
}
/* Disabled görünümlü ama tıklanabilir buton */
.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
  /* Tıklamayı engelleme (pointer-events) YAPMIYORUZ ki toast çalışsın */
}
/* --- BAŞLAT BUTONU TIKLAMA YÖNETİMİ --- */

/* Pasif görünümlü buton (Turuncu ama soluk) */
.btn--primary.btn-disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  filter: grayscale(0.2); /* Hafif grileşsin */
}

/* Pasifken üzerine gelindiğinde RENGİ DEĞİŞMESİN (Siyahlaşma Çözümü) */
.btn--primary.btn-disabled:hover {
  background: linear-gradient(
    135deg,
    var(--primary),
    var(--primary-700)
  ) !important;
  transform: none !important; /* Zıplamasın */
  filter: grayscale(0.2); /* Filtreyi koru */
  box-shadow: none;
}
/* Aktif (Disabled olmayan) Başlat butonu üzerine gelince */
.btn--primary:not(.btn-disabled):hover {
  /* Gri arka planı ez ve turuncu gradyanı koru */
  background: linear-gradient(
    135deg,
    var(--primary),
    var(--primary-700)
  ) !important;

  /* Biraz daha parlasın */
  filter: saturate(1.2) brightness(1.1);

  /* Hafif yukarı kalksın (Zaten vardı, garanti olsun) */
  transform: translateY(-1px);

  /* Hafif turuncu bir gölge ekleyelim, şık dursun */
  box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
}
