/* ==========================================================================
   SAMPLE — application design
   ==========================================================================
   A dense product interface. The marketing sample next door is light, airy and
   set in a serif; this one is dark, tight and set in a UI sans, because the two
   jobs are not the same job. Showing one look only proves you can build one.

   Scoped under .app so nothing leaks into the portfolio around it.
   ========================================================================== */

.app {
  --bg:      #0e1017;
  --bg-2:    #141824;
  --panel:   #171c29;
  --panel-2: #1d2331;
  --line:    #252c3d;
  --line-2:  #333c52;
  --txt:     #e7eaf3;
  --txt-2:   #9aa3ba;
  --txt-3:   #858ea6;   /* 5.2:1 on the panel; #6b7488 was 3.6 and failed */

  --violet:  #8b7cf6;
  --violet-2:#a897ff;
  --cyan:    #38bdf8;
  --green:   #34d399;
  --amber:   #fbbf24;
  --rose:    #fb7185;

  --app-sans: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --app-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  --r: 10px;
  --sidebar: 232px;

  background: var(--bg);
  color: var(--txt);
  font-family: var(--app-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
.app *, .app *::before, .app *::after { box-sizing: border-box; }
.app a { color: inherit; text-decoration: none; }
.app svg { display: block; }
.app ::selection { background: var(--violet); color: #0e1017; }

/* -------------------------------------------------------------- the label -- */

.app-flag {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1rem;
  padding: .55rem 1.25rem;
  background: #05070c;
  color: #c7cde0;
  font-family: var(--app-mono);
  font-size: .72rem;
  border-bottom: 1px solid var(--line);
}
.app-flag b { color: var(--violet-2); font-weight: 500; }
.app-flag a { margin-left: auto; color: #fff; border-bottom: 1px solid rgba(255,255,255,.3); white-space: nowrap; }

/* ---------------------------------------------------------------- shell --- */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: calc(100vh - 2.4rem);
}
@media (max-width: 60rem) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .app-side { display: none; }
}

/* -------------------------------------------------------------- sidebar --- */

.app-side {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 1rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.app-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .5rem 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.app-brand span { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(140deg, var(--violet), var(--cyan)); display: block; flex: none; }

.app-side h5 {
  font-family: var(--app-mono);
  font-size: .62rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--txt-3);
  margin: 1.25rem .6rem .5rem;
  font-weight: 400;
}
.app-nav {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .52rem .6rem;
  border-radius: 8px;
  color: var(--txt-2);
  font-size: .875rem;
  cursor: pointer;
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: background .16s, color .16s;
}
.app-nav:hover { background: var(--panel); color: var(--txt); }
.app-nav[aria-current="page"] { background: var(--panel-2); color: var(--txt); }
.app-nav[aria-current="page"] svg { color: var(--violet-2); }
.app-nav svg { width: 16px; height: 16px; flex: none; }
.app-nav .badge {
  margin-left: auto;
  font-family: var(--app-mono);
  font-size: .64rem;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 99px;
  padding: .05rem .4rem;
  color: var(--txt-2);
}

.app-side__foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: .75rem; }
.app-user { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; }
.app-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--violet), var(--cyan));
  color: #0e1017; font-size: .72rem; font-weight: 700;
}
.app-user div { min-width: 0; }
.app-user strong { display: block; font-size: .8rem; font-weight: 500; }
.app-user small { color: var(--txt-3); font-size: .7rem; }

/* ---------------------------------------------------------------- main --- */

.app-main { min-width: 0; display: flex; flex-direction: column; }

