/* RIO_TERMINAL_UI_V5 */

:root {
  --bg-0: #050b13;
  --bg-1: #071321;
  --bg-2: #0a1929;
  --panel: #0a1726;
  --panel-2: #0d1d2f;
  --line: #1a344b;
  --line-soft: rgba(139, 197, 225, .12);
  --text: #e8f1f8;
  --muted: #8fa5b8;
  --faint: #617789;
  --accent: #63dff6;
  --accent-soft: rgba(99, 223, 246, .12);
  --positive: #57d998;
  --warning: #e8bf5a;
  --danger: #ee7280;
  --sidebar: 228px;
  --topbar: 60px;
  --radius: 8px;
  --gap: 10px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg-0);
  font-size: 14px;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg-0);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: #a5f3ff;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #102238;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
}

button:hover,
.button:hover {
  border-color: #2d5874;
  background: #132a42;
}

.button.primary,
button.primary,
.command-button {
  border-color: #438ca1;
  background: #69dff3;
  color: #031119;
}

.button.secondary,
button.secondary {
  background: #102238;
  color: var(--text);
}

.button.danger-outline,
.danger-outline {
  border-color: rgba(238, 114, 128, .42);
  background: rgba(238, 114, 128, .08);
  color: #ff9ca7;
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: none;
  background: #081522;
  color: var(--text);
  font-size: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #3f879d;
  box-shadow: 0 0 0 2px rgba(99, 223, 246, .08);
}

option {
  background: #0a1726;
  color: var(--text);
}

.full-width {
  width: 100%;
}

/* Auth */

.auth-page,
.member-auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(rgba(5,11,19,.96), rgba(5,11,19,.96)),
    radial-gradient(circle at 30% 0%, #123451, transparent 40%);
}

.auth-card,
.member-auth-card {
  width: min(390px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 22px 70px rgba(0,0,0,.38);
}

.auth-brand,
.member-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-orbit {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid #3d8298;
  border-radius: 50%;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.auth-brand h1,
.member-logo h1 {
  margin: 1px 0 0;
  font-size: 20px;
  letter-spacing: -.03em;
}

.auth-brand p,
.auth-copy,
.security-foot {
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  font-size: 11px;
}

.tier-badge {
  margin: 14px 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  text-align: center;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .16em;
}

/* Main shell */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  width: 100vw;
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: var(--sidebar);
  height: 100vh;
  padding: 12px 10px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #050e18;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  margin: 0 4px 8px;
  color: var(--text);
}

.brand .brand-orbit {
  width: 34px;
  height: 34px;
}

.brand strong {
  display: block;
  font-size: 14px;
  line-height: 1.05;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.sidebar .tier-badge {
  margin: 5px 4px 10px;
  padding: 6px 8px;
  border-radius: 5px;
  text-align: left;
}

.nav-stack {
  display: grid;
  gap: 2px;
  margin: 3px 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 8px;
  border-radius: 5px;
  color: #8ea5b8;
  font-size: 11.5px;
  font-weight: 720;
  line-height: 1.1;
}

.nav-link span {
  display: inline-grid;
  place-items: center;
  width: 17px;
  color: var(--accent);
  font-size: 11px;
}

.nav-link:hover {
  background: #0b1b2c;
  color: var(--text);
}

.nav-link.active {
  background: #10283a;
  color: #b5f5ff;
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-spacer {
  flex: 1;
  min-height: 10px;
}

.nav-secondary {
  padding-top: 7px;
  border-top: 1px solid var(--line-soft);
}

.user-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  padding: 7px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(255,255,255,.025);
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.user-copy {
  min-width: 0;
}

.user-copy strong,
.user-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy strong {
  font-size: 10.5px;
}

.user-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8.5px;
}

.icon-plain {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 5px;
}

.main-shell {
  min-width: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(6,17,29,.96), rgba(5,11,19,.98)),
    radial-gradient(circle at 20% 0%, rgba(26,83,120,.32), transparent 34%);
}

.topbar-v2 {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--topbar);
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 13, 22, .94);
  backdrop-filter: blur(12px);
}

.mobile-menu {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
}

.breadcrumb {
  margin: 0;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
}

.topbar-v2 h1 {
  margin: 2px 0 0;
  font-size: 23px;
  line-height: 1;
  letter-spacing: -.035em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #0b1928;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
}

.command-button {
  min-height: 30px;
  font-size: 10.5px;
}

.command-button kbd {
  margin-left: 4px;
  padding: 2px 4px;
  border-radius: 3px;
  background: rgba(0,0,0,.18);
  font-size: 9px;
}

.content-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 14px 16px 34px;
}

.flash-stack {
  padding: 8px 16px 0;
}

