@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("assets/fonts/source-sans-3-latin.woff2") format("woff2-variations");
}

:root {
  color-scheme: light;
  --bg: #f4f8fc;
  --surface: #ffffff;
  --surface-2: #eaf3fa;
  --ink: #10243a;
  --muted: #5e7185;
  --line: #cfdfea;
  --primary: #1686e8;
  --primary-dark: #0868c2;
  --primary-soft: #e3f3ff;
  --loss: #b73535;
  --loss-soft: #f6dfdd;
  --gain: #168f61;
  --gain-soft: #dcf5e9;
  --warn: #9a6715;
  --warn-soft: #f8ecd3;
  --focus: #1686e8;
  --shadow: 0 18px 45px rgba(16, 36, 58, 0.09);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #081522;
  --surface: #102438;
  --surface-2: #173149;
  --ink: #edf7ff;
  --muted: #a8c0d4;
  --line: #29465f;
  --primary: #46b8ff;
  --primary-dark: #7bd0ff;
  --primary-soft: #123a59;
  --loss: #ff8b86;
  --loss-soft: #3a201f;
  --gain: #55dda2;
  --gain-soft: #123d2d;
  --warn: #e1b66c;
  --warn-soft: #3a2d18;
  --focus: #46b8ff;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Source Sans 3", "Source Sans Pro", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  overflow-x: hidden;
}

