/* ─── Variables (same as public site) ─────────────────────────── */
:root {
  --black:    #080808;
  --surface:  #0e0e0e;
  --surface2: #131313;
  --border:   rgba(255,255,255,0.07);
  --border2:  rgba(255,255,255,0.12);
  --white:    #f0f0f0;
  --muted:    rgba(240,240,240,0.38);
  --accent:   #c8ff40;
  --positive: #4ade80;
  --negative: #f87171;
  --radius:   4px;
  --mono:     'JetBrains Mono', monospace;
  --sans:     'Inter', system-ui, sans-serif;
  --sidebar:  220px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { background: var(--black); color: var(--white); font-family: var(--sans); font-weight: 300; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--sans); }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--black); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* ─── Login ────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
}
.login-box {
  width: 100%;
  max-width: 380px;
  padding: 40px;
  background: var(--surface);
  border: 1px solid var(--border2);
}
.login-logo { font-family: var(--mono); font-size: 14px; letter-spacing: 0.2em; color: var(--white); margin-bottom: 6px; }
.login-sub { font-size: 11px; color: var(--muted); margin-bottom: 32px; }
.login-error { font-size: 11px; color: var(--negative); margin-bottom: 12px; }
.login-hint { font-size: 10.5px; color: var(--muted); margin-top: 20px; }
.login-hint strong { color: var(--white); }

/* ─── Admin layout ─────────────────────────────────────────────── */
.admin-app { display: flex; min-height: 100vh; }

/* ─── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}
.sidebar-brand {
  padding: 24px 20px 20px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.16em;
  border-bottom: 1px solid var(--border);
  color: var(--white);
}
.sidebar-brand span { color: var(--muted); font-size: 10px; letter-spacing: 0.1em; }
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}
.sidebar-item:hover { background: rgba(255,255,255,0.04); color: var(--white); }
.sidebar-item.active { background: var(--accent2, rgba(200,255,64,0.1)); color: var(--accent); }
.sidebar-icon { font-size: 10px; opacity: 0.6; }
.sidebar-footer { padding: 16px 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.sidebar-preview { font-size: 11.5px; color: var(--accent); font-family: var(--mono); }
.sidebar-logout { background: none; border: none; color: var(--muted); font-size: 11.5px; text-align: left; padding: 0; }
.sidebar-logout:hover { color: var(--white); }

/* ─── Main ─────────────────────────────────────────────────────── */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar);
  min-height: 100vh;
  padding: 32px 40px;
  max-width: 1100px;
}

/* ─── Views ────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
  flex-wrap: wrap;
}
.view-title { font-size: 24px; font-weight: 300; letter-spacing: -0.02em; }
.view-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.form-actions { display: flex; gap: 10px; align-items: center; }
.back-btn { font-size: 11.5px; color: var(--muted); background: none; border: none; margin-top: 4px; display: block; }
.back-btn:hover { color: var(--white); }

/* ─── Buttons ──────────────────────────────────────────────────── */
.btn-primary {
  padding: 10px 22px;
  background: var(--accent);
  color: var(--black);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  border: none;
  border-radius: var(--radius);
  transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary.full { width: 100%; padding: 12px; }
.btn-ghost {
  padding: 9px 20px;
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
  font-size: 12px;
  border-radius: var(--radius);
  transition: border-color 0.2s, color 0.2s;
}
.btn-ghost:hover { border-color: var(--white); color: var(--white); }
.btn-ghost.small { padding: 6px 14px; font-size: 11px; }

/* ─── Fields ───────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.field-input {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--white);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 300;
  padding: 10px 12px;
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.field-input:focus { border-color: var(--accent); }
.field-input::placeholder { color: rgba(240,240,240,0.2); }
.field-textarea { resize: vertical; line-height: 1.6; }

/* select styled like field-input */
.field-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23888' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
  width: auto;
}
.field-select option { background: #1a1a1a; color: #f0f0f0; }

/* pair of selects side by side */
.date-select-pair {
  display: flex;
  gap: 8px;
  align-items: center;
}
.content-editor { font-family: var(--mono); font-size: 12.5px; min-height: 480px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-or { font-size: 10px; color: var(--muted); text-align: center; margin: 6px 0; }

/* ─── Checkbox ─────────────────────────────────────────────────── */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}
.checkbox-label.small { font-size: 11px; margin-top: 4px; }
.checkbox-label input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; }

/* ─── Content help ─────────────────────────────────────────────── */
.content-help {
  font-size: 10px;
  color: var(--muted);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius);
  letter-spacing: 0.04em;
}

.content-toolbar {
  display: flex;
  gap: 8px;
  margin: 6px 0;
}

.insert-img-panel {
  background: rgba(200,255,64,0.03);
  border: 1px solid rgba(200,255,64,0.18);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
}