.flash {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
}

/* Page heads */

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin: 0 0 10px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(11, 29, 47, .78);
  box-shadow: none;
}

.hero-panel.compact {
  min-height: 68px;
}

.eyebrow-v2 {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 8.5px;
  font-weight: 850;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.hero-panel h2 {
  margin: 0 0 4px;
  font-size: 19px;
  line-height: 1.12;
  letter-spacing: -.025em;
}

.hero-panel p,
.section-intro,
.panel-header p,
.security-note {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.asof-control,
.page-actions,
.form-row,
.actions-right {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 7px;
}

.asof-control {
  min-width: 215px;
}

.asof-control label {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
}

.page-actions {
  justify-content: space-between;
  margin: 0 0 10px;
  padding: 5px 0;
}

/* Compact metrics */

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

.kpi-card {
  min-height: 82px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(9, 23, 38, .92);
  box-shadow: none;
}

.kpi-card span {
  display: block;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.kpi-card strong {
  display: block;
  margin: 7px 0 3px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 760;
  line-height: 1;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
}

.kpi-card small {
  color: var(--faint);
  font-size: 9.5px;
}

.waapi-card strong {
  color: var(--warning);
}

/* Dense panels */

.dashboard-grid,
.valuation-controls {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 10px;
}

.dashboard-grid > .panel:not(.span-2):not(.span-3):not(.span-4),
.valuation-controls > .panel:not(.span-2):not(.span-3):not(.span-4) {
  grid-column: span 3;
}

.span-2 {
  grid-column: span 6;
}

.span-3 {
  grid-column: span 9;
}

.span-4 {
  grid-column: 1 / -1;
}

.panel {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(9, 23, 38, .92);
  box-shadow: none;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-header h3 {
  margin: 0;
  font-size: 13px;
  line-height: 1.15;
}

.panel-meta,
.text-link {
  color: var(--accent);
  font-size: 9.5px;
  font-weight: 750;
}

.loading-block {
  min-height: 112px;
  display: grid;
  place-items: center;
  border: 1px dashed #24445d;
  border-radius: 5px;
  background: rgba(255,255,255,.015);
  color: var(--faint);
  font-size: 10px;
}

.line-chart,
.donut-wrap {
  min-height: 175px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 9.5px;
}

.list-stack {
  display: grid;
  gap: 5px;
}

/* Dynamic product/list formatting */

.terminal-grid,
#productList,
#productsList,
#productsGrid,
.product-list,
.product-grid,
.selection-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(335px, 1fr));
  gap: 8px;
  align-items: start;
}

.terminal-card,
#productList > article,
#productList > div,
#productsList > article,
#productsList > div,
#productsGrid > article,
#productsGrid > div,
.product-card,
.product-row,
.record-card,
.list-card {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(9, 23, 38, .92);
  color: var(--text);
  box-shadow: none;
}

.terminal-card > *,
.product-card > *,
.product-row > * {
  margin-top: 0;
  margin-bottom: 5px;
}

.terminal-card h2,
.terminal-card h3,
.product-card h2,
.product-card h3,
.product-row h2,
.product-row h3 {
  margin: 1px 0 7px;
  font-size: 13px;
  line-height: 1.15;
}

.terminal-card .eyebrow-v2,
.product-card .eyebrow-v2,
.product-row .eyebrow-v2 {
  margin-bottom: 3px;
}

.terminal-card > div:not(.terminal-actions),
.terminal-card .product-meta,
.terminal-card .product-metrics,
.product-card > div:not(.terminal-actions),
.product-row > div:not(.terminal-actions) {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 7px;
  color: var(--muted);
  font-size: 10px;
}

.terminal-card span,
.terminal-card small,
.product-card span,
.product-card small,
.product-row span,
.product-row small {
  color: var(--muted);
  font-size: 9.5px;
}

.terminal-card strong,
.product-card strong,
.product-row strong {
  color: var(--text);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.terminal-actions,
.terminal-card footer,
.product-card footer,
.product-row footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line-soft);
}

.meta-grid,
.detail-grid,
.product-meta,
.record-meta,
.card-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 5px;
}

.meta-grid > *,
.detail-grid > *,
.product-meta > *,
.record-meta > *,
.card-meta > * {
  padding: 5px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: rgba(255,255,255,.02);
}

/* Tables */

.table-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.data-table,
table {
  width: 100%;
  border-collapse: collapse;
  background: #071421;
  color: var(--text);
  font-size: 10.5px;
}

th,
td {
  height: 31px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0d1d2f;
  color: #8fb8cc;
  font-size: 8.5px;
  font-weight: 850;
  letter-spacing: .09em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: rgba(99, 223, 246, .045);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: min(340px, 100%);
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #081522;
}

