:root {
  --ink: #17213b;
  --muted: #687189;
  --line: #e6e9f1;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --primary: #5f55d9;
  --primary-soft: #eeecff;
  --positive: #168a68;
  --positive-soft: #e7f7f1;
  --negative: #c24d60;
  --negative-soft: #fff0f2;
  --warning: #c77c12;
  --warning-soft: #fff5dc;
  --blue: #2f74c0;
  --shadow: 0 14px 35px rgba(36, 47, 76, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

button { font: inherit; }

.app-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
}

h1 { margin: 3px 0 2px; font-size: clamp(24px, 3vw, 36px); line-height: 1.25; }
h2 { margin: 0; font-size: 19px; }
h3 { margin: 0 0 6px; font-size: 15px; }
p { margin: 0; color: var(--muted); }

.header-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.button, .tab {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}
.button:hover, .tab:hover { transform: translateY(-1px); }
.button { padding: 10px 14px; font-weight: 700; }
.button.primary { color: #fff; background: var(--primary); }
.button.secondary { color: var(--ink); background: #fff; border: 1px solid var(--line); }
.button:disabled { opacity: .55; cursor: wait; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.badge.demo { color: var(--warning); background: var(--warning-soft); }
.badge.live { color: var(--positive); background: var(--positive-soft); }
.badge.call { color: var(--blue); background: #eaf3ff; }
.badge.put { color: #8a4dba; background: #f5ebff; }
.badge.short { color: var(--negative); background: var(--negative-soft); }
.badge.long { color: var(--positive); background: var(--positive-soft); }

.notice {
  margin-bottom: 16px;
  padding: 12px 15px;
  border: 1px solid #ebd7a0;
  border-radius: 12px;
  color: #76500d;
  background: var(--warning-soft);
  font-size: 13px;
}
.notice.live { color: #12664e; border-color: #b9e5d4; background: var(--positive-soft); }
.notice.error { color: #9f3446; border-color: #f0bdc6; background: var(--negative-soft); }

.tabs {
  display: flex;
  gap: 7px;
  padding: 6px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(36, 47, 76, .04);
}
.tab { flex: 1; min-width: 145px; padding: 11px 14px; color: var(--muted); background: transparent; font-weight: 700; }
.tab.active { color: #fff; background: var(--primary); }
.tab-panel { display: none; padding-top: 18px; }
.tab-panel.active { display: block; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 14px; }
.metric, .card {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.metric { padding: 16px; }
.metric-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.metric-value { display: block; direction: ltr; text-align: left; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.metric-foot { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.positive { color: var(--positive) !important; }
.negative { color: var(--negative) !important; }

.content-grid { display: grid; grid-template-columns: 1.05fr 1.95fr; gap: 14px; margin-bottom: 14px; }
.content-grid.equal { grid-template-columns: 1fr 1fr; }
.card { padding: 17px; overflow: hidden; }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-subtitle { color: var(--muted); font-size: 11px; }

.allocation { display: flex; align-items: center; gap: 22px; min-height: 210px; }
.donut {
  position: relative;
  width: 150px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--primary) 0 52%, var(--positive) 52% 77%, var(--blue) 77% 91%, #dfe3ed 91% 100%);
}
.donut::after { content: ""; position: absolute; inset: 28px; border-radius: 50%; background: #fff; }
.donut-center { position: absolute; z-index: 1; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center strong { direction: ltr; font-size: 19px; }
.donut-center span { color: var(--muted); font-size: 10px; }
.legend { flex: 1; display: grid; gap: 9px; }
.legend-row { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; font-size: 12px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.legend-value { direction: ltr; color: var(--muted); }

.bars { display: grid; gap: 12px; }
.bar-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 5px; font-size: 12px; }
.bar-symbol { direction: ltr; font-weight: 800; }
.bar-detail { margin-left: 8px; color: var(--muted); font-size: 10px; direction: ltr; }
.bar-track { height: 8px; overflow: hidden; border-radius: 999px; background: #eceff5; }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #8d86f0); }
.overview-charts { margin-top: 14px; }
.chart-allocation { min-height: 190px; }
.chart-legend { max-height: 190px; overflow-y: auto; padding-right: 4px; }
.chart-legend-row { grid-template-columns: 10px minmax(90px, 1fr) auto; }
.institution-check { margin-top: 14px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th { padding: 10px 9px; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 11px; text-align: left; white-space: nowrap; }
td { padding: 12px 9px; border-bottom: 1px solid #f0f2f6; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: #fafaff; }
tfoot td { padding: 13px 9px; border-top: 2px solid var(--line); background: #f7f7fc; font-weight: 800; white-space: nowrap; }
.total-row td:first-child { border-radius: 10px 0 0 10px; }
.total-row td:last-child { border-radius: 0 10px 10px 0; }
.ltr { direction: ltr; text-align: left; }
.symbol-cell { direction: ltr; font-weight: 800; }
.subcell { display: block; color: var(--muted); font-size: 10px; font-weight: 400; }
.empty { padding: 42px 20px; color: var(--muted); text-align: center; }

.risk-list { display: grid; gap: 10px; }
.risk-item { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 12px; }
.risk-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 10px; background: var(--primary-soft); }
.risk-title { font-size: 12px; font-weight: 800; }
.risk-detail { color: var(--muted); font-size: 10px; }
.risk-value { direction: ltr; font-size: 13px; font-weight: 800; }

.calendar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.calendar-block { padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #fbfbfe; }
.calendar-block strong { display: block; direction: ltr; margin: 4px 0; font-size: 19px; }
.calendar-block span { color: var(--muted); font-size: 11px; }

.income-chart { display: flex; align-items: end; gap: 9px; height: 190px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.income-column { display: flex; flex: 1; height: 100%; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; min-width: 42px; }
.income-value { direction: ltr; color: var(--muted); font-size: 9px; }
.income-bar { width: min(36px, 70%); min-height: 3px; border-radius: 7px 7px 0 0; background: linear-gradient(180deg, #6f65e4, #5147c8); }
.income-label { color: var(--muted); font-size: 10px; }

.disclaimer { padding: 12px 14px; border-radius: 12px; color: var(--muted); background: #f6f7fa; font-size: 11px; }
.footer { display: flex; justify-content: space-between; gap: 14px; margin-top: 16px; color: var(--muted); font-size: 10px; }
.audit-card { margin-top: 18px; }
.audit-fields { display: grid; gap: 10px; margin-top: 18px; }
.audit-field { display: grid; grid-template-columns: 180px 1fr; gap: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #f8f9fc; font-size: 12px; line-height: 1.5; }
.audit-field strong { color: var(--ink); }
.audit-field span { color: var(--muted); overflow-wrap: anywhere; }
.reconciliation-line { display: grid; grid-template-columns: 1fr auto 100px auto; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #f8f9fc; font-size: 12px; }
.reconciliation-line strong { direction: ltr; font-size: 14px; }

@media (max-width: 900px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid, .content-grid.equal { grid-template-columns: 1fr; }
  .calendar { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .app-shell { padding: 16px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr; }
  .allocation { align-items: flex-start; flex-direction: column; }
  .calendar { grid-template-columns: 1fr; }
  .footer { flex-direction: column; }
  .audit-field { grid-template-columns: 1fr; gap: 4px; }
  .reconciliation-line { grid-template-columns: 1fr auto; }
}

@media print {
  body { background: #fff; }
  .app-shell { width: 100%; padding: 0; }
  .header-actions, .tabs, .notice { display: none; }
  .tab-panel { display: block !important; break-after: page; }
  .metric, .card { box-shadow: none; }
}
