:root {
  color-scheme: light;
  --bg: #e9eee9;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --surface-grid: #fbfcfb;
  --grid-head: #eef4f1;
  --ink: #10231f;
  --muted: #65736f;
  --line: rgba(16, 35, 31, 0.13);
  --accent: #0f6b5f;
  --accent-2: #bd7c25;
  --good: #0c7a43;
  --bad: #b73d2b;
  --warn: #b67812;
  --shadow: 0 18px 45px rgba(29, 45, 40, 0.12);
  font-family: "Aptos", "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101715;
  --surface: rgba(20, 29, 26, 0.9);
  --surface-strong: #1b2824;
  --surface-grid: #131d1a;
  --grid-head: #1e2c28;
  --ink: #e8f0ed;
  --muted: #9bada7;
  --line: rgba(232, 240, 237, 0.13);
  --accent: #37ad9c;
  --accent-2: #d89a42;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, rgba(15, 107, 95, 0.18), transparent 28rem),
    radial-gradient(circle at 90% 20%, rgba(189, 124, 37, 0.16), transparent 26rem),
    linear-gradient(145deg, var(--bg), color-mix(in srgb, var(--bg), #000 5%));
}

button,
input,
textarea {
  font: inherit;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.52rem 0.65rem;
  color: var(--ink);
  background: var(--surface-strong);
}

button,
.link-button {
  border: 0;
  border-radius: 10px;
  padding: 0.58rem 0.9rem;
  color: white;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(15, 107, 95, 0.22);
  text-decoration: none;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
}

button.danger {
  background: var(--bad);
}

.compact-button {
  padding: 0.32rem 0.58rem;
  border-radius: 8px;
  font-size: 0.72rem;
}

.target-copy {
  display: block;
  width: 100%;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  text-align: left;
  white-space: normal;
}

.target-copy:hover strong,
.target-copy.copied strong {
  color: var(--accent);
}

.target-copy[data-copied="true"]::after {
  content: "Kopyalandı";
  display: inline-block;
  margin-left: 0.45rem;
  color: var(--accent);
  font-size: 0.66rem;
  font-weight: 900;
}

.copy-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 80;
  max-width: min(360px, calc(100vw - 2rem));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  color: var(--ink);
  background: var(--surface-strong);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
  font-size: 0.78rem;
  font-weight: 900;
}

button.ghost,
.link-button {
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  box-shadow: none;
}

.full-width {
  width: 100%;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 2rem;
}

.login-card {
  width: min(440px, 100%);
  padding: 2.2rem;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  font-weight: 900;
}

.login-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.4rem;
}

.login-form label {
  display: grid;
  gap: 0.4rem;
}

.login-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.82rem 0.95rem;
  color: var(--ink);
  background: var(--surface-strong);
}

.notice,
.error {
  margin-top: 1rem;
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
}

.notice {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn), transparent 90%);
}

.error {
  color: var(--bad);
  background: color-mix(in srgb, var(--bad), transparent 90%);
}

.notice.compact {
  display: none;
  margin: 0;
  padding: 0.55rem 0.7rem;
  font-size: 0.78rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 1.2rem;
  padding: 1rem;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface), transparent 6%);
  backdrop-filter: blur(22px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 48px;
}

.brand-row span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.side-nav {
  display: grid;
  gap: 0.35rem;
}

.nav-link {
  display: grid;
  gap: 0.15rem;
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  color: var(--ink);
  text-decoration: none;
}

.nav-link small {
  color: var(--muted);
  font-size: 0.72rem;
}

.nav-link:hover,
.nav-link.active {
  background: var(--surface-strong);
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar form {
  margin-top: auto;
}

.dashboard {
  display: flex;
  min-width: 0;
  max-height: 100vh;
  flex-direction: column;
  gap: 0.85rem;
  overflow: hidden;
  padding: 0.9rem;
}

.page-header,
.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
}

.page-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  letter-spacing: -0.05em;
}

.page-header p {
  margin-bottom: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.metric {
  padding: 0.75rem 0.9rem;
}

.metric span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.8rem;
  letter-spacing: -0.07em;
}

.metric.good strong {
  color: var(--good);
}

.metric.bad strong {
  color: var(--bad);
}

.metric.warn strong {
  color: var(--warn);
}

.dashboard-split {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.85rem;
}

.panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  padding: 0.75rem;
}

.fill-panel {
  flex: 1;
}

.panel-heading,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1rem;
}

.panel-heading span {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.75rem;
}

