:root {
  color-scheme: light;
  --ink: #15191e;
  --ink-contrast: #ffffff;
  --muted: #69717a;
  --soft: #f3f5f6;
  --surface: #ffffff;
  --line: #dfe3e6;
  --line-strong: #c9ced2;
  --green: #147a4b;
  --green-soft: #e8f5ee;
  --red: #b43a3a;
  --red-soft: #faeceb;
  --amber: #a56911;
  --amber-soft: #fbf2df;
  --amber-chart: #d7a24b;
  --teal: #177a79;
  --red-ink: #7e2d2d;
  --shadow: 0 14px 40px rgba(21, 25, 30, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf1f3;
  --ink-contrast: #101418;
  --muted: #9aa5ae;
  --soft: #171c21;
  --surface: #101418;
  --line: #293139;
  --line-strong: #3a454e;
  --green: #49c98b;
  --green-soft: #142a22;
  --red: #f07878;
  --red-soft: #321c1f;
  --amber: #e3ad55;
  --amber-soft: #302719;
  --amber-chart: #d8a54e;
  --teal: #63c2be;
  --red-ink: #f2a0a0;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }
html { width: 100%; overflow-x: clip; }
html, body { margin: 0; min-height: 100%; background: var(--surface); color: var(--ink); }
body { width: 100%; overflow-x: hidden; overscroll-behavior-x: none; }
body { font-size: 14px; }
button, input { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  min-height: 72px;
  padding: 12px clamp(16px, 3vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.brand-block, .header-actions, .control-band, .sync-label, .section-heading, .legend {
  display: flex;
  align-items: center;
}
.brand-block { gap: 12px; min-width: 0; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: 5px;
  flex: 0 0 auto;
}
.brand-mark span { display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.brand-mark span:first-child { color: var(--ink-contrast); background: var(--ink); }
.brand-mark span:last-child { color: var(--ink); background: #f2c96d; }
.brand-mark.large { width: 52px; height: 52px; }
.brand-mark.large span { font-size: 17px; }
h1, h2, h3, p { margin: 0; letter-spacing: 0; }
h1 { font-size: 18px; line-height: 1.15; }
.wallet-label { margin-top: 4px; color: var(--muted); font: 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.header-actions { gap: 8px; }
.header-actions form { margin: 0; }
.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
}
.icon-button:hover { background: var(--soft); border-color: var(--line-strong); }
.icon-button svg { width: 17px; height: 17px; }
.live-state {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  white-space: nowrap;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #9299a0; }
.live-state.live { color: var(--green); border-color: #b9ddca; background: var(--green-soft); }
.live-state.live .status-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(20, 122, 75, .12); }
.live-state.stale { color: var(--amber); background: var(--amber-soft); border-color: #ead3a7; }
.live-state.stale .status-dot { background: var(--amber); }
.live-state.down { color: var(--red); background: var(--red-soft); border-color: #edc8c5; }
.live-state.down .status-dot { background: var(--red); }

.control-band {
  min-height: 54px;
  padding: 8px clamp(16px, 3vw, 40px);
  justify-content: space-between;
  gap: 16px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}
.segmented { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); }
.segmented button {
  min-height: 30px;
  padding: 0 12px;
  color: var(--muted);
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}
.segmented button:hover { color: var(--ink); background: var(--soft); }
.segmented button.active,
html[data-window="1h"] #windowControl button[data-window="1h"],
html[data-window="6h"] #windowControl button[data-window="6h"],
html[data-window="24h"] #windowControl button[data-window="24h"],
html[data-window="7d"] #windowControl button[data-window="7d"],
html[data-window="all"] #windowControl button[data-window="all"] {
  color: var(--ink-contrast);
  background: var(--ink);
}
.segmented.compact button { min-height: 28px; padding: 0 10px; }

#rangeLabel:empty::before { content: "Son 24 saat"; }
html[data-window="1h"] #rangeLabel:empty::before { content: "Son 1 saat"; }
html[data-window="6h"] #rangeLabel:empty::before { content: "Son 6 saat"; }
html[data-window="7d"] #rangeLabel:empty::before { content: "Son 7 gün"; }
html[data-window="all"] #rangeLabel:empty::before { content: "Tüm kayıtlar"; }
.sync-label { gap: 6px; color: var(--muted); font-size: 12px; }
.sync-label svg { width: 14px; height: 14px; }

.metric-band {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}
.metric { min-width: 0; padding: 22px clamp(14px, 2vw, 28px); border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric-label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 12px; }
.metric-value-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 9px; min-width: 0; }
.metric strong { display: block; overflow-wrap: anywhere; font-size: clamp(18px, 2vw, 26px); line-height: 1.05; font-variant-numeric: tabular-nums; }
.usd-value, .cell-usd, .lane-usd { color: var(--muted); font-size: 10px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-sub { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; }
.metric.primary strong.positive { color: var(--green); }
.metric.primary strong.negative, .danger-metric strong { color: var(--red); }

main { width: 100%; min-width: 0; }
.performance-section, .transactions-section { padding: 28px clamp(16px, 3vw, 40px); border-bottom: 1px solid var(--line); }
.section-heading { justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading h2 { font-size: 16px; }
.section-heading p { margin-top: 5px; color: var(--muted); font-size: 12px; }
.legend { gap: 16px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-line { width: 20px; height: 2px; background: var(--green); }
.legend-bar { width: 8px; height: 10px; background: #d7a24b; }
.performance-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: stretch; min-width: 0; }
.chart-wrap { position: relative; min-width: 0; min-height: 300px; width: 100%; overflow: hidden; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
#netChart {
  width: 100%;
  height: 300px;
  display: block;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.chart-cursor {
  position: absolute;
  z-index: 2;
  width: 9px;
  height: 9px;
  border: 2px solid var(--green);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 18%, transparent);
  pointer-events: none;
  transform: translate(-50%, -50%);
}
.chart-cursor.negative {
  border-color: var(--red);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--red) 18%, transparent);
}
.chart-tooltip {
  position: absolute;
  z-index: 3;
  min-width: 190px;
  padding: 10px 11px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  box-shadow: var(--shadow);
  pointer-events: none;
  font-size: 11px;
}
.chart-tooltip-time { margin-bottom: 7px; color: var(--muted); font-size: 10px; }
.chart-tooltip-row { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; padding: 2px 0; }
.chart-tooltip-row strong { font-variant-numeric: tabular-nums; }
.chart-tooltip-row small { margin-left: 5px; color: var(--muted); font-size: 9px; font-weight: 500; }
.chart-tooltip-counts { margin-top: 6px; padding-top: 6px; color: var(--muted); border-top: 1px solid var(--line); }
.lane-summary { padding-left: 28px; border-left: 1px solid var(--line); }
.lane-summary h3 { margin-bottom: 12px; font-size: 12px; color: var(--muted); font-weight: 600; }
.lane-summary .error-heading { margin-top: 24px; }
.lane-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.lane-row:first-child { padding-top: 0; }
.lane-row-head, .lane-row-values { display: flex; justify-content: space-between; gap: 12px; }
.lane-row-head { font-weight: 650; }
.lane-row-values { margin-top: 7px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.lane-net.positive { color: var(--green); }
.lane-net.negative { color: var(--red); }
.lane-net { text-align: right; }
.lane-usd { display: block; margin-top: 3px; }
.error-rows { display: flex; flex-wrap: wrap; gap: 7px; }
.error-pill { display: inline-flex; gap: 7px; padding: 5px 7px; border-radius: 4px; background: var(--red-soft); color: var(--red-ink); font-size: 12px; }
.muted-row { color: var(--muted); font-size: 12px; padding: 8px 0; }

.table-heading { margin-bottom: 14px; }
.table-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  contain: inline-size;
  border-top: 1px solid var(--line-strong);
}
table { width: 100%; min-width: 1040px; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--soft); font-size: 11px; font-weight: 650; }
td { font-size: 12px; font-variant-numeric: tabular-nums; }
.cell-usd { display: block; margin-top: 3px; }
th:nth-child(1) { width: 76px; }
th:nth-child(2) { width: 128px; }
th:nth-child(3) { width: 144px; }
th:nth-child(4) { width: 130px; }
th:nth-child(5), th:nth-child(6), th:nth-child(7), th:nth-child(8) { width: 100px; }
th:nth-child(9) { width: 110px; }
th:nth-child(10) { width: 42px; }
.num { text-align: right; }
.status-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 7px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.status-badge.success { color: var(--green); background: var(--green-soft); }
.status-badge.failed { color: var(--red); background: var(--red-soft); }
.tx-time span, .provider-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.net-cell.positive { color: var(--green); font-weight: 700; }
.net-cell.negative { color: var(--red); font-weight: 700; }
.signature-link { width: 28px; height: 28px; display: inline-grid; place-items: center; color: var(--muted); border-radius: 4px; }
.signature-link:hover { color: var(--ink); background: var(--soft); }
.signature-link svg { width: 15px; height: 15px; }
.empty-state { padding: 42px 0; color: var(--muted); text-align: center; border-bottom: 1px solid var(--line); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--soft); }
.login-shell { width: min(100%, 380px); padding: 34px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 7px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; }
.login-brand h1 { font-size: 20px; }
.login-form { display: grid; gap: 9px; }
.login-form label { color: var(--muted); font-size: 12px; }
.login-form input { width: 100%; height: 42px; padding: 0 11px; margin-bottom: 8px; color: var(--ink); border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); outline: none; }
.login-form input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(23, 122, 121, .12); }
.login-form button { height: 42px; margin-top: 7px; color: var(--ink-contrast); border: 0; border-radius: 5px; background: var(--ink); cursor: pointer; font-weight: 700; }
.login-form button:hover { opacity: .88; }
.login-error { padding: 9px 10px; color: var(--red); background: var(--red-soft); border-radius: 4px; font-size: 12px; }

@media (max-width: 1040px) {
  .metric-band { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric:nth-child(3) { border-right: 0; }
  .metric:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .performance-grid { grid-template-columns: 1fr; }
  .lane-summary { padding: 0; border-left: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
  .lane-summary .error-heading { margin-top: 0; }
}

@media (max-width: 680px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    min-height: 64px;
    padding: 10px 12px;
    gap: 10px;
  }
  .brand-block { gap: 10px; }
  .brand-mark { width: 38px; height: 38px; }
  h1 { font-size: 16px; }
  .wallet-label { max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-actions { gap: 6px; }
  .icon-button, .live-state { width: 34px; height: 34px; }
  .live-state { padding: 0; justify-content: center; }
  .live-state span:last-child { display: none; }
  .control-band { min-height: 52px; padding: 8px 12px; overflow: hidden; }
  #windowControl { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; }
  #windowControl button { min-width: 0; padding: 0 4px; }
  .sync-label { display: none; }
  .metric-band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: 18px 14px; border-bottom: 1px solid var(--line); }
  .metric:nth-child(odd) { border-right: 1px solid var(--line); }
  .metric:nth-child(even) { border-right: 0; }
  .metric:nth-last-child(-n+2) { border-bottom: 0; }
  .metric strong { font-size: 20px; }
  .performance-section, .transactions-section { padding: 20px 12px; }
  .section-heading { align-items: flex-start; margin-bottom: 15px; }
  .legend { display: none; }
  .performance-grid { gap: 24px; }
  .chart-wrap { min-height: 270px; }
  #netChart { height: 270px; }
  .chart-tooltip.touch-tooltip {
    top: 8px !important;
    left: 8px !important;
    right: 8px;
    width: auto;
    min-width: 0;
  }
  .chart-tooltip-row { gap: 10px; }
  .chart-tooltip-row strong { text-align: right; }
  .lane-summary { display: block; }
  .lane-summary .error-heading { margin-top: 24px; }
  .table-heading { flex-wrap: wrap; }
  .table-scroll { overflow: visible; contain: none; border-top: 0; }
  table { display: block; min-width: 0; table-layout: auto; }
  thead { display: none; }
  tbody { display: grid; gap: 8px; }
  tbody tr {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
  }
  tbody td {
    min-width: 0;
    padding: 0;
    border: 0;
    overflow-wrap: anywhere;
  }
  tbody td:nth-child(1) { grid-column: 1; }
  tbody td:nth-child(2) { grid-column: 2; padding-right: 28px; }
  tbody td:nth-child(9) { grid-column: 1 / -1; }
  tbody td:nth-child(10) { position: absolute; top: 9px; right: 8px; }
  tbody td:nth-child(n+3):nth-child(-n+9)::before {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 650;
  }
  tbody td:nth-child(3)::before { content: "Yön"; }
  tbody td:nth-child(4)::before { content: "Sender"; }
  tbody td:nth-child(5)::before { content: "Spend"; }
  tbody td:nth-child(6)::before { content: "Brüt"; }
  tbody td:nth-child(7)::before { content: "Fee + tip"; }
  tbody td:nth-child(8)::before { content: "Net"; }
  tbody td:nth-child(9)::before { content: "Hata"; }
  tbody .num { text-align: left; }
  tbody .signature-link { width: 30px; height: 30px; }
  .login-shell { padding: 26px 22px; }
}

@media (max-width: 360px) {
  .topbar { grid-template-columns: 1fr; }
  .header-actions { width: 100%; justify-content: space-between; }
  .wallet-label { max-width: 210px; }
  .metric strong { font-size: 18px; }
  .segmented button { font-size: 12px; }
}