.insert-img-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.insert-img-filename {
  font-size: 11px;
  color: var(--muted);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Article form ─────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}
.form-col { display: flex; flex-direction: column; gap: 20px; }
.field-full { grid-column: 1 / -1; }

/* ─── Image upload ─────────────────────────────────────────────── */
.image-upload-area {
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
}
.image-placeholder { padding: 20px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.image-placeholder .mono { font-size: 11px; color: var(--muted); }
.image-preview { position: relative; }
.image-preview img { width: 100%; height: 180px; object-fit: cover; display: block; }
.image-remove {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(0,0,0,0.7);
  border: none;
  color: var(--white);
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}

/* ─── Articles list ────────────────────────────────────────────── */
.articles-list { display: flex; flex-direction: column; gap: 2px; }
.article-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background 0.15s;
}
.article-row:hover { background: rgba(255,255,255,0.035); }
.article-row-thumb {
  width: 52px; height: 38px;
  object-fit: cover;
  flex-shrink: 0;
  background: #141414;
  border-radius: 2px;
  overflow: hidden;
}
.article-row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.article-row-info { flex: 1; min-width: 0; }
.article-row-title { font-size: 13.5px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.article-row-meta { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-top: 3px; }
.article-row-tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  padding: 2px 7px;
  border: 1px solid var(--border2);
  border-radius: 2px;
  color: var(--muted);
  flex-shrink: 0;
}
.article-row-featured { font-family: var(--mono); font-size: 9px; color: var(--accent); flex-shrink: 0; }
.article-row-edit {
  background: none;
  border: 1px solid var(--border2);
  color: var(--muted);
  font-size: 11px;
  padding: 5px 12px;
  border-radius: var(--radius);
  flex-shrink: 0;
}
.article-row-edit:hover { border-color: var(--white); color: var(--white); }
.article-row-delete {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 14px;
  padding: 4px 8px;
  border-radius: var(--radius);
  flex-shrink: 0;
  line-height: 1;
}
.article-row-delete:hover { color: var(--negative); border-color: var(--negative); }

/* ─── Portfolio tabs ───────────────────────────────────────────── */
.portfolio-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 28px; }
.ptab {
  background: transparent; border: none; color: var(--muted);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  padding: 9px 18px; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
}
.ptab:hover { color: var(--white); }
.ptab.active { color: var(--accent); border-color: var(--accent); }
.ptab-panel { display: none; }
.ptab-panel.active { display: block; }

/* ─── KPIs grid ────────────────────────────────────────────────── */
.kpis-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ─── Holdings admin table ─────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.admin-table th {
  text-align: left; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--border2); font-weight: 400;
}
.admin-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table td input { background: transparent; border: none; color: var(--white); font-family: var(--mono); font-size: 12px; width: 100%; outline: none; padding: 4px 0; }
.admin-table td input:focus { border-bottom: 1px solid var(--accent); }
.admin-table .delete-row { background: none; border: none; color: var(--muted); font-size: 14px; padding: 2px 6px; }
.admin-table .delete-row:hover { color: var(--negative); }
.admin-table select { background: var(--surface2); border: 1px solid var(--border2); color: var(--white); font-family: var(--mono); font-size: 11px; padding: 3px 6px; border-radius: 2px; outline: none; }

/* ─── Holdings live price ──────────────────────────────────────── */
.holdings-admin-toolbar { display: flex; gap: 10px; margin-bottom: 10px; }
.holdings-hint { font-size: 10.5px; color: var(--muted); margin-bottom: 12px; letter-spacing: 0.04em; }
.price-live  { font-size: 12px; color: var(--white); display: inline-block; min-width: 72px; }
.weight-live { font-size: 12px; color: var(--muted); display: inline-block; min-width: 48px; font-family: var(--mono); }
.price-live.fetching { color: var(--accent); animation: blink 0.8s ease infinite; }
.price-live.price-error { color: var(--negative); font-size: 10px; }
.pnl-live { font-size: 12px; min-width: 70px; display: inline-block; }
.pnl-live.positive { color: var(--positive); }
.pnl-live.negative { color: var(--negative); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.35} }

/* compact text/number input in table */
.field-input-sm {
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--white);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 3px 2px;
  outline: none;
  width: 100%;
}
.field-input-sm:focus { border-bottom-color: var(--accent); }

