:root {
  --apps-black: #050505;
  --apps-panel: rgba(8, 8, 8, .94);
  --apps-panel-soft: rgba(255, 255, 255, .025);
  --apps-line: rgba(255, 255, 255, .08);
  --apps-text: rgba(255, 255, 255, .86);
  --apps-muted: rgba(255, 255, 255, .48);
  --apps-dim: rgba(255, 255, 255, .32);
  --apps-orange: #f97316;
  --apps-gold: #c88728;
  --apps-ui: var(--font-primary, 'Inter', sans-serif);
  --apps-serif: var(--font-heading, 'Playfair Display', serif);
  --apps-mono: 'DM Mono', monospace;
}

body.apps-page {
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  background: var(--apps-black);
  color: var(--apps-text);
  font-family: var(--apps-ui);
  overflow: hidden;
}

body.apps-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .7), transparent 66%);
}

.apps-sidebar,
.apps-main {
  position: relative;
  z-index: 1;
}

.apps-sidebar {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  border-right: 1px solid var(--apps-line);
  background: #050505;
}

.apps-brand {
  color: #fff;
  font-weight: 800;
  letter-spacing: .02em;
  text-decoration: none;
}

.apps-brand span {
  color: var(--apps-orange);
}

.apps-user {
  margin-top: 1.2rem;
  padding: .85rem 0;
  border-top: 1px solid rgba(255, 255, 255, .055);
  border-bottom: 1px solid rgba(255, 255, 255, .055);
}

.apps-user span,
.apps-kicker,
.side-stat span,
.workspace-card span,
.apps-sidebar-foot {
  color: var(--apps-orange);
  font-family: var(--apps-mono);
  font-size: .58rem;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.apps-user strong {
  display: block;
  margin-top: .4rem;
  color: rgba(255, 255, 255, .58);
  font-family: var(--apps-mono);
  font-size: .68rem;
  font-weight: 400;
  word-break: break-word;
}

.side-dashboard {
  display: grid;
  gap: 0;
  margin-top: .35rem;
}

.side-stat {
  padding: .85rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, .055);
}

.side-stat strong {
  display: block;
  margin-top: .35rem;
  color: rgba(255, 255, 255, .82);
  font-family: var(--apps-ui);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
}

.side-stat p {
  margin: .45rem 0 0;
  color: rgba(255, 255, 255, .38);
  font-size: .72rem;
  line-height: 1.45;
}

.plan-card.pro strong {
  color: var(--apps-orange);
}

.apps-sidebar-foot {
  display: flex;
  gap: 1rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--apps-line);
}

.apps-sidebar-foot a {
  color: var(--apps-muted);
  text-decoration: none;
}

.apps-sidebar-foot a:hover {
  color: #fff;
}

.apps-main {
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 1.35rem clamp(1.2rem, 3vw, 2.5rem) 2.5rem;
}

.apps-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--apps-line);
}

.apps-topbar h1 {
  margin: .25rem 0 0;
  color: #fff;
  font-family: var(--apps-serif);
  font-size: clamp(1.9rem, 4vw, 3.5rem);
  line-height: .98;
}

.apps-top-actions {
  display: flex;
  align-items: center;
  gap: .65rem;
}

.apps-top-actions a,
.apps-top-actions button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
  border: 1px solid var(--apps-line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .035);
  color: rgba(255, 255, 255, .72);
  cursor: pointer;
  font-family: var(--apps-ui);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-decoration: none;
  text-transform: uppercase;
}

.apps-top-actions a:hover,
.apps-top-actions button:hover {
  border-color: rgba(249, 115, 22, .35);
  color: #fff;
}

.ibnr-tabs {
  display: inline-flex;
  align-self: flex-start;
  gap: .35rem;
  margin-top: 1.2rem;
  padding: .25rem;
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 999px;
  background: rgba(8, 8, 8, .92);
}

.ibnr-tab {
  min-width: 112px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, .48);
  cursor: pointer;
  font-family: var(--apps-mono);
  font-size: .62rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  transition: background .18s ease, color .18s ease;
}

.ibnr-tab:hover {
  color: #fff;
}

.ibnr-tab.on {
  background: var(--gradient-1);
  color: #fff;
}

.apps-content {
  margin-top: 1.2rem;
}

.apps-panel {
  display: none;
}

.apps-panel.active {
  display: block;
}

.portfolio-panel,
.portfolio-detail {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--apps-line);
  border-radius: 18px;
  background: rgba(8, 8, 8, .94);
}

.portfolio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.portfolio-head h2 {
  margin: .25rem 0 0;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
}

