* {
  box-sizing: border-box;
  font-family: Arial, "Microsoft JhengHei", sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.22), transparent 32%),
    linear-gradient(135deg, #020617 0%, #0f172a 48%, #111827 100%);
  color: #e5e7eb;
}

.container {
  width: min(100%, 1380px);
  margin: 0 auto;
  padding: 32px 18px 48px;
}

.header {
  text-align: center;
  margin-bottom: 24px;
}

.header h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 36px);
  letter-spacing: 1px;
}

.header p {
  color: #94a3b8;
  margin-top: 10px;
}

.card {
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  margin-bottom: 20px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 18px;
  font-weight: 800;
}

.badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.16);
  color: #93c5fd;
  font-size: 13px;
}

label {
  display: block;
  margin-bottom: 7px;
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid #334155;
  border-radius: 13px;
  background: #020617;
  color: #f8fafc;
  font-size: 16px;
  outline: none;
}

input:focus,
select:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.15);
}

button {
  height: 48px;
  border: 0;
  border-radius: 13px;
  padding: 0 16px;
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

.primary-btn {
  background: #2563eb;
}

.green-btn {
  background: #16a34a;
}

.gray-btn {
  background: #64748b;
}

.red-btn {
  background: #ef4444;
}

.edit-btn {
  background: #f59e0b;
  min-width: 56px;
  height: 36px;
  border-radius: 12px;
  padding: 0 10px;
  font-size: 14px;
}

.danger-main {
  height: 48px;
}

.full-btn {
  width: 100%;
  margin-top: 14px;
}

.portfolio-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) 140px minmax(180px, 1.1fr) 140px 140px;
  gap: 12px;
  align-items: end;
}

.stock-row {
  display: grid;
  grid-template-columns: 1fr 1.3fr 0.8fr 1fr 140px;
  gap: 12px;
  align-items: end;
}

.cash-row {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 12px;
  margin-top: 14px;
}

.import-export-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.hint {
  margin-top: 12px;
  color: #94a3b8;
  line-height: 1.6;
  font-size: 14px;
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 20px;
  align-items: start;
}

.account-title {
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.summary-box {
  padding: 15px;
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.65);
  border: 1px solid #334155;
}

.summary-box .label {
  color: #94a3b8;
  font-size: 13px;
  margin-bottom: 6px;
}

.summary-box .value {
  color: #f8fafc;
  font-size: 20px;
  font-weight: 900;
}

.table-scroll {
  overflow-x: visible;
  border-radius: 16px;
  border: 1px solid #334155;
}

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

th,
td {
  padding: 14px 8px;
  text-align: center;
  border-bottom: 1px solid #334155;
  white-space: nowrap;
}

th {
  background: #111827;
  color: #cbd5e1;
  font-weight: 900;
}

td {
  background: rgba(15, 23, 42, 0.72);
}

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

th:nth-child(1),
td:nth-child(1) {
  width: 52px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 92px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 120px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 80px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 110px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 90px;
}

th:nth-child(7),
td:nth-child(7) {
  width: 140px;
}

.code-pill {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 999px;
  background: #1e293b;
  color: #dbeafe;
  font-weight: 800;
}

.name-cell {
  overflow: hidden;
  text-overflow: ellipsis;
}

.percent {
  color: #60a5fa;
  font-weight: 900;
}

.drag-handle {
  cursor: grab;
  user-select: none;
  color: #94a3b8;
  font-weight: 900;
}

tr.dragging td {
  opacity: 0.55;
  background: rgba(37, 99, 235, 0.18);
}

tr.drag-over td {
  border-top: 3px solid #60a5fa;
}

.action-wrap {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
}

.chart-card {
  min-height: 560px;
}

.chart-box {
  height: 420px;
}

canvas {
  max-width: 100%;
  max-height: 100%;
}

.chart-detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.chart-detail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.65);
  border: 1px solid #334155;
  font-size: 14px;
}

.chart-detail-left {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.color-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chart-detail-name {
  color: #e5e7eb;
  font-weight: 800;
  word-break: break-word;
}

.chart-detail-percent {
  color: #60a5fa;
  font-weight: 900;
  flex-shrink: 0;
}

.empty {
  color: #94a3b8;
  padding: 24px;
}

@media (max-width: 1100px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 760px;
    table-layout: auto;
  }
}

@media (max-width: 760px) {
  body {
    background: #020617;
  }

  .container {
    padding: 14px 10px 28px;
  }

  .header {
    text-align: left;
    margin-bottom: 16px;
  }

  .header h1 {
    font-size: 24px;
    line-height: 1.25;
  }

  .header p {
    font-size: 13px;
    line-height: 1.6;
  }

  .card {
    padding: 14px;
    border-radius: 18px;
    margin-bottom: 14px;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 16px;
  }

  .badge {
    font-size: 12px;
    padding: 5px 10px;
  }

  label {
    font-size: 13px;
    margin-bottom: 6px;
  }

  input,
  select,
  button {
    height: 46px;
    font-size: 15px;
    border-radius: 12px;
  }

  button {
    width: 100%;
  }

  .portfolio-row,
  .stock-row,
  .cash-row,
  .import-export-row,
  .summary-grid,
  .main-layout {
    grid-template-columns: 1fr;
    gap: 10px;
  }

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

  .summary-box:last-child {
    grid-column: 1 / -1;
  }

  .summary-box {
    padding: 12px;
  }

  .summary-box .label {
    font-size: 12px;
  }

  .summary-box .value {
    font-size: 17px;
  }

  .account-title {
    font-size: 17px;
    margin-bottom: 12px;
  }

  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 720px;
    table-layout: auto;
    font-size: 14px;
  }

  th,
  td {
    padding: 12px 8px;
  }

  .name-cell {
    max-width: 130px;
  }

  .action-wrap {
    gap: 6px;
  }

  .edit-btn,
  .red-btn {
    min-width: 56px;
    height: 34px;
    font-size: 13px;
    padding: 0 10px;
  }

  .chart-card {
    min-height: auto;
  }

  .chart-box {
    height: 300px;
  }

  .chart-detail-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .chart-detail-item {
    padding: 9px 10px;
    font-size: 13px;
  }

  .hint {
    font-size: 13px;
  }
}

@media (max-width: 420px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .chart-box {
    height: 260px;
  }

  table {
    min-width: 680px;
  }

  .header h1 {
    font-size: 22px;
  }
}