body.modal-open {
  overflow: hidden;
  overscroll-behavior: none;
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-screen {
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: var(--bg);
}

.auth-card {
  width: min(100%, 430px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-logo {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.auth-card h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

.auth-card > p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.auth-submit {
  width: 100%;
  margin-top: 2px;
}

.auth-switch {
  margin: 3px 0 0;
  color: var(--muted);
  text-align: center;
}

.auth-switch button {
  border: 0;
  color: var(--primary);
  background: transparent;
  font-weight: 900;
}

.auth-status {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-weight: 800;
  line-height: 1.35;
}

.auth-status.is-error {
  color: var(--loss);
  background: var(--loss-soft);
}

.captcha-box {
  min-height: 78px;
  display: grid;
  align-items: center;
  max-width: 100%;
}

.captcha-box.is-scaled {
  align-items: start;
  overflow: hidden;
}

.captcha-box:empty {
  min-height: 0;
}

.captcha-warning {
  min-height: auto;
  padding: 10px 12px;
  border: 1px solid #e4c4c2;
  border-radius: 8px;
  color: var(--loss);
  background: var(--loss-soft);
  font-weight: 800;
  line-height: 1.35;
}

.internal-captcha {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  width: 100%;
}

.internal-captcha label {
  min-width: 0;
}

.internal-captcha input {
  margin-top: 5px;
}

.captcha-refresh {
  min-width: 38px;
  min-height: 38px;
}

.totp-setup {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfe;
}

.totp-setup strong {
  font-size: 14px;
}

.totp-setup p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.totp-qr {
  width: min(100%, 220px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.totp-qr-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.totp-setup code {
  display: block;
  max-width: 100%;
  padding: 8px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-2);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.session-button {
  min-width: 0;
  min-height: 38px;
  padding-inline: 10px;
  white-space: nowrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: rgba(8, 21, 34, 0.62);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal {
  width: min(100%, 980px);
  max-height: min(88vh, 860px);
  max-height: min(88dvh, 860px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal:focus {
  outline: none;
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.modal-head h2,
.modal-head p {
  margin: 0;
}

.password-modal {
  width: min(100%, 520px);
}

.csv-import-modal {
  width: min(100%, 920px);
}

.csv-import-form {
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) minmax(260px, 1.6fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.csv-import-form input[type="file"] {
  min-height: 38px;
  padding: 6px 8px;
  overflow: visible;
  white-space: normal;
}

.csv-import-form input[type="file"]::file-selector-button,
.csv-import-form input[type="file"]::-webkit-file-upload-button {
  min-height: 30px;
  margin-right: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface-2);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.csv-import-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  margin: 16px;
  border-block: 1px solid var(--line);
}

.csv-import-summary-item {
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
  text-align: center;
}

.csv-import-summary-item:last-child {
  border-right: 0;
}

.csv-import-summary-item span,
.csv-import-summary-item strong {
  display: block;
  overflow: visible;
  overflow-wrap: anywhere;
  white-space: normal;
}

.csv-import-summary-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.csv-import-summary-item strong {
  margin-top: 2px;
  color: var(--ink);
  font-size: 20px;
}

.csv-import-preview {
  padding: 0 16px 16px;
}

.csv-import-preview .table-wrap {
  max-height: 360px;
  overflow-y: auto;
}

.csv-preview-table th,
.csv-preview-table td {
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.csv-preview-table th:nth-child(1),
.csv-preview-table td:nth-child(1) { width: 12%; }
.csv-preview-table th:nth-child(2),
.csv-preview-table td:nth-child(2) { width: 11%; }
.csv-preview-table th:nth-child(3),
.csv-preview-table td:nth-child(3) { width: 16%; }
.csv-preview-table th:nth-child(4),
.csv-preview-table td:nth-child(4) { width: 25%; }
.csv-preview-table th:nth-child(5),
.csv-preview-table td:nth-child(5) { width: 13%; }
.csv-preview-table th:nth-child(6),
.csv-preview-table td:nth-child(6) { width: 13%; }
.csv-preview-table th:nth-child(7),
.csv-preview-table td:nth-child(7) { width: 10%; }

.csv-import-issues {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--loss);
  color: var(--muted);
  background: var(--loss-soft);
  overflow-wrap: anywhere;
}

.csv-import-issues p {
  margin: 0;
}

.csv-import-issues p + p {
  margin-top: 5px;
}

.password-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.password-form .button {
  width: 100%;
}

.password-form .admin-status {
  margin: 0;
}

.modal-head h2 {
  font-size: 19px;
  line-height: 1.2;
}

.modal-head p {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.admin-overview {
  display: grid;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.admin-overview-head,
.admin-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.admin-overview-head h3,
.admin-overview-head p,
.admin-overview-panel-head h3,
.admin-overview-panel-head p,
.admin-section-head h3,
.admin-section-head p {
  margin: 0;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.admin-overview-head h3,
.admin-section-head h3 {
  font-size: 16px;
}

.admin-overview-head p,
.admin-section-head p,
.admin-overview-panel-head p {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.4;
}

.admin-version {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--primary-dark);
  background: var(--surface);
  font-size: 12px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.admin-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.admin-summary-item {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  text-align: center;
}

.admin-summary-item span,
.admin-summary-item strong,
.admin-summary-item small {
  display: block;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.admin-summary-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-summary-item strong {
  margin-top: 2px;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.15;
}

.admin-summary-item small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

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

.admin-overview-panel {
  min-width: 0;
}

.admin-overview-panel + .admin-overview-panel {
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.admin-overview-panel-head {
  margin-bottom: 8px;
}

.admin-overview-panel-head h3 {
  font-size: 14px;
}

.admin-overview-panel-head p {
  font-size: 12px;
}

.admin-control-list {
  display: grid;
}

.admin-control-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.admin-control-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.admin-control-dot.is-success { background: var(--gain); }
.admin-control-dot.is-warning { background: var(--warn); }
.admin-control-dot.is-danger { background: var(--loss); }
.admin-control-dot.is-info { background: var(--primary); }
.admin-control-dot.is-inactive { background: var(--muted); }

.admin-control-copy {
  min-width: 0;
}

.admin-control-copy strong,
.admin-control-copy span {
  display: block;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.admin-control-copy strong {
  font-size: 13px;
}

.admin-control-copy span {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.admin-state-badge {
  max-width: 112px;
  padding: 3px 7px;
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.25;
  overflow: visible;
  overflow-wrap: anywhere;
  text-align: center;
  white-space: normal;
}

.admin-state-badge.is-success {
  color: var(--gain);
  background: var(--gain-soft);
}

.admin-state-badge.is-warning {
  color: var(--warn);
  background: var(--warn-soft);
}

.admin-state-badge.is-danger {
  color: var(--loss);
  background: var(--loss-soft);
}

.admin-state-badge.is-info {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.admin-section-head {
  padding: 14px 16px 0;
}

.admin-section-head p {
  font-size: 12px;
}

.admin-create-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.admin-create-form .button {
  align-self: end;
}

.admin-status {
  margin: 14px 16px 0;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-weight: 800;
}

.admin-status.is-error {
  color: var(--loss);
  background: var(--loss-soft);
}

.admin-user-list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.admin-empty {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.admin-user-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-user-card.is-inactive {
  border-color: var(--warn);
}

.admin-user-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.admin-user-identity strong,
.admin-user-identity span,
.admin-user-identity small {
  display: block;
  max-width: 100%;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.admin-user-identity span,
.admin-user-identity small {
  margin-top: 3px;
  color: var(--muted);
}

.admin-user-identity strong {
  font-size: 16px;
  line-height: 1.2;
}

.admin-user-identity small {
  font-size: 11px;
}

.admin-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 900;
  overflow-wrap: anywhere;
  white-space: normal;
}

.admin-badge.is-admin {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.admin-badge.is-active,
.admin-badge.is-success {
  color: var(--gain);
  background: var(--gain-soft);
}

.admin-badge.is-open,
.admin-badge.is-warning {
  color: var(--warn);
  background: var(--warn-soft);
}

.admin-badge.is-off,
.admin-badge.is-danger {
  color: var(--loss);
  background: var(--loss-soft);
}

.admin-user-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.admin-user-status-panel {
  min-width: 0;
}

.admin-user-status-panel + .admin-user-status-panel {
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.admin-user-status-head {
  margin-bottom: 6px;
}

.admin-user-status-head h4,
.admin-user-status-head span,
.admin-user-edit-head h4 {
  margin: 0;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.admin-user-status-head h4,
.admin-user-edit-head h4 {
  font-size: 13px;
}

.admin-user-status-head span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.admin-user-edit-head {
  padding-top: 2px;
}

.admin-user-fields,
.admin-user-actions {
  display: grid;
  grid-template-columns: 1.4fr 1.2fr minmax(110px, 0.7fr) minmax(86px, 0.5fr) auto;
  gap: 10px;
  align-items: end;
}

.admin-user-actions {
  grid-template-columns: 1fr repeat(3, auto);
}

.admin-active-toggle {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.admin-active-toggle input {
  width: auto;
  min-height: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 68px;
  padding: max(10px, env(safe-area-inset-top)) max(clamp(14px, 3vw, 30px), env(safe-area-inset-right)) 10px max(clamp(14px, 3vw, 30px), env(safe-area-inset-left));
  background: rgba(244, 248, 252, 0.94);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

:root[data-theme="dark"] .topbar {
  background: rgba(8, 21, 34, 0.95);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: #fff;
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  overflow: visible;
  box-shadow: 0 8px 20px rgba(22, 134, 232, 0.18);
}

.brand-mark img {
  width: 46px;
  height: 46px;
  display: block;
  border-radius: 12px;
  object-fit: contain;
}

.auth-logo {
  width: 58px;
  height: 58px;
}

.auth-logo img {
  width: 58px;
  height: 58px;
  border-radius: 14px;
}

.brand h1,
.brand p,
.section-head h2,
.panel-heading h2 {
  margin: 0;
}

.brand h1 {
  font-size: 21px;
  line-height: 1.1;
}

.brand-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid #cfe5f5;
  border-radius: 999px;
  color: #52728d;
  background: #edf7ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

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

.header-account-control {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 1 280px;
  min-width: 220px;
  max-width: 320px;
}

.header-account-select {
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  min-height: 34px;
  padding: 0 28px 0 9px;
  font-size: 13px;
  font-weight: 800;
}

.header-account-add,
.header-account-delete {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 19px;
  line-height: 1;
}

.header-account-quick-form {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  z-index: 30;
  width: min(320px, calc(100vw - 20px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 36px rgba(16, 36, 58, 0.2);
}

.header-account-quick-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.header-account-form-actions {
  display: flex;
  gap: 7px;
  margin-top: 9px;
}

.header-account-form-actions .button {
  flex: 1 1 0;
}

.market-clock-strip {
  display: flex;
  align-items: stretch;
  gap: 5px;
  flex: 1 1 540px;
  max-width: 760px;
  min-width: 0;
}

.market-clock {
  display: grid;
  grid-template-areas:
    "flag city"
    "flag time"
    "flag hours";
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1px;
  flex: 1 1 0;
  min-width: 0;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

:root[data-theme="dark"] .market-clock {
  background: rgba(255, 255, 255, 0.05);
}

.market-clock-flag {
  grid-area: flag;
  align-self: center;
  margin-right: 4px;
  width: 18px;
  height: 12px;
  display: block;
  border: 1px solid rgba(16, 36, 58, 0.18);
  border-radius: 2px;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 1px 2px rgba(16, 36, 58, 0.08);
}

.market-clock-city {
  grid-area: city;
}

.market-clock-time {
  grid-area: time;
}

.market-clock-hours {
  grid-area: hours;
}

.market-clock-city,
.market-clock-hours {
  overflow: visible;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: normal;
  text-overflow: clip;
  white-space: nowrap;
}

.market-clock-time {
  overflow: visible;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.1;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.top-actions,
.section-head,
.tabs,
.split {
  display: flex;
  align-items: center;
}

.top-actions {
  align-self: flex-start;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.alpha-usage {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  overflow: visible;
  overflow-wrap: normal;
  text-overflow: clip;
  white-space: nowrap;
}

.alpha-usage.is-warning {
  color: var(--warn);
  background: var(--warn-soft);
}

.alpha-usage.is-exhausted {
  color: var(--loss);
  background: var(--loss-soft);
}

.top-actions .button {
  min-height: 34px;
  padding-right: 10px;
  padding-left: 10px;
}

.top-actions .button-icon-only {
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 700;
  text-decoration: none;
  overflow-wrap: anywhere;
  white-space: normal;
}

.button:focus-visible,
.tab:focus-visible,
input:focus-visible,
select:focus-visible,
.chart-range:focus-visible,
.auth-switch button:focus-visible,
.action-menu:focus-visible {
  outline: 3px solid rgba(22, 134, 232, 0.24);
  outline-offset: 2px;
}

@supports not selector(:focus-visible) {
  button:focus,
  input:focus,
  select:focus {
    outline: 3px solid rgba(22, 134, 232, 0.24);
    outline-offset: 2px;
  }
}

.button-primary {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.button-danger {
  border-color: #e4c4c2;
  color: var(--loss);
  background: #fff7f6;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

@media (hover: hover) and (pointer: fine) {
  .button:hover {
    border-color: #b9cede;
    background: #f8fbfe;
  }

  .button-primary:hover {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
  }

  :root[data-theme="dark"] .button:hover {
    background: #142b40;
  }

  :root[data-theme="dark"] .button-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
  }
}

.button-icon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  font-size: 12px;
  line-height: 1;
}

.button:not(.button-primary) .button-icon {
  color: var(--primary);
  background: var(--primary-soft);
}

.button-icon-only {
  width: 42px;
  min-width: 42px;
  padding: 0;
}

.button-icon-only .button-icon {
  width: 22px;
  height: 22px;
  background: transparent;
  font-size: 19px;
}

.button-icon-only.is-loading .refresh-icon {
  animation: refresh-spin 0.8s linear infinite;
}

.admin-nav-button {
  min-width: 132px;
}

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

.file-button input {
  width: 1px;
  height: 1px;
  overflow: hidden;
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.shell {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 12px max(clamp(10px, 2.4vw, 24px), env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(clamp(10px, 2.4vw, 24px), env(safe-area-inset-left));
}

.summary-band {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.summary-row {
  display: grid;
  min-width: 0;
  gap: 6px;
  align-items: stretch;
}

.summary-row-market {
  grid-template-columns: minmax(0, 1fr);
}

.summary-row-values,
.summary-row-performance {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-row .metric-card {
  height: 100%;
}

.metric-card,
.content {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  align-self: start;
  min-width: 0;
  min-height: 60px;
  padding: 6px 8px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  white-space: normal;
}

.metric-card strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  line-height: 1.12;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: normal;
}

.metric-card small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.18;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  white-space: normal;
}

#summaryBand .metric-card > span,
#summaryBand .metric-card > strong,
#summaryBand .metric-card > small,
#overviewPanel .metric-card > span,
#overviewPanel .metric-card > strong,
#overviewPanel .metric-card > small {
  overflow-wrap: normal;
  white-space: nowrap;
}

.metric-card strong span,
.metric-card small span {
  display: inline;
  font-size: inherit;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

/* Keep signed performance values visible over the generic card typography. */
.metric-card .gain {
  color: var(--gain);
}

.metric-card .loss {
  color: var(--loss);
}

.metric-card .trade-outcome,
.metric-card .trade-outcome span {
  display: inline;
  font-size: inherit;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.market-widget {
  grid-column: auto;
}

#summaryBand .market-widget > span {
  font-size: 11px;
}

.market-overview-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin-top: 4px;
}

.market-overview-item {
  display: grid;
  grid-template-columns: minmax(64px, 1fr) auto;
  gap: 1px 6px;
  min-width: 0;
  min-height: 38px;
  padding: 5px 10px;
  align-items: baseline;
  border-left: 1px solid var(--line);
}

.market-overview-item:nth-child(4n + 1) {
  border-left: 0;
}

.market-overview-item:nth-child(n + 5) {
  border-top: 1px solid var(--line);
}

.market-overview-name {
  min-width: 0;
  overflow: visible;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.15;
  text-overflow: clip;
  text-transform: uppercase;
  overflow-wrap: normal;
  white-space: nowrap;
}

.market-overview-value {
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.15;
  text-align: right;
  overflow-wrap: normal;
  white-space: nowrap;
}

.market-source,
.quote-source {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
}

.market-source {
  margin-left: 3px;
  vertical-align: super;
}

.numeric .quote-source {
  margin-top: 2px;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.market-overview-change {
  grid-column: 1 / -1;
  margin-top: 0 !important;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.15;
  text-align: right;
  overflow-wrap: normal;
  white-space: nowrap;
}

.market-overview-empty {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.market-overview-list .market-overview-name,
.market-overview-list .market-overview-value,
.market-overview-list .market-overview-change,
.market-overview-list .market-overview-change span {
  font-size: 11px;
  overflow-wrap: normal;
  white-space: nowrap;
}

.market-overview-list .market-overview-change span {
  display: inline;
  font-size: inherit;
  text-transform: none;
}

.workspace {
  display: block;
}

.content {
  min-width: 0;
}

.panel-heading,
.section-head {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-heading h2,
.section-head h2 {
  font-size: 17px;
  line-height: 1.2;
}

.content {
  padding: 12px;
}

.tabs {
  gap: 4px;
  padding: 3px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  flex-wrap: nowrap;
  overflow: visible;
}

.tab {
  flex: 1 1 120px;
  min-width: 0;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  overflow-wrap: normal;
  white-space: nowrap;
}

.tab.is-active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 6px rgba(16, 36, 58, 0.08);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.status-pill,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 800;
  overflow-wrap: normal;
  white-space: nowrap;
}

.pill-gain {
  color: var(--gain);
  background: var(--gain-soft);
}

.pill-loss {
  color: var(--loss);
  background: var(--loss-soft);
}

.pill-warn {
  color: var(--warn);
  background: var(--warn-soft);
}

.metrics-grid,
.cash-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 6px;
  margin-bottom: 6px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 6px;
  margin-bottom: 6px;
}

#overviewPanel .metrics-grid .metric-card,
#overviewPanel .analytics-grid .metric-card {
  min-height: 52px;
  padding: 5px 7px;
  text-align: center;
}

#overviewPanel > .section-head {
  margin-bottom: 6px;
}

.overview-card {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.portfolio-card-grid {
  display: grid;
  grid-template-columns: minmax(400px, 0.72fr) minmax(0, 1.28fr);
  gap: 8px;
  align-items: start;
}

.overview-summary-card {
  grid-column: 1 / -1;
}

.overview-summary-card .section-head {
  margin-bottom: 4px;
}

.overview-subheading {
  margin: 5px 0 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.15;
  text-transform: uppercase;
  white-space: nowrap;
}

.overview-summary-card .metrics-grid,
.overview-summary-card .analytics-grid {
  gap: 0;
  margin-bottom: 0;
  border-top: 1px solid var(--line);
}

.overview-summary-card .metric-card {
  min-height: 50px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.overview-summary-card .metrics-grid .metric-card:first-child,
.overview-summary-card .analytics-grid .metric-card:nth-child(5n + 1) {
  border-left: 0;
}

.overview-summary-card .analytics-grid .metric-card:nth-child(n + 6) {
  border-top: 1px solid var(--line);
}

.chart-panel {
  margin-bottom: 0;
}

.overview-holdings-panel h3 {
  margin: 0 0 4px;
  font-size: 13px;
  white-space: nowrap;
}

.chart-panel h3 {
  margin: 0;
  font-size: 13px;
  white-space: nowrap;
}

.chart-panel h4 {
  margin: 6px 0 3px;
  font-size: 12px;
  white-space: nowrap;
}

.chart-legend {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 22px;
  height: 3px;
}

.legend-account { background: var(--primary); }
.legend-benchmark { background: var(--warn); }

.chart-controls {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  margin: 0 0 4px;
}

.chart-range {
  min-height: 26px;
  min-width: 36px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f6faff;
  font-size: 11px;
  font-weight: 900;
}

.chart-range.is-active {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.portfolio-chart {
  min-height: 180px;
}

.portfolio-chart-svg {
  display: block;
  width: 100%;
  height: 180px;
}

.chart-grid {
  stroke: #d8e7f2;
  stroke-width: 1;
}

.chart-zero-line {
  stroke: var(--ink);
  stroke-dasharray: 5 5;
  stroke-opacity: 0.52;
  stroke-width: 1.4;
}

.chart-area {
  fill: url(#portfolioArea);
}

.chart-line {
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chart-benchmark-line {
  fill: none;
  stroke: var(--warn);
  stroke-dasharray: 7 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
}

.equity-chart {
  min-height: 130px;
}

.equity-chart .portfolio-chart-svg {
  height: 130px;
}

.chart-point {
  fill: #fff;
  stroke: var(--primary);
  stroke-width: 2;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.chart-axis-label.is-loss {
  fill: var(--loss);
}

.chart-axis-label.is-gain {
  fill: var(--gain);
}

.empty-chart {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.entry-grid,
.compact-form {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfe;
}

.entry-grid {
  grid-template-columns: repeat(5, minmax(128px, 1fr));
  align-items: end;
}

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

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  line-height: 1.2;
}

select {
  padding-right: 28px;
}

input[type="checkbox"] {
  accent-color: var(--primary);
}

input[type="date"],
input[type="file"] {
  min-width: 0;
  max-width: 100%;
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select {
  color: var(--ink);
  background: #081522;
}

:root[data-theme="dark"] .csv-import-form {
  background: var(--surface-2);
}

:root[data-theme="dark"] .button,
:root[data-theme="dark"] .overview-card,
:root[data-theme="dark"] .table-wrap,
:root[data-theme="dark"] .entry-grid,
:root[data-theme="dark"] .compact-form,
:root[data-theme="dark"] tbody tr,
:root[data-theme="dark"] .totp-setup,
:root[data-theme="dark"] .totp-qr {
  background: var(--surface);
}

:root[data-theme="dark"] .button-primary,
:root[data-theme="dark"] .chart-range.is-active {
  color: #10243a;
  background: var(--primary);
  border-color: var(--primary);
}

:root[data-theme="dark"] .button-danger {
  background: var(--loss-soft);
}

:root[data-theme="dark"] .tabs,
:root[data-theme="dark"] .chart-range,
:root[data-theme="dark"] th,
:root[data-theme="dark"] .summary-row td,
:root[data-theme="dark"] .totp-setup code {
  background: var(--surface-2);
}

:root[data-theme="dark"] .tab.is-active {
  background: var(--surface);
}

input::placeholder {
  color: #9eb2c3;
}

.identifier-input {
  text-transform: uppercase;
}

.wide {
  grid-column: span 2;
}

.form-submit {
  align-self: end;
}

.sale-form {
  grid-template-columns: repeat(6, minmax(130px, 1fr));
}

.quote-form {
  grid-template-columns: repeat(5, minmax(130px, 1fr));
}

.table-wrap {
  width: 100%;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12px;
}

.overview-table th:nth-child(1),
.overview-table td:nth-child(1) { width: 12%; }
.overview-table th:nth-child(2),
.overview-table td:nth-child(2) { width: 17%; }
.overview-table th:nth-child(3),
.overview-table td:nth-child(3) { width: 10%; }
.overview-table th:nth-child(4),
.overview-table td:nth-child(4) { width: 10%; }
.overview-table th:nth-child(5),
.overview-table td:nth-child(5) { width: 10%; }
.overview-table th:nth-child(6),
.overview-table td:nth-child(6) { width: 11%; }
.overview-table th:nth-child(7),
.overview-table td:nth-child(7) { width: 10%; }
.overview-table th:nth-child(8),
.overview-table td:nth-child(8) { width: 10%; }
.overview-table th:nth-child(9),
.overview-table td:nth-child(9) { width: 10%; }

.overview-table th,
.overview-table td {
  text-align: center;
  vertical-align: middle;
  overflow-wrap: normal;
  white-space: nowrap;
}

.overview-table td strong,
.overview-table td small,
.trade-counts-inline {
  display: inline;
  margin-top: 0;
  overflow-wrap: normal;
  white-space: nowrap;
}

.positions-table th:nth-child(1),
.positions-table td:nth-child(1) { width: 7%; }
.positions-table th:nth-child(2),
.positions-table td:nth-child(2) { width: 17%; }
.positions-table th:nth-child(3),
.positions-table td:nth-child(3) { width: 8%; }
.positions-table th:nth-child(4),
.positions-table td:nth-child(4) { width: 7%; }
.positions-table th:nth-child(5),
.positions-table td:nth-child(5) { width: 7%; }
.positions-table th:nth-child(6),
.positions-table td:nth-child(6) { width: 6%; }
.positions-table th:nth-child(7),
.positions-table td:nth-child(7) { width: 8%; }
.positions-table th:nth-child(8),
.positions-table td:nth-child(8) { width: 9%; }
.positions-table th:nth-child(9),
.positions-table td:nth-child(9) { width: 9%; }
.positions-table th:nth-child(10),
.positions-table td:nth-child(10) { width: 9%; }
.positions-table th:nth-child(11),
.positions-table td:nth-child(11) { width: 7%; }
.positions-table th:nth-child(12),
.positions-table td:nth-child(12) { width: 6%; }

.history-table th:nth-child(1),
.history-table td:nth-child(1) { width: 9%; }
.history-table th:nth-child(2),
.history-table td:nth-child(2) { width: 19%; }
.history-table th:nth-child(3),
.history-table td:nth-child(3),
.history-table th:nth-child(4),
.history-table td:nth-child(4) { width: 9%; }
.history-table th:nth-child(5),
.history-table td:nth-child(5) { width: 8%; }
.history-table th:nth-child(6),
.history-table td:nth-child(6),
.history-table th:nth-child(7),
.history-table td:nth-child(7) { width: 10%; }
.history-table th:nth-child(8),
.history-table td:nth-child(8) { width: 11%; }
.history-table th:nth-child(9),
.history-table td:nth-child(9) { width: 6%; }
.history-table th:nth-child(10),
.history-table td:nth-child(10) { width: 9%; }

.cash-table th:nth-child(1),
.cash-table td:nth-child(1) { width: 12%; }
.cash-table th:nth-child(2),
.cash-table td:nth-child(2) { width: 18%; }
.cash-table th:nth-child(3),
.cash-table td:nth-child(3) { width: 12%; }
.cash-table th:nth-child(4),
.cash-table td:nth-child(4) { width: 16%; }
.cash-table th:nth-child(5),
.cash-table td:nth-child(5) { width: 30%; }
.cash-table th:nth-child(6),
.cash-table td:nth-child(6) { width: 12%; }

th,
td {
  min-width: 0;
  max-width: none;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow: visible;
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: normal;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f6faff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.summary-row td {
  background: #f5faff;
  font-weight: 800;
}

td strong {
  display: block;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.comment-line {
  max-width: 44ch;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.position-events {
  display: grid;
  gap: 2px;
  margin-top: 4px;
}

.position-event {
  min-width: 0;
  overflow: visible;
  color: var(--muted);
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.position-event.is-buy {
  color: var(--primary-dark);
}

.position-event.is-sale {
  color: var(--warn);
}

.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.25;
  font-size: 12px;
}

td.numeric {
  max-width: none;
}

.numeric > *,
.numeric span,
.numeric small,
.numeric strong {
  max-width: 100%;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.numeric small {
  font-size: 11px;
  line-height: 1.25;
}

.gain {
  color: var(--gain);
  font-weight: 800;
}

.loss {
  color: var(--loss);
  font-weight: 800;
}

.muted {
  color: var(--muted);
}

.empty-cell {
  height: 88px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.action-menu {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 800;
  text-overflow: clip;
  white-space: normal;
}

.flash {
  animation: flash 700ms ease-out;
}

@keyframes flash {
  from {
    background: var(--primary-soft);
  }
  to {
    background: transparent;
  }
}

@media (max-width: 1180px) {
  .entry-grid,
  .sale-form,
  .quote-form,
  .admin-create-form {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .admin-user-fields,
  .admin-user-actions {
    grid-template-columns: 1fr 1fr;
  }

  .market-overview-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .analytics-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

}

@media (max-width: 860px) {
  .csv-import-form {
    grid-template-columns: 1fr 1.5fr;
  }

  .csv-import-form .button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .header-account-control {
    width: min(100%, 360px);
    max-width: none;
    flex-basis: auto;
  }

  .market-clock-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-width: none;
    flex-basis: auto;
  }

  .top-actions {
    justify-content: stretch;
    width: 100%;
  }

  .top-actions .button,
  .top-actions .file-button {
    flex: 1 1 140px;
  }

  .alpha-usage {
    flex: 0 0 auto;
  }

  .top-actions .session-button {
    flex: 0 0 auto;
    margin-left: auto;
  }

  .metrics-grid,
  .analytics-grid,
  .cash-grid {
    grid-template-columns: 1fr 1fr;
  }

}

@media (max-width: 640px) {
  .button,
  .tab,
  .chart-range,
  .action-menu,
  .auth-switch button {
    min-height: 44px;
  }

  .shell {
    padding-right: max(10px, env(safe-area-inset-right));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .market-clock-strip {
    gap: 4px;
  }

  .market-clock {
    padding: 5px 6px;
  }

  .market-clock-city,
  .market-clock-hours {
    font-size: 9px;
    white-space: nowrap;
  }

  .market-clock-time {
    font-size: 13px;
  }

  .metrics-grid,
  .cash-grid,
  .entry-grid,
  .sale-form,
  .quote-form,
  .admin-create-form,
  .admin-user-fields,
  .admin-user-actions {
    grid-template-columns: 1fr;
  }

  .summary-row-values,
  .summary-row-performance {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  #overviewPanel .analytics-grid .metric-card > small {
    display: none;
  }

  #overviewPanel .analytics-grid .metric-card {
    min-height: 48px;
  }

  #overviewPanel .chart-panel .section-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: start;
    gap: 4px;
  }

  #portfolioChartReturn {
    max-width: 100%;
    font-size: 9px;
  }

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

  .admin-overview-columns {
    grid-template-columns: 1fr;
  }

  .admin-overview-panel + .admin-overview-panel {
    padding-top: 14px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .admin-overview-head,
  .admin-section-head {
    display: grid;
  }

  .admin-version {
    justify-self: start;
  }

  .market-overview-list {
    grid-template-columns: 1fr 1fr;
  }

  .market-overview-item {
    grid-template-columns: minmax(50px, 1fr) auto;
    gap: 1px 4px;
    padding: 5px 4px;
  }

  .market-overview-item:nth-child(4n + 1) {
    border-left: 1px solid var(--line);
  }

  .market-overview-item:nth-child(odd) {
    border-left: 0;
  }

  .market-overview-item:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .admin-user-card-head {
    display: grid;
  }

  .admin-badges {
    justify-content: flex-start;
  }

  .admin-user-status-grid {
    grid-template-columns: 1fr;
  }

  .admin-user-status-panel + .admin-user-status-panel {
    padding-top: 14px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .wide {
    grid-column: auto;
  }

  .csv-import-form,
  .csv-import-summary {
    grid-template-columns: 1fr;
  }

  .csv-import-summary-item {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .csv-import-summary-item:last-child {
    border-bottom: 0;
  }

  .content {
    padding: 9px;
  }

  .modal-backdrop {
    place-items: start center;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .modal {
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }

  input,
  select,
  .csv-import-form input[type="file"] {
    min-height: 44px;
    font-size: 16px;
  }

  .metric-card strong {
    font-size: 14px;
  }

  .summary-band,
  .summary-row,
  .metrics-grid,
  .analytics-grid {
    gap: 5px;
  }

  #summaryBand .metric-card {
    min-height: 50px;
    padding: 5px 6px;
  }

  #summaryBand .metric-card > span,
  #overviewPanel .metric-card > span {
    font-size: 8px;
  }

  #summaryBand .metric-card > small,
  #overviewPanel .metric-card > small {
    font-size: 8px;
  }

  .portfolio-chart,
  .portfolio-chart-svg {
    min-height: 170px;
    height: 170px;
  }

  .equity-chart,
  .equity-chart .portfolio-chart-svg {
    min-height: 125px;
    height: 125px;
  }
}

@media (max-width: 440px) {
  .version-badge {
    display: none;
  }

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

  .admin-control-item {
    grid-template-columns: 10px minmax(0, 1fr);
  }

  .admin-state-badge {
    grid-column: 2;
    justify-self: start;
    max-width: 100%;
  }
}

@media (max-width: 900px) {
  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  table {
    min-width: 0;
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0 10px;
  }

  th,
  td {
    width: auto !important;
    max-width: none;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tbody tr {
    overflow: visible;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(16, 36, 58, 0.07);
  }

  td {
    display: grid;
    grid-template-columns: minmax(105px, 38%) 1fr;
    gap: 12px;
    align-items: start;
    min-height: 42px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
  }

  td.numeric {
    text-align: left;
  }

  td > * {
    min-width: 0;
  }

  td.empty-cell {
    display: block;
    height: auto;
    min-height: 88px;
    padding: 28px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-align: center;
  }

  td.empty-cell::before {
    content: "";
  }

  .action-menu {
    max-width: 180px;
  }
}

/* The account overview is a compact metric list beside the charts. */
.overview-holdings-panel .table-wrap {
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.overview-holdings-panel .overview-table {
  table-layout: auto;
  border-collapse: collapse;
  border-spacing: 0;
}

.overview-holdings-panel .overview-table thead {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.overview-holdings-panel .overview-table tbody {
  display: grid;
  gap: 0;
}

.overview-holdings-panel .overview-table tr {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0 6px;
  width: 100%;
  padding: 5px 0;
  overflow: visible;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.overview-holdings-panel .overview-table tr:first-child {
  padding-top: 2px;
}

.overview-holdings-panel .overview-table tr:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.overview-holdings-panel .overview-table td {
  display: block;
  width: auto !important;
  min-width: 0;
  min-height: 0;
  padding: 3px 2px;
  border: 0;
  background: transparent;
  font-size: 10px;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: normal;
  white-space: nowrap;
}

.overview-holdings-panel .overview-table td::before {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  content: attr(data-label);
  font-size: 8px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
  overflow-wrap: normal;
  white-space: nowrap;
}

.overview-holdings-panel .overview-table td:first-child,
.overview-holdings-panel .overview-table td:nth-child(2) {
  text-align: left;
}

.overview-holdings-panel .overview-table td:first-child {
  grid-column: 1 / 2;
}

.overview-holdings-panel .overview-table td:nth-child(2) {
  grid-column: 2 / -1;
}

.overview-holdings-panel .overview-table td:first-child::before,
.overview-holdings-panel .overview-table td:nth-child(2)::before {
  display: inline;
  margin-right: 6px;
}

.overview-holdings-panel .overview-table td strong,
.overview-holdings-panel .overview-table td small,
.overview-holdings-panel .trade-counts-inline,
.overview-holdings-panel .trade-counts-inline span {
  display: inline;
  margin: 0;
  font-size: inherit;
  overflow-wrap: normal;
  white-space: nowrap;
}

@media (max-width: 1120px) {
  .portfolio-card-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .overview-holdings-panel {
    order: 1;
  }

  .overview-holdings-panel .overview-table tr {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .overview-holdings-panel .overview-table td:first-child {
    grid-column: 1 / 3;
  }

  .overview-holdings-panel .overview-table td:nth-child(2) {
    grid-column: 3 / -1;
  }

  .portfolio-card-grid .chart-panel {
    order: 2;
  }
}

@media (min-width: 861px) and (max-width: 1180px) {
  .overview-summary-card .analytics-grid .metric-card {
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .overview-summary-card .analytics-grid .metric-card:nth-child(3n + 1) {
    border-left: 0;
  }

  .overview-summary-card .analytics-grid .metric-card:nth-child(n + 4) {
    border-top: 1px solid var(--line);
  }
}

@media (min-width: 641px) and (max-width: 860px) {
  .overview-summary-card .metrics-grid .metric-card,
  .overview-summary-card .analytics-grid .metric-card {
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .overview-summary-card .metrics-grid .metric-card:nth-child(2n + 1),
  .overview-summary-card .analytics-grid .metric-card:nth-child(2n + 1) {
    border-left: 0;
  }

  .overview-summary-card .metrics-grid .metric-card:nth-child(n + 3),
  .overview-summary-card .analytics-grid .metric-card:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  #summaryBand .market-widget > span,
  #summaryBand .market-overview-list .market-overview-name,
  #summaryBand .market-overview-list .market-overview-value,
  #summaryBand .market-overview-list .market-overview-change,
  #summaryBand .market-overview-list .market-overview-change span {
    font-size: 10px;
  }

  .overview-summary-card .metrics-grid .metric-card {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .overview-summary-card .metrics-grid .metric-card:first-child {
    border-top: 0;
  }

  .overview-summary-card .analytics-grid .metric-card {
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  .overview-summary-card .analytics-grid .metric-card:nth-child(2n + 1) {
    border-left: 0;
  }

  .overview-summary-card .analytics-grid .metric-card:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .overview-holdings-panel .overview-table tr {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .overview-holdings-panel .overview-table td:first-child {
    grid-column: 1 / 2;
  }

  .overview-holdings-panel .overview-table td:nth-child(2) {
    grid-column: 2 / -1;
  }
}

@media (hover: none), (pointer: coarse) {
  .button,
  .tab,
  .chart-range,
  .action-menu,
  .auth-switch button {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
