/* BIST Paper Trade — professional trading UI
   Type, materials & motion follow Apple's design language:
   translucent chrome, instant press feedback, size-specific tracking,
   critically-damped transitions, reduced-motion/transparency fallbacks. */

:root {
  color-scheme: light;
  --page:           #f4f4f2;
  --surface:        #fdfdfc;
  --chrome:         rgba(250, 250, 248, 0.72);
  --text-primary:   #0b0b0b;
  --text-secondary: #4e4d4a;
  --text-muted:     #8a8880;
  --grid:           #e4e3dc;
  --hairline:       rgba(11, 11, 11, 0.08);
  --baseline:       #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);
  --series-1:       #2a78d6;
  --series-1-soft:  rgba(42, 120, 214, 0.09);
  --good:           #0ca30c;
  --warning:        #fab219;
  --critical:       #d03b3b;
  --delta-up:       #067a06;
  --delta-down:     #cf3535;
  --good-wash:      rgba(12, 163, 12, 0.10);
  --critical-wash:  rgba(208, 59, 59, 0.10);
  --muted-wash:     rgba(137, 135, 129, 0.12);
  --shadow-card:    0 1px 2px rgba(11, 11, 11, 0.04);
  --shadow-pop:     0 16px 48px rgba(11, 11, 11, 0.22);
  /* Categorical palette — strategy colors (fixed order) */
  --cat-1: #2a78d6; --cat-2: #eb6834; --cat-3: #1baf7a; --cat-4: #eda100;
  --cat-5: #e87ba4; --cat-6: #008300; --cat-7: #4a3aa7; --cat-8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page:           #0a0a0b;
    --surface:        #151517;
    --chrome:         rgba(14, 14, 16, 0.72);
    --text-primary:   #f5f5f4;
    --text-secondary: #c3c2ba;
    --text-muted:     #8a8880;
    --grid:           #26262a;
    --hairline:       rgba(255, 255, 255, 0.07);
    --baseline:       #38383d;
    --border:         rgba(255, 255, 255, 0.09);
    --series-1:       #3987e5;
    --series-1-soft:  rgba(57, 135, 229, 0.12);
    --delta-up:       #2fbf4f;
    --delta-down:     #f0564f;
    --good-wash:      rgba(47, 191, 79, 0.13);
    --critical-wash:  rgba(240, 86, 79, 0.13);
    --muted-wash:     rgba(137, 135, 129, 0.16);
    --shadow-card:    0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-pop:     0 24px 64px rgba(0, 0, 0, 0.6);
    --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70; --cat-4: #c98500;
    --cat-5: #d55181; --cat-6: #00a300; --cat-7: #9085e9; --cat-8: #e66767;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: -apple-system, system-ui, "Segoe UI", sans-serif;
  font-size: 13.5px;
  line-height: 1.45;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 22px; }
main { padding-bottom: 56px; }

/* ── Chrome: translucent sticky header, content scrolls under ── */
.chrome {
  position: sticky; top: 0; z-index: 30;
  background: var(--chrome);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
}
.chrome::after { /* scroll-edge effect instead of a hard divider */
  content: ""; position: absolute; left: 0; right: 0; bottom: -14px; height: 14px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.07), transparent);
}
@media (prefers-reduced-transparency: reduce) {
  .chrome { background: var(--page); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  .chrome { background: var(--page); backdrop-filter: none; border-bottom: 1px solid var(--text-primary); }
}

header { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 0 8px; }
header h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -0.015em; }
header .sub { color: var(--text-muted); font-size: 12px; letter-spacing: 0; }
.spacer { flex: 1; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--hairline); border-radius: 999px;
  padding: 3px 11px; font-size: 11.5px; color: var(--text-secondary);
  background: var(--surface); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); flex: none; }
.pill.on .dot { background: var(--good); box-shadow: 0 0 6px var(--good); }
.pill.off .dot { background: var(--critical); }
.pill button { all: unset; cursor: pointer; color: var(--text-muted); }
.pill button:hover { color: var(--critical); }

/* ── Primary tabs ── */
nav.tabs { display: flex; gap: 2px; padding-bottom: 0; flex-wrap: wrap; }
nav.tabs button {
  appearance: none; background: none; border: none; cursor: pointer;
  font: inherit; font-size: 13px; color: var(--text-secondary);
  padding: 8px 13px 10px; border-bottom: 2px solid transparent; margin-bottom: -1px;
  letter-spacing: 0.01em;
  transition: color 120ms ease-out;
}
nav.tabs button:hover { color: var(--text-primary); }
nav.tabs button:active { transform: translateY(0.5px); }
nav.tabs button.active { color: var(--text-primary); font-weight: 600; border-bottom-color: var(--series-1); }