.app-top {
  display: flex;
  flex-wrap: wrap;          /* or Refresh is clipped by the panel at 320px */
  align-items: center;
  gap: .75rem;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.app-top h1 { font-size: 1.05rem; font-weight: 600; margin: 0; letter-spacing: -0.015em; }
.app-top .sp { margin-left: auto; }

.app-search {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .4rem .65rem;
  min-width: 0;
  flex: 0 1 22rem;
  transition: border-color .16s;
}
.app-search:focus-within { border-color: var(--violet); }
.app-search svg { width: 14px; height: 14px; color: var(--txt-3); flex: none; }
.app-search input {
  font: inherit;
  font-size: .85rem;
  background: none;
  border: 0;
  outline: none;
  color: var(--txt);
  width: 100%;
  min-width: 0;
}
.app-search input::placeholder { color: var(--txt-3); }
.app-search kbd {
  font-family: var(--app-mono);
  font-size: .64rem;
  color: var(--txt-3);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: .05rem .3rem;
  flex: none;
}

.app-btn {
  font: inherit;
  font-size: .82rem;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .8rem;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--txt);
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s, border-color .16s, transform .12s;
}
.app-btn:hover { background: var(--panel-2); border-color: var(--txt-3); }
.app-btn:active { transform: scale(.97); }
.app-btn svg { width: 14px; height: 14px; }
.app-btn--primary { background: var(--violet); border-color: var(--violet); color: #0d0f18; font-weight: 600; }
.app-btn--primary:hover { background: var(--violet-2); border-color: var(--violet-2); }
.app-btn[disabled] { opacity: .4; cursor: not-allowed; }

.app-body { padding: 1.25rem; display: grid; gap: 1.25rem; }

/* ---------------------------------------------------------------- tiles --- */

.app-tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }
.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1rem 1.1rem;
  display: grid;
  gap: .4rem;
}
.tile__label { font-size: .74rem; color: var(--txt-3); letter-spacing: .02em; }
.tile__row { display: flex; align-items: flex-end; gap: .6rem; }
.tile__n { font-size: 1.65rem; font-weight: 600; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.tile__d { font-size: .74rem; font-weight: 500; padding-bottom: .15rem; }
.tile__d--up { color: var(--green); }
.tile__d--down { color: var(--rose); }
.tile svg { width: 100%; height: 34px; margin-top: .2rem; }

/* --------------------------------------------------------------- panels --- */

.app-cols { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 68rem) { .app-cols { grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr); } }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  min-width: 0;
}
.panel__head {
  display: flex;
  flex-wrap: wrap;          /* or the controls run off the panel at 320px */
  align-items: center;
  gap: .75rem;
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.panel__head h2 { font-size: .92rem; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.panel__head .sp { margin-left: auto; }
.panel__body { padding: 1.1rem; }

.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button {
  font: inherit; font-size: .76rem;
  border: 0; background: none; color: var(--txt-3);
  padding: .28rem .6rem; border-radius: 6px; cursor: pointer;
  transition: background .16s, color .16s;
}
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--txt); }

/* The area chart. Drawn from the same array the table uses. */
.chart { position: relative; }
.chart svg { width: 100%; height: 260px; overflow: visible; }
.chart__tip {
  position: absolute;
  pointer-events: none;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: .5rem .65rem;
  font-size: .74rem;
  white-space: nowrap;
  transform: translate(-50%, -120%);
  opacity: 0;
  transition: opacity .14s;
  box-shadow: 0 12px 28px -12px rgba(0,0,0,.8);
  z-index: 5;
}
.chart__tip.is-on { opacity: 1; }
.chart__tip b { display: block; font-size: .86rem; font-variant-numeric: tabular-nums; }
.chart__tip span { color: var(--txt-3); }

.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .75rem; color: var(--txt-2); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: .35rem; }

