:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #657181;
  --line: #d9e0e7;
  --panel: #ffffff;
  --canvas: #f4f6f8;
  --teal: #0f766e;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b42318;
  --green: #15803d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "Segoe UI", "Microsoft JhengHei", system-ui, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.login-panel h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

button,
nav a {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

button {
  color: #ffffff;
  border-color: var(--blue);
  background: var(--blue);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.layout {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px 32px 40px;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(8, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

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

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #ffffff;
  font: inherit;
}

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

.metric,
.panel,
.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(24, 33, 47, 0.06);
}

.metric {
  display: grid;
  gap: 6px;
  padding: 18px;
}

.metric.accent {
  border-color: rgba(15, 118, 110, 0.35);
}

.metric span,
.metric small {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  font-size: 28px;
  line-height: 1;
}

.split {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(300px, 0.9fr);
  gap: 14px;
  margin-top: 14px;
}

.portfolio-panel {
  margin-top: 14px;
}

.portfolio-bars {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.portfolio-bars span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.portfolio-bars strong {
  display: block;
  margin: 4px 0 8px;
  font-size: 18px;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef3;
}

.bar-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.bar-fill.muted {
  background: var(--blue);
}

.panel.wide {
  grid-column: 1 / -1;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 17px;
}

.pill {
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--teal);
  background: #dff5f0;
  font-size: 12px;
  font-weight: 800;
}

.pill.danger {
  color: var(--red);
  background: #fee4e2;
}

.ticket-list,
.position-list {
  display: grid;
  gap: 10px;
}

.ticket,
.position {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.ticket h3,
.position h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.ticket dl,
.position dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 0;
}

.ticket dt,
.position dt {
  color: var(--muted);
  font-size: 12px;
}

.ticket dd,
.position dd {
  margin: 2px 0 0;
  font-weight: 800;
}

.entry-reason {
  margin: 12px 0 0;
  padding: 10px 12px;
  color: var(--ink);
  border: 1px solid #e6ecf1;
  border-radius: 8px;
  background: #ffffff;
  font-size: 13px;
  line-height: 1.55;
}

.ticket-actions,
.close-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

button.small {
  min-height: 36px;
  padding: 0 10px;
  font-size: 13px;
}

button.secondary {
  color: var(--ink);
  border-color: var(--line);
  background: #ffffff;
}

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

.empty {
  margin: 0;
  padding: 18px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 12px;
}

td:first-child,
th:first-child {
  width: 28%;
}

td:nth-child(2),
th:nth-child(2),
td:nth-child(3),
th:nth-child(3),
td:nth-child(4),
th:nth-child(4) {
  width: 12%;
}

.journal-table {
  min-width: 1180px;
}

.journal-table th:first-child,
.journal-table td:first-child {
  width: 14%;
}

.journal-table th:nth-child(2),
.journal-table td:nth-child(2) {
  width: 8%;
}

.journal-table th:nth-child(3),
.journal-table td:nth-child(3),
.journal-table th:nth-child(4),
.journal-table td:nth-child(4),
.journal-table th:nth-child(5),
.journal-table td:nth-child(5),
.journal-table th:nth-child(6),
.journal-table td:nth-child(6),
.journal-table th:nth-child(7),
.journal-table td:nth-child(7) {
  width: 10%;
}

.journal-table th:nth-child(8),
.journal-table td:nth-child(8) {
  width: 28%;
}

.reason-cell p {
  margin: 0;
  line-height: 1.5;
}

.source-list {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
  padding-left: 16px;
  color: var(--muted);
}

.source-list a {
  color: var(--blue);
}

.symbol {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.symbol strong,
td {
  overflow-wrap: anywhere;
}

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

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

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

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

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.12), transparent 45%),
    var(--canvas);
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 18px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--teal);
  font-weight: 900;
}

.login-panel p {
  margin: 8px 0 22px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 12px;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 980px) {
  .toolbar,
  .summary-grid,
  .split,
  .portfolio-bars {
    grid-template-columns: 1fr;
  }

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

  nav {
    width: 100%;
  }

  nav button,
  nav a {
    flex: 1;
    display: grid;
    place-items: center;
  }
}

@media (max-width: 640px) {
  .topbar,
  .layout {
    padding-left: 16px;
    padding-right: 16px;
  }

  .ticket dl,
  .position dl,
  .ticket-actions,
  .close-row {
    grid-template-columns: 1fr;
  }
}
