:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-muted: #f8f9fb;
  --border: #e8ecf3;
  --ink: #102033;
  --muted: #607287;
  --brand: #104f86;
  --positive: #18794f;
  --negative: #b43a51;
  --positive-soft: rgba(34, 197, 94, 0.12);
  --negative-soft: rgba(239, 68, 68, 0.13);
  --neutral-soft: #eef1f6;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: radial-gradient(1200px 420px at 50% -220px, #d9e7fb, transparent), var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: 82px;
  font-variant-numeric: tabular-nums;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid rgba(232, 236, 243, 0.7);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
}

.topbar-title-wrap {
  display: grid;
  gap: 2px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.topbar-subtitle {
  font-size: 0.8rem;
}

.header-actions {
  display: flex;
  gap: 8px;
}

#app {
  padding: 14px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.card {
  background: var(--surface);
  border: 0;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 6px 18px rgba(9, 23, 39, 0.06);
}

.login-card {
  max-width: 460px;
  margin: 56px auto 0;
}

h2,
h3,
h4 {
  margin: 0 0 8px;
}

.small {
  color: var(--muted);
  font-size: 0.82rem;
}

.error-text {
  color: var(--negative);
  font-size: 0.8rem;
  min-height: 1em;
}

.btn,
input,
select,
textarea {
  font: inherit;
}

.btn {
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  min-height: 44px;
  padding: 10px 15px;
  font-weight: 600;
}

.btn:hover {
  opacity: 0.96;
}

.btn.secondary {
  background: #e3edf9;
  color: var(--ink);
}

.btn.ghost {
  background: #eef2f7;
  color: #2c3f55;
}

.btn.danger {
  background: var(--negative);
}

.btn:disabled {
  opacity: 0.65;
}

form {
  display: grid;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid #c8d5e7;
  padding: 10px;
  background: #fff;
}

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

.stat {
  background: var(--surface-muted);
  border-radius: 12px;
  padding: 12px;
}

.stat .label {
  color: var(--muted);
  font-size: 0.74rem;
}

.stat .value {
  margin-top: 5px;
  font-size: 1.05rem;
  font-weight: 700;
}

.value-currency {
  font-size: 1.3rem;
  letter-spacing: 0.2px;
}

.pnl-positive {
  color: var(--positive);
}

.pnl-negative {
  color: var(--negative);
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
}

.meta-line {
  margin-top: 6px;
  font-size: 0.9rem;
  font-weight: 700;
}

.account-card {
  display: grid;
  gap: 14px;
}

.premium-account {
  padding: 18px;
}

.account-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.account-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.account-total {
  font-size: 1.4rem;
  font-weight: 600;
  text-align: right;
  letter-spacing: 0.2px;
}

.account-pl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.holding-grid {
  display: grid;
  gap: 12px;
}

.holdings-empty {
  text-align: center;
  color: var(--muted);
  padding: 22px 10px;
}

.holding-item {
  position: relative;
  background: var(--surface-muted);
  border-radius: 16px;
  padding: 16px 16px 16px 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.holding-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.08);
}

.holding-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 4px;
  background: #d6dce7;
}

.holding-item.tone-positive::before {
  background: rgba(24, 121, 79, 0.5);
}

.holding-item.tone-negative::before {
  background: rgba(180, 58, 81, 0.5);
}

.holding-top,
.holding-bottom {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.holding-bottom {
  margin-top: 12px;
  align-items: center;
}

.holding-name {
  font-size: 0.96rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.holding-meta,
.holding-cost {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.holding-value {
  min-width: 100px;
  text-align: right;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.holding-pill {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  text-align: right;
}

.holding-pill.tone-positive {
  background: var(--positive-soft);
  color: var(--positive);
}

.holding-pill.tone-negative {
  background: var(--negative-soft);
  color: var(--negative);
}

.holding-pill.tone-neutral {
  background: var(--neutral-soft);
  color: #5f6f84;
}

.quote-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #ecf0f5;
  color: #5b6f88;
  font-size: 0.68rem;
  font-weight: 600;
}

.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.text-link {
  background: transparent;
  color: var(--brand);
  border: 0;
  padding: 0;
  font-weight: 600;
}

.account-filter-link {
  justify-self: flex-end;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid #e6edf7;
  padding: 8px 0;
}

.lot-row {
  display: grid;
  gap: 8px;
}

.lot-form {
  display: grid;
  gap: 6px;
}

.confirm-panel {
  background: #fff2f5;
  border: 1px solid #f1c4d0;
  border-radius: 10px;
  padding: 10px;
}

.holdings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.holdings-table th,
.holdings-table td {
  text-align: left;
  padding: 8px 4px;
  border-bottom: 1px solid #e6edf7;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.tab {
  border: 0;
  border-radius: 10px;
  min-height: 44px;
  background: #eaf1fa;
}

.tab.active {
  background: var(--brand);
  color: #fff;
}

.toast-host {
  position: fixed;
  right: 10px;
  left: 10px;
  bottom: 94px;
  z-index: 40;
  display: grid;
  gap: 8px;
}

.toast {
  padding: 10px 12px;
  border-radius: 10px;
  color: #fff;
  background: #22384f;
}

.toast.error {
  background: var(--negative);
}

@media (min-width: 860px) {
  body {
    max-width: 860px;
    margin: 0 auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

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

@media (min-width: 900px) {
  .holding-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