/* Breakdown bars. */
.bars { display: grid; gap: .85rem; }
.bar__top { display: flex; justify-content: space-between; font-size: .8rem; margin-bottom: .3rem; }
.bar__top span { color: var(--txt-2); }
.bar__top b { font-weight: 500; font-variant-numeric: tabular-nums; }
.bar__track { height: 7px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.bar__fill { height: 100%; border-radius: 99px; transition: width .7s cubic-bezier(.16,1,.3,1); }

/* ---------------------------------------------------------------- table --- */

/* overflow-x alone is not enough: a grid or flex item still sizes to its
   content unless it is explicitly allowed to shrink below it. Without the
   min-width the 704px table widened the whole page on a narrow phone. */
.app-table-wrap { overflow-x: auto; min-width: 0; }
table.app-table { width: 100%; border-collapse: collapse; font-size: .84rem; min-width: 44rem; }
.app-table th, .app-table td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.app-table thead th {
  font-size: .7rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--txt-3);
  font-weight: 500;
  background: var(--bg-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.app-table th[data-sort] { cursor: pointer; user-select: none; }
.app-table th[data-sort]:hover { color: var(--txt); }
.app-table th[data-sort]::after {
  content: "";
  display: inline-block;
  width: 0; height: 0;
  margin-left: .35rem;
  border: 4px solid transparent;
  vertical-align: middle;
  opacity: .35;
  border-top-color: currentColor;
}
.app-table th[aria-sort="ascending"]::after { border-top-color: transparent; border-bottom-color: var(--violet-2); opacity: 1; margin-bottom: 4px; }
.app-table th[aria-sort="descending"]::after { border-top-color: var(--violet-2); opacity: 1; }

.app-table tbody tr { cursor: pointer; transition: background .12s; }
.app-table tbody tr:hover { background: var(--panel-2); }
.app-table tbody tr.is-sel { background: color-mix(in srgb, var(--violet) 14%, transparent); }
.app-table td.num { font-variant-numeric: tabular-nums; text-align: right; }
.app-table .who { display: flex; align-items: center; gap: .55rem; }
.app-table .who span {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: .66rem; font-weight: 700; color: #0e1017;
  flex: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .7rem;
  border-radius: 99px;
  padding: .15rem .55rem;
  border: 1px solid;
}
.chip i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.chip[data-s="paid"]     { color: var(--green);  border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.chip[data-s="pending"]  { color: var(--amber);  border-color: color-mix(in srgb, var(--amber) 40%, transparent); }
.chip[data-s="refunded"] { color: var(--rose);   border-color: color-mix(in srgb, var(--rose) 40%, transparent); }
.chip[data-s="shipped"]  { color: var(--cyan);   border-color: color-mix(in srgb, var(--cyan) 40%, transparent); }

.app-pager {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem 1.1rem;
  border-top: 1px solid var(--line);
  font-size: .78rem;
  color: var(--txt-3);
}
.app-pager .sp { margin-left: auto; }

.app-empty { padding: 3rem 1rem; text-align: center; color: var(--txt-3); font-size: .86rem; }

/* --------------------------------------------------------------- drawer --- */

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(26rem, 100%);
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  z-index: 60;
  transform: translateX(100%);
  transition: transform .34s cubic-bezier(.16,1,.3,1);
  display: flex;
  flex-direction: column;
  box-shadow: -30px 0 60px -30px rgba(0,0,0,.8);
}
.drawer.is-on { transform: none; }
.drawer__head { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); }
.drawer__head h2 { font-size: .95rem; margin: 0; font-weight: 600; }
.drawer__head .sp { margin-left: auto; }
.drawer__body { padding: 1.1rem; overflow-y: auto; display: grid; gap: 1.1rem; }
.drawer__foot { margin-top: auto; padding: 1rem 1.1rem; border-top: 1px solid var(--line); display: flex; gap: .5rem; }

.kvs { display: grid; gap: .55rem; font-size: .82rem; }
.kvs div { display: flex; gap: 1rem; }
.kvs dt { color: var(--txt-3); width: 8rem; flex: none; }
.kvs dd { margin: 0; font-variant-numeric: tabular-nums; }

.timeline { display: grid; gap: 0; position: relative; padding-left: 1.1rem; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--line-2); }
.timeline div { position: relative; padding: .35rem 0; font-size: .8rem; }
.timeline div::before {
  content: ""; position: absolute; left: -1.1rem; top: .7rem;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg-2); border: 2px solid var(--line-2);
}
.timeline div:first-child::before { border-color: var(--violet); }
.timeline small { display: block; color: var(--txt-3); font-size: .72rem; }

.scrim {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(5, 7, 12, .6);
  opacity: 0; visibility: hidden;
  transition: opacity .28s, visibility .28s;
}
.scrim.is-on { opacity: 1; visibility: visible; }

/* --------------------------------------------------------------- toasts --- */

.toasts { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 70; display: grid; gap: .5rem; justify-items: end; }
.toast {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--violet);
  border-radius: 9px;
  padding: .6rem .9rem;
  font-size: .82rem;
  box-shadow: 0 16px 40px -20px rgba(0,0,0,.9);
  animation: toast-in .3s cubic-bezier(.16,1,.3,1);
}
.toast[data-tone="ok"] { border-left-color: var(--green); }
.toast[data-tone="warn"] { border-left-color: var(--amber); }
.toast.is-out { animation: toast-out .25s forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(20px); } }

@media (prefers-reduced-motion: reduce) {
  .app *, .app *::before, .app *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* The site-wide focus ring is the portfolio's teal. Inside a sample that
   reads as a leak from the host page, so each one states its own. */
.app :focus-visible { outline-color: var(--violet); }
