/* ===== Page container ===== */
.page { padding: 28px 24px; max-width: 100%; min-height: 100vh; }

/* ===== Mobile single-column (default) ===== */
.page--mobile { max-width: 540px; margin: 0 auto; width: 100%; }

/* ===== PC Layout: sidebar + main ===== */
.layout-pc { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 24px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 2px 12px;
}
.sidebar__brand-mark {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
}
.sidebar__brand-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}
.sidebar__brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.sidebar__brand-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1.4px;
  text-transform: uppercase;
}
.sidebar__brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.1;
}
.sidebar__brand-subtitle {
  font-size: 0.6875rem;
  color: var(--muted);
  letter-spacing: 0.3px;
}
.sidebar__nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar__link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-input);
  font-size: 0.875rem; font-weight: 500; color: var(--ink);
  text-decoration: none; transition: background 0.15s;
}
.sidebar__link:hover { background: var(--panel-alt); text-decoration: none; }
.sidebar__link--active { background: var(--accent); color: #fff; }
.sidebar__link--active:hover { background: var(--accent-hover); }
.sidebar__link svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar__divider {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 14px 14px 4px;
  margin-top: 4px;
}
.sidebar__user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px 10px;
  border-top: 1px solid var(--line);
  margin-bottom: 4px;
}
.sidebar__user-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.sidebar__user-link:hover {
  text-decoration: none;
  color: inherit;
}
.sidebar__footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
}
.sidebar__user-name { font-size: 0.8125rem; font-weight: 500; }
.sidebar__user-role { font-size: 0.6875rem; color: var(--muted); }

.main-content {
  flex: 1;
  padding: 24px 28px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-x: hidden;
}

/* ===== Page Header ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.page-header__info { display: flex; flex-direction: column; gap: 4px; }
.page-header__title { font-size: 1.625rem; font-weight: 600; }
.page-header__desc { font-size: 0.8125rem; color: var(--muted); }
.page-header__actions { display: flex; gap: 8px; align-items: center; }

.dashboard-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ===== Content rows ===== */
.content-row { display: flex; gap: 16px; }
.content-row--stretch { align-items: stretch; }
.content-main { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.content-side { width: 360px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; }

/* ===== Stat row ===== */
.stat-row { display: flex; gap: 16px; }
.stat-row > * { flex: 1; }

/* ===== Stack (vertical gap) ===== */
.stack { display: flex; flex-direction: column; }
.stack--sm > * + * { margin-top: 8px; }
.stack--md > * + * { margin-top: 12px; }
.stack--page > * + * { margin-top: 16px; }
.stack--lg > * + * { margin-top: 18px; }
.stack--xl > * + * { margin-top: 24px; }

/* ===== Flex helpers ===== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.gap-lg { gap: 16px; }

/* ===== User PC layout (regular users on desktop) ===== */
.layout-user {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.user-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 24px;
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}
.user-nav__brand {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--accent);
  margin-right: 16px;
  letter-spacing: 0.5px;
}
.user-nav__links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}
.user-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-input);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  transition: background 0.15s;
}
.user-nav__link:hover { background: var(--panel-alt); text-decoration: none; }
.user-nav__link--active { background: var(--accent); color: #fff; }
.user-nav__link--active:hover { background: var(--accent-hover); }
.user-nav__link svg { width: 16px; height: 16px; }
.user-nav__right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.user-nav__username {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 500;
}
.user-body {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 32px;
}

/* ===== Responsive breakpoint ===== */
@media (max-width: 768px) {
  .layout-pc {
    flex-direction: column;
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
  }
  .page {
    padding: 18px 14px 20px;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 60;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 9px 12px;
    gap: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar__brand { display: none; }
  .sidebar__nav {
    flex: 1;
    min-width: max-content;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
  }
  .sidebar__link {
    white-space: nowrap;
    padding: 7px 11px;
    font-size: 0.765rem;
    gap: 6px;
    min-height: 38px;
  }
  .sidebar__divider { display: none; }
  .sidebar__user-info { display: none; }
  .sidebar__footer {
    margin-top: 0;
    display: none;
  }
  .main-content { padding: 12px; }
  .content-row { flex-direction: column; gap: 14px; }
  .content-main,
  .content-side {
    width: 100%;
    gap: 14px;
  }
  .stat-row { flex-direction: column; }
  .page-header {
    flex-direction: column;
    gap: 10px;
  }
  .page-header__info {
    gap: 5px;
  }
  .page-header__actions {
    width: 100%;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
  }
  .page-header__actions > .btn,
  .page-header__actions > a.btn {
    flex: 1 1 calc(50% - 5px);
    min-width: 0;
  }
  .page-header__actions > .tag {
    align-self: flex-start;
  }
  .user-nav { display: none; }
  .user-body { padding: 0; }
  .dashboard-shell {
    gap: 12px;
  }

  .stat-row--dashboard {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .stat-row--dashboard > * {
    min-width: 0;
  }
  .stat-row--dashboard > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
  .stat-row--dashboard-primary .stat-card--metric-stock {
    order: -1;
    grid-column: 1 / -1;
  }
}

/* ===== Asset grid (PC layout for regular users) ===== */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
@media (max-width: 768px) {
  .asset-grid { grid-template-columns: 1fr; gap: 12px; }
}

.mobile-top-shell {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.mobile-top-shell__brand {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.8px;
  white-space: nowrap;
}
.mobile-top-shell__menu {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.mobile-top-shell__menu::-webkit-scrollbar { display: none; }
.mobile-top-shell__scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
  padding-right: 2px;
}
.mobile-top-shell__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 11px;
  min-height: 38px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 0.765rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  -webkit-text-fill-color: var(--ink);
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.mobile-top-shell__link:visited {
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
}
.mobile-top-shell__link:hover {
  background: var(--panel-alt);
  text-decoration: none;
}
.mobile-top-shell__link:active {
  background: var(--accent-soft);
  border-color: var(--line-strong);
  text-decoration: none;
}
.mobile-top-shell__link--active,
.mobile-top-shell__link--active:visited,
.mobile-top-shell__link[aria-current="page"] {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff;
  box-shadow: 0 6px 16px rgba(201, 109, 59, 0.18);
  text-decoration: none;
}
.mobile-top-shell__link svg {
  width: 14px;
  height: 14px;
  color: currentColor;
  stroke: currentColor;
}
.mobile-top-shell__link--active svg,
.mobile-top-shell__link[aria-current="page"] svg {
  color: #fff;
  stroke: currentColor;
}