/* ── View transitions (critically damped, reduced-motion aware) ── */
@keyframes viewIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}
main > .view-enter { animation: viewIn 200ms cubic-bezier(0.2, 0.9, 0.3, 1); }

/* ── Cards & stat tiles ── */
.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 16px 18px; margin-bottom: 14px;
  box-shadow: var(--shadow-card);
}
.card h2, .microlabel {
  font-size: 11px; margin: 0 0 12px; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
}

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 10px; margin: 14px 0; }
.tile {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px;
  padding: 11px 14px 12px; box-shadow: var(--shadow-card);
}
.tile .label { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
.tile .value {
  font-size: 21px; font-weight: 650; margin-top: 3px;
  letter-spacing: -0.015em; font-variant-numeric: tabular-nums;
}
.tile .hint  { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .value.up   { color: var(--delta-up); }
.tile .value.down { color: var(--delta-down); }

/* ── Tables ── */
.tablewrap { overflow-x: auto; overscroll-behavior-x: contain; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; }
th {
  text-align: left; color: var(--text-muted); font-weight: 600;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em;
  padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap;
}
td {
  padding: 6.5px 10px; border-bottom: 1px solid var(--hairline); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }
tbody tr { transition: background 100ms ease-out; }
tbody tr:hover td { background: var(--series-1-soft); }
.sym { font-weight: 650; cursor: pointer; letter-spacing: 0.01em; }
.sym:hover { color: var(--series-1); text-decoration: underline; }
.up   { color: var(--delta-up); }
.down { color: var(--delta-down); }
.mut  { color: var(--text-muted); }

/* ── Badges (icon + label, never color alone) ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 6px; padding: 1.5px 7px; font-size: 11.5px; font-weight: 650;
  letter-spacing: 0.01em;
}
.badge.al    { background: var(--good-wash);     color: var(--delta-up); }
.badge.sat   { background: var(--critical-wash); color: var(--delta-down); }
.badge.bekle { background: var(--muted-wash);    color: var(--text-secondary); }
.badge.paused { background: var(--muted-wash);   color: var(--text-secondary); }
.badge.active { background: var(--good-wash);    color: var(--delta-up); }

.dotc { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* ── Charts ── */
.chartbox { position: relative; }
.chartbox svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 2px 2px 10px; font-size: 12px; color: var(--text-secondary); }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 9px; height: 9px; border-radius: 3px; }
.tooltip {
  position: absolute; pointer-events: none; display: none;
  background: var(--chrome);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border: 1px solid var(--hairline); border-radius: 9px;
  padding: 7px 10px; font-size: 12px; box-shadow: var(--shadow-pop);
  white-space: nowrap; z-index: 5;
}
@media (prefers-reduced-transparency: reduce) {
  .tooltip { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
.tooltip .t-ts { color: var(--text-muted); font-size: 11px; margin-bottom: 3px; }
.tooltip .t-row { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }

/* ── Strategy cards ── */
.stratgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.strat {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px;
  padding: 14px 16px; border-top: 3px solid var(--baseline);
  box-shadow: var(--shadow-card);
  transition: transform 140ms cubic-bezier(0.2, 0.9, 0.3, 1), box-shadow 140ms ease-out;
}
.strat:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10); }
.strat .head { display: flex; align-items: center; gap: 8px; }
.strat .head b { font-size: 14.5px; letter-spacing: -0.01em; }
.strat .params { color: var(--text-muted); font-size: 11.5px; margin: 6px 0 10px; line-height: 1.65; }
.strat .kpis { display: flex; gap: 16px; align-items: baseline; margin-bottom: 6px; }
.strat .kpis .big { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.strat .actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.spark { width: 100%; height: 42px; margin: 4px 0; }

/* ── Detail view header ── */
.detail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 16px 0 4px; }
.detail-head h1 { font-size: 21px; margin: 0; font-weight: 700; letter-spacing: -0.02em; display: flex; align-items: center; gap: 9px; }
.backlink {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
  color: var(--series-1); font-size: 13px; font-weight: 550;
  background: none; border: none; font-family: inherit; padding: 4px 6px; border-radius: 7px;
}
.backlink:hover { background: var(--series-1-soft); }

