/* =====================================================================
   TRADE CAPITAL MARKET — DASHBOARD SHELL
   ---------------------------------------------------------------------
   Shared by the customer dashboard (dashboard.html) and the admin
   panel (admin.html). Loads after style.css and reuses its tokens.
   ===================================================================== */

/* ---------------------------------------------------------------------
   SHELL
   --------------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: 262px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
}

/* ---------------------------------------------------------------------
   SIDEBAR
   --------------------------------------------------------------------- */
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  padding: 22px 16px;
  background: var(--bg-3);
  border-right: 1px solid var(--border-soft);
  overflow-y: auto;
  z-index: 60;
}

.side__brand { padding-inline: 6px; margin-bottom: 4px; }

.side__section {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-2);
  padding: 0 10px;
  margin-bottom: 8px;
}

.side__nav { display: grid; gap: 2px; }
.side__link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid transparent;
  transition: all var(--t-fast);
  cursor: pointer;
  background: none;
  width: 100%;
  text-align: left;
}
.side__link .icon { width: 18px; height: 18px; color: var(--muted-2); transition: color var(--t-fast); }
.side__link:hover { background: rgba(255, 255, 255, 0.04); color: var(--white); }
.side__link:hover .icon { color: var(--green); }
.side__link.is-active {
  background: var(--tint);
  border-color: var(--border);
  color: var(--green);
}
.side__link.is-active .icon { color: var(--green); }
.side__link .pill {
  margin-left: auto;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: rgba(25, 245, 154, 0.14);
  color: var(--green);
}

.side__foot { margin-top: auto; display: grid; gap: 10px; }
.side__user {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-soft);
  background: var(--card);
}
.avatar {
  width: 34px; height: 34px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--green), var(--green-dim));
  color: #032015;
  font-weight: 800;
  font-size: 0.8rem;
}
.side__user-name { font-size: 0.82rem; font-weight: 700; line-height: 1.2; }
.side__user-mail { font-size: 0.7rem; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------------
   TOPBAR
   --------------------------------------------------------------------- */
.app__main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 14px 28px;
  background: rgba(5, 11, 18, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar__title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 800; }
.topbar__sub { font-size: 0.75rem; color: var(--muted-2); }
.topbar__spacer { margin-left: auto; }
.topbar__actions { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--t-fast);
}
.icon-btn:hover { color: var(--green); border-color: var(--border); }

.side-toggle { display: none; }

/* ---------------------------------------------------------------------
   CONTENT
   --------------------------------------------------------------------- */
.app__content { padding: 28px; display: grid; gap: var(--sp-5); align-content: start; }

.view { display: none; gap: var(--sp-5); }
.view.is-active { display: grid; }

.view__head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  align-items: flex-end;
  justify-content: space-between;
}
.view__head h2 { font-size: 1.3rem; }
.view__head p { font-size: 0.83rem; color: var(--muted-2); margin-top: 4px; }

/* welcome banner with a photo background */
.banner {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  min-height: 190px;
  display: flex;
  align-items: center;
  padding: var(--sp-6);
  box-shadow: var(--glow);
}
.banner img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.8) brightness(0.4);
  z-index: 0;
}
.banner::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(90deg, rgba(5, 11, 18, 0.94) 6%, rgba(5, 11, 18, 0.6) 60%, rgba(25, 245, 154, 0.12) 100%);
}
.banner__body { position: relative; z-index: 2; max-width: 56ch; }
.banner h2 { font-size: 1.45rem; margin-bottom: 8px; }
.banner p { font-size: 0.86rem; color: var(--muted); }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); }
.stat {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border-soft);
  background: linear-gradient(160deg, rgba(25, 245, 154, 0.05), transparent 52%), var(--card);
  transition: border-color var(--t), transform var(--t);
}
.stat:hover { border-color: var(--border); transform: translateY(-3px); }
.stat__icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--tint);
  color: var(--green);
  margin-bottom: 14px;
}
.stat__icon .icon { width: 19px; height: 19px; }
.stat__value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.stat__label { font-size: 0.78rem; color: var(--muted); }
.stat__delta { font-size: 0.72rem; margin-top: 6px; color: var(--muted-2); }
.stat__delta.up { color: var(--green); }

/* toolbar above tables */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: var(--sp-4);
}
.toolbar .input, .toolbar .select { width: auto; min-width: 180px; padding: 9px 13px; font-size: 0.82rem; }
.toolbar__spacer { margin-left: auto; }

/* row actions */
.row-actions { display: flex; gap: 6px; }
.row-actions .icon-btn { width: 30px; height: 30px; border-radius: var(--r-sm); }
.row-actions .icon-btn .icon { width: 15px; height: 15px; }

/* two-column split inside a view */
.split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: var(--sp-5); align-items: start; }
.split--even { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* timeline */
.timeline { display: grid; gap: 14px; }
.timeline li { display: grid; grid-template-columns: 22px 1fr; gap: 12px; font-size: 0.82rem; }
.timeline .dot {
  width: 10px; height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(25, 245, 154, 0.12);
}
.timeline time { display: block; font-size: 0.7rem; color: var(--muted-2); margin-top: 2px; }

/* credentials block */
.creds {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--tint);
}
.creds__row { display: flex; justify-content: space-between; gap: 12px; font-size: 0.83rem; }
.creds__row span:first-child { color: var(--muted); }
.creds__row .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* proof thumbnail */
.proof-thumb {
  max-width: 100%;
  max-height: 320px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-soft);
}

/* mini bar chart (admin sales) */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 160px;
  padding-top: 10px;
}
.chart__bar {
  flex: 1;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--green), rgba(25, 245, 154, 0.15));
  min-height: 4px;
  position: relative;
  transition: filter var(--t-fast);
}
.chart__bar:hover { filter: brightness(1.25); }
.chart__labels { display: flex; gap: 8px; margin-top: 8px; }
.chart__labels span { flex: 1; text-align: center; font-size: 0.66rem; color: var(--muted-2); }

/* product editor grid */
.prod-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }

/* backdrop for the mobile sidebar */
.side-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(3, 7, 12, 0.7);
  backdrop-filter: blur(4px);
  display: none;
}
.side-backdrop.is-open { display: block; }

/* ---------------------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .prod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed;
    inset: 0 auto 0 0;
    width: 272px;
    transform: translateX(-100%);
    transition: transform var(--t);
    box-shadow: var(--shadow-lg);
  }
  .side.is-open { transform: none; }
  .side-toggle { display: grid; }
  .app__content { padding: 20px 16px; }
  .topbar { padding: 12px 16px; }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .prod-grid { grid-template-columns: 1fr; }
  .view__head { align-items: flex-start; }
  .toolbar .input, .toolbar .select { min-width: 0; flex: 1 1 100%; }
}
