:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-subtle: #f8f9fa;
  --surface-blue: #f4f8ff;
  --border: #e4e7eb;
  --border-strong: #d6d9de;
  --text: #202124;
  --muted: #5f6368;
  --muted-light: #8a9098;
  --blue: #1a73e8;
  --blue-hover: #1765cc;
  --green: #137333;
  --red: #c5221f;
  --yellow: #f9ab00;
  --shadow: 0 10px 30px rgba(32, 33, 36, 0.12);
  --radius: 18px;
  --font: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

.auth-view {
  min-height: 100vh;
  padding: 32px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 15%, rgba(26, 115, 232, 0.09), transparent 32%),
    radial-gradient(circle at 82% 78%, rgba(19, 115, 51, 0.05), transparent 30%),
    #fff;
}

.login-card {
  width: min(440px, 100%);
  padding: 44px 42px 38px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 55px rgba(32, 33, 36, 0.12);
  text-align: center;
}

.login-brand-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 24px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: var(--surface-blue);
}

.login-brand-mark svg {
  width: 32px;
  fill: currentColor;
}

.login-eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-card h1 {
  margin: 8px 0 10px;
  font-size: 36px;
  letter-spacing: -1px;
}

.login-card > p {
  max-width: 330px;
  margin: 0 auto 28px;
  color: var(--muted);
}

.google-login-button {
  width: 100%;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 11px;
  color: var(--text);
  background: #fff;
  font-weight: 700;
}

.google-login-button:hover {
  border-color: #b8c7df;
  background: var(--surface-blue);
}

.google-login-button svg {
  width: 20px;
}

.google-login-button svg path:nth-child(1) { fill: #4285f4; }
.google-login-button svg path:nth-child(2) { fill: #34a853; }
.google-login-button svg path:nth-child(3) { fill: #fbbc05; }
.google-login-button svg path:nth-child(4) { fill: #ea4335; }

.login-status {
  min-height: 20px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
}

.login-status.is-error {
  color: var(--red);
}

.app-shell {
  width: min(1480px, calc(100% - 48px));
  margin: 0 auto;
  padding: 0 0 56px;
}

.topbar {
  min-height: 112px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: end;
  gap: 24px;
  border-bottom: 1px solid var(--border);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 22px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface-blue);
  color: var(--blue);
}

.brand-mark svg {
  width: 24px;
  fill: currentColor;
}

.brand-block h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.4px;
}

.brand-block p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.top-tabs {
  display: flex;
  align-items: flex-end;
  height: 100%;
  gap: 4px;
}

.tab {
  position: relative;
  height: 56px;
  padding: 0 22px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  font-weight: 600;
}

.tab.is-active {
  color: var(--text);
}

.tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--blue);
}

.tab span {
  margin-left: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  color: #fff;
  background: var(--blue);
  font-size: 11px;
  font-weight: 700;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding-bottom: 18px;
}

.icon-button,
.close-button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.icon-button:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.icon-button svg {
  width: 21px;
  fill: currentColor;
}

.icon-button.is-spinning svg {
  animation: spin 0.8s linear infinite;
}

.auth-button,
.primary-button,
.secondary-button,
.danger-button {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 700;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.auth-button,
.primary-button {
  color: #fff;
  background: var(--blue);
}

.auth-button:hover,
.primary-button:hover {
  background: var(--blue-hover);
}

.primary-button svg {
  width: 18px;
  fill: currentColor;
}

.secondary-button {
  color: var(--blue);
  background: #fff;
  border-color: var(--border-strong);
}

.secondary-button:hover {
  background: var(--surface-blue);
}

.danger-button {
  color: var(--red);
  background: #fff;
  border-color: #f1c7c6;
}

.danger-button:hover {
  background: #fce8e6;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 28px 0 18px;
}

.summary-card {
  min-height: 142px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.summary-primary {
  background: var(--surface-blue);
  border-color: #d8e7ff;
}

.summary-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.summary-value {
  margin-top: 12px;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1;
  font-weight: 500;
  letter-spacing: -1.2px;
}

.summary-secondary {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.summary-secondary .dot {
  padding: 0 7px;
}

.is-positive {
  color: var(--green) !important;
}

.is-negative {
  color: var(--red) !important;
}

.control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  min-height: 64px;
  margin-bottom: 14px;
}

.market-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.market-status strong {
  color: var(--text);
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-light);
}

.status-dot.is-live {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(19, 115, 51, 0.1);
}

.separator {
  color: #bdc1c6;
}


.position-editor {
  margin: -2px 0 18px;
  padding: 14px;
  border: 1px solid #d8e7ff;
  border-radius: 14px;
  background: var(--surface-blue);
  overflow-x: auto;
}

.position-inline-form {
  min-width: 1160px;
  display: grid;
  grid-template-columns:
    minmax(110px, 1.2fr)
    76px
    88px
    104px
    82px
    104px
    58px
    104px
    minmax(112px, 1.1fr)
    76px
    auto;
  gap: 8px;
  align-items: end;
}

.inline-field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.inline-field > span {
  padding-left: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.inline-field input,
.inline-field select {
  width: 100%;
  height: 38px;
  padding: 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  outline: none;
  font-size: 13px;
}

.inline-field input:focus,
.inline-field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.13);
}

.inline-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.compact-primary-button,
.compact-secondary-button,
.compact-danger-button {
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.compact-primary-button {
  min-width: 58px;
  border: 1px solid var(--blue);
  color: #fff;
  background: var(--blue);
}

.compact-primary-button:hover { background: var(--blue-hover); }

.compact-secondary-button {
  border: 1px solid var(--border-strong);
  color: var(--text);
  background: #fff;
}

.compact-danger-button {
  border: 1px solid #f1c7c6;
  color: var(--red);
  background: #fff;
}

#addPositionButton.is-active {
  background: var(--blue-hover);
}

