/* ─────────────────────────────────────────────────────────
   Sales dashboard — dark, sober
   One numeric size (--val) and one label size (--lbl) across
   the whole board. Everything is left aligned.
   ───────────────────────────────────────────────────────── */

:root {
  --bg:          #0A0A0A;
  --surface:     #131313;
  --surface-2:   #191919;
  --border:      #212121;
  --border-soft: #1B1B1B;
  --text:        #EDEDED;
  --text-2:      #A8A8A8;
  --muted:       #7A7A7A;
  --dim:         #565656;
  --accent:      #2DD4A7;
  --accent-soft: rgba(45, 212, 167, .13);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  --pad: 16px;
  --gap: 10px;

  --val: 20px;
  --lbl: 12.5px;
  --chart-h: 122px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  --ease: cubic-bezier(.22, 1, .36, 1);

  color-scheme: dark;
}

* { box-sizing: border-box; }

/* every rule below sets `display`, which would beat the UA sheet's
   [hidden] { display: none } — this keeps the attribute authoritative */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; background: var(--bg); }

body {
  font-family: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

p, ul { margin: 0; padding: 0; }
ul { list-style: none; }

button, input, select { font: inherit; color: inherit; font-family: inherit; }

button {
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ── App bar ───────────────────────────────────────────── */

.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: var(--safe-t);
  background: rgba(10, 10, 10, .82);
  backdrop-filter: saturate(170%) blur(18px);
  -webkit-backdrop-filter: saturate(170%) blur(18px);
  border-bottom: 1px solid var(--border-soft);
}

.appbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px var(--pad) 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color .16s;
}
.search:focus-within { border-color: #333; }

.search-ico { width: 15px; height: 15px; flex: none; color: var(--muted); }

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font-size: 13.5px;
  letter-spacing: -.006em;
  -webkit-appearance: none;
  appearance: none;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.search-clear {
  width: 18px;
  height: 18px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #2A2A2A;
  color: var(--text-2);
}
.search-clear svg { width: 10px; height: 10px; }

.controls {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
  height: 29px;
  padding: 0 24px 0 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: background .16s, border-color .16s;
}
.pill:hover { background: var(--surface-2); }

.pill select {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  outline: 0;
  background: none;
  padding: 0;
  font-size: var(--lbl);
  font-weight: 500;
  color: var(--text);
  letter-spacing: -.006em;
  cursor: pointer;
}

.pill-chev {
  position: absolute;
  right: 7px;
  width: 13px;
  height: 13px;
  color: var(--muted);
  pointer-events: none;
}

.stamp {
  margin-left: auto;
  flex: none;
  font-size: var(--lbl);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.icon-btn {
  width: 29px;
  height: 29px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--muted);
  transition: background .16s, color .16s, opacity .16s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn svg { width: 15px; height: 15px; }

.icon-btn.is-busy .refresh-ico { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Layout ────────────────────────────────────────────── */

main {
  max-width: 1180px;
  min-width: 0;
  margin: 0 auto;
  padding: var(--gap) var(--pad) calc(96px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ── Chart board ───────────────────────────────────────── */

.board {
  display: grid;
  grid-template-columns: 1fr;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .02);
  overflow: hidden;
}

.slot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  padding: 13px 14px 7px;
  border-top: 1px solid var(--border-soft);
}
.slot:first-child { border-top: 0; }

.slot-label {
  max-width: 100%;
  font-size: var(--lbl);
  color: var(--muted);
  letter-spacing: -.004em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-value {
  font-size: var(--val);
  font-weight: 600;
  letter-spacing: -.022em;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

/* ── Chart ─────────────────────────────────────────────── */

.chart {
  position: relative;
  align-self: stretch;
  height: var(--chart-h);
  min-width: 0;
  margin-top: 4px;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

/* absolute on purpose: keeps the SVG aspect ratio from
   feeding back into the column width on resize */
.chart svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart .grid-line { stroke: #1C1C1C; stroke-width: 1; shape-rendering: crispEdges; }
.chart .grid-text,
.chart .axis-text { fill: var(--dim); font-size: 10px; font-variant-numeric: tabular-nums; }

.chart .area { opacity: 0; transition: opacity .5s var(--ease); }
.chart .area.is-in { opacity: 1; }

.chart .line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart .cursor-line { stroke: #383838; stroke-width: 1; shape-rendering: crispEdges; }
.chart .cursor-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2.5; }
.chart .cursor-hit { fill: transparent; }

.tip {
  position: absolute;
  top: -4px;
  z-index: 5;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  background: #1E1E1E;
  border: 1px solid #2A2A2A;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .55);
  font-size: 11.5px;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 0);
  transition: opacity .12s;
}
.tip.is-on { opacity: 1; }
.tip b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip i { display: block; font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── Stat tiles ────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}

.stat {
  min-width: 0;
  padding: 11px 13px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .02);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.stat-label {
  max-width: 100%;
  font-size: var(--lbl);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  max-width: 100%;
  font-size: var(--val);
  font-weight: 600;
  letter-spacing: -.022em;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Orders ────────────────────────────────────────────── */

.panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .02);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px 12px;
}

.panel-title { font-size: 13.5px; font-weight: 500; letter-spacing: -.008em; }
.panel-note { font-size: 11.5px; color: var(--dim); font-variant-numeric: tabular-nums; }

.orders:not(:empty) { border-top: 1px solid var(--border-soft); }

.order {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.order:last-child { border-bottom: 0; }

.order-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
}
.order[data-status="pending"] .order-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.order[data-status="failed"] .order-dot  { background: #363636; }

.order-main { flex: 1; min-width: 0; }

.order-name {
  display: block;
  font-size: 13px;
  letter-spacing: -.006em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-meta {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* amounts stay right aligned so the decimal points line up
   down the column — the only right aligned text in the app */
.order-right { text-align: right; flex: none; }

.order-value {
  display: block;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

.order-status { display: block; font-size: 11.5px; color: var(--accent); }
.order[data-status="pending"] .order-status { color: var(--muted); }
.order[data-status="failed"] .order-status  { color: var(--dim); }
.order[data-status="failed"] .order-name,
.order[data-status="failed"] .order-value { color: var(--text-2); }

.empty {
  padding: 4px 14px 18px;
  font-size: 12.5px;
  color: var(--dim);
}

/* ── Tab bar ───────────────────────────────────────────── */

.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(10px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 45;
  width: min(calc(100% - 24px), 400px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 5px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(19, 19, 19, .86);
  backdrop-filter: saturate(160%) blur(22px);
  -webkit-backdrop-filter: saturate(160%) blur(22px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .6);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px 5px;
  border-radius: 13px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: -.004em;
  transition: color .16s, background .16s;
}
.tab svg { width: 18px; height: 18px; }
.tab.is-active { color: var(--text); }
.tab.is-active svg { color: var(--accent); }
.tab:hover { color: var(--text-2); }

/* ── Profile sheet ─────────────────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity .28s var(--ease);
}
.scrim.is-on { opacity: 1; }

.sheet {
  position: fixed;
  z-index: 55;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88vh;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -18px 60px rgba(0, 0, 0, .7);
  transform: translateY(101%);
  transition: transform .34s var(--ease);
}
.sheet.is-open { transform: translateY(0); }

.sheet-grip {
  width: 34px;
  height: 4px;
  margin: 8px auto 0;
  border-radius: 99px;
  background: #2C2C2C;
  flex: none;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex: none;
}

.profile { display: flex; align-items: center; gap: 11px; min-width: 0; }

.avatar {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
}

.profile-text { display: flex; flex-direction: column; min-width: 0; }
.profile-name { font-size: 14px; font-weight: 500; letter-spacing: -.01em; }
.profile-mail {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-body {
  padding: 16px 16px calc(22px + var(--safe-b));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 17px;
}

.group-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--dim);
  letter-spacing: .07em;
  text-transform: uppercase;
}

.divider { height: 1px; background: var(--border-soft); }

.field { display: flex; flex-direction: column; gap: 8px; }

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--text-2);
}

.field-value { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.field-hint { font-size: 11.5px; line-height: 1.45; color: var(--dim); }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  transition: border-color .16s;
}
.input-wrap:focus-within { border-color: #363636; }

.input-pre { font-size: 13px; color: var(--muted); flex: none; }

.input-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  -moz-appearance: textfield;
}
.input-wrap input::-webkit-outer-spin-button,
.input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.input-tag { font-size: 11px; color: var(--dim); flex: none; white-space: nowrap; }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
}

.segmented button {
  height: 34px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: -.008em;
  transition: background .16s, color .16s;
}
.segmented button:hover { color: var(--text-2); }
.segmented button.is-on { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: none;
  outline: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 99px; background: #242424; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px; margin-top: -7px;
  border-radius: 50%; background: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .6);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 99px; background: #242424; }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--text); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.008em;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
.btn:hover { background: #1F1F1F; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #06231B; font-weight: 600; }
.btn-primary:hover { background: #3FE0B4; border-color: #3FE0B4; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: transparent; color: var(--text); }

.sheet-actions { display: grid; gap: 6px; }

.sheet-foot { font-size: 11.5px; line-height: 1.5; color: var(--dim); text-align: center; }

/* ── Wide screens ──────────────────────────────────────── */

@media (min-width: 760px) {
  :root { --pad: 24px; --gap: 12px; --chart-h: 150px; --val: 21px; }

  .appbar-inner {
    flex-direction: row-reverse;
    align-items: center;
    gap: 14px;
    padding: 11px var(--pad);
  }
  .search { flex: 1; max-width: 340px; }
  .controls { flex: 1; }
  .stamp { margin-left: auto; }

  .board { grid-template-columns: repeat(3, 1fr); }
  .slot { border-top: 0; border-left: 1px solid var(--border-soft); padding: 15px 16px 9px; }
  .slot:first-child { border-left: 0; }

  .stats { grid-template-columns: repeat(4, 1fr); }

  .sheet {
    left: auto;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-height: none;
    border-radius: 0;
    border-left: 1px solid var(--border);
    border-top: 0;
    transform: translateX(101%);
  }
  .sheet.is-open { transform: translateX(0); }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: 18px; }
}

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