.action-row {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.manual-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.manual-form label {
  display: grid;
  gap: 0.32rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.manual-form .wide-field {
  grid-column: span 2;
}

.check-field {
  align-content: end;
  grid-template-columns: auto 1fr !important;
  align-items: center;
  color: var(--ink) !important;
}

.manual-form-actions {
  display: flex;
  align-items: end;
  gap: 0.5rem;
}

.grid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.pager-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.pager-controls label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.filter-field {
  display: grid;
  min-width: min(420px, 100%);
  gap: 0.32rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.pager-controls select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.48rem 0.65rem;
  color: var(--ink);
  background: var(--surface-strong);
}

.page-indicator {
  min-width: 86px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
}

.data-shell {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-grid);
}

.data-shell.tall {
  flex: 1;
  max-height: calc(100vh - 188px);
}

.data-shell.compact {
  flex: 1;
  max-height: calc(50vh - 70px);
}

.data-grid {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ink);
  font-size: 0.76rem;
  line-height: 1.2;
  table-layout: fixed;
}

.incidents-grid {
  --sticky-primary-width: 230px;
  --sticky-secondary-width: 92px;
  min-width: 1480px;
}

.samples-grid {
  --sticky-primary-width: 260px;
  --sticky-secondary-width: 112px;
  min-width: 1200px;
}

.push-grid {
  --sticky-primary-width: 260px;
  --sticky-secondary-width: 96px;
  min-width: 1120px;
}

.coverage-grid {
  --sticky-primary-width: 330px;
  --sticky-secondary-width: 130px;
  min-width: 1280px;
}

.review-grid {
  --sticky-primary-width: 330px;
  --sticky-secondary-width: 118px;
  min-width: 1500px;
}

.visual-grid {
  --sticky-primary-width: 260px;
  --sticky-secondary-width: 92px;
  min-width: 1580px;
}

.data-grid th,
.data-grid td {
  height: 31px;
  max-width: 240px;
  border-bottom: 1px solid var(--line);
  padding: 0.32rem 0.5rem;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.data-grid th {
  position: sticky;
  top: 0;
  z-index: 4;
  color: var(--muted);
  background: var(--grid-head);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.data-grid tbody tr:hover td {
  background: color-mix(in srgb, var(--accent), var(--surface-grid) 91%);
}

.data-grid .sticky-primary,
.data-grid .sticky-secondary {
  position: sticky;
  z-index: 3;
  background: var(--surface-grid);
}

.data-grid th.sticky-primary,
.data-grid th.sticky-secondary {
  z-index: 6;
  background: var(--grid-head);
}

.data-grid .sticky-primary {
  left: 0;
  width: var(--sticky-primary-width);
  min-width: var(--sticky-primary-width);
}

.data-grid .sticky-secondary {
  left: var(--sticky-primary-width);
  width: var(--sticky-secondary-width);
  min-width: var(--sticky-secondary-width);
}

.data-grid strong,
.data-grid small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-grid small {
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.67rem;
}

.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: "SFMono-Regular", Consolas, monospace;
}

.clipped {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clipped.wide {
  max-width: 360px;
}

.latency {
  font-weight: 800;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.grid-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  border-radius: 999px;
  padding: 0.16rem 0.45rem;
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 0.68rem;
  font-weight: 800;
}

.grid-pill.good {
  color: var(--good);
  background: color-mix(in srgb, var(--good), transparent 88%);
}

.grid-pill.bad {
  color: var(--bad);
  background: color-mix(in srgb, var(--bad), transparent 88%);
}

.grid-pill.warn {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn), transparent 86%);
}

.visual-actions {
  display: flex;
  gap: 0.35rem;
}

.compact-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0.26rem 0.55rem;
  border-radius: 8px;
  font-size: 0.72rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(7, 12, 11, 0.58);
  backdrop-filter: blur(6px);
}

.modal-card {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.modal-heading,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.modal-heading {
  margin-bottom: 1rem;
}

.modal-heading h3 {
  margin: 0 0 0.25rem;
}

.modal-card label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.modal-card textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem;
  color: var(--ink);
  background: var(--surface-grid);
}

.modal-actions {
  margin-top: 1rem;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    z-index: 20;
    height: auto;
    gap: 0.75rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 0.15rem;
  }

  .nav-link {
    min-width: 136px;
  }

  .sidebar form {
    margin-top: 0;
  }

  .dashboard {
    max-height: none;
    overflow: visible;
  }

  .dashboard-split {
    grid-template-columns: 1fr;
  }

  .data-shell.tall,
  .data-shell.compact {
    max-height: 58vh;
  }

  .manual-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .page-header,
  .panel-heading,
  .grid-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions,
  .action-row,
  .pager-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .pager-controls label {
    align-items: stretch;
    flex-direction: column;
  }

  .manual-form,
  .manual-form .wide-field {
    grid-template-columns: 1fr;
    grid-column: span 1;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  button,
  .link-button {
    width: 100%;
  }
}