/* sector dropdown in table */
.field-select-sm {
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--white);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 3px 2px;
  outline: none;
  width: 100%;
  cursor: pointer;
}
.field-select-sm:focus { border-bottom-color: var(--accent); }
.field-select-sm option { background: #1a1a1a; color: var(--white); }

/* portfolio summary bar */
.portfolio-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(200,255,64,0.04);
  border: 1px solid rgba(200,255,64,0.15);
  border-radius: 4px;
  padding: 10px 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.ps-label { font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.ps-value { font-size: 14px; font-weight: 400; color: var(--white); }
.ps-value.positive { color: var(--positive); }
.ps-value.negative { color: var(--negative); }
.ps-pct { font-size: 11px; color: var(--muted); }
.ps-pct.positive { color: var(--positive); }
.ps-pct.negative { color: var(--negative); }
.ps-sep { width: 1px; height: 20px; background: var(--border2); margin: 0 6px; }

/* ─── Allocation computed ──────────────────────────────────────── */
.alloc-computed-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.alloc-section { margin-bottom: 32px; }
.alloc-title { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.alloc-computed-list { display: flex; flex-direction: column; gap: 8px; }
.alloc-computed-row { display: flex; align-items: center; gap: 8px; }
.alloc-computed-bar-wrap { flex: 1; height: 4px; background: rgba(255,255,255,0.07); border-radius: 2px; overflow: hidden; }
.alloc-computed-bar { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.4s; }
.alloc-computed-label { font-size: 11px; color: var(--white); min-width: 90px; }
.alloc-computed-value { font-size: 11px; color: var(--muted); min-width: 32px; text-align: right; }

/* ─── Holdings country badge ───────────────────────────────────── */
.h-country-badge { font-size: 9px; color: var(--muted); letter-spacing: 0.06em; margin-top: 2px; min-height: 12px; }

/* ─── Reporting admin ──────────────────────────────────────────── */
.report-form-wrap { margin-bottom: 24px; }
.report-form-card { background: var(--surface); border: 1px solid var(--border); padding: 24px; border-radius: 4px; }
.report-form-title { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 20px; }
.reports-admin-list { display: flex; flex-direction: column; gap: 2px; }
.report-admin-row { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--border); padding: 14px 18px; }
.report-admin-info { display: flex; align-items: center; gap: 14px; flex: 1; }
.report-admin-period { font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); min-width: 60px; }
.report-admin-title { font-size: 14px; color: var(--white); }
.report-admin-actions { display: flex; gap: 8px; }
.report-file-zone {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}
.report-file-name {
  font-size: 12px;
  color: var(--accent);
}
.report-file-hint {
  font-size: 11.5px;
  color: var(--muted);
}

/* ─── Settings ─────────────────────────────────────────────────── */
.settings-sections { display: flex; flex-direction: column; gap: 2px; max-width: 560px; }
.settings-card { background: var(--surface); border: 1px solid var(--border); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.settings-card--highlight { border-color: rgba(200,255,64,0.25); background: rgba(200,255,64,0.03); }
.settings-title { font-size: 13px; letter-spacing: 0.08em; color: var(--white); }
.settings-desc { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.settings-desc code { font-family: var(--mono); background: rgba(255,255,255,0.07); padding: 1px 5px; border-radius: 2px; }
.token-status { font-size: 11px; color: var(--positive); margin-left: 12px; }

/* ─── About editor ─────────────────────────────────────────────── */
.about-editor {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 32px;
  align-items: start;
}
.about-editor-left { display: flex; flex-direction: column; gap: 20px; }
.about-editor-right { display: flex; flex-direction: column; gap: 20px; }

.mode-selector { display: flex; gap: 8px; }
.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.18s;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.mode-btn:hover { border-color: rgba(240,240,240,0.3); color: var(--white); }
.mode-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(200,255,64,0.05); }
.mode-icon-box { border: 1.5px solid currentColor; border-radius: 2px; }
.mode-icon-box.portrait { width: 18px; height: 26px; }
.mode-icon-box.landscape { width: 26px; height: 18px; }

.repos-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  cursor: grab;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: #000;
  user-select: none;
  touch-action: none;
}
.repos-container.portrait { height: 460px; }
.repos-container.landscape { height: 220px; }
.repos-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  display: block;
}
.repos-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px) 0 33.3% / 100% 33.3%,
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px) 33.3% 0 / 33.3% 100%;
}
.repos-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.78);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 9.5px;
  color: rgba(240,240,240,0.45);
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.08em;
}
.repos-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.repos-pos { font-size: 10.5px; color: var(--muted); font-family: var(--mono); }

/* ─── Table wrapper ────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

/* ─── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px; right: 28px;
  background: var(--surface);
  border: 1px solid var(--border2);
  padding: 12px 20px;
  font-family: var(--mono);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1000;
  max-width: 320px;
}
.toast.visible { opacity: 1; pointer-events: auto; }
.toast.success { border-color: var(--positive); color: var(--positive); }
.toast.error { border-color: var(--negative); color: var(--negative); }

/* ─── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
  .kpis-grid { grid-template-columns: 1fr 1fr; }
  .admin-main { padding: 24px 20px; }
  .alloc-computed-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  :root { --sidebar: 0px; }
  .sidebar { display: none; }
  .admin-main { margin-left: 0; }
  .kpis-grid { grid-template-columns: 1fr; }
}