.portfolio-head button {
  min-height: 34px;
  padding: 0 .8rem;
  border: 1px solid var(--apps-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .035);
  color: rgba(255, 255, 255, .66);
  cursor: pointer;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.portfolio-empty {
  color: var(--apps-orange);
  font-family: var(--apps-mono);
  font-size: .58rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.portfolio-list {
  margin-top: .9rem;
}

.portfolio-table-wrap {
  overflow-x: auto;
}

.portfolio-table {
  width: 100%;
  border-collapse: collapse;
}

.portfolio-table th {
  padding: .45rem .5rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  color: rgba(255, 255, 255, .34);
  font-family: var(--apps-mono);
  font-size: .56rem;
  font-weight: 500;
  letter-spacing: .12em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.portfolio-table td {
  padding: .62rem .5rem;
  border-bottom: 1px solid rgba(255, 255, 255, .045);
  color: rgba(255, 255, 255, .66);
  font-family: var(--apps-mono);
  font-size: .68rem;
  vertical-align: middle;
}

.portfolio-table tbody tr:hover td {
  background: rgba(255, 255, 255, .018);
}

.portfolio-table td:first-child {
  width: 112px;
  color: rgba(255, 255, 255, .48);
  white-space: nowrap;
}

.portfolio-table td:nth-child(2) {
  width: 260px;
}

.portfolio-table td:last-child {
  width: 160px;
}

.portfolio-app {
  display: block;
  color: rgba(255, 255, 255, .72);
  font-family: var(--apps-mono);
  font-size: .68rem;
}

.portfolio-option {
  display: block;
  margin-top: .2rem;
  color: #fb923c;
  font-family: var(--apps-mono);
  font-size: .58rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.portfolio-table strong {
  display: block;
  color: rgba(255, 255, 255, .84);
  font-family: var(--apps-ui);
  font-size: .82rem;
  font-weight: 650;
  line-height: 1.35;
}

.portfolio-table small {
  display: block;
  margin-top: .18rem;
  color: rgba(255, 255, 255, .36);
  font-family: var(--apps-ui);
  font-size: .72rem;
  line-height: 1.35;
}

.portfolio-actions {
  display: flex;
  gap: .45rem;
  justify-content: flex-end;
}

.portfolio-actions a,
.portfolio-actions button {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 .55rem;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 8px;
  background: rgba(255, 255, 255, .025);
  color: rgba(255, 255, 255, .62);
  cursor: pointer;
  font-size: .56rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-decoration: none;
  text-transform: uppercase;
}

.portfolio-actions a:hover,
.portfolio-actions button:hover,
.portfolio-head button:hover {
  border-color: rgba(249, 115, 22, .35);
  color: #fff;
}

.portfolio-detail[hidden] {
  display: none;
}

.detail-results {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .65rem;
  margin: 1rem 0 0;
}

.detail-result,
.detail-empty {
  min-width: 0;
  padding: .8rem;
  border: 1px solid rgba(255, 255, 255, .055);
  border-radius: 12px;
  background: rgba(0, 0, 0, .55);
}

.detail-empty,
.detail-result span,
.detail-summary span {
  color: #fb923c;
  font-family: var(--apps-mono);
  font-size: .56rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.detail-empty {
  grid-column: 1 / -1;
  color: rgba(255, 255, 255, .46);
  line-height: 1.5;
}

.detail-result strong {
  display: block;
  margin-top: .35rem;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-result small {
  display: block;
  margin-top: .25rem;
  color: rgba(255, 255, 255, .38);
  font-size: .68rem;
  line-height: 1.35;
}

.detail-summary {
  margin-top: .75rem;
  padding: .8rem;
  border: 1px solid rgba(255, 255, 255, .055);
  border-radius: 12px;
  background: rgba(0, 0, 0, .45);
}

.detail-summary p {
  margin: .45rem 0 0;
  color: rgba(255, 255, 255, .62);
  font-size: .82rem;
  line-height: 1.5;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.workspace-card {
  min-height: 170px;
  display: flex;
  flex-direction: column;
  padding: 1.15rem;
  border: 1px solid var(--apps-line);
  border-radius: 18px;
  background: rgba(8, 8, 8, .94);
  color: inherit;
  text-decoration: none;
  transition: border-color .18s ease, transform .18s ease;
}

.workspace-card:hover {
  border-color: rgba(249, 115, 22, .34);
  transform: translateY(-2px);
}

.workspace-card h3 {
  margin: .8rem 0 .55rem;
  color: #fff;
  font-size: 1.08rem;
  font-weight: 800;
}

.workspace-card p {
  margin: 0;
  color: var(--apps-muted);
  font-size: .88rem;
  line-height: 1.55;
}

@media (max-width: 1120px) {
  body.apps-page {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .apps-sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--apps-line);
  }

  .side-dashboard {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .apps-main {
    height: auto;
    overflow: visible;
  }

  .apps-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .side-dashboard,
  .apps-grid {
    grid-template-columns: 1fr;
  }

  .apps-topbar,
  .apps-top-actions,
  .portfolio-head {
    align-items: stretch;
    flex-direction: column;
  }
}