.search-field input {
  min-height: 30px;
  padding: 4px 0;
  border: 0;
  background: transparent;
}

.grow {
  flex: 1 1 auto;
}

/* Dialogs and forms */

dialog,
.modal-dialog-v2,
.sheet-dialog {
  color: var(--text);
  border: 0;
  padding: 0;
  background: transparent;
}

dialog:not([open]),
.modal-dialog-v2:not([open]),
.sheet-dialog:not([open]) {
  display: none !important;
}

dialog[open],
.modal-dialog-v2[open],
.sheet-dialog[open] {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1000 !important;
  width: 100vw !important;
  max-width: none !important;
  height: 100vh !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 14px !important;
  display: grid !important;
  place-items: center !important;
  overflow: auto !important;
  background: rgba(1, 5, 9, .72) !important;
  backdrop-filter: blur(5px);
}

dialog::backdrop {
  background: rgba(1, 5, 9, .72);
}

.modal-card-v2,
.sheet-shell {
  width: min(830px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 14px;
  border: 1px solid #28506a;
  border-radius: 8px;
  background: #081522;
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0,0,0,.55);
}

.modal-dialog-v2.wide .modal-card-v2,
.modal-card-v2.wide,
.sheet-shell.wide {
  width: min(1040px, calc(100vw - 28px));
}

.modal-card-v2 > header,
.sheet-shell > header,
.modal-card-v2 header,
.sheet-shell header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  padding: 0 0 9px;
  border-bottom: 1px solid var(--line);
}

.modal-card-v2 h2,
.sheet-shell h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -.02em;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.form-grid .full,
label.full {
  grid-column: 1 / -1;
}

.modal-card-v2 label,
.sheet-shell label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 720;
}

.modal-card-v2 input,
.modal-card-v2 select,
.modal-card-v2 textarea,
.sheet-shell input,
.sheet-shell select,
.sheet-shell textarea {
  min-height: 33px;
}

.modal-card-v2 textarea,
.sheet-shell textarea {
  min-height: 72px;
  resize: vertical;
}

.toggle {
  display: flex !important;
  align-items: center;
  gap: 7px;
}

.toggle input[type="checkbox"],
input[type="checkbox"] {
  width: 15px !important;
  height: 15px !important;
  min-height: 15px !important;
  flex: 0 0 auto;
}

.modal-card-v2 footer,
.sheet-shell footer,
.sheet-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.footer-spacer {
  flex: 1;
}

/* AI console */

.ai-layout {
  display: grid;
  grid-template-columns: 285px minmax(0, 1fr);
  gap: 8px;
}

.ai-info,
.chat-panel,
.guardrail-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(9, 23, 38, .92);
}

.ai-info h2 {
  margin: 6px 0 5px;
  font-size: 15px;
}

.ai-info p,
.guardrail-card span {
  color: var(--muted);
  font-size: 10px;
}

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 9px 0;
}

.prompt-chips button {
  min-height: 28px;
  padding: 5px 8px;
  font-size: 9.5px;
}

.guardrail-card {
  display: grid;
  gap: 5px;
}

.guardrail-card strong {
  font-size: 10px;
}

.chat-thread {
  display: grid;
  gap: 7px;
  min-height: 220px;
  margin-bottom: 8px;
}

.chat-message {
  display: flex;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(255,255,255,.02);
}

.chat-avatar,
.ai-orb {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px auto;
  gap: 6px;
  align-items: end;
}

.chat-composer textarea {
  min-height: 54px;
}

/* Member portal */

.member-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #050e18;
}

.member-content {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px;
}

.member-grid,
.member-totals {
  display: grid;
  gap: 8px;
}

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

.member-totals {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

/* Responsive */

@media (max-width: 1220px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .dashboard-grid > .panel:not(.span-2):not(.span-3):not(.span-4) {
    grid-column: span 6;
  }
}

@media (max-width: 900px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-stack {
    display: flex;
    overflow-x: auto;
  }

  .nav-link {
    white-space: nowrap;
  }

  .sidebar-spacer,
  .user-card {
    display: none;
  }

  .topbar-v2 {
    position: relative;
  }

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

  .dashboard-grid,
  .valuation-controls {
    grid-template-columns: 1fr;
  }

  .dashboard-grid > .panel,
  .valuation-controls > .panel,
  .span-2,
  .span-3,
  .span-4 {
    grid-column: 1 / -1 !important;
  }

  .hero-panel,
  .ai-layout,
  .chat-composer,
  .form-grid,
  .member-grid {
    grid-template-columns: 1fr;
  }

  .top-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}