.notice {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 10px;
  color: #174ea6;
  background: #e8f0fe;
  font-size: 13px;
}

.notice.is-error {
  color: #8c1d18;
  background: #fce8e6;
}

.is-hidden {
  display: none !important;
}

.portfolio-sections {
  display: grid;
  gap: 26px;
}

.currency-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.currency-heading {
  min-height: 74px;
  padding: 17px 20px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.currency-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.currency-badge {
  min-width: 49px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--blue);
  background: var(--surface-blue);
  font-size: 13px;
  font-weight: 800;
}

.currency-title h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.2px;
}

.currency-title p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.currency-total {
  text-align: right;
}

.currency-total strong {
  display: block;
  font-size: 19px;
  font-weight: 500;
}

.currency-total span {
  color: var(--muted);
  font-size: 12px;
}

.table-scroll {
  overflow-x: auto;
}

.portfolio-table {
  width: 100%;
  min-width: 1030px;
  border-collapse: collapse;
}

.portfolio-table th {
  height: 48px;
  padding: 0 16px;
  color: var(--muted);
  background: #fff;
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.portfolio-table th:first-child,
.portfolio-table td:first-child {
  padding-left: 20px;
  text-align: left;
}

.portfolio-table th:last-child,
.portfolio-table td:last-child {
  padding-right: 14px;
}

.portfolio-table td {
  height: 62px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
}

.portfolio-table tbody tr:last-child td {
  border-bottom: 0;
}

.portfolio-table tbody tr {
  transition: background 0.15s ease;
}

.portfolio-table tbody tr:hover {
  background: #fafafa;
}

.symbol-cell {
  min-width: 260px;
}

.symbol-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.symbol-main {
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.15px;
}

.symbol-subtitle {
  max-width: 260px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.position-chip {
  padding: 2px 7px;
  border-radius: 999px;
  color: #3c4043;
  background: #f1f3f4;
  font-size: 10px;
  font-weight: 800;
}

.position-chip.short {
  color: #8c1d18;
  background: #fce8e6;
}

.number-primary {
  color: var(--text);
  font-size: 15px;
}

.number-secondary {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.price-auto {
  color: var(--blue);
  font-weight: 700;
}

.price-error {
  color: var(--red);
}

.allocation-cell {
  min-width: 134px;
}

.allocation-value {
  font-size: 15px;
}

.allocation-track {
  width: 88px;
  height: 4px;
  margin: 7px 0 0 auto;
  border-radius: 99px;
  background: #e8eaed;
  overflow: hidden;
}

.allocation-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.row-action {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  font-size: 22px;
  line-height: 1;
}

.row-action:hover {
  color: var(--text);
  background: #eef0f2;
}

.section-footer {
  min-height: 58px;
  padding: 11px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 28px;
  color: var(--muted);
  background: #fbfbfb;
  font-size: 12px;
}

.section-footer strong {
  margin-left: 7px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.empty-state {
  padding: 78px 20px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.empty-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: var(--blue);
  background: var(--surface-blue);
}

.empty-icon svg {
  width: 30px;
  fill: currentColor;
}

.empty-state h3 {
  margin: 18px 0 6px;
  font-size: 20px;
}

.empty-state p {
  max-width: 470px;
  margin: 0;
  color: var(--muted);
}

.empty-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.dialog {
  width: min(760px, calc(100% - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.dialog::backdrop {
  background: rgba(32, 33, 36, 0.46);
  backdrop-filter: blur(2px);
}

.dialog-card {
  max-height: calc(100vh - 40px);
  padding: 24px;
  overflow-y: auto;
  background: #fff;
}

.dialog-card-small {
  max-width: 520px;
  margin: 0 auto;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 22px;
}

.dialog-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.close-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
}

.close-button:hover {
  background: var(--surface-subtle);
}

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

.form-grid.one-column {
  grid-template-columns: 1fr;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.form-grid label > span {
  color: #3c4043;
  font-size: 12px;
  font-weight: 700;
}

.form-grid input,
.form-grid select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.form-grid input:focus,
.form-grid select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

.form-grid small {
  color: var(--muted);
  font-size: 11px;
}

.calculation-preview {
  margin-top: 18px;
  padding: 13px 14px;
  border-radius: 10px;
  color: #3c4043;
  background: var(--surface-subtle);
  font-size: 12px;
}

.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
}

.dialog-spacer {
  flex: 1;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 920px) {
  .app-shell {
    width: min(100% - 28px, 1480px);
  }

  .topbar {
    grid-template-columns: 1fr auto;
    align-items: center;
    min-height: 82px;
  }

  .brand-block,
  .top-actions {
    padding-bottom: 0;
  }

  .top-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    order: 3;
    height: 52px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-card {
    min-height: 118px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: calc(100% - 20px);
  }

  .brand-mark {
    display: none;
  }

  .brand-block h1 {
    font-size: 21px;
  }

  .top-actions .icon-button {
    display: none;
  }

  .auth-button {
    padding: 0 13px;
  }

  .tab {
    padding: 0 14px;
    font-size: 15px;
  }

  .summary-grid {
    padding-top: 18px;
  }

  .control-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .primary-button {
    min-height: 42px;
  }

  .control-row > .primary-button {
    width: 100%;
  }

  .currency-heading {
    align-items: flex-start;
  }

  .currency-total strong {
    font-size: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .dialog-card {
    padding: 20px;
  }

  .empty-actions {
    width: 100%;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .auth-view { padding: 18px; }
  .login-card { padding: 36px 24px 30px; }
}