/* ── Segmented control (sub-tabs) ── */
.seg {
  display: inline-flex; gap: 2px; background: var(--muted-wash);
  border-radius: 9px; padding: 2.5px; margin: 10px 0 14px;
}
.seg button {
  appearance: none; border: none; cursor: pointer; font: inherit;
  font-size: 12.5px; font-weight: 550; color: var(--text-secondary);
  padding: 5px 14px; border-radius: 7px; background: transparent;
  transition: color 120ms ease-out, background 120ms ease-out, transform 100ms ease-out;
}
.seg button:active { transform: scale(0.97); }
.seg button.active {
  background: var(--surface); color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* ── Forms ── */
label.field { display: block; margin-bottom: 12px; }
label.field span.name { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 550; }
label.field .desc { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
input[type="number"], input[type="text"], input[type="password"], input[type="search"], select {
  width: 100%; max-width: 280px; height: 33px;
  background: var(--page); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0 10px; font: inherit; font-size: 13px;
  transition: border-color 120ms ease-out;
}
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 28px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23898781' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
input:focus, select:focus { outline: 2px solid var(--series-1); outline-offset: 0; border-color: transparent; }
.check { display: inline-flex; align-items: center; gap: 7px; margin: 4px 16px 8px 0; font-size: 13px; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--series-1); }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 22px; }

/* ── Buttons: feedback on press, instantly ── */
button.btn {
  appearance: none; font: inherit; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text-primary);
  padding: 6px 15px; font-weight: 600; font-size: 13px;
  transition: transform 90ms ease-out, border-color 120ms ease-out, color 120ms ease-out, opacity 120ms ease-out;
}
button.btn:hover { border-color: var(--series-1); color: var(--series-1); }
button.btn:active { transform: scale(0.96); }
button.btn.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
button.btn.primary:hover { opacity: 0.88; color: #fff; }
button.btn.danger:hover { border-color: var(--critical); color: var(--critical); }
button.btn.small { padding: 3px 10px; font-size: 12px; font-weight: 550; }
button.btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters input[type="search"] { max-width: 190px; }
.filters select { max-width: 160px; }

.toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 60;
  background: var(--chrome);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--hairline); border-left: 3px solid var(--series-1);
  border-radius: 10px; padding: 10px 16px; box-shadow: var(--shadow-pop);
  display: none; max-width: 340px; font-size: 13px;
}
.toast.err { border-left-color: var(--critical); }
@media (prefers-reduced-transparency: reduce) {
  .toast { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

details.reasons summary { cursor: pointer; color: var(--series-1); font-size: 12px; list-style: none; }
details.reasons summary::-webkit-details-marker { display: none; }
details.reasons ul { margin: 6px 0 2px; padding-left: 16px; color: var(--text-secondary); font-size: 12px; white-space: normal; }
.empty { color: var(--text-muted); padding: 20px 4px; text-align: center; font-size: 13px; }

/* ── Progress ── */
.progress { height: 5px; border-radius: 3px; background: var(--muted-wash); overflow: hidden; flex: 1; min-width: 120px; }
.progress > div { height: 100%; background: var(--series-1); border-radius: 3px; transition: width 400ms cubic-bezier(0.2, 0.9, 0.3, 1); }

/* ── Modal: materializes (blur + scale together), exits same path ── */
.overlay {
  position: fixed; inset: 0; z-index: 40; display: none;
  background: rgba(0, 0, 0, 0.42); align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 44px 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 14px;
  padding: 20px 22px; width: 100%; max-width: 800px; box-shadow: var(--shadow-pop);
}
@keyframes materialize {
  from { opacity: 0; transform: scale(0.975) translateY(6px); filter: blur(3px); }
  to   { opacity: 1; transform: none; filter: none; }
}
.overlay.open .modal { animation: materialize 220ms cubic-bezier(0.2, 0.9, 0.3, 1); }
.modal h3 { margin: 0 0 14px; font-size: 16px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Login ── */
#login-screen {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: var(--page); align-items: center; justify-content: center;
}
#login-screen.open { display: flex; }
#login-screen .box {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 14px;
  padding: 32px 36px; width: 330px; text-align: center; box-shadow: var(--shadow-pop);
}
#login-screen h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -0.015em; }
#login-screen p { color: var(--text-muted); font-size: 12.5px; margin: 0 0 16px; }
#login-screen input { max-width: none; margin-bottom: 12px; text-align: center; }
#login-screen .err { color: var(--critical); font-size: 12.5px; margin-top: 10px; min-height: 16px; }

/* ── Reduced motion: cross-fades, no movement ── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  main > .view-enter { animation: none; }
  .overlay.open .modal { animation: none; }
  .strat:hover { transform: none; }
  button.btn:active, .seg button:active { transform: none; }
}
