:root {
  --bg-0: #030811;
  --bg-1: #071426;
  --bg-2: #0a1d35;
  --card: rgba(8, 21, 40, 0.88);
  --card-soft: rgba(8, 21, 40, 0.68);
  --text: #dce5f6;
  --muted: #96a6bf;
  --line: rgba(79, 109, 154, 0.33);
  --brand: #13d5a2;
  --brand-2: #35ffd0;
  --warn: #fcbf49;
  --ok: #26d97f;
  --danger: #ff6e7a;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  color: var(--text);
  background:
    radial-gradient(1200px 620px at 8% -10%, rgba(19, 213, 162, 0.13), transparent 58%),
    radial-gradient(920px 520px at 100% 0%, rgba(44, 153, 255, 0.11), transparent 56%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 52%, var(--bg-2));
  font-family: "Heebo", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
  font-family: "Rajdhani", "Heebo", sans-serif;
  letter-spacing: 0.01em;
}

p {
  margin: 0;
}

.app-shell {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 14px 12px 28px;
  overflow-x: visible;
}

#mainContent,
.view,
.card,
.kpi-grid,
.kpi-item,
.chart-wrap {
  min-width: 0;
  max-width: 100%;
}

.card {
  background: linear-gradient(165deg, var(--card), var(--card-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  position: sticky;
  top: 8px;
  z-index: 20;
  backdrop-filter: blur(6px);
  overflow: hidden;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand-title {
  font-size: clamp(1.2rem, 4.6vw, 1.9rem);
  font-weight: 700;
  word-break: normal;
  overflow-wrap: normal;
}

.stackfi {
  color: var(--brand-2);
  font-size: 0.7em;
  letter-spacing: 0.03em;
  font-weight: 600;
}

.brand-sub {
  margin-top: 1px;
  font-size: 0.79rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.64rem 0.95rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 40px;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

a.btn {
  text-decoration: none;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: 2px solid rgba(53, 255, 208, 0.65);
  outline-offset: 2px;
}

.btn.primary {
  border-color: rgba(19, 213, 162, 0.5);
  background: linear-gradient(160deg, rgba(19, 213, 162, 0.2), rgba(19, 213, 162, 0.08));
}

.btn.ghost {
  border-color: var(--line);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.hidden {
  display: none !important;
}

#mainContent {
  margin-top: 14px;
}

.view {
  display: grid;
  gap: 12px;
}

.login-card,
.kpi-grid,
.chart-wrap {
  width: 100%;
}

.login-card {
  padding: 18px;
}

.login-card h2 {
  font-size: clamp(1.45rem, 6vw, 2rem);
}

.muted {
  color: var(--muted);
}

.hint {
  font-size: 0.86rem;
  color: #9db3ce;
  margin-top: 10px;
}

.error {
  margin: 4px 0 0;
  color: var(--danger);
  font-size: 0.92rem;
}

.form-grid {
  display: grid;
  gap: 12px;
  margin-top: 13px;
}

label {
  display: grid;
  gap: 6px;
  color: #c4d2e9;
  font-size: 0.93rem;
}

input {
  width: 100%;
  background: rgba(9, 21, 38, 0.94);
  border: 1px solid rgba(77, 103, 141, 0.45);
  color: var(--text);
  border-radius: 11px;
  min-height: 44px;
  padding: 0.62rem 0.82rem;
  font-size: 1rem;
}

input:focus {
  outline: 2px solid rgba(53, 255, 208, 0.35);
  outline-offset: 1px;
  border-color: rgba(53, 255, 208, 0.55);
}

select,
textarea {
  width: 100%;
  background: rgba(9, 21, 38, 0.94);
  border: 1px solid rgba(77, 103, 141, 0.45);
  color: var(--text);
  border-radius: 11px;
  min-height: 44px;
  padding: 0.62rem 0.82rem;
  font-size: 1rem;
}

select:focus,
textarea:focus {
  outline: 2px solid rgba(53, 255, 208, 0.35);
  outline-offset: 1px;
  border-color: rgba(53, 255, 208, 0.55);
}

.model-block {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-top: 10px;
  background: rgba(7, 18, 35, 0.58);
}

.model-block h3 {
  font-size: 1.22rem;
  margin-bottom: 2px;
}

.card {
  padding: 14px;
  overflow: hidden;
}

.welcome-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.welcome-card h2 {
  font-size: clamp(1.4rem, 6vw, 2.1rem);
  margin-bottom: 4px;
}

.badge-wrap {
  flex-shrink: 0;
}

.status-badge {
  border-radius: 999px;
  border: 1px solid rgba(38, 217, 127, 0.48);
  color: #b3ffd4;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 10px;
  background: rgba(38, 217, 127, 0.12);
}

.kpi-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.kpi-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  background: rgba(7, 19, 35, 0.65);
}

.kpi-item p {
  font-size: 0.83rem;
  color: #9fb0c8;
}

.kpi-item h3 {
  margin-top: 3px;
  font-size: clamp(1.2rem, 5.2vw, 1.68rem);
  line-height: 1.15;
  word-break: normal;
  overflow-wrap: anywhere;
}

.mono {
  font-family: "IBM Plex Mono", monospace;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.chart-wrap {
  margin-top: 10px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(6, 16, 32, 0.7);
  padding: 8px;
  overflow: hidden;
}

.trend-svg {
  width: 100%;
  height: 220px;
  display: block;
  max-width: 100%;
}

.trend-grid {
  stroke: rgba(96, 121, 154, 0.35);
  stroke-width: 1;
}

.trend-line {
  fill: none;
  stroke: var(--brand-2);
  stroke-width: 2.5;
}

.trend-dot {
  fill: var(--brand-2);
}

.axis-text {
  fill: #97a8c2;
  font-size: 11px;
  font-family: "IBM Plex Mono", monospace;
}

.claim-enabled {
  color: #b9ffd6;
}

.claim-disabled {
  color: #ffd2b6;
}

.table-scroll {
  margin-top: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 540px;
}

th,
td {
  text-align: start;
  border-bottom: 1px solid rgba(88, 116, 153, 0.35);
  padding: 10px 8px;
  white-space: nowrap;
}

th {
  color: #a6bad8;
  font-size: 0.82rem;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
  letter-spacing: 0.01em;
}

td {
  font-size: 0.95rem;
}

.chip {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.76rem;
  border: 1px solid rgba(38, 217, 127, 0.42);
  color: #ccffe4;
  background: rgba(38, 217, 127, 0.14);
}

.detail-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.detail-list li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 11px;
  background: rgba(8, 18, 35, 0.6);
  color: #c1d0e7;
}

.detail-key {
  display: block;
  color: #9bb0cb;
  font-size: 0.79rem;
}

.admin-layout {
  display: grid;
  gap: 12px;
}

.admin-panel-title {
  font-size: clamp(1.25rem, 4.9vw, 1.8rem);
}

.admin-table-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.mini-btn {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 6px 10px;
  min-height: 36px;
  min-width: 44px;
  font-size: 0.74rem;
  font-family: "IBM Plex Mono", monospace;
  cursor: pointer;
}

.mini-btn.active {
  border-color: rgba(19, 213, 162, 0.44);
  background: rgba(19, 213, 162, 0.14);
}

.admin-form-grid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.field-grid-2 {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
}

.admin-note {
  border: 1px dashed rgba(108, 136, 177, 0.55);
  border-radius: 10px;
  padding: 9px 10px;
  margin-top: 10px;
  color: #b8c8df;
  font-size: 0.88rem;
}

.investor-row-meta {
  color: #97abc8;
  font-size: 0.78rem;
}

.admin-status {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.72rem;
  border: 1px solid rgba(94, 122, 157, 0.4);
}

.admin-status.active {
  color: #c8ffe1;
  border-color: rgba(38, 217, 127, 0.43);
  background: rgba(38, 217, 127, 0.11);
}

.admin-status.inactive {
  color: #ffd5c4;
  border-color: rgba(252, 139, 99, 0.43);
  background: rgba(252, 139, 99, 0.1);
}

@media (min-width: 700px) {
  .app-shell {
    padding: 20px 18px 44px;
  }

  .view {
    gap: 14px;
  }

  #loginSection {
    grid-template-columns: 1fr 1.25fr;
    align-items: start;
  }

  .card {
    padding: 16px;
  }

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

  .admin-layout {
    grid-template-columns: 1.2fr 1fr;
    align-items: start;
  }
}

@media (max-width: 768px) {
  .app-shell {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0 6px 16px;
  }

  #mainContent {
    margin-top: 0;
  }

  .view {
    gap: 8px;
  }

  .topbar {
    position: static;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
    padding: 10px 8px;
  }

  .card {
    border-radius: 10px;
    margin-inline: 0;
    box-shadow: none;
  }

  .brand-sub {
    display: none;
  }

  .trend-svg {
    height: 170px;
  }

  .axis-text {
    font-size: 8px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0 0 14px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .brand {
    width: 100%;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px;
  }

  .brand > div {
    min-width: 0;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
  }

  .brand-title {
    font-size: 1.2rem;
    white-space: normal;
    line-height: 1.08;
  }

  .brand-sub {
    display: none;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
    gap: 6px;
  }

  .topbar-actions .btn {
    width: 100%;
    font-size: 0.72rem;
    padding: 0.48rem 0.5rem;
    min-height: 36px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .welcome-card h2 {
    font-size: 1.15rem;
    line-height: 1.22;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .kpi-item {
    padding: 8px 9px;
  }

  .kpi-item p {
    font-size: 0.72rem;
  }

  .kpi-item h3 {
    font-size: 1rem;
  }

  .section-head h3 {
    font-size: 1.08rem;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .section-head .mono {
    font-size: 0.82rem;
  }

  .axis-text {
    font-size: 9px;
  }

  .table-scroll {
    margin-inline: 0;
  }

  table {
    min-width: 100%;
  }

  th,
  td {
    font-size: 0.84rem;
    padding: 8px 6px;
  }

  .claims-table {
    min-width: 0;
  }

  .claims-table thead {
    display: none;
  }

  .claims-table,
  .claims-table tbody,
  .claims-table tr,
  .claims-table td {
    display: block;
    width: 100%;
  }

  .claims-table tr {
    border-bottom: 1px solid rgba(88, 116, 153, 0.35);
    padding: 8px 0;
  }

  .claims-table td {
    border-bottom: 0;
    white-space: normal;
    word-break: break-word;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 2px;
  }

  .claims-table td::before {
    content: attr(data-label);
    color: #9bb0cb;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    flex: 0 0 auto;
  }

  .admin-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .field-grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1024px) {
  .app-shell {
    padding-left: 24px;
    padding-right: 24px;
  }

  .card {
    padding: 18px;
  }

  .trend-svg {
    height: 260px;
  }
}

html[dir='rtl'] body {
  font-family: "Heebo", sans-serif;
}

html[dir='rtl'] .topbar-actions {
  justify-content: flex-start;
}

html[dir='rtl'] th,
html[dir='rtl'] td,
html[dir='rtl'] .detail-list li,
html[dir='rtl'] p,
html[dir='rtl'] h1,
html[dir='rtl'] h2,
html[dir='rtl'] h3,
html[dir='rtl'] label {
  text-align: right;
}
